functionAddCtrl.js
5.25 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
(function (angular) {
function functionAddCtrl($scope, params, $http, $uibModalInstance, $uibModal, DTColumnBuilder, DTOptionsBuilder,systemService,$rootScope) {
$scope.functionId = params.id;
$scope.menuCode = params.menuCode;
$scope.menuName = params.menuName;
$scope.formData = {
functionAttrType:''
}
$scope.functionAttrTypes=[
{id:1,name:'文本输入框'},
{id:2,name:'单项选择框'},
{id:3,name:'按钮'},
{id:4,name:'文本输入框(属性限制)'},
{id:5,name:'后台业务开关'}
];
$scope.changeMenu = function(type){
if(type == 1){
$scope.formData.secondMenuCode = null;
$scope.formData.thirdMenuCode = null;
}else if(type == 2){
$scope.formData.thirdMenuCode = null;
}
}
$scope.addFunction = function (userType) {
if($scope.creatForm.$invalid || $scope.formData.functionAttrType == undefined){
$scope.isInValidate = true;
return false;
}
var params = {};
if($scope.functionId){
params.id = $scope.functionId;
}
if($scope.menuCode){
params.menuCode = $scope.menuCode;
}else if($scope.formData.thirdMenuCode){
params.menuCode = $scope.formData.thirdMenuCode.code;
}else if($scope.formData.secondMenuCode){
params.menuCode = $scope.formData.secondMenuCode.code;
}else{
params.menuCode = $scope.formData.firsrMenuCode.code;
}
params.functionName = $scope.formData.functionName;
params.functionAttrName = $scope.formData.functionAttrName;
params.functionAttrType = $scope.formData.functionAttrType.id;
params.userLimitType = $scope.formData.userLimitType;
if(params.userLimitType != 0 && $scope.formData.userLimitDataIdStrs){
params.userLimitDataIdStrs = $scope.formData.userLimitDataIdStrs;
}
if ($scope.formData.functionRemark) {
params.functionRemark = $scope.formData.functionRemark;
}
if ((params.functionAttrType == 2 || params.functionAttrType == 4 ) && $scope.formData.addFunctionValueStrs) {
params.functionValueStrs = $scope.formData.addFunctionValueStrs;
}
params.orderNo = $scope.formData.orderNo;
console.log(params)
systemService.addOrUpdateFunction($.param(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(){
if($scope.functionId){
systemService.getFunctionById({'id':$scope.functionId},function(res){// 通过id获取到功能内容 a按钮,1,1;b按钮,2,2;
if(res.returnCode == 0){
$scope.formData = res.data;
$scope.formData.userLimitType = res.data.userLimitType + '';
if(res.data.dataIds && res.data.dataIds.length > 0){
$scope.formData.userLimitDataIdStrs = res.data.dataIds.join(",");
}
$scope.formData.functionAttrType = $scope.functionAttrTypes[res.data.functionAttrType-1];
for(var i = 0;i< $rootScope.curUserMenuClassList.length;i++){
var firsrMenuCode = $rootScope.curUserMenuClassList[i];
if(firsrMenuCode.code == res.data.menuCode){
$scope.formData.firsrMenuCode = firsrMenuCode;
break;
}
var isBreak = false;
for(var j = 0;j< firsrMenuCode.sublist.length;j++){
var secondMenuCode = firsrMenuCode.sublist[j];
if(secondMenuCode.code == res.data.menuCode){
$scope.formData.firsrMenuCode = firsrMenuCode;
$scope.formData.secondMenuCode = secondMenuCode;
isBreak = true;
break;
}
for(var k = 0;k< secondMenuCode.sublist.length;k++){
var thirdMenuCode = secondMenuCode.sublist[k];
if(thirdMenuCode.code == res.data.menuCode){
$scope.formData.firsrMenuCode = firsrMenuCode;
$scope.formData.secondMenuCode = secondMenuCode;
$scope.formData.thirdMenuCode = thirdMenuCode;
isBreak = true;
break;
}
}
if(isBreak){
break;
}
}
if(isBreak){
break;
}
}
}else{
swal({type: 'error',title: '',text: res.message||'查询失败',timer: 1500},function(){window.sweetAlert.close();});
}
})
} else {
$scope.formData.functionAttrType = $scope.functionAttrTypes[1];
$scope.formData.userLimitType = '0';
}
};
$scope.init();
}
angular.module('system').controller('functionAddCtrl', functionAddCtrl);
})(angular);