menu.js
5.61 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
var prefix = "/sys/menu"
$(document).ready(function () {
load();
});
var load = function () {
$('#exampleTable')
.bootstrapTreeTable(
{
id: 'menuId',
code: 'menuId',
parentCode: 'parentId',
type: "GET", // 请求数据的ajax类型
url: prefix + '/list', // 请求数据的ajax的url
ajaxParams: {sort:'order_num'}, // 请求数据的ajax的data属性
expandColumn: '1',// 在哪一列上面显示展开按钮
striped: true, // 是否各行渐变色
bordered: true, // 是否显示边框
expandAll: false, // 是否全部展开
// toolbar : '#exampleToolbar',
columns: [
{
title: '编号',
field: 'menuId',
visible: false,
align: 'center',
valign: 'center',
width: '5%'
},
{
title: '名称',
valign: 'center',
field: 'name',
width: '20%'
},
{
title: '图标',
field: 'icon',
align: 'center',
valign: 'center',
width : '5%',
formatter: function (item, index) {
return item.icon == null ? ''
: '<i class="' + item.icon
+ ' fa-lg"></i>';
}
},
{
title: '类型',
field: 'type',
align: 'center',
valign: 'center',
width : '10%',
formatter: function (item, index) {
if (item.type === 0) {
return '<span class="label label-primary">目录</span>';
}
if (item.type === 1) {
return '<span class="label label-success">菜单</span>';
}
if (item.type === 2) {
return '<span class="label label-warning">按钮</span>';
}
}
},
{
title: '地址',
valign: 'center',
width : '20%',
field: 'url'
},
{
title: '权限标识',
valign: 'center',
width : '20%',
field: 'perms'
},
{
title: '操作',
field: 'id',
align: 'center',
valign: 'center',
formatter: function (item, index) {
var e = '<a class="btn btn-primary btn-sm '
+ s_edit_h
+ '" href="#" mce_href="#" title="编辑" onclick="edit(\''
+ item.menuId
+ '\')"><i class="fa fa-edit"></i></a> ';
var p = '<a class="btn btn-primary btn-sm '
+ s_add_h
+ '" href="#" mce_href="#" title="添加下级" onclick="add(\''
+ item.menuId
+ '\')"><i class="fa fa-plus"></i></a> ';
var d = '<a class="btn btn-warning btn-sm '
+ s_remove_h
+ '" href="#" title="删除" mce_href="#" onclick="remove(\''
+ item.menuId
+ '\')"><i class="fa fa-remove"></i></a> ';
return e + d + p;
}
}]
});
}
function reLoad() {
load();
}
function add(pId) {
layer.open({
type: 2,
title: '增加菜单',
maxmin: true,
shadeClose: false, // 点击遮罩关闭层
area: ['800px', '520px'],
content: prefix + '/add/' + pId // iframe的url
});
}
function remove(id) {
layer.confirm('确定要删除选中的记录?', {
btn: ['确定', '取消']
}, function () {
$.ajax({
url: prefix + "/remove",
type: "post",
data: {
'id': id
},
success: function (data) {
if (data.code == 0) {
layer.msg("删除成功");
reLoad();
} else {
layer.msg(data.msg);
}
}
});
})
}
function edit(id) {
layer.open({
type: 2,
title: '菜单修改',
maxmin: true,
shadeClose: false, // 点击遮罩关闭层
area: ['800px', '520px'],
content: prefix + '/edit/' + id // iframe的url
});
}
function batchRemove() {
// var rows = $('#exampleTable').bootstrapTable('getSelections');
}