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,53 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<nm-form ref="form" v-bind="form" v-on="on">
|
|
3
|
+
<el-row :gutter="50">
|
|
4
|
+
<el-col :span="10" :offset="2">
|
|
5
|
+
<el-form-item label="父节点">
|
|
6
|
+
<el-input v-model="parent.path" disabled />
|
|
7
|
+
</el-form-item>
|
|
8
|
+
</el-col>
|
|
9
|
+
<el-col :span="10">
|
|
10
|
+
<el-form-item label="菜单名称:" prop="name">
|
|
11
|
+
<el-input v-model="form.model.name" />
|
|
12
|
+
</el-form-item>
|
|
13
|
+
</el-col>
|
|
14
|
+
</el-row>
|
|
15
|
+
<el-row :gutter="50">
|
|
16
|
+
<el-col :span="10" :offset="2">
|
|
17
|
+
<el-form-item label="图标:" prop="icon">
|
|
18
|
+
<nm-icon-picker v-model="form.model.icon" />
|
|
19
|
+
</el-form-item>
|
|
20
|
+
</el-col>
|
|
21
|
+
<el-col :span="10">
|
|
22
|
+
<el-form-item label="图标颜色:" prop="iconColor">
|
|
23
|
+
<nm-color-picker v-model="form.model.iconColor" />
|
|
24
|
+
</el-form-item>
|
|
25
|
+
</el-col>
|
|
26
|
+
</el-row>
|
|
27
|
+
<el-row :gutter="50">
|
|
28
|
+
<el-col :span="10" :offset="2">
|
|
29
|
+
<el-form-item label="排序:" prop="sort">
|
|
30
|
+
<el-input v-model="form.model.sort" />
|
|
31
|
+
</el-form-item>
|
|
32
|
+
</el-col>
|
|
33
|
+
<el-col :span="10">
|
|
34
|
+
<el-form-item label="显示:" prop="show">
|
|
35
|
+
<el-switch v-model="form.model.show" />
|
|
36
|
+
</el-form-item>
|
|
37
|
+
</el-col>
|
|
38
|
+
</el-row>
|
|
39
|
+
<el-row :gutter="50">
|
|
40
|
+
<el-col :span="20" :offset="2">
|
|
41
|
+
<el-form-item label="备注:" prop="remarks">
|
|
42
|
+
<el-input v-model="form.model.remarks" type="textarea" :rows="2" placeholder="请输入内容"></el-input>
|
|
43
|
+
</el-form-item>
|
|
44
|
+
</el-col>
|
|
45
|
+
</el-row>
|
|
46
|
+
</nm-form>
|
|
47
|
+
</template>
|
|
48
|
+
<script>
|
|
49
|
+
import mixins from '../mixins'
|
|
50
|
+
export default {
|
|
51
|
+
mixins: [mixins]
|
|
52
|
+
}
|
|
53
|
+
</script>
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<nm-form ref="form" v-bind="form" v-on="on">
|
|
3
|
+
<el-row :gutter="50">
|
|
4
|
+
<el-col :span="20" :offset="2">
|
|
5
|
+
<el-form-item label="父节点">
|
|
6
|
+
<el-input v-model="parent.path" disabled />
|
|
7
|
+
</el-form-item>
|
|
8
|
+
</el-col>
|
|
9
|
+
</el-row>
|
|
10
|
+
<el-row :gutter="50">
|
|
11
|
+
<el-col :span="10" :offset="2">
|
|
12
|
+
<el-form-item label="所属模块:" prop="moduleCode">
|
|
13
|
+
<nm-module-select v-model="form.model.moduleCode" />
|
|
14
|
+
</el-form-item>
|
|
15
|
+
</el-col>
|
|
16
|
+
<el-col :span="10">
|
|
17
|
+
<el-form-item label="选择页面:" prop="route">
|
|
18
|
+
<el-select v-model="form.model.routeName" placeholder="请选择" @change="onPageChange">
|
|
19
|
+
<el-option v-for="p in pages" :key="p.code" :label="p.name" :value="p.code">
|
|
20
|
+
<span>{{ p.name }}__{{ p.code }}</span>
|
|
21
|
+
</el-option>
|
|
22
|
+
</el-select>
|
|
23
|
+
</el-form-item>
|
|
24
|
+
</el-col>
|
|
25
|
+
</el-row>
|
|
26
|
+
<el-row :gutter="50">
|
|
27
|
+
<el-col :span="10" :offset="2">
|
|
28
|
+
<el-form-item label="菜单名称:" prop="name">
|
|
29
|
+
<el-input v-model="form.model.name" />
|
|
30
|
+
</el-form-item>
|
|
31
|
+
</el-col>
|
|
32
|
+
<el-col :span="10">
|
|
33
|
+
<el-form-item label="路由名称:" prop="routeName">
|
|
34
|
+
<el-input v-model="form.model.routeName" disabled />
|
|
35
|
+
</el-form-item>
|
|
36
|
+
</el-col>
|
|
37
|
+
</el-row>
|
|
38
|
+
<el-row :gutter="50">
|
|
39
|
+
<el-col :span="10" :offset="2">
|
|
40
|
+
<el-form-item label="路由参数:" prop="routeParams">
|
|
41
|
+
<el-input v-model="form.model.routeParams" type="textarea" :rows="2" placeholder="params"></el-input>
|
|
42
|
+
</el-form-item>
|
|
43
|
+
</el-col>
|
|
44
|
+
<el-col :span="10">
|
|
45
|
+
<el-form-item label="路由参数:" prop="routeQuery">
|
|
46
|
+
<el-input v-model="form.model.routeQuery" type="textarea" :rows="2" placeholder="query"></el-input>
|
|
47
|
+
</el-form-item>
|
|
48
|
+
</el-col>
|
|
49
|
+
</el-row>
|
|
50
|
+
<el-row :gutter="50">
|
|
51
|
+
<el-col :span="10" :offset="2">
|
|
52
|
+
<el-form-item label="图标:" prop="icon">
|
|
53
|
+
<nm-icon-picker v-model="form.model.icon" />
|
|
54
|
+
</el-form-item>
|
|
55
|
+
</el-col>
|
|
56
|
+
<el-col :span="10">
|
|
57
|
+
<el-form-item label="图标颜色:" prop="iconColor">
|
|
58
|
+
<nm-color-picker v-model="form.model.iconColor" />
|
|
59
|
+
</el-form-item>
|
|
60
|
+
</el-col>
|
|
61
|
+
</el-row>
|
|
62
|
+
<el-row :gutter="50">
|
|
63
|
+
<el-col :span="10" :offset="2">
|
|
64
|
+
<el-form-item label="排序:" prop="sort">
|
|
65
|
+
<el-input v-model="form.model.sort" />
|
|
66
|
+
</el-form-item>
|
|
67
|
+
</el-col>
|
|
68
|
+
<el-col :span="10">
|
|
69
|
+
<el-form-item label="显示:" prop="show">
|
|
70
|
+
<el-switch v-model="form.model.show" />
|
|
71
|
+
</el-form-item>
|
|
72
|
+
</el-col>
|
|
73
|
+
</el-row>
|
|
74
|
+
<el-row :gutter="50">
|
|
75
|
+
<el-col :span="20" :offset="2">
|
|
76
|
+
<el-form-item label="备注:" prop="remarks">
|
|
77
|
+
<el-input v-model="form.model.remarks" type="textarea" :rows="2" placeholder="请输入内容"></el-input>
|
|
78
|
+
</el-form-item>
|
|
79
|
+
</el-col>
|
|
80
|
+
</el-row>
|
|
81
|
+
</nm-form>
|
|
82
|
+
</template>
|
|
83
|
+
<script>
|
|
84
|
+
import { mapState } from 'vuex'
|
|
85
|
+
import mixins from '../mixins'
|
|
86
|
+
export default {
|
|
87
|
+
mixins: [mixins],
|
|
88
|
+
data() {
|
|
89
|
+
return {
|
|
90
|
+
form: {
|
|
91
|
+
model: {
|
|
92
|
+
type: 1
|
|
93
|
+
},
|
|
94
|
+
rules: {
|
|
95
|
+
moduleCode: [{ required: true, message: '请选择模块' }],
|
|
96
|
+
routeName: [{ required: true, message: '请选择路由名称' }]
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
computed: {
|
|
102
|
+
...mapState('app/page', { allPages: s => s.pages }),
|
|
103
|
+
pages() {
|
|
104
|
+
if (!this.form.model.moduleCode) return []
|
|
105
|
+
return this.allPages.filter(m => m.moduleCode.toLowerCase() === this.form.model.moduleCode.toLowerCase())
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
methods: {
|
|
109
|
+
onPageChange(val) {
|
|
110
|
+
for (var i = 0; i < this.pages.length; i++) {
|
|
111
|
+
let page = this.pages[i]
|
|
112
|
+
if (page.code === val) {
|
|
113
|
+
this.form.model.name = page.name
|
|
114
|
+
this.form.model.routeName = page.code
|
|
115
|
+
this.form.model.icon = page.icon
|
|
116
|
+
break
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
</script>
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<nm-dialog v-bind="dialog" @open="onOpen" :visible.sync="visible_">
|
|
3
|
+
<node-menu ref="node" v-if="model.type === 0" :model="model" :parent="parent" v-on="on" />
|
|
4
|
+
<route-menu ref="route" v-else-if="model.type === 1" :model="model" :parent="parent" v-on="on" />
|
|
5
|
+
<link-menu ref="link" v-else :model="model" :parent="parent" v-on="on" />
|
|
6
|
+
<template v-slot:footer>
|
|
7
|
+
<nm-button text="保存" type="success" @click="onSubmit" />
|
|
8
|
+
<nm-button text="重置" type="info" @click="onReset" />
|
|
9
|
+
</template>
|
|
10
|
+
</nm-dialog>
|
|
11
|
+
</template>
|
|
12
|
+
<script>
|
|
13
|
+
import { mixins } from 'netmodular-ui'
|
|
14
|
+
import NodeMenu from './components/node'
|
|
15
|
+
import RouteMenu from './components/route'
|
|
16
|
+
import LinkMenu from './components/link'
|
|
17
|
+
|
|
18
|
+
const api = $api.admin.menu
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
mixins: [mixins.dialog],
|
|
22
|
+
components: { NodeMenu, RouteMenu, LinkMenu },
|
|
23
|
+
data() {
|
|
24
|
+
return {
|
|
25
|
+
model: {
|
|
26
|
+
type: 0
|
|
27
|
+
},
|
|
28
|
+
dialog: {
|
|
29
|
+
footer: true,
|
|
30
|
+
title: '编辑菜单',
|
|
31
|
+
icon: 'add',
|
|
32
|
+
width: '60%',
|
|
33
|
+
class: 'nm-admin-menu-edit',
|
|
34
|
+
loading: false,
|
|
35
|
+
draggable: true
|
|
36
|
+
},
|
|
37
|
+
on: {
|
|
38
|
+
success: this.onSuccess,
|
|
39
|
+
error: this.onError,
|
|
40
|
+
'validate-error': this.onValidateError
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
props: ['parent', 'id'],
|
|
45
|
+
methods: {
|
|
46
|
+
async edit() {
|
|
47
|
+
if (this.id === '') {
|
|
48
|
+
this._warning('请选择要编辑的菜单~')
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
this.dialog.loading = true
|
|
53
|
+
this.model = await api.edit(this.id)
|
|
54
|
+
this.setModel()
|
|
55
|
+
this.dialog.loading = false
|
|
56
|
+
},
|
|
57
|
+
onOpen() {
|
|
58
|
+
this.edit()
|
|
59
|
+
},
|
|
60
|
+
onSubmit() {
|
|
61
|
+
this.dialog.loading = true
|
|
62
|
+
this.getModel().submit()
|
|
63
|
+
},
|
|
64
|
+
onReset() {
|
|
65
|
+
this.$nextTick(() => {
|
|
66
|
+
this.getModel().reset()
|
|
67
|
+
})
|
|
68
|
+
},
|
|
69
|
+
onSuccess(model) {
|
|
70
|
+
this.dialog.loading = false
|
|
71
|
+
this.$emit('success', model)
|
|
72
|
+
},
|
|
73
|
+
onError() {
|
|
74
|
+
this.dialog.loading = false
|
|
75
|
+
},
|
|
76
|
+
onValidateError() {
|
|
77
|
+
this.dialog.loading = false
|
|
78
|
+
},
|
|
79
|
+
setModel() {
|
|
80
|
+
this.$nextTick(() => {
|
|
81
|
+
this.getModel().setModel()
|
|
82
|
+
})
|
|
83
|
+
},
|
|
84
|
+
getModel() {
|
|
85
|
+
if (this.model.type === 0) {
|
|
86
|
+
return this.$refs.node
|
|
87
|
+
} else if (this.model.type === 1) {
|
|
88
|
+
return this.$refs.route
|
|
89
|
+
} else {
|
|
90
|
+
return this.$refs.link
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
</script>
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<nm-box page header refresh title="菜单预览" icon="menu" @refresh="refresh">
|
|
3
|
+
<el-tree class="nm-tree" ref="tree" v-bind="tree" :show-checkbox="showCheckbox" :default-expand-all="defaultExpandAll" v-on="on">
|
|
4
|
+
<span slot-scope="{ data }">
|
|
5
|
+
<nm-icon :name="data.item.icon || 'attachment'" />
|
|
6
|
+
<span class="nm-m-l-5">{{ data.label }}</span>
|
|
7
|
+
</span>
|
|
8
|
+
</el-tree>
|
|
9
|
+
</nm-box>
|
|
10
|
+
</template>
|
|
11
|
+
<script>
|
|
12
|
+
const api = $api.admin.menu
|
|
13
|
+
export default {
|
|
14
|
+
data() {
|
|
15
|
+
return {
|
|
16
|
+
tree: {
|
|
17
|
+
data: [],
|
|
18
|
+
nodeKey: 'id',
|
|
19
|
+
highlightCurrent: true,
|
|
20
|
+
props: { children: 'children', label: 'label' },
|
|
21
|
+
currentNodeKey: '00000000-0000-0000-0000-000000000000',
|
|
22
|
+
expandOnClickNode: false,
|
|
23
|
+
defaultExpandedKeys: ['00000000-0000-0000-0000-000000000000']
|
|
24
|
+
},
|
|
25
|
+
on: {
|
|
26
|
+
'current-change': this.onChange,
|
|
27
|
+
'node-expand': this.onNodeExpand,
|
|
28
|
+
'node-collapse': this.onNodeCollapse,
|
|
29
|
+
'check-change': this.onCheckChange,
|
|
30
|
+
check: this.onCheck
|
|
31
|
+
},
|
|
32
|
+
selection: null
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
props: {
|
|
36
|
+
//创建时刷新
|
|
37
|
+
refreshOnCreated: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: true
|
|
40
|
+
},
|
|
41
|
+
showCheckbox: Boolean,
|
|
42
|
+
defaultExpandAll: Boolean
|
|
43
|
+
},
|
|
44
|
+
methods: {
|
|
45
|
+
//刷新
|
|
46
|
+
refresh(init) {
|
|
47
|
+
api.getTree().then(data => {
|
|
48
|
+
this.tree.data = [data]
|
|
49
|
+
if (init) {
|
|
50
|
+
//初始化触发一次change事件
|
|
51
|
+
this.onChange(data)
|
|
52
|
+
} else {
|
|
53
|
+
//刷新要保留当前点击节点
|
|
54
|
+
this.$nextTick(() => {
|
|
55
|
+
this.$refs.tree.setCurrentKey(this.tree.currentNodeKey)
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
},
|
|
60
|
+
onChange(data, node) {
|
|
61
|
+
if (this.selection === data) return
|
|
62
|
+
|
|
63
|
+
this.tree.currentNodeKey = data.id
|
|
64
|
+
this.selection = data
|
|
65
|
+
this.$emit('change', this.selection, node)
|
|
66
|
+
},
|
|
67
|
+
onCheck(data, checkedObject) {
|
|
68
|
+
this.$emit('check', data, checkedObject)
|
|
69
|
+
},
|
|
70
|
+
onCheckChange(data, checked) {
|
|
71
|
+
this.$emit('check-change', data, checked)
|
|
72
|
+
},
|
|
73
|
+
onNodeExpand(data) {
|
|
74
|
+
//记录展开的节点
|
|
75
|
+
this.tree.defaultExpandedKeys.push(data.id)
|
|
76
|
+
},
|
|
77
|
+
onNodeCollapse(data) {
|
|
78
|
+
//移除展开的节点
|
|
79
|
+
this.$_.pull(this.tree.defaultExpandedKeys, data.id)
|
|
80
|
+
},
|
|
81
|
+
/**插入 */
|
|
82
|
+
insert(data) {
|
|
83
|
+
data.path = this.selection.path.concat([data.label])
|
|
84
|
+
|
|
85
|
+
//设置子节点
|
|
86
|
+
if (!data.children) {
|
|
87
|
+
data.children = []
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
let children = this.selection.children
|
|
91
|
+
//如果不包含子节点,直接push
|
|
92
|
+
if (children.length < 1) {
|
|
93
|
+
children.push(data)
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
for (let i = 0; i < children.length; i++) {
|
|
97
|
+
if (data.item.sort < children[i].item.sort) {
|
|
98
|
+
children.splice(i, 0, data)
|
|
99
|
+
break
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
//如果是最后一个,则附加到最后一个节点后面
|
|
103
|
+
if (i === children.length - 1) {
|
|
104
|
+
children.push(data)
|
|
105
|
+
break
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
/**删除 */
|
|
110
|
+
remove(id) {
|
|
111
|
+
let children = this.selection.children
|
|
112
|
+
for (let i = 0; i < children.length; i++) {
|
|
113
|
+
let child = children[i]
|
|
114
|
+
if (id === child.id) {
|
|
115
|
+
children.splice(i, 1)
|
|
116
|
+
return child
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
/**更新 */
|
|
121
|
+
update(model) {
|
|
122
|
+
//先判断是否展开,已展开的先删除
|
|
123
|
+
let expanded = this.$refs.tree.getNode(model.id).expanded
|
|
124
|
+
if (!expanded) {
|
|
125
|
+
this.$_.pull(this.tree.defaultExpandedKeys, model.id)
|
|
126
|
+
}
|
|
127
|
+
//保存原来的子节点,同时先删除,再添加,这样可以保证排序
|
|
128
|
+
model.children = this.remove(model.id).children
|
|
129
|
+
this.insert(model)
|
|
130
|
+
//若是展开状态要再次展开
|
|
131
|
+
if (expanded) {
|
|
132
|
+
this.tree.defaultExpandedKeys.push(model.id)
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
setCheckedKeys(checkedKeys) {
|
|
136
|
+
this.$nextTick(() => {
|
|
137
|
+
if (this.showCheckbox) {
|
|
138
|
+
this.$refs.tree.setCheckedKeys(checkedKeys)
|
|
139
|
+
}
|
|
140
|
+
})
|
|
141
|
+
},
|
|
142
|
+
/**排序,重新刷新 */
|
|
143
|
+
sort() {
|
|
144
|
+
this.refresh()
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
created() {
|
|
148
|
+
if (this.refreshOnCreated) {
|
|
149
|
+
this.refresh(true)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
</script>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export default [
|
|
2
|
+
{
|
|
3
|
+
name: 'id',
|
|
4
|
+
label: '编号',
|
|
5
|
+
show: false
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
name: 'name',
|
|
9
|
+
label: '名称',
|
|
10
|
+
sortable: true,
|
|
11
|
+
width: '150'
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'typeName',
|
|
15
|
+
label: '类型'
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'routeName',
|
|
19
|
+
label: '路由名称',
|
|
20
|
+
width: '150'
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'icon',
|
|
24
|
+
label: '图标'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'iconColor',
|
|
28
|
+
label: '图标颜色'
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'level',
|
|
32
|
+
label: '等级'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'show',
|
|
36
|
+
label: '是否显示'
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'sort',
|
|
40
|
+
label: '排序'
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'targetName',
|
|
44
|
+
label: '打开方式'
|
|
45
|
+
}
|
|
46
|
+
]
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<nm-container>
|
|
3
|
+
<nm-split v-model="split">
|
|
4
|
+
<template v-slot:left>
|
|
5
|
+
<menu-tree ref="tree" @change="onTreeChange" />
|
|
6
|
+
</template>
|
|
7
|
+
<template v-slot:right>
|
|
8
|
+
<nm-list ref="list" :title="title" v-bind="list">
|
|
9
|
+
<!--查询条件-->
|
|
10
|
+
<template v-slot:querybar>
|
|
11
|
+
<el-form-item label="名称:" prop="name">
|
|
12
|
+
<el-input v-model="list.model.name" clearable />
|
|
13
|
+
</el-form-item>
|
|
14
|
+
<el-form-item label="编码:" prop="code">
|
|
15
|
+
<el-input v-model="list.model.code" clearable />
|
|
16
|
+
</el-form-item>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<!--按钮-->
|
|
20
|
+
<template v-slot:querybar-buttons="{ total }">
|
|
21
|
+
<nm-button :disabled="!menu.isNode" v-bind="buttons.add" @click="add(total)" />
|
|
22
|
+
<nm-button :disabled="!menu.isNode" v-bind="buttons.sort" @click="openSort" />
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<!--类型-->
|
|
26
|
+
<template v-slot:col-typeName="{ row }">
|
|
27
|
+
<el-tag type="success" v-if="row.type === 0">{{ row.typeName }}</el-tag>
|
|
28
|
+
<el-tag type="warning" v-if="row.type === 1">{{ row.typeName }}</el-tag>
|
|
29
|
+
<el-tag v-if="row.type === 2">{{ row.typeName }}</el-tag>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<!--图标-->
|
|
33
|
+
<template v-slot:col-icon="{ row }">
|
|
34
|
+
<el-tooltip :content="row.icon" effect="dark" placement="right" v-if="row.icon">
|
|
35
|
+
<label>
|
|
36
|
+
<nm-icon :name="row.icon" size="20px" />
|
|
37
|
+
</label>
|
|
38
|
+
</el-tooltip>
|
|
39
|
+
<label v-else>无</label>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<!--是否显示-->
|
|
43
|
+
<template v-slot:col-show="{ row }">{{ row.show ? '是' : '否' }}</template>
|
|
44
|
+
|
|
45
|
+
<!--操作列-->
|
|
46
|
+
<template v-slot:col-operation="{ row }">
|
|
47
|
+
<el-dropdown trigger="click">
|
|
48
|
+
<span class="el-dropdown-link">
|
|
49
|
+
操作
|
|
50
|
+
<i class="el-icon-arrow-down el-icon--right"></i>
|
|
51
|
+
</span>
|
|
52
|
+
<el-dropdown-menu class="nm-list-operation-dropdown" slot="dropdown">
|
|
53
|
+
<el-dropdown-item>
|
|
54
|
+
<nm-button v-bind="buttons.edit" @click="edit(row)" />
|
|
55
|
+
</el-dropdown-item>
|
|
56
|
+
<el-dropdown-item>
|
|
57
|
+
<nm-button-delete v-bind="buttons.del" :action="remove" :id="row.id" @success="onDelete(row.id)" />
|
|
58
|
+
</el-dropdown-item>
|
|
59
|
+
</el-dropdown-menu>
|
|
60
|
+
</el-dropdown>
|
|
61
|
+
</template>
|
|
62
|
+
</nm-list>
|
|
63
|
+
</template>
|
|
64
|
+
</nm-split>
|
|
65
|
+
|
|
66
|
+
<!--添加菜单-->
|
|
67
|
+
<add-page :parent="menu" :sort="total" :visible.sync="dialog.add" @success="onAdd" />
|
|
68
|
+
<!--编辑菜单-->
|
|
69
|
+
<edit-page :parent="menu" :id="curr.id" :visible.sync="dialog.edit" @success="onEdit" />
|
|
70
|
+
<!--排序-->
|
|
71
|
+
<nm-drag-sort-dialog v-bind="dragSort" :visible.sync="dialog.sort" @success="onSort" />
|
|
72
|
+
</nm-container>
|
|
73
|
+
</template>
|
|
74
|
+
<script>
|
|
75
|
+
import page from './page'
|
|
76
|
+
import cols from './cols.js'
|
|
77
|
+
import AddPage from '../components/add'
|
|
78
|
+
import EditPage from '../components/edit'
|
|
79
|
+
import MenuTree from '../components/tree'
|
|
80
|
+
|
|
81
|
+
// 接口
|
|
82
|
+
const api = $api.admin.menu
|
|
83
|
+
|
|
84
|
+
export default {
|
|
85
|
+
name: page.name,
|
|
86
|
+
components: { MenuTree, AddPage, EditPage },
|
|
87
|
+
data() {
|
|
88
|
+
return {
|
|
89
|
+
split: 0.2,
|
|
90
|
+
curr: { id: '' },
|
|
91
|
+
list: {
|
|
92
|
+
cols,
|
|
93
|
+
action: api.query,
|
|
94
|
+
labelWidth: '60px',
|
|
95
|
+
model: {
|
|
96
|
+
parentId: '',
|
|
97
|
+
name: '',
|
|
98
|
+
code: ''
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
remove: api.remove,
|
|
102
|
+
// 当前数量
|
|
103
|
+
total: 0,
|
|
104
|
+
// 弹出框
|
|
105
|
+
dialog: {
|
|
106
|
+
add: false,
|
|
107
|
+
edit: false,
|
|
108
|
+
// 排序
|
|
109
|
+
sort: false
|
|
110
|
+
},
|
|
111
|
+
// 左侧菜单树选择的菜单
|
|
112
|
+
menu: {
|
|
113
|
+
id: '',
|
|
114
|
+
name: '',
|
|
115
|
+
path: ''
|
|
116
|
+
},
|
|
117
|
+
buttons: page.buttons,
|
|
118
|
+
dragSort: {
|
|
119
|
+
queryAction: this.querySortList,
|
|
120
|
+
updateAction: api.updateSortList,
|
|
121
|
+
height: '700px'
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
computed: {
|
|
126
|
+
title() {
|
|
127
|
+
return '菜单列表—' + this.menu.name
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
methods: {
|
|
131
|
+
refresh() {
|
|
132
|
+
this.list.model.parentId = this.menu.id
|
|
133
|
+
this.$refs.list.refresh()
|
|
134
|
+
},
|
|
135
|
+
onTreeChange({ id, label, path, item }) {
|
|
136
|
+
this.menu.id = id
|
|
137
|
+
this.menu.name = label
|
|
138
|
+
//是否是节点菜单
|
|
139
|
+
this.menu.isNode = item.type === 0
|
|
140
|
+
this.menu.path = path.join(' / ')
|
|
141
|
+
this.refresh()
|
|
142
|
+
},
|
|
143
|
+
add(total) {
|
|
144
|
+
this.total = total
|
|
145
|
+
this.dialog.add = true
|
|
146
|
+
},
|
|
147
|
+
edit(row) {
|
|
148
|
+
this.curr = row
|
|
149
|
+
this.dialog.edit = true
|
|
150
|
+
},
|
|
151
|
+
querySortList() {
|
|
152
|
+
return api.querySortList(this.menu.id)
|
|
153
|
+
},
|
|
154
|
+
openSort() {
|
|
155
|
+
this.dialog.sort = true
|
|
156
|
+
},
|
|
157
|
+
onAdd(model) {
|
|
158
|
+
this.$refs.tree.insert(model)
|
|
159
|
+
this.refresh()
|
|
160
|
+
},
|
|
161
|
+
onDelete(id) {
|
|
162
|
+
this.$refs.tree.remove(id)
|
|
163
|
+
this.refresh()
|
|
164
|
+
},
|
|
165
|
+
onEdit(model) {
|
|
166
|
+
this.$refs.tree.update(model)
|
|
167
|
+
this.refresh()
|
|
168
|
+
},
|
|
169
|
+
onSort(data) {
|
|
170
|
+
this.$refs.tree.sort(data)
|
|
171
|
+
this.refresh()
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
</script>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** 页面信息 */
|
|
2
|
+
const page = new (function() {
|
|
3
|
+
this.title = '菜单管理'
|
|
4
|
+
this.icon = 'menu'
|
|
5
|
+
this.name = 'admin_menu'
|
|
6
|
+
this.path = '/admin/menu'
|
|
7
|
+
// 权限
|
|
8
|
+
this.permissions = [`${this.name}_query_get`, `${this.name}_tree_get`]
|
|
9
|
+
// 按钮
|
|
10
|
+
this.buttons = {
|
|
11
|
+
add: {
|
|
12
|
+
text: '添加',
|
|
13
|
+
icon: 'add',
|
|
14
|
+
type: 'success',
|
|
15
|
+
code: `${this.name}_add`,
|
|
16
|
+
permissions: [`${this.name}_add_post`]
|
|
17
|
+
},
|
|
18
|
+
edit: {
|
|
19
|
+
text: '编辑',
|
|
20
|
+
icon: 'edit',
|
|
21
|
+
type: 'text',
|
|
22
|
+
code: `${this.name}_edit`,
|
|
23
|
+
permissions: [`${this.name}_edit_Get`, `${this.name}_update_post`]
|
|
24
|
+
},
|
|
25
|
+
del: {
|
|
26
|
+
text: '删除',
|
|
27
|
+
icon: 'delete',
|
|
28
|
+
type: 'text',
|
|
29
|
+
code: `${this.name}_del`,
|
|
30
|
+
permissions: [`${this.name}_delete_delete`]
|
|
31
|
+
},
|
|
32
|
+
sort: {
|
|
33
|
+
text: '排序',
|
|
34
|
+
icon: 'sort',
|
|
35
|
+
type: 'warning',
|
|
36
|
+
code: `${this.name}_sort`,
|
|
37
|
+
permissions: [`${this.name}_sort_get`, `${this.name}_sort_post`]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
})()
|
|
41
|
+
|
|
42
|
+
/** 路由信息 */
|
|
43
|
+
export const route = {
|
|
44
|
+
page,
|
|
45
|
+
component: () => import(/* webpackChunkName: "admin.menu" */ './index')
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default page
|