关于批量删除 用两个时间计算年龄

<!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>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值