userEnabledFlagEditCtrl.js 2.11 KB
(function (angular) {
    function userEnabledFlagEditCtrl($scope, params, $http, $uibModalInstance, $uibModal,systemService,$filter,$rootScope,$q,SweetAlertX) {
    	$scope.accountEnabledFlag = [{'name':'正常',value:'Y'},{'name':'未启用',value:'N'},{'name':'已注销',value:'C'}];
    	$scope.userId = params.userId;
    	$scope.info = {};
    	$scope.info.enabledFlag = $filter('filter')($scope.accountEnabledFlag, {'value':params.enabledFlag}, false)[0];
        $scope.ok = function () {
    		if($scope.creatForm.$invalid){
                $scope.isInValidate = true;
                return false;
            }
    		SweetAlertX.swal({
    	          title: "确定要变更账号状态为" + $scope.info.enabledFlag.name + "吗?",
    	          text: "",
    	          type: "info",
    	          showCancelButton: true,
    	          closeOnConfirm: false,
    	          showLoaderOnConfirm: true,
    	          confirmButtonText: "确认",
    	          cancelButtonText: "取消",
    	     },function (b) {
    	          if (b) {
    	        	$scope.saveBtnDisabled = true;
    	      		swal({title: '',text: '处理中...',imageUrl: 'images/timg.gif',showConfirmButton: false});
    	      		var params = {};
    	      		if($scope.userId){
    	      			params.userId = $scope.userId;
    	      		}
    	      		params.enabledFlag = $scope.info.enabledFlag.value;
    	      		systemService.updateUserEnabledFlag(params,function(res){
    	      			$scope.saveBtnDisabled = false;
    	      			if(res.returnCode == 0){
    	      				swal({type: 'success',title: '',text:'操作成功',showConfirmButton:false,timer: 1500},function(){
    	                          window.sweetAlert.close();
    	                          $uibModalInstance.close();
    	                      });
    	      			}else{
    	      				swal({type: 'error',title: '',text: res.message||'操作失败',timer: 1500},function(){window.sweetAlert.close();});
    	      			}
    	      		});
    	          }
    	     });
        };
    }
    angular.module('system').controller('userEnabledFlagEditCtrl', userEnabledFlagEditCtrl);

})(angular);