<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
td,th{
width: 120px;
height: 60px;
border: 1px solid #69717d;
}
table{
border-collapse: collapse;
margin-top: 6px;
margin-bottom: 6px;
}
.but{
margin-top: 6px;
margin-bottom: 6px;
background: #0a9dc7;
}
.red{
border: 1px solid red;
}
</style>
<script src="angular-1.5.5/angular.min.js"></script>
<script>
var myapp=angular.module("myapp",[]);
myapp.controller("myCtrl",function ($scope) {
$scope.items=[
{
done:false,
"id":1,
"sname":"小米",
"yname":"张三",
"phone":111111,
"price":1000,
"city":"北京",
"times":3,
"ztai":"发货"
},
{
done:false,
"id":2,
"sname":"苹果",
"yname":"李四",
"phone":222222,
"price":2000,
"city":"上海",
"times":5,
"ztai":"发货"
},
{
done:false,
"id":3,
"sname":"小米",
"yname":"王五",
"phone":333333,
"price":3000,
"city":"重庆",
"times":7,
"ztai":"已发货"
},
{
done:false,
"id":4,
"sname":"三星",
"yname":"赵六",
"phone":444444,
"price":4000,
"city":"天津",
"times":9,
"ztai":"已发货"
}
]
$scope.citySSS="城市选择";
$scope.citySize=function (item) {
if($scope.citySSS!="城市选择"){
if(item.city==$scope.citySSS){
return true;
}else{
return false;
}
}else{
return true;
}
}
$scope.ztaiSSS="状态选择";
$scope.ztaiSize=function (item) {
if($scope.ztaiSSS!="状态选择"){
if(item.ztai==$scope.ztaiSSS){
return true;
}else{
return false;
}
}else{
return true;
}
}
$scope.timesSize="开始月份";
$scope.timesFilter=function(item){
if($scope.timesSize!="开始月份"){
var timesSize=$scope.timesSize;
var timesArr=timesSize.split("-");
var min=timesArr[0];
var max=timesArr[1];
var times=item.times;
if(times>max||times<min){
return false
}else{
return true;
}
}else{
return true;
}
};
$scope.xian=false;
$scope.showall=function () {
$scope.xian=true;
}
$scope.additem=function () {
for(var i=0;i<$scope.items.length;i++){
if($scope.sname==$scope.items[i].sname&&$scope.yname==$scope.items[i].yname&&$scope.phone==$scope.items[i].phone&&$scope.city==$scope.items[i].city){
alert("订单填写重复");
return;
}
if($scope.sname==null||$scope.yname==null||$scope.phone.length<8||$scope.phone.length>12||$scope.city==null){
alert("请填写完整")
return;
}
}
$scope.items.push({'id':"0",'sname':$scope.sname,'yname':$scope.yname,'phone':$scope.phone,'price':"999",'city':$scope.city,'times':"6",'ztai':"发货"});
$scope.xian=false;
}
$scope.checkall=function () {
if ($scope.check1 == true) {
for (var i = 0; i < $scope.items.length; i++) {
$scope.items[i].done = true;
}
}
else {
for (var i = 0; i < $scope.items.length; i++) {
$scope.items[i].done = false;
}
}
}
var n=0;
$scope.fx=function (index) {
if($scope.items[index].done==true){
n++;
}else{
n--;
}
if(n==$scope.items.length){
$scope.check1=true;
}else {
$scope.check1=false;
}
}
$scope.revers=false;
$scope.sortColumn="id";
$scope.sort=function (Column) {
if($scope.sortColumn==Column){
$scope.revers=!$scope.revers;
}
$scope.sortColumn=Column;
};
$scope.yfh="已发货"
$scope.fun=function (index) {
if($scope.items[index].ztai=="发货"){
$scope.items[index].ztai=$scope.yfh;
}
}
})
</script>
</head>
<body ng-app="myapp" ng-controller="myCtrl">
<input type="text" placeholder="用户名搜索" ng-model="cz">
<input type="text" placeholder="手机号搜索" ng-model="czs">
<select ng-model="citySSS">
<option>城市选择</option>
<option>北京</option>
<option>上海</option>
<option>重庆</option>
<option>天津</option>
</select>
<select ng-model="ztaiSSS">
<option>状态选择</option>
<option>发货</option>
<option>已发货</option>
</select>
<select ng-model="timesSize">
<option>开始月份</option>
<option>1-3</option>
<option>4-6</option>
<option>7-9</option>
<option>10-12</option>
</select>
<select>
<option>结束月份</option>
<option>1-3</option>
<option>4-6</option>
<option>7-9</option>
<option>10-12</option>
</select><br>
<button class="but" ng-click="showall()">新增订单</button>
<button class="but">批量发货</button><br>
<div ng-show="xian">
<h3>新增订单</h3>
商品名:<input type="text" placeholder="请填写商品" ng-model="sname" ng-class="{red:check}"><br>
用户名:<input type="text" placeholder="请填写用户名" ng-model="yname" ng-class="{red:check}"><br>
手机号:<input type="text" placeholder="手机号为8-12位" ng-model="phone" ng-class="{red:check}"><br>
城市选择:<select ng-model="city">
<option>北京</option>
<option>上海</option>
<option>重庆</option>
<option>天津</option>
</select><br>
<button class="but" ng-click="additem()">提交</button>
</div>
<table>
<tr>
<th><input type="checkbox" ng-click="checkall()" ng-model="check1"></th>
<th>ID<button ng-click="sort('id')">排序</button></th>
<th>商品名</th>
<th>用户名</th>
<th>手机号</th>
<th>价格<button ng-click="sort('price')">排序</button></th>
<th>城市</th>
<th>下单时间<button ng-click="sort('times')">排序</button></th>
<th>状态</th>
</tr>
<tr ng-repeat="item in items|filter:{yname:cz}|filter:{phone:czs}|filter:citySize|filter:ztaiSize|filter:timesFilter|orderBy:sortColumn:revers">
<td><input type="checkbox" ng-model="item.done" ng-click="fx($index)"></td>
<td>{{item.id}}</td>
<td>{{item.sname}}</td>
<td>{{item.yname}}</td>
<td>{{item.phone}}</td>
<td>{{item.price}}</td>
<td>{{item.city}}</td>
<td>{{item.times}}</td>
<td ng-click="fun($index)">{{item.ztai}}</td>
</tr>
</table>
</body>
</html>