包含敏感词与查询

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../angular-1.5.5/angular.min.js"></script>
    <style>
        .xz{
            background: #00b0e0;
            margin-top: 10px;
            width: 100px;
            height: 40px;
        }
        table{
            margin-top: 10px;
            border-collapse: collapse;
        }
        th,td{
            padding: 10px;
            border: 1px solid #000000;
        }
    </style>
    <script>
        var myapp = angular.module("myapp",[]);
        myapp.controller("myCtrl",function ($scope) {
            $scope.data=[{
                name:"张三",
                wz:"控球后卫",
                num:"11",
                ps:"999"
            },{
                name:"李四",
                wz:"得分后卫",
                num:"08",
                ps:"888"
            },{
                name:"王五",
                wz:"大前锋",
                num:"03",
                ps:"777"
            },{
                name:"赵龙",
                wz:"小前锋",
                num:"05",
                ps:"666"
            },{
                name:"周磊",
                wz:"后卫",
                num:"15",
                ps:"555"
            },{
                name:"枪火",
                wz:"前锋",
                num:"23",
                ps:"444"
            }];
            $scope.search="";
            $scope.search2="";
            $scope.$watch("search",function (value) {
                console.log(value);
                if (value.indexOf("枪火")!=-1){
                    alert("包含敏感词");
                    $scope.search="";
                } else {
                    $scope.search2=$scope.search;
                }
            });
            //选择排序部分
            $scope.sort="--请选择--";
            //$scope.revers=null;
            $scope.fun=function () {
                if ($scope.sort!="--请选择--"){
                    if ($scope.sort=="票数倒序"){
                        $scope.revers=true;
                    } else if ($scope.sort=="票数正序"){
                        $scope.revers=false;
                    }
                }
            };
            //新增球员部分
            $scope.show=false;
            $scope.add=function () {
                $scope.show = true;
            };
            $scope.push=function () {
                for (var i=0;i<$scope.data.length;i++){
                    if ($scope.name==$scope.data[i].name){
                        alert("重复");
                        return;
                    }
                }
                $scope.data.push({name:$scope.name,wz:$scope.wz,num:$scope.num,ps:$scope.ps});
            };
            console.log(angular.isNumber(0));
        })
    </script>
</head>
<body ng-app="myapp" ng-controller="myCtrl">
<span>查询</span>
<input type="text" ng-model="search">
<select ng-model="sort" ng-change="fun()" style="margin-left: 50px">
    <option>--请选择--</option>
    <option>票数倒序</option>
    <option>票数正序</option>
</select></br>
<button ng-click="add()" class="xz">新增球员</button>
<table>
    <thead>
    <tr>
        <th>姓名</th>
        <th>位置</th>
        <th>球号</th>
        <th>票数</th>
    </tr>
    </thead>
    <tbody >
    <tr ng-repeat="item in data|filter:search2|orderBy:'ps':revers">
        <td>{{item.name}}</td>
        <td>{{item.wz}}</td>
        <td>{{item.num}}</td>
        <td>{{item.ps}}</td>
    </tr>
    </tbody>
</table>
<table ng-show="show">
    <tr>
        <td>姓名</td>
        <td><input type="text" ng-model="name"></td>
    </tr>
    <tr>
        <td>位置</td>
        <td><input type="text" ng-model="wz"></td>
    </tr>
    <tr>
        <td>球号</td>
        <td><input type="text" ng-model="num"></td>
    </tr>
    <tr>
        <td>票数</td>
        <td><input type="text" ng-model="ps"></td>
    </tr>
    <tr>
        <td colspan="2"><button ng-click="push()">添加</button></td>
    </tr>
</table>
</body>
</html>


