<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="angular-1.3.0.js"></script> <script src="jquery-1.11.0.js"></script> <script> var myapp= angular.module("myapp",[]); var data=[ { done:false, id:"1", name:"张三", pwd:123, year:22, sex:"男", }, { done:false, id:"2", name:"李四", pwd:"456", year:33, sex:"女", }, { done:false, id:"3", name:"王五", pwd:"789", year:44, sex:"男", } ] myapp.controller("myctrl",function ($scope) { $scope.data=data; $scope.col="id"; $scope.desc=0; /*批量删除*/ $scope.delall=function () { var con=confirm("确定删除么?"); if(con==true){ for(var i=0;i<$scope.data.length;i++) { if($scope.data[i].done==true) { $scope.data.splice(i,1); i--; } } }else{ } } /*全选框*/ $scope.checkAll=function () { for(var i=0;i<$scope.data.length;i++) { if($scope.chec==true) { $scope.data[i].done=true; } else{ $scope.data[i].done=false; } } } $scope.dels=function () { var con=confirm("确定删除么?"); $scope.data=[]; } $scope.tj=function () { $scope.addusershow=true; } var id = 4; $scope.hq = function () { if($scope.name==null||$scope.name==""){ alert("用户名不可为空!"); }else if($scope.year<10||$scope.year>60){ alert("年龄在10到60之间!"); }else { $scope.data.push({ id: id++, name: $scope.name, pwd: $scope.pwd, year: $scope.year, sex: $scope.sex }); $scope.name = ""; $scope.pwd = ""; $scope.year = ""; $scope.sex = ""; $scope.addusershow = false; } }; $scope.editUser = function (index) { var user = $scope.data[index]; $scope.e_name = user.name; $scope.e_old_password = ""; $scope.e_password = ""; $scope.e_repassword = ""; $scope.editUserIsShow = true; $scope.index = index; }; $scope.edit = function () { if ($scope.e_password != $scope.e_repassword) { alert("两次密码不一致!"); return; } $scope.data[$scope.index].pwd = $scope.e_password; $scope.editUserIsShow = false; }; }); $(function () { $("#a").click(function () { $("#a").css("color","red"); $("#aa").css("color","black"); $("#a3").css("color","black"); $("#a4").css("color","black"); $("#a5").css("color","black"); }); $("#aa").click(function () { $("#a").css("color","black"); $("#aa").css("color","red"); $("#a3").css("color","black"); $("#a4").css("color","black"); $("#a5").css("color","black"); }); $("#a3").click(function () { $("#a").css("color","black"); $("#aa").css("color","black"); $("#a3").css("color","red"); $("#a4").css("color","black"); $("#a5").css("color","black"); }); $("#a4").click(function () { $("#a").css("color","black"); $("#aa").css("color","black"); $("#a3").css("color","black"); $("#a4").css("color","red"); $("#a5").css("color","black"); }); $("#a5").click(function () { $("#a").css("color","black"); $("#aa").css("color","black"); $("#a3").css("color","black"); $("#a4").css("color","black"); $("#a5").css("color","red"); }); }); </script> </head> <body ng-app="myapp" ng-controller="myctrl"> <div> <h2 style="margin-left: 600px">用户信息表</h2> <hr> <div style="background-color: #E8FBFF;height:25px"> <input type="text" value="" placeholder="用户名查询" ng-model="search"> 年龄:<select ng-model="search2"> <option>--请选择--</option> <option>22</option> <option>33</option> <option>44</option> </select> 性别:<select ng-model="search3"> <option>男</option> <option>女</option> <option>全选</option> </select> <button type="button" style="color:#c3c3c3;background-color:red " ng-click="dels()">全部删除</button> <button type="button" style="color:#c3c3c3;background-color:red " ng-click="delall()">批量删除</button> </div> </div> <div> <table border="1" bordercolor="#c3c3c3" width="500" cellpadding="0" cellspacing="0" style="width:1350px;text-align: center"> <tr> <td><input type="checkbox" ng-click="checkAll()" ng-model="chec"></td> <td>id</td> <td>用户名</td> <td>密码</td> <td>年龄</td> <td>性别</td> <td>操作</td> </tr > <tr ng-repeat="item in data|filter:{'name':search}|filter:{'year':search2}|filter:{'sex':search3}"> <td><input type="checkbox" ng-model="item.done"></td> <td>{{item.id}}</td> <td>{{item.name}}</td> <td>{{item.pwd}}</td> <td>{{item.year}}</td> <td>{{item.sex}}</td> <td> <button style="color: #E8FBFF;background-color: yellow"ng-click="editUser($index)" >修改密码</button> </td> </tr> </table> <br> <div style="margin-left: 600px"> <Button style="background-color: #0c60ee" ng-click="tj()" >添加用户</Button> </div> </div> <br> <br> <div style="margin-left: 500px" ng-show="addusershow" > <table border="1" bordercolor="#c3c3c3" width="500" cellpadding="0" cellspacing="0" style="width:500px;text-align: center" > <tr> <td>用户名:<input type="text" placeholder="请输入用户名" ng-model="name"></td> </tr> <tr> <td>密码:<input type="text" placeholder="请输入密码"ng-model="pwd"></td> </tr> <tr> <td>年龄:<input type="text" placeholder="请输入年龄"ng-model="year"></td> </tr> <tr> <td>性别:<input type="text" placeholder="请输入性别"ng-model="sex"></td> </tr> <tr> <td><input type="button" value="提交" ng-click="hq()"></td> </tr> </table> </div> <div ng-show="editUserIsShow"> <table border="1"> <tr> <td> 用户名: </td> <td> <input type="text" ng-model="e_name" disabled/> </td> </tr> <tr> <td> 旧密码: </td> <td> <input type="text" ng-model="e_old_password"/> </td> </tr> <tr> <td> 新密码: </td> <td> <input type="text" ng-model="e_password"/> </td> </tr> <tr> <td> 确认密码: </td> <td> <input type="text" ng-model="e_repassword"/> </td> </tr> <tr> <td colspan="2" align="center"> <input type="hidden" ng-model="index"/> <button ng-click="edit()">提交</button> </td> </tr> </table> </div> </body> </html>
用户信息列表 查询+年龄,性别搜索 +全部删除,批量删除+添加用户+修改密码
最新推荐文章于 2021-06-11 12:26:28 发布