haiwei-module-admin 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +54 -0
- package/src/api/components/account.js +58 -0
- package/src/api/components/auditInfo.js +30 -0
- package/src/api/components/auth.js +47 -0
- package/src/api/components/cache.js +16 -0
- package/src/api/components/config.js +34 -0
- package/src/api/components/file.js +41 -0
- package/src/api/components/log.js +22 -0
- package/src/api/components/menu.js +68 -0
- package/src/api/components/mime.js +10 -0
- package/src/api/components/module.js +18 -0
- package/src/api/components/permission.js +25 -0
- package/src/api/components/role.js +73 -0
- package/src/api/components/tool.js +29 -0
- package/src/api/index.js +13 -0
- package/src/components/config-admin/index.vue +47 -0
- package/src/components/enum-checkbox/index.vue +31 -0
- package/src/components/enum-radio/index.vue +31 -0
- package/src/components/enum-select/index.vue +31 -0
- package/src/components/file-download/index.vue +81 -0
- package/src/components/file-img/index.vue +55 -0
- package/src/components/file-upload/index.vue +140 -0
- package/src/components/file-upload-img/index.vue +263 -0
- package/src/components/index.js +10 -0
- package/src/components/login-mode-select/index.vue +11 -0
- package/src/components/module-select/index.vue +11 -0
- package/src/components/platform-select/index.vue +28 -0
- package/src/components/role-select/index.vue +11 -0
- package/src/components/upload-mixins.js +127 -0
- package/src/config/index.js +18 -0
- package/src/index.js +69 -0
- package/src/main.js +5 -0
- package/src/module.js +10 -0
- package/src/routes/index.js +3 -0
- package/src/store/index.js +4 -0
- package/src/views/account/components/save/index.vue +65 -0
- package/src/views/account/index/cols.js +50 -0
- package/src/views/account/index/index.vue +127 -0
- package/src/views/account/index/page.js +57 -0
- package/src/views/auditInfo/components/details/index.vue +64 -0
- package/src/views/auditInfo/index/cols.js +63 -0
- package/src/views/auditInfo/index/index.vue +118 -0
- package/src/views/auditInfo/index/page.js +34 -0
- package/src/views/button/permission-bind/index.vue +50 -0
- package/src/views/cache/index/cols.js +10 -0
- package/src/views/cache/index/index.vue +64 -0
- package/src/views/cache/index/page.js +29 -0
- package/src/views/config/index.vue +43 -0
- package/src/views/config/library/components/auth/index.vue +165 -0
- package/src/views/config/library/components/component/index.vue +149 -0
- package/src/views/config/library/components/path/index.vue +45 -0
- package/src/views/config/library/components/quartz/index.vue +66 -0
- package/src/views/config/library/components/system/index.vue +58 -0
- package/src/views/config/library/form-mixins.js +25 -0
- package/src/views/config/library/index.vue +76 -0
- package/src/views/config/module/index.vue +64 -0
- package/src/views/config/page.js +21 -0
- package/src/views/file/index/cols.js +53 -0
- package/src/views/file/index/index.vue +52 -0
- package/src/views/file/index/page.js +42 -0
- package/src/views/home/components/bottom/index.vue +217 -0
- package/src/views/home/components/top-left/index.vue +43 -0
- package/src/views/home/components/top-right/index.vue +148 -0
- package/src/views/home/index.vue +27 -0
- package/src/views/home/page.js +15 -0
- package/src/views/icon/index.vue +92 -0
- package/src/views/icon/page.js +15 -0
- package/src/views/log/login-log/cols.js +43 -0
- package/src/views/log/login-log/index.vue +86 -0
- package/src/views/log/login-log/page.js +27 -0
- package/src/views/menu/components/add/components/link/index.vue +106 -0
- package/src/views/menu/components/add/components/mixins.js +83 -0
- package/src/views/menu/components/add/components/node/index.vue +53 -0
- package/src/views/menu/components/add/components/route/index.vue +122 -0
- package/src/views/menu/components/add/index.vue +86 -0
- package/src/views/menu/components/edit/components/link/index.vue +106 -0
- package/src/views/menu/components/edit/components/mixins.js +80 -0
- package/src/views/menu/components/edit/components/node/index.vue +53 -0
- package/src/views/menu/components/edit/components/route/index.vue +122 -0
- package/src/views/menu/components/edit/index.vue +95 -0
- package/src/views/menu/components/tree/index.vue +153 -0
- package/src/views/menu/index/cols.js +46 -0
- package/src/views/menu/index/index.vue +175 -0
- package/src/views/menu/index/page.js +48 -0
- package/src/views/mime/components/save/index.vue +45 -0
- package/src/views/mime/index/cols.js +16 -0
- package/src/views/mime/index/index.vue +55 -0
- package/src/views/mime/index/page.js +42 -0
- package/src/views/module/components/page-list/index.vue +234 -0
- package/src/views/module/components/permission-list/cols.js +36 -0
- package/src/views/module/components/permission-list/index.vue +90 -0
- package/src/views/module/index/index.vue +226 -0
- package/src/views/module/index/page.js +21 -0
- package/src/views/role/components/menu-bind/index.vue +85 -0
- package/src/views/role/components/page-bind/index.vue +221 -0
- package/src/views/role/components/platform-bind/index.vue +105 -0
- package/src/views/role/components/save/index.vue +45 -0
- package/src/views/role/components/tree/index.vue +112 -0
- package/src/views/role/index/index.vue +67 -0
- package/src/views/role/index/page.js +64 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<nm-container>
|
|
3
|
+
<nm-box v-bind="box">
|
|
4
|
+
<template v-slot:title
|
|
5
|
+
>模块中心<span class="nm-p-l-10 nm-size-12">
|
|
6
|
+
当前模块:<label class="nm-text-primary">{{ list.length }}</label></span
|
|
7
|
+
>
|
|
8
|
+
</template>
|
|
9
|
+
<template v-slot:toolbar>
|
|
10
|
+
<nm-button icon="refresh" size="mini" @click="refresh" />
|
|
11
|
+
</template>
|
|
12
|
+
<div class="module-list">
|
|
13
|
+
<div class="module-list-item" v-for="(item, i) in list" :key="i">
|
|
14
|
+
<div class="module-list-item-bar" :style="{ backgroundColor: item.color }"></div>
|
|
15
|
+
<div class="module-list-item-wrapper">
|
|
16
|
+
<div class="module-list-item-icon" :style="{ backgroundColor: item.color }"><nm-icon :name="item.icon" /></div>
|
|
17
|
+
<div class="module-list-item-info">
|
|
18
|
+
<p>
|
|
19
|
+
{{ getNo(item) }}_{{ item.name
|
|
20
|
+
}}<label class="api-request-count"
|
|
21
|
+
>访问<label class="nm-text-warning nm-p-l-3 nm-p-r-3">{{ item.apiRequestCount }}</label
|
|
22
|
+
>次</label
|
|
23
|
+
>
|
|
24
|
+
</p>
|
|
25
|
+
<p><span>编码:</span>{{ item.code }}</p>
|
|
26
|
+
<p><span>版本:</span>{{ item.version }}</p>
|
|
27
|
+
<p :title="item.remarks"><span>说明:</span>{{ item.remarks }}</p>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="module-list-item-btn">
|
|
30
|
+
<nm-button text="接口" size="mini" type="success" @click="openPermission(item)" />
|
|
31
|
+
<nm-button text="页面" size="mini" type="primary" @click="openPage(item)" />
|
|
32
|
+
<nm-button text="删除" size="mini" type="danger" @click="remove(item)" />
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
</nm-box>
|
|
38
|
+
<!--接口列表-->
|
|
39
|
+
<permission-list :module="module" :visible.sync="dialog.permission" />
|
|
40
|
+
<!--页面列表-->
|
|
41
|
+
<page-list :module="module" :visible.sync="dialog.page" />
|
|
42
|
+
</nm-container>
|
|
43
|
+
</template>
|
|
44
|
+
<script>
|
|
45
|
+
import PermissionList from '../components/permission-list'
|
|
46
|
+
import PageList from '../components/page-list'
|
|
47
|
+
import page from './page'
|
|
48
|
+
// 接口
|
|
49
|
+
const { query } = $api.admin.module
|
|
50
|
+
|
|
51
|
+
export default {
|
|
52
|
+
name: page.name,
|
|
53
|
+
components: { PermissionList, PageList },
|
|
54
|
+
data() {
|
|
55
|
+
return {
|
|
56
|
+
list: [],
|
|
57
|
+
colors: ['#409EFF', '#67C23A', '#E6A23C', '#F56C6C', '#6d3cf7', '#0079de'],
|
|
58
|
+
box: {
|
|
59
|
+
page: true,
|
|
60
|
+
header: true,
|
|
61
|
+
icon: 'app',
|
|
62
|
+
fullscreen: true,
|
|
63
|
+
loading: false
|
|
64
|
+
},
|
|
65
|
+
dialog: {
|
|
66
|
+
permission: false,
|
|
67
|
+
page: false
|
|
68
|
+
},
|
|
69
|
+
buttons: page.buttons,
|
|
70
|
+
module: {}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
methods: {
|
|
74
|
+
refresh() {
|
|
75
|
+
this.box.loading = true
|
|
76
|
+
query()
|
|
77
|
+
.then(data => {
|
|
78
|
+
this.list = data.map(m => {
|
|
79
|
+
m.color = this.colors[parseInt(Math.random() * this.colors.length)]
|
|
80
|
+
return m
|
|
81
|
+
})
|
|
82
|
+
this.box.loading = false
|
|
83
|
+
})
|
|
84
|
+
.catch(() => {
|
|
85
|
+
this.box.loading = false
|
|
86
|
+
})
|
|
87
|
+
},
|
|
88
|
+
getNo(item) {
|
|
89
|
+
return item.number < 10 ? '0' + item.number : '' + item.number
|
|
90
|
+
},
|
|
91
|
+
openPermission(m) {
|
|
92
|
+
this.module = m
|
|
93
|
+
this.dialog.permission = true
|
|
94
|
+
},
|
|
95
|
+
openPage(m) {
|
|
96
|
+
this.module = m
|
|
97
|
+
this.dialog.page = true
|
|
98
|
+
},
|
|
99
|
+
remove() {
|
|
100
|
+
this._warning('在线删除模块功能开发中,敬请期待~', '提示')
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
created() {
|
|
104
|
+
this.refresh()
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
</script>
|
|
108
|
+
<style lang="scss" scoped>
|
|
109
|
+
.module-list {
|
|
110
|
+
height: 100%;
|
|
111
|
+
&-item {
|
|
112
|
+
position: relative;
|
|
113
|
+
display: inline-block;
|
|
114
|
+
margin: 0 1% 10px 0;
|
|
115
|
+
width: 24%;
|
|
116
|
+
height: 100px;
|
|
117
|
+
|
|
118
|
+
&:nth-child(2n + 1) {
|
|
119
|
+
margin-left: 0.5%;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&:nth-child(2n) {
|
|
123
|
+
margin-right: 0.5%;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
&-bar {
|
|
127
|
+
position: absolute;
|
|
128
|
+
left: 50%;
|
|
129
|
+
top: 0;
|
|
130
|
+
height: 2px;
|
|
131
|
+
width: 0;
|
|
132
|
+
margin-left: 0;
|
|
133
|
+
transition: all 0.3s ease-in-out;
|
|
134
|
+
z-index: 9999;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
&-wrapper {
|
|
138
|
+
position: absolute;
|
|
139
|
+
padding: 0 0 0 80px;
|
|
140
|
+
width: 100%;
|
|
141
|
+
border: 1px solid #ebeef5;
|
|
142
|
+
box-sizing: border-box;
|
|
143
|
+
cursor: pointer;
|
|
144
|
+
background-color: #fff;
|
|
145
|
+
height: 100px;
|
|
146
|
+
transition: all 0.3s ease-in-out;
|
|
147
|
+
overflow: hidden;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
&-icon {
|
|
151
|
+
position: absolute;
|
|
152
|
+
left: 10px;
|
|
153
|
+
top: 20px;
|
|
154
|
+
width: 60px;
|
|
155
|
+
height: 60px;
|
|
156
|
+
line-height: 60px;
|
|
157
|
+
text-align: center;
|
|
158
|
+
font-size: 40px;
|
|
159
|
+
transition: all 0.4s ease-in-out;
|
|
160
|
+
color: #fff;
|
|
161
|
+
border-radius: 30px;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
&-info {
|
|
165
|
+
padding: 5px 10px 5px 0;
|
|
166
|
+
height: 80px;
|
|
167
|
+
line-height: 1.7;
|
|
168
|
+
font-size: 12px;
|
|
169
|
+
|
|
170
|
+
p {
|
|
171
|
+
position: relative;
|
|
172
|
+
padding-left: 34px;
|
|
173
|
+
white-space: nowrap;
|
|
174
|
+
text-overflow: ellipsis;
|
|
175
|
+
overflow: hidden;
|
|
176
|
+
word-break: break-all;
|
|
177
|
+
color: #606266;
|
|
178
|
+
|
|
179
|
+
span {
|
|
180
|
+
position: absolute;
|
|
181
|
+
left: 0;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
p:first-child {
|
|
186
|
+
padding-left: 0;
|
|
187
|
+
font-size: 14px;
|
|
188
|
+
font-weight: 600;
|
|
189
|
+
color: #333;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.api-request-count {
|
|
193
|
+
float: right;
|
|
194
|
+
font-size: 11px;
|
|
195
|
+
font-weight: 400;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
&-btn {
|
|
200
|
+
padding: 10px;
|
|
201
|
+
text-align: right;
|
|
202
|
+
|
|
203
|
+
.el-button--mini {
|
|
204
|
+
padding: 4px 6px;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
&:hover {
|
|
209
|
+
.module-list-item-bar {
|
|
210
|
+
width: 100% !important;
|
|
211
|
+
margin-left: -50%;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.module-list-item-wrapper {
|
|
215
|
+
height: 135px;
|
|
216
|
+
z-index: 999;
|
|
217
|
+
box-shadow: 0 2px 12px 0 rgba(64, 158, 255, 0.5);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.module-list-item-icon {
|
|
221
|
+
transform: rotateZ(360deg);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
</style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** 页面信息 */
|
|
2
|
+
const page = new (function() {
|
|
3
|
+
this.title = '模块中心'
|
|
4
|
+
this.icon = 'product'
|
|
5
|
+
this.name = 'admin_module'
|
|
6
|
+
this.path = '/admin/module'
|
|
7
|
+
|
|
8
|
+
// 关联权限
|
|
9
|
+
this.permissions = [`${this.name}_query_get`, `admin_permission_query_get`, `admin_permission_querybycodes_get`]
|
|
10
|
+
|
|
11
|
+
// 按钮
|
|
12
|
+
this.buttons = {}
|
|
13
|
+
})()
|
|
14
|
+
|
|
15
|
+
/** 路由信息 */
|
|
16
|
+
export const route = {
|
|
17
|
+
page,
|
|
18
|
+
component: () => import(/* webpackChunkName: "admin.module" */ './index')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default page
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<nm-box page :header="false" footer :loading="loading">
|
|
3
|
+
<el-alert title="提示" type="warning" class="nm-m-b-10" description="路由菜单基于页面配置,同一个页面可以配置任意个菜单" show-icon> </el-alert>
|
|
4
|
+
<el-tree ref="tree" class="nm-admin-role-menus-tree" v-bind="menuTree">
|
|
5
|
+
<div class="nm-admin-role-menus-tree-node" slot-scope="{ data }">
|
|
6
|
+
<span class="nm-admin-role-menus-tree-node-label"><nm-icon :name="data.item.icon || 'attachment'" /> {{ data.label }}</span>
|
|
7
|
+
</div>
|
|
8
|
+
</el-tree>
|
|
9
|
+
|
|
10
|
+
<template v-slot:footer>
|
|
11
|
+
<nm-button type="success" text="保存" @click="save" />
|
|
12
|
+
<nm-button type="info" text="重置" @click="reset" />
|
|
13
|
+
</template>
|
|
14
|
+
</nm-box>
|
|
15
|
+
</template>
|
|
16
|
+
<script>
|
|
17
|
+
const menuApi = $api.admin.menu
|
|
18
|
+
const { queryBindMenus, bindMenus } = $api.admin.role
|
|
19
|
+
export default {
|
|
20
|
+
data() {
|
|
21
|
+
return {
|
|
22
|
+
loading: false,
|
|
23
|
+
menuTree: {
|
|
24
|
+
data: [],
|
|
25
|
+
nodeKey: 'id',
|
|
26
|
+
'expand-on-click-node': false,
|
|
27
|
+
'default-expand-all': true,
|
|
28
|
+
'show-checkbox': true
|
|
29
|
+
},
|
|
30
|
+
menus: []
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
props: {
|
|
34
|
+
//角色ID
|
|
35
|
+
id: String
|
|
36
|
+
},
|
|
37
|
+
methods: {
|
|
38
|
+
queryMenuTree() {
|
|
39
|
+
this.loading = true
|
|
40
|
+
menuApi.getTree().then(data => {
|
|
41
|
+
this.menuTree.data = [data]
|
|
42
|
+
this.loading = false
|
|
43
|
+
})
|
|
44
|
+
},
|
|
45
|
+
queryBindMenus() {
|
|
46
|
+
this.menus = []
|
|
47
|
+
if (this.id) {
|
|
48
|
+
this.loading = true
|
|
49
|
+
queryBindMenus(this.id).then(data => {
|
|
50
|
+
this.menus = data
|
|
51
|
+
this.reset()
|
|
52
|
+
this.loading = false
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
save() {
|
|
57
|
+
let model = {
|
|
58
|
+
roleId: this.id,
|
|
59
|
+
menus: this.$refs.tree.getCheckedKeys().concat(this.$refs.tree.getHalfCheckedKeys())
|
|
60
|
+
}
|
|
61
|
+
this.loading = true
|
|
62
|
+
bindMenus(model).then(() => {
|
|
63
|
+
this._success('保存成功')
|
|
64
|
+
this.menus = model.menus
|
|
65
|
+
this.loading = false
|
|
66
|
+
})
|
|
67
|
+
},
|
|
68
|
+
reset() {
|
|
69
|
+
this.$nextTick(() => {
|
|
70
|
+
this.$refs.tree.setCheckedKeys(this.menus)
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
created() {
|
|
75
|
+
this.queryMenuTree()
|
|
76
|
+
this.queryBindMenus()
|
|
77
|
+
},
|
|
78
|
+
watch: {
|
|
79
|
+
id() {
|
|
80
|
+
//延迟加载,防止无法渲染已选择的数据
|
|
81
|
+
setTimeout(this.queryBindMenus, 100)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
</script>
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<nm-box page :header="false" footer :loading="loading">
|
|
3
|
+
<el-alert
|
|
4
|
+
title="提示"
|
|
5
|
+
type="warning"
|
|
6
|
+
class="nm-m-b-10"
|
|
7
|
+
description="Web端授权是通过绑定页面以及按钮实现的,页面以及按钮都会关联所用到接口权限,因此只要绑定了页面以及按钮就能拥有所关联的接口权限"
|
|
8
|
+
show-icon
|
|
9
|
+
>
|
|
10
|
+
</el-alert>
|
|
11
|
+
|
|
12
|
+
<nm-box class="nm-m-b-5" no-padding>
|
|
13
|
+
<el-form label-width="100px">
|
|
14
|
+
<el-form-item class="nm-m-b-0" label="快捷操作:">
|
|
15
|
+
<el-checkbox label="全选" @change="onCheckAllChange"></el-checkbox>
|
|
16
|
+
</el-form-item>
|
|
17
|
+
</el-form>
|
|
18
|
+
</nm-box>
|
|
19
|
+
|
|
20
|
+
<el-tree ref="tree" class="nm-admin-role-menus-tree" v-bind="tree" @check="onTreeCheck">
|
|
21
|
+
<div class="nm-admin-role-menus-tree-node" slot-scope="{ data }">
|
|
22
|
+
<span class="nm-admin-role-menus-tree-node-label">{{ data.label }}</span>
|
|
23
|
+
<div class="nm-admin-role-menus-tree-node-buttons">
|
|
24
|
+
<el-checkbox v-for="btn in data.buttons" :key="btn.code" v-model="btn.checked" :label="btn.text" :disabled="!data.checked"></el-checkbox>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
</el-tree>
|
|
28
|
+
|
|
29
|
+
<template v-slot:footer>
|
|
30
|
+
<nm-button type="success" text="保存" @click="save" />
|
|
31
|
+
<nm-button type="info" text="重置" @click="resetTree" />
|
|
32
|
+
</template>
|
|
33
|
+
</nm-box>
|
|
34
|
+
</template>
|
|
35
|
+
<script>
|
|
36
|
+
import { mapState } from 'vuex'
|
|
37
|
+
const moduleApi = $api.admin.module
|
|
38
|
+
const { queryBindPages, bindPages } = $api.admin.role
|
|
39
|
+
export default {
|
|
40
|
+
data() {
|
|
41
|
+
return {
|
|
42
|
+
loading: false,
|
|
43
|
+
tree: {
|
|
44
|
+
data: [],
|
|
45
|
+
nodeKey: 'code',
|
|
46
|
+
'expand-on-click-node': false,
|
|
47
|
+
'default-expand-all': true,
|
|
48
|
+
'show-checkbox': true
|
|
49
|
+
},
|
|
50
|
+
bindPages: [],
|
|
51
|
+
pages: []
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
props: {
|
|
55
|
+
//角色ID
|
|
56
|
+
id: String
|
|
57
|
+
},
|
|
58
|
+
computed: {
|
|
59
|
+
...mapState('app/page', { allPages: 'pages' })
|
|
60
|
+
},
|
|
61
|
+
methods: {
|
|
62
|
+
resolveTreeData() {
|
|
63
|
+
this.loading = true
|
|
64
|
+
//获取模块列表
|
|
65
|
+
moduleApi.select().then(data => {
|
|
66
|
+
data.forEach(m => {
|
|
67
|
+
let node = {
|
|
68
|
+
id: m.value.toLowerCase(),
|
|
69
|
+
label: m.label,
|
|
70
|
+
checked: false,
|
|
71
|
+
children: this.allPages
|
|
72
|
+
.filter(x => x.moduleCode.toLowerCase() === m.value.toLowerCase())
|
|
73
|
+
.map(y => {
|
|
74
|
+
let buttons = []
|
|
75
|
+
for (let key in y.buttons) {
|
|
76
|
+
let btn = y.buttons[key]
|
|
77
|
+
buttons.push({
|
|
78
|
+
text: btn.text,
|
|
79
|
+
code: btn.code,
|
|
80
|
+
permissions: btn.permissions,
|
|
81
|
+
checked: false
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
let page = {
|
|
85
|
+
code: y.code,
|
|
86
|
+
label: y.name,
|
|
87
|
+
buttons: buttons,
|
|
88
|
+
permissions: y.permissions,
|
|
89
|
+
checked: false
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
this.pages.push(page)
|
|
93
|
+
return page
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
this.tree.data.push(node)
|
|
97
|
+
})
|
|
98
|
+
this.loading = false
|
|
99
|
+
|
|
100
|
+
this.queryBindPages()
|
|
101
|
+
})
|
|
102
|
+
},
|
|
103
|
+
queryBindPages() {
|
|
104
|
+
this.bindPages = []
|
|
105
|
+
if (this.id) {
|
|
106
|
+
this.loading = true
|
|
107
|
+
queryBindPages(this.id).then(data => {
|
|
108
|
+
this.bindPages = data.pages
|
|
109
|
+
this.resetTree()
|
|
110
|
+
this.loading = false
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
save() {
|
|
115
|
+
let model = {
|
|
116
|
+
roleId: this.id,
|
|
117
|
+
pages: this.pages
|
|
118
|
+
.filter(m => m.checked)
|
|
119
|
+
.map(m => {
|
|
120
|
+
let buttons = m.buttons.filter(n => n.checked)
|
|
121
|
+
let page = {
|
|
122
|
+
code: m.code,
|
|
123
|
+
buttons: buttons.map(x => x.code),
|
|
124
|
+
permissions: m.permissions
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (page.buttons && page.buttons.length > 0) {
|
|
128
|
+
buttons.forEach(x => {
|
|
129
|
+
if (x.permissions && x.permissions.length > 0) {
|
|
130
|
+
x.permissions.forEach(y => {
|
|
131
|
+
page.permissions.push(y)
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return page
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
this.loading = true
|
|
141
|
+
bindPages(model).then(() => {
|
|
142
|
+
this._success('保存成功')
|
|
143
|
+
this.loading = false
|
|
144
|
+
})
|
|
145
|
+
},
|
|
146
|
+
/**重置树 */
|
|
147
|
+
resetTree() {
|
|
148
|
+
let checkedKeys = []
|
|
149
|
+
|
|
150
|
+
//已绑定的菜单
|
|
151
|
+
this.pages.forEach(m => {
|
|
152
|
+
let n = this.bindPages.find(x => x.code === m.code)
|
|
153
|
+
if (n) {
|
|
154
|
+
checkedKeys.push(m.code)
|
|
155
|
+
m.checked = true
|
|
156
|
+
if (m.buttons && m.buttons.length > 0) {
|
|
157
|
+
m.buttons.forEach(x => {
|
|
158
|
+
x.checked = n.buttons.includes(x.code)
|
|
159
|
+
})
|
|
160
|
+
}
|
|
161
|
+
} else {
|
|
162
|
+
m.checked = false
|
|
163
|
+
if (m.buttons && m.buttons.length > 0) {
|
|
164
|
+
m.buttons.forEach(x => {
|
|
165
|
+
x.checked = false
|
|
166
|
+
})
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
})
|
|
170
|
+
this.$nextTick(() => {
|
|
171
|
+
this.$refs.tree.setCheckedKeys(checkedKeys)
|
|
172
|
+
})
|
|
173
|
+
},
|
|
174
|
+
onCheckAllChange(checked) {
|
|
175
|
+
let checkedKeys = []
|
|
176
|
+
if (checked) {
|
|
177
|
+
this.pages.forEach(m => {
|
|
178
|
+
m.checked = true
|
|
179
|
+
checkedKeys.push(m.code)
|
|
180
|
+
if (m.buttons && m.buttons.length > 0) {
|
|
181
|
+
m.buttons.forEach(x => {
|
|
182
|
+
x.checked = true
|
|
183
|
+
})
|
|
184
|
+
}
|
|
185
|
+
})
|
|
186
|
+
} else {
|
|
187
|
+
this.pages.forEach(m => {
|
|
188
|
+
m.checked = false
|
|
189
|
+
if (m.buttons && m.buttons.length > 0) {
|
|
190
|
+
m.buttons.forEach(x => {
|
|
191
|
+
x.checked = false
|
|
192
|
+
})
|
|
193
|
+
}
|
|
194
|
+
})
|
|
195
|
+
}
|
|
196
|
+
this.$nextTick(() => {
|
|
197
|
+
this.$refs.tree.setCheckedKeys(checkedKeys)
|
|
198
|
+
})
|
|
199
|
+
},
|
|
200
|
+
onTreeCheck(data, nodes) {
|
|
201
|
+
this.pages.forEach(m => {
|
|
202
|
+
m.checked = nodes.checkedNodes.findIndex(n => n.code === m.code) > -1
|
|
203
|
+
if (!m.checked && m.buttons && m.buttons.length > 0) {
|
|
204
|
+
m.buttons.forEach(m => {
|
|
205
|
+
m.checked = false
|
|
206
|
+
})
|
|
207
|
+
}
|
|
208
|
+
})
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
created() {
|
|
212
|
+
this.resolveTreeData()
|
|
213
|
+
},
|
|
214
|
+
watch: {
|
|
215
|
+
id() {
|
|
216
|
+
//延迟加载,防止无法渲染已选择的数据
|
|
217
|
+
setTimeout(this.queryBindPages, 100)
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
</script>
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<nm-box page :header="false" footer :loading="loading">
|
|
3
|
+
<el-alert title="提示" type="warning" class="nm-m-10" description="平台授权是给Web平台以外的平台绑定权限使用的,比如安卓、IOS、小程序等等" show-icon> </el-alert>
|
|
4
|
+
<el-form label-width="100px">
|
|
5
|
+
<el-form-item style="width:500px;margin:15px 0;" label="选择平台:">
|
|
6
|
+
<nm-platform-select v-model="platform" no-web @change="queryBindPlatformPermissions" :clearable="false" />
|
|
7
|
+
</el-form-item>
|
|
8
|
+
</el-form>
|
|
9
|
+
<el-tree ref="tree" v-bind="tree">
|
|
10
|
+
<span slot-scope="{ data }">
|
|
11
|
+
<nm-icon name="attachment" />
|
|
12
|
+
<span class="nm-m-l-5"
|
|
13
|
+
>{{ data.label
|
|
14
|
+
}}<label v-if="data.item.isPermission" class="nm-p-l-5 nm-text-info nm-size-14" style="font-style: italic;"
|
|
15
|
+
>(<label>{{ data.item.code }}</label
|
|
16
|
+
>)</label
|
|
17
|
+
></span
|
|
18
|
+
>
|
|
19
|
+
</span>
|
|
20
|
+
</el-tree>
|
|
21
|
+
<template v-slot:footer>
|
|
22
|
+
<nm-button type="success" text="保存" @click="save" />
|
|
23
|
+
<nm-button type="info" text="重置" @click="reset" />
|
|
24
|
+
</template>
|
|
25
|
+
</nm-box>
|
|
26
|
+
</template>
|
|
27
|
+
<script>
|
|
28
|
+
import { mixins } from 'netmodular-ui'
|
|
29
|
+
const api = $api.admin.permission
|
|
30
|
+
const { queryBindPlatformPermissions, bindPlatformPermissions } = $api.admin.role
|
|
31
|
+
export default {
|
|
32
|
+
mixins: [mixins.visible],
|
|
33
|
+
data() {
|
|
34
|
+
return {
|
|
35
|
+
tree: {
|
|
36
|
+
data: [],
|
|
37
|
+
nodeKey: 'id',
|
|
38
|
+
defaultExpandAll: true,
|
|
39
|
+
showCheckbox: true
|
|
40
|
+
},
|
|
41
|
+
platform: 1,
|
|
42
|
+
loading: false,
|
|
43
|
+
permissions: []
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
props: {
|
|
47
|
+
id: String
|
|
48
|
+
},
|
|
49
|
+
methods: {
|
|
50
|
+
queryPermissionTree() {
|
|
51
|
+
this.loading = true
|
|
52
|
+
api
|
|
53
|
+
.tree()
|
|
54
|
+
.then(data => {
|
|
55
|
+
this.tree.data = [data]
|
|
56
|
+
this.loading = false
|
|
57
|
+
})
|
|
58
|
+
.catch(() => {
|
|
59
|
+
this.loading = false
|
|
60
|
+
})
|
|
61
|
+
},
|
|
62
|
+
queryBindPlatformPermissions() {
|
|
63
|
+
this.loading = true
|
|
64
|
+
queryBindPlatformPermissions({ roleId: this.id, platform: this.platform }).then(data => {
|
|
65
|
+
this.permissions = data
|
|
66
|
+
this.reset()
|
|
67
|
+
this.loading = false
|
|
68
|
+
})
|
|
69
|
+
},
|
|
70
|
+
save() {
|
|
71
|
+
let permissions = this.$refs.tree
|
|
72
|
+
.getCheckedNodes()
|
|
73
|
+
.filter(m => m.item.isPermission)
|
|
74
|
+
.map(m => {
|
|
75
|
+
return m.item.code
|
|
76
|
+
})
|
|
77
|
+
this.loading = true
|
|
78
|
+
bindPlatformPermissions({ roleId: this.id, platform: this.platform, permissions })
|
|
79
|
+
.then(() => {
|
|
80
|
+
this._success('保存成功')
|
|
81
|
+
this.permissions = permissions
|
|
82
|
+
this.loading = false
|
|
83
|
+
})
|
|
84
|
+
.catch(() => {
|
|
85
|
+
this.loading = false
|
|
86
|
+
})
|
|
87
|
+
},
|
|
88
|
+
reset() {
|
|
89
|
+
this.$nextTick(() => {
|
|
90
|
+
this.$refs.tree.setCheckedKeys(this.permissions)
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
created() {
|
|
95
|
+
this.queryPermissionTree()
|
|
96
|
+
this.queryBindPlatformPermissions()
|
|
97
|
+
},
|
|
98
|
+
watch: {
|
|
99
|
+
id() {
|
|
100
|
+
this.platform = 1
|
|
101
|
+
this.queryBindPlatformPermissions()
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
</script>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<nm-form-dialog ref="form" v-bind="form" v-on="on" :visible.sync="visible_">
|
|
3
|
+
<el-row>
|
|
4
|
+
<el-col :span="20" :offset="1">
|
|
5
|
+
<el-form-item label="名称:" prop="name">
|
|
6
|
+
<el-input v-model="form.model.name" />
|
|
7
|
+
</el-form-item>
|
|
8
|
+
<el-form-item label="备注:" prop="remarks">
|
|
9
|
+
<el-input type="textarea" v-model="form.model.remarks"></el-input>
|
|
10
|
+
</el-form-item>
|
|
11
|
+
</el-col>
|
|
12
|
+
</el-row>
|
|
13
|
+
</nm-form-dialog>
|
|
14
|
+
</template>
|
|
15
|
+
<script>
|
|
16
|
+
import { mixins } from 'netmodular-ui'
|
|
17
|
+
|
|
18
|
+
// 接口
|
|
19
|
+
const { add, edit, update } = $api.admin.role
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
mixins: [mixins.formSave],
|
|
23
|
+
data() {
|
|
24
|
+
return {
|
|
25
|
+
title: '角色',
|
|
26
|
+
actions: {
|
|
27
|
+
add,
|
|
28
|
+
edit,
|
|
29
|
+
update
|
|
30
|
+
},
|
|
31
|
+
form: {
|
|
32
|
+
width: '30%',
|
|
33
|
+
model: {
|
|
34
|
+
id: '',
|
|
35
|
+
name: '',
|
|
36
|
+
remarks: ''
|
|
37
|
+
},
|
|
38
|
+
rules: {
|
|
39
|
+
name: [{ required: true, message: '请输入名称', trigger: 'blur' }]
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
</script>
|