index.vue
3.62 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
<template>
<gl-row :gutter="100">
<gl-col :span='8'>
<left-manager :title='"菜单列表"' v-model="menuMG" :node-click='nodeClick'></left-manager>
</gl-col>
<gl-col :span='16'>
<right-form :form='form' v-model="menuMG"></right-form>
</gl-col>
</gl-row>
</template>
<script>
import { LeftManager, RightForm } from '@/components/index'
import { findMenuById } from '@/api/api'
export default {
name: 'menuMG',
data() {
return {
menuMG: {
sublings: false,
children: false,
del: false,
push: true,
showDetails: false,
btnTxt: '修改',
node: null,
props: null,
allNode: null,
data: [],
form: {
urlName: '',
hostName: '',
openStyle: '新系统',
menuType: '',
name: '',
path: '',
url: '',
baseUrl: '',
iorder: null,
isHidden: 0,
createTime: null,
updateTime: null,
grade: 0,
iconUrl: '',
id: 0,
lastOperatorId: 0,
lastOperatorName: '',
parentId: 0,
state: 0,
title: ''
}
},
form: [
{ label: '名称', value: 'urlName' },
{ label: '主机自定义名称', value: 'hostName' },
{
label: '打开模式',
value: 'openStyle',
type: 'select',
options: [
{
value: 0,
label: '本系统'
},
{
value: 1,
label: '新系统'
}
]
},
{
label: '功能类型',
value: 'menuType',
type: 'select',
options: [
{
value: 0,
label: '菜单路由'
},
{
value: 1,
label: '菜单'
},
{
value: '选项3',
label: '按钮'
}
]
},
{ label: '上级菜单', value: 'name', disabled: true },
{ label: '菜单路径', value: 'path', disabled: true },
{ label: '路由', value: 'url' },
{ label: '基础路径', value: 'baseUrl' },
{ label: '排序', value: 'iorder' },
{ label: '是否隐藏', value: 'isHidden', type: 'switch' },
{ label: '创建时间', value: 'createTime', disabled: true },
{ label: '修改时间', value: 'updateTime', disabled: true }
]
}
},
components: {
LeftManager,
RightForm
},
methods: {
nodeClick(data, node, that, props) {
this.menuMG.showDetails = true
if (node.level === 1) this.menuMG.data = node.parent.data
this.menuMG.btnTxt = '修改'
this.menuMG.node = node
this.menuMG.allNode = data
this.menuMG.props = props
this.menuMG.sublings = false
this.menuMG.children = false
this.menuMG.del = true
this.menuMG.push = false
findMenuById.req({ id: data.id }).then(res => {
console.log(res)
for (const key in this.menuMG.form) {
if (key === 'isHidden') {
this.menuMG.form[key] = res[key] === 0
} else if (key === 'createTime' || key === 'updateTime') {
this.menuMG.form[key] = new Date(res[key]).format('yyyy-MM-dd HH:mm:ss')
} else if (key === 'name') {
this.menuMG.form[key] = node.level === 1 ? '顶级菜单' : node.parent.data[props.label]
} else {
this.menuMG.form[key] = res[key]
}
}
}).catch(err => {
console.log(err)
})
}
}
}
</script>