userEnabledFlagEditCtrl.js
2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
(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);