appAccessDialogCtrl.js
2.46 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
(function (angular) {
function appAccessDialogCtrl($scope, params, $http, $uibModalInstance, $uibModal, dopService,$filter,$rootScope) {
$scope.appStatusList = [{id:1,name:'启用'},{id:2,name:'停用'},{id:3,name:'异常'}];
$scope.id = params.id;
$scope.ok = function () {
if($scope.creatForm.$invalid){
$scope.isInValidate = true;
return false;
}
var params = {};
if($scope.id){
params.id = $scope.id;
}
params.appId = $scope.info.appId;
params.appName = $scope.info.appName;
params.appPrincipal = $scope.info.appPrincipal;
if($scope.info.appStatus){
params.appStatus = $scope.info.appStatus.id;
}
if($scope.id){
dopService.updateAppAccess(params,function(res){
if(res.returnCode == 0){
swal({type: 'success',title: '',text: res.message||'更新成功',showConfirmButton:false,timer: 1500},function(){
window.sweetAlert.close();
$uibModalInstance.close();
});
}else{
swal({type: 'error',title: '',text: res.message||'更新失败',timer: 1500},function(){window.sweetAlert.close();});
}
});
}else{
dopService.createAppAccess(params,function(res){
if(res.returnCode == 0){
swal({type: 'success',title: '',text: res.message||'创建成功',showConfirmButton:false,timer: 1500},function(){
window.sweetAlert.close();
$uibModalInstance.close();
});
}else{
swal({type: 'error',title: '',text: res.message||'创建失败',timer: 1500},function(){window.sweetAlert.close();});
}
});
}
};
$scope.init = function(){
$scope.info={};
if($scope.id){
dopService.getAppAccess({'id':$scope.id},function(res){
if(res.returnCode == 0){
$scope.info = res.data;
angular.forEach($scope.appStatusList, function(r){
if(r.id == $scope.info.appStatus){
$scope.info.appStatus = r;
}
});
}else{
swal({type: 'error',title: '',text: res.message||'查询失败',timer: 1500},function(){window.sweetAlert.close();});
}
})
}
};
$scope.init();
}
angular.module('dop').controller('appAccessDialogCtrl', appAccessDialogCtrl);
})(angular);