<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="../js/angularjs-1.5/angular.js" ></script>
<script>
var app=angular.module("myApp",[]);
app.controller("myCtrl",function($scope){
//数据
$scope.stus=[{
id:7,
sname:"OPPO R9SK",
name:"关羽",
phoneid:1577777,
price:4900,
num:2,
city:"北京",
time:new Date("2017-03-03"),
zt:"已发货"
},{
id:12,
sname:"OPPO R9SK",
name:"赵云",
phoneid:1577777,
price:5000,
num:5,
city:"北京",
time:new Date("2017-03-03"),
zt:"已发货"
},{
id:1,
sname:"iph 8",
name:"曹操",
phoneid:15111,
price:2998,
num:4,
city:"北京",
time:new Date("2017-04-03"),
zt:"未发货"
},{
id:11,
sname:"小米",
name:"黄忠",
phoneid:1577777,
price:699,
num:6,
city:"重庆",
time:new Date("2017-05-03"),
zt:"未发货"
}];
//全选
$scope.qx=function(){
for(i=0;i<$scope.stus.length;i++){
$scope.stus[i].ck=$scope.flag;
}
}
//删除
$scope.sc=function(names){
for(i=0;i<$scope.stus.length;i++){
if($scope.stus[i].name==names){
$scope.stus.splice(i,1);
}
}
}
//批量删除
$scope.shows=true;
$scope.plsc=function(i){
for(i=0;i<$scope.stus.length;i++){
if($scope.stus[i].ck){
$scope.stus.splice(i,1);
i--;
}
if($scope.stus.length==0){
$scope.shows=false;
$scope.sshows=true;
}
}
}
//加,减
$scope.count=function(n,names){
for(i=0;i<$scope.stus.length;i++){
if($scope.stus[i].name==names){
if($scope.stus[i].num==1 && n==-1){
$scope.stus.splice(i,1)
}
else{
$scope.stus[i].num=$scope.stus[i].num+n
}
}
}
}
//批量发货
$scope.plfh=function(){
for(i=0;i<$scope.stus.length;i++){
if($scope.stus[i].ck){
$scope.stus[i].zt='已发货';
}
}
}
//时间
$scope.yue=function(m){
var current=m.getMonth()+1;
var start=$scope.startm;
var end=$scope.endm;
if(start==undefined && end==undefined){
return true;
}
if(current>=start && current<=end){
return true;
}
return false;
}
//新增
$scope.formShow = false;
// $scope.ffff = function() {
// if($scope.formShow) {
// $scope.formShow = false;
// } else {
// $scope.formShow = true;
// $scope.updateShow = false;
// }
// }
$scope.sid="";
$scope.ssname="";
$scope.sname="";
$scope.checkSub = [];
$scope.tj=function(){
$scope.checkSub=[];
if($scope.sid==""||$scope.sid==null){
$scope.checkSub.push("产品编号为空");
}else if(isNaN($scope.sid)){
$scope.checkSub.push("产品编号不是整数");
}
if($scope.ssname==""||$scope.ssname==null){
$scope.checkSub.push("商品名为空");
}
if($scope.sname==""||$scope.sname==null){
$scope.checkSub.push("用户名为空");
}
if($scope.checkSub.length > 0) {
$scope.divShow = true;
} else {
$scope.divShow = false;
var newPro = {
"sid": parseInt($scope.sid),
"ssname": $scope.ssname,
"sname": $scope.sname,
};
$scope.stus.push(newPro);
}
}
});
</script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<input type="text" placeholder="用户名搜索 "ng-model="sname"/>
<input type="text" placeholder="手机号搜索 "ng-model="sphone"/>
<select ng-model="scity">
<option value="">选择城市</option>
<option>上海</option>
<option>北京</option>
</select>
<select ng-model="szt">
<option value="">选择状态</option>
<option>已发货</option>
<option>未发货</option>
</select>
<select ng-model="startm">
<option value="">开始月份</option>
<option>3</option>
<option>4</option>
</select>
<select ng-model="endm">
<option value="">结束月份</option>
<option>3</option>
<option>4</option>
</select>
<button ng-click="formShow=true">新增订单</button>
<button ng-click="plsc()">批量删除</button>
<button ng-click="plfh()">批量发货</button>
<p ng-show="sshows">商品为空</p>
<table border="1px" cellpadding="0px" cellspacing="0px" ng-show="shows">
<tr>
<td><input type="checkbox" ng-click="qx()" ng-model="flag"/></td>
<td>ID</td>
<td>商品名</td>
<td>用户名</td>
<td>手机号</td>
<td ng-click="px='price';sj=!sj">价格</td>
<td>数量</td>
<td>小计</td>
<td>城市</td>
<td>下单时间</td>
<td>状态</td>
<td>操作</td>
</tr>
<tr ng-repeat="s in stus|filter:{name:sname,phone:sphone,city:scity,zt:szt}" ng-show="yue(s.time)">
<td><input type="checkbox" ng-model="s.ck"/></td>
<td>{{s.id}}</td>
<td>{{s.sname}}</td>
<td>{{s.name}}</td>
<td>
{{s.phoneid}}
<input type="text" ng-show="f" ng-model="s.phoneid" ng-blur="f=false"/>
</td>
<td>{{s.price}}</td>
<td>
<button ng-click="count(-1,s.name)">-</button>
{{s.num}}
<button ng-click="count(+1,s.name)">+</button>
</td>
<td>{{s.price*s.num}}</td>
<td>{{s.city}}</td>
<td>{{s.time}}</td>
<td>
<span ng-if="s.zt=='未发货'">
<a href="#" ng-click="s.zt='已发货'">{{s.zt}}</a>
</span>
<span ng-if="s.zt=='已发货'">
已发货
</span>
</td>
<td><button ng-click="f=true">修改</button></td>
<td><button ng-click="sc(s.name)">删除</button></td>
</tr>
</table>
<form ng-show="formShow">
<input type="text" placeholder="id" ng-model="sid"/>
<input type="text" placeholder="sname" ng-model="ssname"/>
<input type="text" placeholder="name" ng-model="sname"/>
<div ng-show="divShow">
<ul>
<li ng-repeat="chenk in checkSub">{{chenk}}</li>
</ul>
</div>
<input type="button" value="提交" ng-click="tj()" />
</form>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="../js/angularjs-1.5/angular.js" ></script>
<script>
var app=angular.module("myApp",[]);
app.controller("myCtrl",function($scope){
//数据
$scope.stus=[{
id:7,
sname:"OPPO R9SK",
name:"关羽",
phoneid:1577777,
price:4900,
num:2,
city:"北京",
time:new Date("2017-03-03"),
zt:"已发货"
},{
id:12,
sname:"OPPO R9SK",
name:"赵云",
phoneid:1577777,
price:5000,
num:5,
city:"北京",
time:new Date("2017-03-03"),
zt:"已发货"
},{
id:1,
sname:"iph 8",
name:"曹操",
phoneid:15111,
price:2998,
num:4,
city:"北京",
time:new Date("2017-04-03"),
zt:"未发货"
},{
id:11,
sname:"小米",
name:"黄忠",
phoneid:1577777,
price:699,
num:6,
city:"重庆",
time:new Date("2017-05-03"),
zt:"未发货"
}];
//全选
$scope.qx=function(){
for(i=0;i<$scope.stus.length;i++){
$scope.stus[i].ck=$scope.flag;
}
}
//删除
$scope.sc=function(names){
for(i=0;i<$scope.stus.length;i++){
if($scope.stus[i].name==names){
$scope.stus.splice(i,1);
}
}
}
//批量删除
$scope.shows=true;
$scope.plsc=function(i){
for(i=0;i<$scope.stus.length;i++){
if($scope.stus[i].ck){
$scope.stus.splice(i,1);
i--;
}
if($scope.stus.length==0){
$scope.shows=false;
$scope.sshows=true;
}
}
}
//加,减
$scope.count=function(n,names){
for(i=0;i<$scope.stus.length;i++){
if($scope.stus[i].name==names){
if($scope.stus[i].num==1 && n==-1){
$scope.stus.splice(i,1)
}
else{
$scope.stus[i].num=$scope.stus[i].num+n
}
}
}
}
//批量发货
$scope.plfh=function(){
for(i=0;i<$scope.stus.length;i++){
if($scope.stus[i].ck){
$scope.stus[i].zt='已发货';
}
}
}
//时间
$scope.yue=function(m){
var current=m.getMonth()+1;
var start=$scope.startm;
var end=$scope.endm;
if(start==undefined && end==undefined){
return true;
}
if(current>=start && current<=end){
return true;
}
return false;
}
//新增
$scope.formShow = false;
// $scope.ffff = function() {
// if($scope.formShow) {
// $scope.formShow = false;
// } else {
// $scope.formShow = true;
// $scope.updateShow = false;
// }
// }
$scope.sid="";
$scope.ssname="";
$scope.sname="";
$scope.checkSub = [];
$scope.tj=function(){
$scope.checkSub=[];
if($scope.sid==""||$scope.sid==null){
$scope.checkSub.push("产品编号为空");
}else if(isNaN($scope.sid)){
$scope.checkSub.push("产品编号不是整数");
}
if($scope.ssname==""||$scope.ssname==null){
$scope.checkSub.push("商品名为空");
}
if($scope.sname==""||$scope.sname==null){
$scope.checkSub.push("用户名为空");
}
if($scope.checkSub.length > 0) {
$scope.divShow = true;
} else {
$scope.divShow = false;
var newPro = {
"sid": parseInt($scope.sid),
"ssname": $scope.ssname,
"sname": $scope.sname,
};
$scope.stus.push(newPro);
}
}
});
</script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<input type="text" placeholder="用户名搜索 "ng-model="sname"/>
<input type="text" placeholder="手机号搜索 "ng-model="sphone"/>
<select ng-model="scity">
<option value="">选择城市</option>
<option>上海</option>
<option>北京</option>
</select>
<select ng-model="szt">
<option value="">选择状态</option>
<option>已发货</option>
<option>未发货</option>
</select>
<select ng-model="startm">
<option value="">开始月份</option>
<option>3</option>
<option>4</option>
</select>
<select ng-model="endm">
<option value="">结束月份</option>
<option>3</option>
<option>4</option>
</select>
<button ng-click="formShow=true">新增订单</button>
<button ng-click="plsc()">批量删除</button>
<button ng-click="plfh()">批量发货</button>
<p ng-show="sshows">商品为空</p>
<table border="1px" cellpadding="0px" cellspacing="0px" ng-show="shows">
<tr>
<td><input type="checkbox" ng-click="qx()" ng-model="flag"/></td>
<td>ID</td>
<td>商品名</td>
<td>用户名</td>
<td>手机号</td>
<td ng-click="px='price';sj=!sj">价格</td>
<td>数量</td>
<td>小计</td>
<td>城市</td>
<td>下单时间</td>
<td>状态</td>
<td>操作</td>
</tr>
<tr ng-repeat="s in stus|filter:{name:sname,phone:sphone,city:scity,zt:szt}" ng-show="yue(s.time)">
<td><input type="checkbox" ng-model="s.ck"/></td>
<td>{{s.id}}</td>
<td>{{s.sname}}</td>
<td>{{s.name}}</td>
<td>
{{s.phoneid}}
<input type="text" ng-show="f" ng-model="s.phoneid" ng-blur="f=false"/>
</td>
<td>{{s.price}}</td>
<td>
<button ng-click="count(-1,s.name)">-</button>
{{s.num}}
<button ng-click="count(+1,s.name)">+</button>
</td>
<td>{{s.price*s.num}}</td>
<td>{{s.city}}</td>
<td>{{s.time}}</td>
<td>
<span ng-if="s.zt=='未发货'">
<a href="#" ng-click="s.zt='已发货'">{{s.zt}}</a>
</span>
<span ng-if="s.zt=='已发货'">
已发货
</span>
</td>
<td><button ng-click="f=true">修改</button></td>
<td><button ng-click="sc(s.name)">删除</button></td>
</tr>
</table>
<form ng-show="formShow">
<input type="text" placeholder="id" ng-model="sid"/>
<input type="text" placeholder="sname" ng-model="ssname"/>
<input type="text" placeholder="name" ng-model="sname"/>
<div ng-show="divShow">
<ul>
<li ng-repeat="chenk in checkSub">{{chenk}}</li>
</ul>
</div>
<input type="button" value="提交" ng-click="tj()" />
</form>
</body>
</html>