json

<!DOCTYPE html>
<html>
 <head>
  <meta charset="utf-8" />
  <title></title>
  <script type="text/javascript" src="js/angular.js" ></script>
  <script>
   var app=angular.module("myapp",[]);
   app.controller("myCtrl",function($scope,$http){
    $http.get("http://result.eolinker.com/TucCTQueffdc1d1aaa3be05d8c62e9bb5d3e8b495f97cca?uri=hybrid")
                      .success(function(aaa){
                       $scope.pros=aaa;
                      });
                //年龄
                    $scope.getage=function(bith){
                     var m=new Date(bith).getYear();
                     var n=new Date().getYear();
                     return n-m;
                    }
                //删除
                    $scope.del=function(id){
                     var index=0;
                     for(var i in $scope.pros){
                      if($scope.pros[i].id==id){
                       index=i;
                      }
                     }
                     var f = confirm("确定删除吗?");
                     if(f){
                      $scope.pros.splice(index, 1);
                     }
                     
                    }
                //部门排序
                $scope.getbumen=function(bumen){
                 if($scope.mohus == undefined || $scope.mohus == "") {
       return true;
      }
                 if(bumen.indexOf($scope.mohus) > -1) {
       return true;
      }
      return false;
                }
                //添加
                $scope.jia=false;
                $scope.tianjia=function(){
                 var obj;
                 var dname=$scope.x_department.name;
                 if(dname=="" || dname==undefined){
                  $scope.dd=("部门不能为空");
                 }else if(dname=="市场部"){
                  obj={id:1,name:dname}
                 }else if(dname=="研发部"){
                  obj={id:1,name:dname}
                 }
                 var s={
                  name:$scope.x_name,
                  gender:$scope.x_gender,
                  salary:$scope.x_salary,
                  birthday:$scope.x_birthday,
                  department:obj
                 }
                 $scope.pros.push(s);
     $scope.jia=false;
    
                }
                $scope.qx=function(){
    for(index in $scope.pros){
     if($scope.pros[index].state=$scope.quan){
      
     }
     
    }
   }
               //全部删除
   $scope.quanshan=function(){
    for (var i = 0; i < $scope.pros.length; i++) {
     if($scope.pros[i].state==true){
      $scope.pros.splice(i,1);
      i--;
     }
    }
   }
   });
  </script>
 </head>
 <body ng-app="myapp" ng-controller="myCtrl">
  <center>
   <button ng-click="quanshan()">全部删除</button>
   <input type="text" placeholder="查询员工姓名" ng-model="mohu"/>
   <input type="text" placeholder="查询部门员工" ng-model="mohus"/>
   <select ng-model="pai">
    <option value="">员工薪资排序</option>
    <option value="+salary">正序</option>
    <option value="-salary">倒序</option>
   </select>
   <button ng-click="jia=true">添加</button>
  <table border="1px" cellpadding="15" cellspacing="0" border="1">
   <thead>
    <tr>
     <th><input type="checkbox" ng-model="quan" ng-click="qx()"></th>
     <th>员工姓名</th>
     <th>员工年龄</th>
     <th>员工姓别</th>
     <th>员工薪资</th>
     <th>出生日期</th>
     <th>部门名称</th>
     <th>删除</th>
    </tr>
   </thead>
   <tbody>
    <tr ng-repeat="por in pros | filter:{name:mohu} | orderBy:pai" align="center" ng-show="getbumen(por.department.name)">
     <td><input type="checkbox" ng-model="por.state"></td>
     <td>{{por.name}}</td>
     <td>{{getage(por.birthday)}}</td>
     <td>{{por.gender}}</td>
     <td><span ng-hide="gai">{{por.salary| currency:'¥'}}</span><span ng-show="gai"><input type="text" ng-model="por.salary"><button ng-click="gai=false">保存</button></span></td>
     <td>{{por.birthday | date:"yyyy-MM-dd hh:mm:ss"}}</td>
     <td>{{por.department.name}}</td>
     <td><button ng-click="del(por.id)">删除</button><button ng-click="gai=true">修改</button></td>
    </tr>
   </tbody>
  </table>
  <p ng-show="jia">
   <input type="text" placeholder="添加姓名" ng-model="x_name"/>
   <input type="text" placeholder="添加性别" ng-model="x_gender"/>
   <input type="text" placeholder="添加薪资" ng-model="x_salary"/>
   <input type="text" placeholder="出生日期" ng-model="x_birthday"/>
   <select ng-model="x_department.name">
    <option value="">选择部门</option>
    <option>市场部</option>
    <option>研发部</option>
   </select>
   <span ng-show="dd.length!=0">{{dd}}</span>
   <button ng-click="tianjia()">添加</button>
  </p>
  </center>
 </body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值