functionCtrl.js
4.69 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
(function(angular) {
function functionCtrl($scope, DTOptionsBuilder, DTColumnBuilder, systemService, $uibModal, $filter, $state) {
var typeShow = (function () {
return function (e, dt, node, config) {
var results = null;
if (node.functionAttrType == '1') {
results = "文本输入框"
} else if (node.functionAttrType == '2') {
results = "单项旋转框"
} else if (node.functionAttrType == '3') {
results = "按钮"
} else if (node.functionAttrType == '4') {
results = "文本输入框(属性限制)"
} else if (node.functionAttrType == '5') {
results = "后台业务开关"
}
return results;
};
})();
$scope.dtColumns = [
DTColumnBuilder.newColumn('menuCode').withOption('width',60).withTitle('菜单编号'),
DTColumnBuilder.newColumn('menuName').withOption('width',120).withTitle('菜单名称'),
DTColumnBuilder.newColumn('menuUrl').withOption('width',80).withTitle('菜单地址'),
DTColumnBuilder.newColumn('functionName').withOption('width',100).withTitle('功能名称'),
DTColumnBuilder.newColumn('functionAttrName').withOption('width',120).withTitle('功能属性名'),
DTColumnBuilder.newColumn('functionAttrType').withOption('width',120).withTitle('功能属性类型').renderWith(typeShow),
DTColumnBuilder.newColumn('functionRemark').withOption('width',180).withTitle('功能备注'),
DTColumnBuilder.newColumn('userLimitType').withOption('width',100).withTitle('用户群体').renderWith(function(e, dt, node, config){
if(node.userLimitType == 0){
return "指定角色";
}else if(node.userLimitType == 1){
return "用户类型";
}else if(node.userLimitType == 2){
return "指定用户ID";
}else if(node.userLimitType == 3){
return "所属商户用户类型";
}
return "";
}),
DTColumnBuilder.newColumn('createdDate').withOption('width',140).withTitle('创建时间').renderWith(function(e, dt, node, config){
return $filter('date')(new Date(node.createdDate), 'yyyy-MM-dd HH:mm:ss');
}),
DTColumnBuilder.newColumn(null).withTitle(function(){
return '操作';
}).withOption('width', 60).withClass('text-center').renderWith(function(data, type, full, oSettings) {
var str = '<div class="form-inline">'
+'<div class="form-group"><a class="btn btn-link" ng-click="functionAddOrUpdate('+ data.id +')">编辑</a></div>'
// +'<div class="form-group"><a class="btn btn-link" ng-click="menuAddOrUpdate('+ data.id +')">删除</a></div>';
str += '</div>';
return str;
})
];
$scope.dtOptions = DTOptionsBuilder.newOptions()
.withOption('id','id')
.withFixedColumns({
leftColumns: 2,
rightColumns: 0
})
$scope.dtInstance = {
serverData : systemService.getFunctionList
};
$scope.changeMenu = function(type){
if(type == 1){
$scope.secondMenuCode = null;
$scope.thirdMenuCode = null;
}else if(type == 2){
$scope.thirdMenuCode = null;
}
}
function getParams(){
var obj = {};
if($scope.thirdMenuCode){
obj.menuCode = $scope.thirdMenuCode.code;
}else if($scope.secondMenuCode){
obj.menuCode = $scope.secondMenuCode.code;
}else if($scope.firsrMenuCode){
obj.menuCode = $scope.firsrMenuCode.code;
}
if($scope.functionName){// 功能名称
obj.functionName = $scope.functionName;
}
if($scope.functionAttrType){// 功能类型
obj.functionAttrType = $scope.functionAttrType;
}
if($scope.userLimitType){// 功能类型
obj.userLimitType = $scope.userLimitType;
}
return obj;
}
//查询列表
$scope.functionListForm = function(){
$scope.dtInstance.query(getParams());
}
$scope.functionAddOrUpdate = function (id) {
$uibModal.open({
templateUrl: 'biz/system/view/functionAdd.html',
controller: 'functionAddCtrl',
size: 'lg',
resolve: {
params: function () {
return {'id':id}
}
}
}).result.then(function (data) {
$scope.functionListForm();
},function(){
$scope.functionListForm();
})
};
}
angular.module('system').controller('functionCtrl', functionCtrl)
})(angular);