实时效验ID唯一及提示

北战南征 提交于 2019-12-05 16:31:40

输入id即时提示该ID是否可用

<ui-col style="" class="text-right" sm="2" md="2" lg="2">
            <label class="control-label animated"
              uib-tooltip-html="'hello  <b>world.</b>'" tooltip-popup-delay="" tooltip-popup-close-delay=""
              tooltip-placement="top" tooltip-trigger="'mouseenter'" tooltip-enable="false"
              tooltip-class="">事件id</label>
          </ui-col>
          <ui-col style="" class="text-right" sm="4" md="4" lg="4">
            <input type="text" class="form-control " placeholder="" ng-readonly="showDetail" ng-required="true"
              ng-model="param.bus.event_id" ng-change="checkUnique()">
            <p class="text-left" ng-show="param.bus.event_id!=undefined" ng-bind="param.checkMsg"
              ng-style="{'color':param.pass?'green':'red'}"></p>
            <span>{{typeof(param.bus.event_id)}}</span>
          </ui-col>

 

  //  校验事件ID的唯一
    $scope.checkUnique = function () {
      // console.log(typeof ($scope.param.bus.event_id));
      $http({
        method: "GET",
        url: MSBURL + "....",
        params: {
          event_id: $scope.param.bus.event_id
        }
      }).then(function (response) {

        switch (response.data.code) {
          case "1":
            $scope.param.pass = true;
            $scope.param.checkMsg = "当前事件id唯一,可使用"
            // $scope.query();
            break;
          case "0":
            $scope.param.pass = false;
            $scope.param.checkMsg = "当前事件id已存在,请更换"
            break;
        }
      });
    }

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!