购物车 Angular

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>商品订单信息管理</title>
<script type="text/javascript" src="../js/angular.js"></script>
<script type="text/javascript" src="../js/angular.min.js"></script>
<style>
table {
text-align: center;
}

button {
border-radius: 15%;
background: aqua;
}
</style>
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {

//创建数组
$scope.goods = [{
id: 2,
uname: "铅笔",
name: "张三",
call: "123456",
price: 5,
city: "北京",
data: new Date(),
state: "已发货"    }];

//添加
$scope.add = function() {
if($scope.id == "" || $scope.id == undefined || $scope.id == null) {
$scope.add_id = true;
return false;
} else {
$scope.add_id = false;
}

if($scope.uname == "" || $scope.uname == undefined || $scope.uname == null) {
$scope.add_uname = true;
return false;
} else {
$scope.add_uname = false;
}

if($scope.name == "" || $scope.name == undefined || $scope.name == null) {
$scope.add_name = true;
return false;
} else {
$scope.add_name = false;
}
if($scope.call == "" || $scope.call == undefined || $scope.call == null) {
$scope.add_call = true;
return false;
} else {
$scope.add_call = false;
}
if($scope.price == "" || $scope.price == undefined || $scope.price == null) {
$scope.add_price = true;
return false;
} else {
$scope.add_price = false;
}
if($scope.city == "" || $scope.city == undefined || $scope.city == null) {
$scope.add_city = true;
return false;
} else {
$scope.add_city = false;
}
if($scope.data == "" || $scope.data == undefined || $scope.data == null) {
$scope.add_data = true;
return false;
} else {
$scope.add_data = false;
}
if($scope.state == "" || $scope.state == undefined || $scope.state == null) {
$scope.add_state = true;
return false;
} else {
$scope.add_state = false;
}

var mg = /米/g;

var ss = {
id: $scope.id,
uname: $scope.uname.replace(mg, "*"),
name: $scope.name,
call: $scope.call,
price: $scope.price,
city: $scope.city,
data: $scope.data,
state: $scope.state
};

$scope.goods.push(ss);
$scope.id = "";
$scope.uname = "";
$scope.name = "";
$scope.call = "";
$scope.price = "";
$scope.city = "";
$scope.data = "";
$scope.isshow = false;
}

//全选
$scope.qx = function() {
for(i in $scope.goods) {
$scope.goods[i].ck = $scope.checkAll;
}
}
//批量删除
$scope.det = function() {
for(var i = 0; i < $scope.goods.length; i++) {
if($scope.goods[i].ck == true) {
$scope.goods.splice(i, 1);
i--;
}
}
}

//排序
$scope.s = "";
$scope.j = "id";
$scope.orderBy = 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="isshow=true">新增订单</button>
<button ng-click="det()">批量删除</button>
<input placeholder="按商品名称查询" ng-model="sp" />
<input placeholder="按手机号查询" ng-model="phone" />
<select ng-model="zt">
<option value="">-按状态查询-</option>
<option>已发货</option>
<option>未发货</option>
</select>
<br />
<br />
<table border="1px" cellpadding="5" cellspacing="0">
<tr>
<td><input type="checkbox" ng-model="checkAll" ng-click="qx()" /></td>
<td>id<button ng-click="orderBy(id)">排序</button></td>
<td>商品名</td>
<td>用户名</td>
<td>手机号</td>
<td>价格<button ng-click="orderBy2(price)">排序</button></td>
<td>城市</td>
<td>下单时间<button ng-click="orderBy3(data)">排序</button></td>
<td>状态</td>
</tr>
<tr ng-repeat="tt in goods | filter:{uname:sp,call:phone,state:zt} | orderBy:(s+j)">
<td><input type="checkbox" ng-model="tt.ck" /></td>
<td>{{tt.id}}</td>
<td>{{tt.uname}}</td>
<td>{{tt.name}}</td>
<td>{{tt.call}}</td>
<td>{{tt.price | currency:"¥:"}}</td>
<td>{{tt.city}}</td>
<td>{{tt.data | date:"MM-dd hh:mm"}}</td>
<td>
<span ng-if="tt.state=='已发货'" style="background:#7FFF00;">已发货</span>
<span ng-if="tt.state=='未发货'" style="background:yellow;"><a href="#" ng-click="tt.state='已发货'">{{tt.state}}</a></span>
</td>
</tr>
</table>

<div ng-show="isshow">
<input placeholder="请输入ID" ng-model="id" type="number" /><span style="background-color: yellow;" ng-show="add_id">id不能为空</span><br />
<input placeholder="请输入商品名" ng-model="uname" /><span style="background-color: yellow;" ng-show="add_uname">商品名不能为空</span><br />
<input placeholder="请输入用户名" ng-model="name" /><span style="background-color: yellow;" ng-show="add_name">用户名不能为空</span><br />
<input placeholder="请输入手机号" ng-model="call" /><span style="background-color: yellow;" ng-show="add_call">手机号不能为空</span><br />
<input placeholder="请输入价格" ng-model="price" /><span style="background-color: yellow;" ng-show="add_price">价格不能为空</span><br />
<select ng-model="city">
<option value="">请选择城市</option>
<option>北京</option>
<option>上海</option>
<option>重庆</option>
</select><span style="background-color: yellow;" ng-show="add_city">城市不能为空</span><br />
<input placeholder="请输入下单时间" ng-model="data" type="date" /><span style="background-color: yellow;" ng-show="add_data">下单时间不能为空</span><br />
<input placeholder="请输入状态" ng-model="state" /><span style="background-color: yellow;" ng-show="add_state">状态不能为空</span><br />
<button ng-click="add()">保存</button>
</div>


</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值