第二个
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../angular-1.5.5/angular.js"></script>
    <script src="../angular-1.5.5/angular-route.js"></script>
    <script>
        var app =angular.module("myApp",["ngRoute"]);
        app.config
        app.controller("myCtrl",function ($scope) {
            $scope.users=[{
                name:"张三",
                wz:"控球后卫",
                size:11,
                ps:999
            },{
                name:"李四",
                wz:"大前锋",
                size:21,
                ps:888
            },{
                name:"王五",
                wz:"小前锋",
                size:23,
                ps:777
            },{
                name:"赵六",
                wz:"中锋",
                size:10,
                ps:666
            },{
                name:"周七",
                wz:"得分后卫",
                size:1,
                ps:555
            }];
            $scope.Size="--请选择--"
            $scope.psSize =function (ps,Size) {
                if(Size=="--请选择--"){
                    return true;
                }else{
                    var arr = Size.split("-");
                    var ageMin = arr[0];
                    var ageMax = arr[1];
                    if(ps>ageMin && ps<ageMax){
                        return true;
                    }else{
                        return false;
                    }
                }
            }
            $scope.addUser =function () {
                $scope.myVar = !$scope.myVar;
            }
            $scope.tijiao = function(name1,wz1,size1,ps1){
                if(name1==""||name1==null && wz1==""|| wz1==null && size1==""|| size1==null){
                    alert("不能为空")
                }else {
                    var panduan = false;
                    var panduan1 = false;
                    var panduan2 = false;
                    for (var i = 0; i < $scope.users.length; i++) {
                        if ($scope.users[i].name === name1) {
                            alert("姓名已存在")
                            panduan=false;
                        }else{
                            panduan=true
                        }
                        if ($scope.users[i].wz === wz1) {
                            alert("位置已存在")
                            panduan1=false;
                        }else{
                            panduan1=true
                        }
                        if ($scope.users[i].size === size1) {
                            alert("号码已存在")
                            panduan2=false;
                        }else{
                            panduan2=true
                        }
                    }
                    if(panduan==true&&panduan1==true&&panduan2==true){
                        if (ps1 > 0&& ps1 < 1000){
                            $scope.users.push({
                                name: name1,
                                wz: wz1,
                                size: size1,
                                ps: ps1
                            })
                        }else {
                            alert("票数在0-1000之间")
                        }
                    }
                }
            }
        })
    </script>
    <style type="text/css">
        div{
            display: inline-block;
        }
    </style>
</head>
<body ng-app="myApp" ng-controller="myCtrl" style=" width: 500px; height: 300px; margin: 0 auto;">
<div>
    <h5>查询</h5>
    <input type="text" ng-model="select">
</div>
<div style="margin-left: 200px">
    <h5>排序</h5>
    <select ng-model="Size">
        <option>--请选择--</option>
        <option>100-200</option>
        <option>200-300</option>
        <option>300-400</option>
        <option>400-500</option>
        <option>600-700</option>
        <option>700-800</option>
        <option>800-900</option>
        <option>900-1000</option>
    </select>
</div>
<p></p>
<button style="background: deepskyblue; width: 100px; height: 50px" ng-click="addUser()">新增球员</button>
<br>
<table  border="1px soild" cellspacing="0" cellpadding="10px" style="width: 800px; height: 300px; margin-top: 20px">
    <tr>
        <th>姓名</th>
        <th>位置</th>
        <th>球号</th>
        <th>票数</th>
    </tr>
    <tr ng-repeat="i in users| filter:{name:select} " ng-if="psSize(i.ps,Size)">
        <td>{{i.name}}</td>
        <td>{{i.wz}}</td>
        <td>{{i.size}}</td>
        <td>{{i.ps}}</td>
    </tr>
</table>
<table ng-if="myVar" border="1px soild" cellspacing="0" cellpadding="10px" style="margin: 20px auto">
    <tr>
        <th>
            添加球员
        </th>
    </tr>
    <tr>
        <td>姓名:<input type="text" placeholder="请输入姓名" ng-model="name1"></td>
    </tr>
    <tr>
        <td>位置:<input type="text" placeholder="请输入位置" ng-model="wz1"></td>
    </tr>
    <tr>
        <td>球号:<input type="text" placeholder="请输入球号" ng-model="size1"></td>
    </tr>
    <tr>
        <td>票数:<input type="text" placeholder="请输入票数" ng-model="ps1"></td>
    </tr>
    <tr align="center">
        <td><button  ng-click="tijiao(name1,wz1,size1,ps1)">添加</button></td>
    </tr>
</table>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值