<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>moyue</title> | |
<style> | |
table{margin-top: 10px;}/*这是表格和按钮及搜素框的间距*/ | |
button{background-color:dodgerblue;border-radius:10px ;}/*按钮背景颜色*/ | |
/*隔行变色*/ | |
tbody tr:nth-child(odd){ | |
background-color: gainsboro; | |
} | |
table tr:hover{background-color: #1E90FF;} | |
</style> | |
<script type="text/javascript" src="js/angular.min.js" ></script> | |
<script> | |
var app = angular.module("myApp",[]); | |
app.controller("myCtrl",function($scope,$http){ | |
$http.get("http://result.eolinker.com/lKgJQ8Zec38423e5603b8e055d1193a8127c0c060bb1b55?uri=goodstest") | |
.success(function (data){ | |
$scope.message=data; | |
}) | |
//全选反选 | |
$scope.allxuan=function () { | |
for (var i = 0; i< $scope.message.length; i++) { | |
if ($scope.message[i].ck=true) { | |
$scope.message[i].ck=$scope.qx; | |
} | |
} | |
} | |
//批量删除的 | |
$scope.plsc= function () { | |
for (var i = 0; i< $scope.message.length; i++) { | |
if ($scope.message[i].ck) { | |
$scope.message.splice(i,1); | |
i--; | |
} | |
} | |
} | |
//添加 | |
/*var newid=22; | |
$scope.reguName=false; | |
$scope.xj=function(){ | |
$scope.zj = true; | |
} | |
$scope.save = function(){ | |
if($scope.add_gname == undefined || $scope.add_gname==""){ | |
$scope.a=true; | |
}else{ | |
$scope.a=false; | |
} | |
if($scope.add_uname == undefined || $scope.add_uname==""){ | |
$scope.b=true; | |
}else{ | |
$scope.b=false; | |
} | |
if($scope.add_tel == undefined || $scope.add_tel==""){ | |
$scope.c=true; | |
}else{ | |
$scope.c=false; | |
} | |
if($scope.add_price == undefined || $scope.add_price==""){ | |
$scope.d=true; | |
}else{ | |
$scope.d=false; | |
} | |
if($scope.add_city == undefined || $scope.add_city==""){ | |
$scope.e=1; | |
}else{ | |
$scope.e=0; | |
} | |
if($scope.a||$scope.b||$scope.c||$scope.d||$scope.e){ | |
}else{ | |
var id = newid++; | |
var gname = $scope.add_gname; | |
var uname = $scope.add_uname; | |
var tel = $scope.add_tel; | |
var price = $scope.add_price; | |
var city = $scope.add_city; | |
var regdate = new Date(); | |
$scope.message.push({ | |
id:id, | |
gname : gname, | |
uname : uname, | |
tel : tel, | |
price : price, | |
city : city, | |
regdate : regdate, | |
state:"未发货" | |
}); | |
} | |
}*/ | |
$scope.save= function () { | |
var ii=$scope.add_id; | |
var spm=$scope.add_gname; | |
var yhm=$scope.add_uname; | |
var dh=$scope.add_tel; | |
var jg=$scope.add_price; | |
var cs=$scope.add_city; | |
if(cs==null||cs==""){ | |
$scope.e=1; | |
}else{ | |
$scope.e=0; | |
} | |
if(spm==null||spm==""){ | |
$scope.a=true; | |
}else{ | |
$scope.a=false; | |
} | |
if(ii==null||ii==""){ | |
$scope.ff=true; | |
}else{ | |
$scope.ff=false; | |
} | |
if (yhm==null||yhm=="") { | |
$scope.b=true; | |
} else{ | |
$scope.b=false; | |
} | |
if (dh==null||dh=="") { | |
$scope.c=true; | |
} else{ | |
$scope.c=false; | |
} | |
if ( jg==null||jg=="") { | |
$scope.d=true; | |
} else{ | |
$scope.d=false; | |
} | |
if(ii==null||ii==""||spm==null||spm==""||yhm==null||yhm==""||dh==null||dh==""||jg==null||jg==""||cs==null||cs==""){ | |
}else{ | |
var va = { | |
ck:false, | |
id:$scope.add_id, | |
gname:$scope.add_gname, | |
uname:$scope.add_uname, | |
tel:$scope.add_tel, | |
price:$scope.add_price, | |
city:$scope.add_city, | |
regdate:new Date(), | |
state:'未发货' | |
}; | |
$scope.message.push(va); | |
$scope.fa=false; | |
} | |
} | |
//排序 | |
$scope.s = ""; | |
$scope.j = "id"; | |
$scope.orderBy1=function (clumn) { | |
$scope.j=clumn; | |
if ($scope.s=="") { | |
$scope.s="-"; | |
} else{ | |
$scope.s=""; | |
} | |
} | |
$scope.orderBy2=function (clumn) { | |
$scope.j=clumn; | |
if ($scope.s=="") { | |
$scope.s="-"; | |
} else{ | |
$scope.s=""; | |
} | |
} | |
$scope.orderBy3=function (clumn) { | |
$scope.j=clumn; | |
if ($scope.s=="") { | |
$scope.s="-"; | |
} else{ | |
$scope.s=""; | |
} | |
} | |
}); | |
</script> | |
</head> | |
<body ng-app="myApp" ng-controller="myCtrl"> | |
<button ng-click="f=true">新增订单</button> | |
<button ng-click="plsc()">批量删除</button> | |
<input placeholder="按商品名称查询" ng-model="names" style="border-radius: 10px;" /> | |
<input placeholder="按手机号查询" ng-model="tels" style="border-radius: 10px;"/> | |
<!--查询状态--> | |
<select ng-model="status"> | |
<option value="">--按状态查询--</option> | |
<option value="未发货">未发货</option> | |
<option value="已发货">已发货</option> | |
</select> | |
<table border="1" cellpadding="1" cellspacing="0"> | |
<thead style="background-color: gray;"> | |
<th><input type="checkbox" ng-click="allxuan()" ng-model="qx" /></th> | |
<th>id<button ng-click="orderBy1('id')">排序</button></th> | |
<th>商品名</th> | |
<th>用户名</th> | |
<th>手机号</th> | |
<th>价格<button ng-click="orderBy2('id')">排序</button></th> | |
<th>城市</th> | |
<th>下单时间<button ng-click="orderBy3('id')">排序</button></th> | |
<th>状态</th> | |
</thead> | |
<tbody> | |
<tr ng-repeat="li in message | filter:{gname:names,tel:tels,state:status} |orderBy:(s+j) "> | |
<td><input type="checkbox" ng-model="li.ck" /></td> | |
<td>{{li.id}}</td> | |
<td>{{li.gname}}</td> | |
<td>{{li.uname}}</td> | |
<td>{{li.tel}}</td> | |
<td>{{li.price | currency:"¥"}}</td> | |
<td>{{li.city}}</td> | |
<td>{{li.regdate | date:'MM-dd hh:mm:ss'}}</td> | |
<td> | |
<span ng-if="li.state=='未发货'"> | |
<a href="#" ng-click="li.state='已发货'">{{li.state}}</a> | |
</span> | |
<span ng-if="li.state=='已发货'">已发货</span> | |
</td> | |
</tr> | |
</tbody> | |
</table> | |
<!--这是添加的隐藏--> | |
<div ng-show="f" id="add"> | |
<h3>新增订单</h3> | |
<table> | |
<tr> | |
<td>商品</td> | |
<td> | |
<input ng-model="add_id" type="text" placeholder="输入id号" /> | |
<span ng-show="ff">id号不能为空</span> | |
</td> | |
</tr> | |
<tr> | |
<td>商品</td> | |
<td> | |
<input ng-model="add_gname" type="text" placeholder="输入商品名" /> | |
<span ng-show="a">商品名不能为空</span> | |
</td> | |
</tr> | |
<tr> | |
<td>用户名</td> | |
<td> | |
<input ng-model="add_uname" type="text" placeholder="输入用户名" /> | |
<span ng-show="b">用户名不能为空</span> | |
</td> | |
</tr> | |
<tr> | |
<td>手机号</td> | |
<td> | |
<input ng-model="add_tel" ng-model="add_uname" type="text" placeholder="输入手机号" /> | |
<span ng-show="c">手机号不能为空</span> | |
</td> | |
</tr> | |
<tr> | |
<td>价格</td> | |
<td><input ng-model="add_price" type="text" placeholder="输入价格" /> | |
<span ng-show="d">价格不能为空</span> | |
</td> | |
</tr> | |
<tr> | |
<td>城市</td> | |
<td> | |
<select ng-model="add_city"> | |
<option value="">请输入城市</option> | |
<option>北京</option> | |
<option>上海</option> | |
<option>天津</option> | |
<option>广州</option> | |
<option>河北</option> | |
<option>河南</option> | |
<option>山东</option> | |
</select><span ng-show="e">城市不能为空</span> | |
</td> | |
</tr> | |
<tr> | |
<td> | |
<button ng-click="save()" style="background-color: aquamarine;">保存</button> | |
</td> | |
</tr> | |
</table> | |
</div> | |
</body> | |
</html> | |
模拟题
最新推荐文章于 2023-08-19 11:50:45 发布