configureAddCtrl.js
3.16 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
(function (angular) {
function configureAddCtrl($scope, params, $http, $uibModalInstance, $uibModal, DTColumnBuilder, DTOptionsBuilder,globalFunctionService,systemService,$rootScope,$filter) {
var confGroup = params.confGroup;
$scope.getConfigure = function(confGroup){
systemService.getConfigureByConfGroup({'confGroup':confGroup},function(res){
if(res.returnCode == 0){
$scope.confDescription = res.data.confDescription;
if(res.data.confKeyList){
var isAppendValue = false;
var keys = res.data.confKeyList.join(",");
if(res.data.confValueList){
var values = res.data.confValueList.join(",");
if(values != keys){
isAppendValue = true;
}
}
var confStr = "";
for(var i = 0;i<res.data.confKeyList.length;i++){
if(confStr != ""){
confStr += "&";
}
confStr += res.data.confKeyList[i];
if(isAppendValue && res.data.confValueList && res.data.confValueList[i]){
confStr+= "|" + res.data.confValueList[i];
if(res.data.confNameList && res.data.confNameList[i]){
confStr+= "|" + res.data.confNameList[i];
}
}
}
$scope.confKeys = confStr;
}
}
})
}
$scope.confGroupSelectArr = globalFunctionService.getFunctionVal('configureList', 'confGroup') || [];//配置分组
if($scope.confGroupSelectArr.length > 0){
if(confGroup){
var cg = $filter('filter')($scope.confGroupSelectArr, {code: confGroup}, true);
$scope.confGroup=cg[0] || $scope.confGroupSelectArr[0];
}else{
$scope.confGroup=$scope.confGroupSelectArr[0];
}
$scope.getConfigure($scope.confGroup.code);
}
$scope.addOrUpdate = function (userType) {
if($scope.creatForm.$invalid){
$scope.isInValidate = true;
return false;
}
var params = {};
if($scope.confGroup){
params.confGroup = $scope.confGroup.code;
}
if($scope.confKeys){
params.confKeyList = new Array();
params.confValueList = new Array();
params.confNameList = new Array();
var c = $scope.confKeys.split("&");
for(var index = 0;index<c.length;index++){
var confArr = c[index].split("|");
params.confKeyList.push(confArr[0].trim());
if(confArr[1]){
params.confValueList.push(confArr[1].trim());
if(confArr[2]){
params.confNameList.push(confArr[2].trim());
}
}
}
}
if($scope.confDescription){
params.confDescription = $scope.confDescription;
}
systemService.insertOrUpdateConfigure(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();});
}
});
};
}
angular.module('system').controller('configureAddCtrl', configureAddCtrl);
})(angular);