menuCtrl.js
3.15 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
(function(angular) {
function menuCtrl($scope, DTOptionsBuilder, DTColumnBuilder, systemService, $uibModal, $filter, $state) {
$scope.dtColumns = [
DTColumnBuilder.newColumn('name').withOption('width',200).withTitle('菜单名称'),
DTColumnBuilder.newColumn('code').withOption('width',140).withTitle('菜单编号'),
DTColumnBuilder.newColumn('url').withOption('width',200).withTitle('菜单地址'),
DTColumnBuilder.newColumn('parentCode').withOption('width',100).withTitle('父菜单编号'),
DTColumnBuilder.newColumn('orderNo').withOption('width',100).withTitle('排序值(升序)'),
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', 140).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="menuAddOrUpdate('+ data.id +')">编辑</a></div>'
+'<div class="form-group"><a class="btn btn-link" ng-click="functionAdd(\''+ data.code +'\',\'' + data.name + '\')">功能添加</a></div>';
str += '</div>';
return str;
})
];
$scope.dtOptions = DTOptionsBuilder.newOptions()
.withOption('id','id')
.withFixedColumns({
leftColumns: 2,
rightColumns: 0
})
$scope.dtInstance = {
serverData : systemService.getMenuList
};
function getParams(){
var obj = {};
if($scope.name){
obj.name = $scope.name;
}
if($scope.code){
obj.code = $scope.code;
}
if($scope.parentCode){
obj.parentCode = $scope.parentCode;
}
return obj;
}
//查询列表
$scope.menuListForm = function(){
$scope.dtInstance.query(getParams());
}
$scope.menuAddOrUpdate = function (id) {
$uibModal.open({
templateUrl: 'biz/system/view/menuAdd.html',
controller: 'menuAddCtrl',
size: 'lg',
resolve: {
params: function () {
return {'id':id}
}
}
}).result.then(function (data) {
$scope.dtInstance.query(getParams());
},function(){
$scope.dtInstance.query(getParams());
})
};
$scope.functionAdd = function (menuCode,menuName) {
$uibModal.open({
templateUrl: 'biz/system/view/functionAdd.html',
controller: 'functionAddCtrl',
size: 'lg',
resolve: {
params: function () {
return {'menuCode':menuCode,'menuName':menuName}
}
}
}).result.then(function (data) {
},function(){
$scope.dtInstance.query(getParams());
})
};
}
angular.module('system').controller('menuCtrl', menuCtrl)
})(angular);