用户信息列表 查询+年龄,性别搜索 +全部删除,批量删除+添加用户+修改密码

<!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>

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值