<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="../Day08/js/angular.min.js"></script>
<script>
var app = angular.module("myApp",[]);
app.controller("count",function($scope,$http){
$http.get("http://result.eolinker.com/TucCTQueffdc1d1aaa3be05d8c62e9bb5d3e8b495f97cca?uri=hybrid")
.then(function(d){
$scope.persons = d.data;
});
$scope.getAge = function(bir){
var b = new Date(bir).getYear();
var nowb = new Date().getYear();
return nowb-b;
}
$scope.px = "";
$scope.dele = function(id){
var index = 0;
for(var i in $scope.persons){
if($scope.persons[i].id == id){
index = i;
}
}
if(confirm("是否确认删除")){
$scope.persons.splice(index,1);
}
}
$scope.ckAll = function(){
for(var i=0; i<$scope.persons.length; i++){
$scope.persons[i].ck = $scope.flag;
}
}
$scope.deleAll = function(){
var de = 0;
for(var i=0; i<$scope.persons.length; i++){
if($scope.persons[i].ck){
de++;
$scope.persons.splice(i,1);
i--;
}
}
if(de == 0){
alert("请选择")
}
}
});
</script>
<style>
#box{
width: 700px;
height: 500px;
margin: 0 auto;
padding-top: 50px;
text-align: center;
}
table{
width: 600px;
margin: 0 auto;
}
</style>
</head>
<body ng-app="myApp" ng-controller="count">
<h1 ng-show="persons.length == 0">页面无操作数据</h1>
<div id="box" ng-show="persons.length>0">
<input type="text" placeholder="根据姓名模糊查找" ng-model="selname"/>
<input type="text" placeholder="根据部门模糊查找" ng-model="selbname"/>
<select ng-model="px">
<option value="" ng-selected="true">---请选择---</option>
<option value="+birthday">根据年龄排序</option>
<option value="+salary">根据薪资排序</option>
</select>
<input type="button" value="批量删除" ng-click="deleAll()"/>
<table border="1px" cellpadding="0" cellspacing="0">
<tr>
<th><input type="checkbox" ng-model="flag" ng-click="ckAll()"/></th>
<th>员工姓名</th>
<th>员工年龄</th>
<th>员工性别</th>
<th>员工薪资</th>
<th>出生日期</th>
<th>部门名称</th>
<th>删除</th>
</tr>
<tr ng-repeat="d in persons|filter:{name:selname}|filter:{department:{name:selbname}}|orderBy:px">
<td><input type="checkbox" ng-model="d.ck"/></td>
<td>{{d.name}}</td>
<td>{{getAge(d.birthday)}}</td>
<td>{{d.gender}}</td>
<td>{{d.salary|currency:"¥:"}}</td>
<td>{{d.birthday|date:"yyyy-MM-dd hh:mm:ss"}}</td>
<td>{{d.department.name}}</td>
<td><input type="button" value="删除" ng-click="dele(d.id)"/></td>
</tr>
</table>
</div>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="../Day08/js/angular.min.js"></script>
<script>
var app = angular.module("myApp",[]);
app.controller("count",function($scope,$http){
$http.get("http://result.eolinker.com/TucCTQueffdc1d1aaa3be05d8c62e9bb5d3e8b495f97cca?uri=hybrid")
.then(function(d){
$scope.persons = d.data;
});
$scope.getAge = function(bir){
var b = new Date(bir).getYear();
var nowb = new Date().getYear();
return nowb-b;
}
$scope.px = "";
$scope.dele = function(id){
var index = 0;
for(var i in $scope.persons){
if($scope.persons[i].id == id){
index = i;
}
}
if(confirm("是否确认删除")){
$scope.persons.splice(index,1);
}
}
$scope.ckAll = function(){
for(var i=0; i<$scope.persons.length; i++){
$scope.persons[i].ck = $scope.flag;
}
}
$scope.deleAll = function(){
var de = 0;
for(var i=0; i<$scope.persons.length; i++){
if($scope.persons[i].ck){
de++;
$scope.persons.splice(i,1);
i--;
}
}
if(de == 0){
alert("请选择")
}
}
});
</script>
<style>
#box{
width: 700px;
height: 500px;
margin: 0 auto;
padding-top: 50px;
text-align: center;
}
table{
width: 600px;
margin: 0 auto;
}
</style>
</head>
<body ng-app="myApp" ng-controller="count">
<h1 ng-show="persons.length == 0">页面无操作数据</h1>
<div id="box" ng-show="persons.length>0">
<input type="text" placeholder="根据姓名模糊查找" ng-model="selname"/>
<input type="text" placeholder="根据部门模糊查找" ng-model="selbname"/>
<select ng-model="px">
<option value="" ng-selected="true">---请选择---</option>
<option value="+birthday">根据年龄排序</option>
<option value="+salary">根据薪资排序</option>
</select>
<input type="button" value="批量删除" ng-click="deleAll()"/>
<table border="1px" cellpadding="0" cellspacing="0">
<tr>
<th><input type="checkbox" ng-model="flag" ng-click="ckAll()"/></th>
<th>员工姓名</th>
<th>员工年龄</th>
<th>员工性别</th>
<th>员工薪资</th>
<th>出生日期</th>
<th>部门名称</th>
<th>删除</th>
</tr>
<tr ng-repeat="d in persons|filter:{name:selname}|filter:{department:{name:selbname}}|orderBy:px">
<td><input type="checkbox" ng-model="d.ck"/></td>
<td>{{d.name}}</td>
<td>{{getAge(d.birthday)}}</td>
<td>{{d.gender}}</td>
<td>{{d.salary|currency:"¥:"}}</td>
<td>{{d.birthday|date:"yyyy-MM-dd hh:mm:ss"}}</td>
<td>{{d.department.name}}</td>
<td><input type="button" value="删除" ng-click="dele(d.id)"/></td>
</tr>
</table>
</div>
</body>
</html>