<!DOCTYPE html>
<html>
<head>
<script src="js/angular.js"></script>
<script src="js/jquery-3.2.1.min.js"></script>
<meta charset="utf-8" />
<title></title>
<script>
var app=angular.module("Liu",[]);
app.controller("myApp",function($scope,$http){
$scope.jsonForm="";
$http({
method:"get",
url:"http://result.eolinker.com/TucCTQueffdc1d1aaa3be05d8c62e9bb5d3e8b495f97cca?uri=hybrid"
}).then(
function success(response){
$scope.jsonForm=response.data;
},function error(response){
}
);
//计算年龄
$scope.getAge = function(startDate){
// 获得今天的时间
var date = new Date();
startDate = new Date(startDate);
var newDate = date.getTime() - startDate.getTime();
// 向下取整 例如 10岁 20天 会计算成 10岁
// 如果要向上取整 计算成11岁,把floor替换成 ceil
return Math.ceil(newDate / 1000 / 60 / 60 / 24 / 365);
}
$scope.Flag=true;
//删除数据
$scope.delete=function($index){
$scope.jsonForm.splice($index,1);
if($scope.jsonForm.length==0){
$scope.Flag=false;
}
}
//批量删除
$scope.dele=function(){
for(var i=$scope.jsonForm.length-1;i>=0;i--){
debugger;
var _ck = $scope.jsonForm[i];
debugger;
if(_ck.ck){
$scope.jsonForm.splice(i,1);
}
}
}
$scope.sele1="";
$scope.sele2="";
$scope.px="";
});
</script>
</head>
<body ng-app="Liu" ng-controller="myApp">
<center>
<input type="text" placeholder="根据姓名模糊查询" ng-model="sele1"/>
<input type="text" placeholder="根据部门模糊查询" ng-model="sele2"/>
<select ng-model="px">
<option value="" selected="selected">--请选择--</option>
<option value="birthday">按时间正序</option>
<option value="-birthday">按时间倒序</option>
</select>
<input type="button" value="批量删除" ng-click="dele()"/><br /><br />
<table border="1" cellspacing="0" style="width: 600px;" ng-show="Flag">
<tr align="center">
<th><input type="checkbox" ng-model="uu"/></th>
<th>员工姓名</th>
<th>员工年龄</th>
<th>员工性别</th>
<th>员工薪资</th>
<th ng-click="px='birthday'">出生日期</th>
<th>部门名称</th>
<th>删除</th>
</tr>
<tr align="center" ng-repeat="g in jsonForm | orderBy:px| filter:{name:sele1,department:{name:sele2}}">
<td><input type="checkbox" ng-checked="uu" ng-model="g.ck" name='g.name'/></td>
<td>{{g.name}}</td>
<td>{{getAge(g.birthday)}}</td>
<td>{{g.gender}}</td>
<td>{{g.salary | currency:"¥"}}</td>
<td>{{g.birthday | date:"yyyy-MM-dd"}}</td>
<td>{{g.department.name}}</td>
<td><input type="button" value="删除" ng-click="delete($index)"/></td>
</tr>
</table>
</center>
</body>
</html>
<html>
<head>
<script src="js/angular.js"></script>
<script src="js/jquery-3.2.1.min.js"></script>
<meta charset="utf-8" />
<title></title>
<script>
var app=angular.module("Liu",[]);
app.controller("myApp",function($scope,$http){
$scope.jsonForm="";
$http({
method:"get",
url:"http://result.eolinker.com/TucCTQueffdc1d1aaa3be05d8c62e9bb5d3e8b495f97cca?uri=hybrid"
}).then(
function success(response){
$scope.jsonForm=response.data;
},function error(response){
}
);
//计算年龄
$scope.getAge = function(startDate){
// 获得今天的时间
var date = new Date();
startDate = new Date(startDate);
var newDate = date.getTime() - startDate.getTime();
// 向下取整 例如 10岁 20天 会计算成 10岁
// 如果要向上取整 计算成11岁,把floor替换成 ceil
return Math.ceil(newDate / 1000 / 60 / 60 / 24 / 365);
}
$scope.Flag=true;
//删除数据
$scope.delete=function($index){
$scope.jsonForm.splice($index,1);
if($scope.jsonForm.length==0){
$scope.Flag=false;
}
}
//批量删除
$scope.dele=function(){
for(var i=$scope.jsonForm.length-1;i>=0;i--){
debugger;
var _ck = $scope.jsonForm[i];
debugger;
if(_ck.ck){
$scope.jsonForm.splice(i,1);
}
}
}
$scope.sele1="";
$scope.sele2="";
$scope.px="";
});
</script>
</head>
<body ng-app="Liu" ng-controller="myApp">
<center>
<input type="text" placeholder="根据姓名模糊查询" ng-model="sele1"/>
<input type="text" placeholder="根据部门模糊查询" ng-model="sele2"/>
<select ng-model="px">
<option value="" selected="selected">--请选择--</option>
<option value="birthday">按时间正序</option>
<option value="-birthday">按时间倒序</option>
</select>
<input type="button" value="批量删除" ng-click="dele()"/><br /><br />
<table border="1" cellspacing="0" style="width: 600px;" ng-show="Flag">
<tr align="center">
<th><input type="checkbox" ng-model="uu"/></th>
<th>员工姓名</th>
<th>员工年龄</th>
<th>员工性别</th>
<th>员工薪资</th>
<th ng-click="px='birthday'">出生日期</th>
<th>部门名称</th>
<th>删除</th>
</tr>
<tr align="center" ng-repeat="g in jsonForm | orderBy:px| filter:{name:sele1,department:{name:sele2}}">
<td><input type="checkbox" ng-checked="uu" ng-model="g.ck" name='g.name'/></td>
<td>{{g.name}}</td>
<td>{{getAge(g.birthday)}}</td>
<td>{{g.gender}}</td>
<td>{{g.salary | currency:"¥"}}</td>
<td>{{g.birthday | date:"yyyy-MM-dd"}}</td>
<td>{{g.department.name}}</td>
<td><input type="button" value="删除" ng-click="delete($index)"/></td>
</tr>
</table>
</center>
</body>
</html>