<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<!--<link rel="stylesheet" type="text/css" href="lib/css/ionic.css"/>-->
<script src="lib/js/ionic.bundle.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
angular.module("jun",[])
.controller("dd",function($scope){
$scope.order=["-------请选择排序方式","按照库存数量正序","按照库存数量倒序","按照入库时间正序","按照入库时间倒序"];
$scope.goods=[{
"name":"云南白药",
"num":100,
"produce":"云南",
"price":19.9,
"date1":"20171120093221"
},{
"name":"999感冒灵",
"num":30,
"produce":"北京",
"price":12.5,
"date1":"20171120103221"
},{
"name":"感康",
"num":20,
"produce":"河北",
"price":16.6,
"date1":"20171120111111"
}]
$scope.isshow=false;
$scope.change=function(){
var name=$scope.SelectedName;
if(name=="按照库存数量正序"){
$scope.goods.stort(function(a,b){
return a.num-b.num;
});
}else if(name=="按照库存数量倒序"){
$scope.goods.stort(function(a,b){
return b.num-a.num;
});
}else if(name=="按照入库时间正序"){
$scope.goods.stort(function(a,b){
return a.date1-b.date1;
});
}else if(name=="按照入库时间倒序"){
$scope.goods.stort(function(a,b){
return b.date1-a.date1;
});
}
}
$scope.dele=function($index){
var a=confirm("是否删除");
if (a) {
$scope.goods.splice($index,1);alert("删除成功");
}
}
$scope.add=function(){
$scope.isshow=true;
}
$scope.sub=function(){
var name=$(".name").val();
var num=$(".num").val();
var price=$(".price").val();
var produce=$(".produce").val();
var date=new Date();
var y=date.getFullYear();
var m = date.getMonth() + 1;
var d = date.getDate();
var h = date.getHours();
var mm = date.getMinutes();
var s = date.getSeconds();
var time = y + "年" + m + "月" + d + "日" + h + "时" + mm + "分" + s+"秒";
if (name=="") {
alert("货品为空");
return;
}
$scope.goods.push({
"name":name,
"num":num,
"produce":produce,
"price":price,
"date1":time
})
$(".name").val("");
$(".num").val("");
$(".price").val("");
$(".produce").val("");
$scope.isshow=false;
}
})
</script>
</head>
<body ng-app="jun" ng-controller="dd">
<div class="tab">
<input type="text" placeholder="输入关键字搜索" class="select" ng-model="select"/>
<div class="right">
<select ng-model="SlectedName" ng-init="SelectedName=order[0]" ng-options="x for x in order" ng-change="change()">
{{x}}
</select>
<input type="button" value="入库" class="add" ng-click="add()"/>
</div>
<table border="1px" cellspacing="1px" cellpadding="1px" class="table table-striped">
<tr style="background: #999999;">
<th>
货物名称
</th>
<th>
货物数量
</th>
<th>
货物产地
</th>
<th>
货物单价
</th>
<th>
货物入库日期
</th>
<th>
操作
</th>
</tr>
<tr ng-repeat="x in goods|filter:select">
<td>
{{x.name}}
</td>
<td>
{{x.num}}
</td>
<td>
{{x.produce}}
</td>
<td>
{{x.price|currency:"¥:"}}
</td>
<td>
{{x.date1|date:"yyyy年MM月dd日 hh时mm分ss秒"}}
</td>
<td>
<a href="javasript:void(0)" ng-click="dele($index)">删除</a>
</td>
</tr>
</table>
</div>
<div class="goods" ng-show="isshow">
货物名称:
<input type="text" class="name"/>
货物数量:
<input type="text" class="num"/>
货物产地
<input type="text" class="produce"/>
货物单价:
<input type="text" class="price"/>
货物入库日期
<input type="text" class="date1"/>
<button ng-click="sub()" class="sub">提交</button>
</div>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<!--<link rel="stylesheet" type="text/css" href="lib/css/ionic.css"/>-->
<script src="lib/js/ionic.bundle.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
angular.module("jun",[])
.controller("dd",function($scope){
$scope.order=["-------请选择排序方式","按照库存数量正序","按照库存数量倒序","按照入库时间正序","按照入库时间倒序"];
$scope.goods=[{
"name":"云南白药",
"num":100,
"produce":"云南",
"price":19.9,
"date1":"20171120093221"
},{
"name":"999感冒灵",
"num":30,
"produce":"北京",
"price":12.5,
"date1":"20171120103221"
},{
"name":"感康",
"num":20,
"produce":"河北",
"price":16.6,
"date1":"20171120111111"
}]
$scope.isshow=false;
$scope.change=function(){
var name=$scope.SelectedName;
if(name=="按照库存数量正序"){
$scope.goods.stort(function(a,b){
return a.num-b.num;
});
}else if(name=="按照库存数量倒序"){
$scope.goods.stort(function(a,b){
return b.num-a.num;
});
}else if(name=="按照入库时间正序"){
$scope.goods.stort(function(a,b){
return a.date1-b.date1;
});
}else if(name=="按照入库时间倒序"){
$scope.goods.stort(function(a,b){
return b.date1-a.date1;
});
}
}
$scope.dele=function($index){
var a=confirm("是否删除");
if (a) {
$scope.goods.splice($index,1);alert("删除成功");
}
}
$scope.add=function(){
$scope.isshow=true;
}
$scope.sub=function(){
var name=$(".name").val();
var num=$(".num").val();
var price=$(".price").val();
var produce=$(".produce").val();
var date=new Date();
var y=date.getFullYear();
var m = date.getMonth() + 1;
var d = date.getDate();
var h = date.getHours();
var mm = date.getMinutes();
var s = date.getSeconds();
var time = y + "年" + m + "月" + d + "日" + h + "时" + mm + "分" + s+"秒";
if (name=="") {
alert("货品为空");
return;
}
$scope.goods.push({
"name":name,
"num":num,
"produce":produce,
"price":price,
"date1":time
})
$(".name").val("");
$(".num").val("");
$(".price").val("");
$(".produce").val("");
$scope.isshow=false;
}
})
</script>
</head>
<body ng-app="jun" ng-controller="dd">
<div class="tab">
<input type="text" placeholder="输入关键字搜索" class="select" ng-model="select"/>
<div class="right">
<select ng-model="SlectedName" ng-init="SelectedName=order[0]" ng-options="x for x in order" ng-change="change()">
{{x}}
</select>
<input type="button" value="入库" class="add" ng-click="add()"/>
</div>
<table border="1px" cellspacing="1px" cellpadding="1px" class="table table-striped">
<tr style="background: #999999;">
<th>
货物名称
</th>
<th>
货物数量
</th>
<th>
货物产地
</th>
<th>
货物单价
</th>
<th>
货物入库日期
</th>
<th>
操作
</th>
</tr>
<tr ng-repeat="x in goods|filter:select">
<td>
{{x.name}}
</td>
<td>
{{x.num}}
</td>
<td>
{{x.produce}}
</td>
<td>
{{x.price|currency:"¥:"}}
</td>
<td>
{{x.date1|date:"yyyy年MM月dd日 hh时mm分ss秒"}}
</td>
<td>
<a href="javasript:void(0)" ng-click="dele($index)">删除</a>
</td>
</tr>
</table>
</div>
<div class="goods" ng-show="isshow">
货物名称:
<input type="text" class="name"/>
货物数量:
<input type="text" class="num"/>
货物产地
<input type="text" class="produce"/>
货物单价:
<input type="text" class="price"/>
货物入库日期
<input type="text" class="date1"/>
<button ng-click="sub()" class="sub">提交</button>
</div>
</body>
</html>