提交 | 用户 | age
|
37669d
|
1 |
import { MockMethod } from 'vite-plugin-mock'; |
8b4b76
|
2 |
import { resultError, resultPageSuccess, resultSuccess } from '../_util'; |
37669d
|
3 |
|
3b8ca4
|
4 |
const accountList = (() => { |
37669d
|
5 |
const result: any[] = []; |
V |
6 |
for (let index = 0; index < 20; index++) { |
|
7 |
result.push({ |
|
8 |
id: `${index}`, |
|
9 |
account: '@first', |
|
10 |
email: '@email', |
|
11 |
nickname: '@cname()', |
|
12 |
role: '@first', |
3b8ca4
|
13 |
createTime: '@datetime', |
V |
14 |
remark: '@cword(10,20)', |
40aac6
|
15 |
'dept|0-2': 1, |
3b8ca4
|
16 |
'status|1': ['0', '1'], |
V |
17 |
}); |
|
18 |
} |
|
19 |
return result; |
|
20 |
})(); |
|
21 |
|
9a1ba7
|
22 |
const roleList = (() => { |
V |
23 |
const result: any[] = []; |
|
24 |
for (let index = 0; index < 4; index++) { |
|
25 |
result.push({ |
418541
|
26 |
id: index + 1, |
9a1ba7
|
27 |
orderNo: `${index + 1}`, |
V |
28 |
roleName: ['超级管理员', '管理员', '文章管理员', '普通用户'][index], |
|
29 |
roleValue: '@first', |
|
30 |
createTime: '@datetime', |
|
31 |
remark: '@cword(10,20)', |
c375e3
|
32 |
menu: [['0', '1', '2'], ['0', '1'], ['0', '2'], ['2']][index], |
9a1ba7
|
33 |
'status|1': ['0', '1'], |
V |
34 |
}); |
|
35 |
} |
|
36 |
return result; |
|
37 |
})(); |
|
38 |
|
3b8ca4
|
39 |
const deptList = (() => { |
V |
40 |
const result: any[] = []; |
|
41 |
for (let index = 0; index < 3; index++) { |
|
42 |
result.push({ |
|
43 |
id: `${index}`, |
|
44 |
deptName: ['华东分部', '华南分部', '西北分部'][index], |
|
45 |
orderNo: index + 1, |
|
46 |
createTime: '@datetime', |
|
47 |
remark: '@cword(10,20)', |
|
48 |
'status|1': ['0', '0', '1'], |
|
49 |
children: (() => { |
|
50 |
const children: any[] = []; |
|
51 |
for (let j = 0; j < 4; j++) { |
|
52 |
children.push({ |
|
53 |
id: `${index}-${j}`, |
|
54 |
deptName: ['研发部', '市场部', '商务部', '财务部'][j], |
|
55 |
orderNo: j + 1, |
|
56 |
createTime: '@datetime', |
|
57 |
remark: '@cword(10,20)', |
|
58 |
'status|1': ['0', '1'], |
|
59 |
parentDept: `${index}`, |
|
60 |
children: undefined, |
|
61 |
}); |
|
62 |
} |
|
63 |
return children; |
|
64 |
})(), |
37669d
|
65 |
}); |
V |
66 |
} |
|
67 |
return result; |
|
68 |
})(); |
|
69 |
|
9a1ba7
|
70 |
const menuList = (() => { |
V |
71 |
const result: any[] = []; |
|
72 |
for (let index = 0; index < 3; index++) { |
|
73 |
result.push({ |
|
74 |
id: `${index}`, |
|
75 |
icon: ['ion:layers-outline', 'ion:git-compare-outline', 'ion:tv-outline'][index], |
|
76 |
component: 'LAYOUT', |
418541
|
77 |
type: '0', |
9a1ba7
|
78 |
menuName: ['Dashboard', '权限管理', '功能'][index], |
V |
79 |
permission: '', |
|
80 |
orderNo: index + 1, |
|
81 |
createTime: '@datetime', |
|
82 |
'status|1': ['0', '0', '1'], |
|
83 |
children: (() => { |
|
84 |
const children: any[] = []; |
|
85 |
for (let j = 0; j < 4; j++) { |
|
86 |
children.push({ |
|
87 |
id: `${index}-${j}`, |
418541
|
88 |
type: '1', |
9a1ba7
|
89 |
menuName: ['菜单1', '菜单2', '菜单3', '菜单4'][j], |
V |
90 |
icon: 'ion:document', |
|
91 |
permission: ['menu1:view', 'menu2:add', 'menu3:update', 'menu4:del'][index], |
|
92 |
component: [ |
|
93 |
'/dashboard/welcome/index', |
|
94 |
'/dashboard/analysis/index', |
|
95 |
'/dashboard/workbench/index', |
|
96 |
'/dashboard/test/index', |
|
97 |
][j], |
|
98 |
orderNo: j + 1, |
|
99 |
createTime: '@datetime', |
|
100 |
'status|1': ['0', '1'], |
|
101 |
parentMenu: `${index}`, |
418541
|
102 |
children: (() => { |
无 |
103 |
const children: any[] = []; |
|
104 |
for (let k = 0; k < 4; k++) { |
|
105 |
children.push({ |
|
106 |
id: `${index}-${j}-${k}`, |
|
107 |
type: '2', |
|
108 |
menuName: '按钮' + (j + 1) + '-' + (k + 1), |
|
109 |
icon: '', |
|
110 |
permission: |
|
111 |
['menu1:view', 'menu2:add', 'menu3:update', 'menu4:del'][index] + |
|
112 |
':btn' + |
|
113 |
(k + 1), |
|
114 |
component: [ |
|
115 |
'/dashboard/welcome/index', |
|
116 |
'/dashboard/analysis/index', |
|
117 |
'/dashboard/workbench/index', |
|
118 |
'/dashboard/test/index', |
|
119 |
][j], |
|
120 |
orderNo: j + 1, |
|
121 |
createTime: '@datetime', |
|
122 |
'status|1': ['0', '1'], |
|
123 |
parentMenu: `${index}-${j}`, |
|
124 |
children: undefined, |
|
125 |
}); |
|
126 |
} |
|
127 |
return children; |
|
128 |
})(), |
9a1ba7
|
129 |
}); |
V |
130 |
} |
|
131 |
return children; |
|
132 |
})(), |
|
133 |
}); |
|
134 |
} |
|
135 |
return result; |
|
136 |
})(); |
|
137 |
|
37669d
|
138 |
export default [ |
V |
139 |
{ |
ed422b
|
140 |
url: '/basic-api/system/getAccountList', |
37669d
|
141 |
timeout: 100, |
V |
142 |
method: 'get', |
|
143 |
response: ({ query }) => { |
|
144 |
const { page = 1, pageSize = 20 } = query; |
3b8ca4
|
145 |
return resultPageSuccess(page, pageSize, accountList); |
V |
146 |
}, |
|
147 |
}, |
|
148 |
{ |
ed422b
|
149 |
url: '/basic-api/system/getRoleListByPage', |
9a1ba7
|
150 |
timeout: 100, |
V |
151 |
method: 'get', |
|
152 |
response: ({ query }) => { |
|
153 |
const { page = 1, pageSize = 20 } = query; |
|
154 |
return resultPageSuccess(page, pageSize, roleList); |
|
155 |
}, |
|
156 |
}, |
|
157 |
{ |
46899a
|
158 |
url: '/basic-api/system/setRoleStatus', |
无 |
159 |
timeout: 500, |
|
160 |
method: 'post', |
|
161 |
response: ({ query }) => { |
|
162 |
const { id, status } = query; |
|
163 |
return resultSuccess({ id, status }); |
|
164 |
}, |
|
165 |
}, |
|
166 |
{ |
ed422b
|
167 |
url: '/basic-api/system/getAllRoleList', |
4628d9
|
168 |
timeout: 100, |
V |
169 |
method: 'get', |
|
170 |
response: () => { |
|
171 |
return resultSuccess(roleList); |
|
172 |
}, |
|
173 |
}, |
|
174 |
{ |
ed422b
|
175 |
url: '/basic-api/system/getDeptList', |
3b8ca4
|
176 |
timeout: 100, |
V |
177 |
method: 'get', |
|
178 |
response: () => { |
|
179 |
return resultSuccess(deptList); |
37669d
|
180 |
}, |
V |
181 |
}, |
9a1ba7
|
182 |
{ |
ed422b
|
183 |
url: '/basic-api/system/getMenuList', |
9a1ba7
|
184 |
timeout: 100, |
V |
185 |
method: 'get', |
|
186 |
response: () => { |
|
187 |
return resultSuccess(menuList); |
|
188 |
}, |
|
189 |
}, |
8b4b76
|
190 |
{ |
无 |
191 |
url: '/basic-api/system/accountExist', |
|
192 |
timeout: 500, |
|
193 |
method: 'post', |
|
194 |
response: ({ body }) => { |
|
195 |
const { account } = body || {}; |
|
196 |
if (account && account.indexOf('admin') !== -1) { |
|
197 |
return resultError('该字段不能包含admin'); |
|
198 |
} else { |
|
199 |
return resultSuccess(`${account} can use`); |
|
200 |
} |
|
201 |
}, |
|
202 |
}, |
37669d
|
203 |
] as MockMethod[]; |