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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
| import { MockMethod } from 'vite-plugin-mock';
| import { resultError, resultPageSuccess, resultSuccess, baseUrl } from '../_util';
|
| const accountList = (() => {
| const result: any[] = [];
| for (let index = 0; index < 20; index++) {
| result.push({
| id: `${index}`,
| account: '@first',
| email: '@email',
| nickname: '@cname()',
| role: '@first',
| createTime: '@datetime',
| remark: '@cword(10,20)',
| 'status|1': ['0', '1'],
| });
| }
| return result;
| })();
|
| const userList = (() => {
| const result: any[] = [];
| for (let index = 0; index < 20; index++) {
| result.push({
| id: `${index}`,
| username: '@first',
| email: '@email',
| realname: '@cname()',
| createTime: '@datetime',
| remark: '@cword(10,20)',
| avatar: 'https://q1.qlogo.cn/g?b=qq&nk=190848757&s=640'
| });
| }
| return result;
| })();
|
| const roleList = (() => {
| const result: any[] = [];
| for (let index = 0; index < 4; index++) {
| result.push({
| id: index + 1,
| orderNo: `${index + 1}`,
| roleName: ['超级管理员', '管理员', '文章管理员', '普通用户'][index],
| roleValue: '@first',
| createTime: '@datetime',
| remark: '@cword(10,20)',
| menu: [['0', '1', '2'], ['0', '1'], ['0', '2'], ['2']][index],
| 'status|1': ['0', '1'],
| });
| }
| return result;
| })();
|
| const newRoleList = (() => {
| const result: any[] = [];
| for (let index = 0; index < 4; index++) {
| result.push({
| id: index + 1,
| orderNo: `${index + 1}`,
| roleName: ['超级管理员', '管理员', '文章管理员', '普通用户'][index],
| roleCode: '@first',
| createTime: '@datetime',
| remark: '@cword(10,20)'
| });
| }
| return result;
| })();
|
| const testList = (() => {
| const result: any[] = [];
| for (let index = 0; index < 4; index++) {
| result.push({
| id: index + 1,
| orderNo: `${index + 1}`,
| testName: ['数据1', '数据2', '数据3', '数据4'][index],
| testValue: '@first',
| createTime: '@datetime'
| });
| }
| return result;
| })();
|
| const tableDemoList = (() => {
| const result: any[] = [];
| for (let index = 0; index < 4; index++) {
| result.push({
| id: index + 1,
| orderCode: '2008200' + `${index + 1}`,
| orderMoney: '@natural(1000,3000)',
| ctype: '@natural(1,2)',
| content: '@cword(10,20)',
| orderDate: '@datetime'
| });
| }
| return result;
| })();
|
| const deptList = (() => {
| const result: any[] = [];
| for (let index = 0; index < 3; index++) {
| result.push({
| id: `${index}`,
| deptName: ['华东分部', '华南分部', '西北分部'][index],
| orderNo: index + 1,
| createTime: '@datetime',
| remark: '@cword(10,20)',
| 'status|1': ['0', '0', '1'],
| children: (() => {
| const children: any[] = [];
| for (let j = 0; j < 4; j++) {
| children.push({
| id: `${index}-${j}`,
| deptName: ['研发部', '市场部', '商务部', '财务部'][j],
| orderNo: j + 1,
| createTime: '@datetime',
| remark: '@cword(10,20)',
| 'status|1': ['0', '1'],
| parentDept: `${index}`,
| children: undefined,
| });
| }
| return children;
| })(),
| });
| }
| return result;
| })();
|
| const menuList = (() => {
| const result: any[] = [];
| for (let index = 0; index < 3; index++) {
| result.push({
| id: `${index}`,
| icon: ['ion:layers-outline', 'ion:git-compare-outline', 'ion:tv-outline'][index],
| component: 'LAYOUT',
| type: '0',
| menuName: ['Dashboard', '权限管理', '功能'][index],
| permission: '',
| orderNo: index + 1,
| createTime: '@datetime',
| 'status|1': ['0', '0', '1'],
| children: (() => {
| const children: any[] = [];
| for (let j = 0; j < 4; j++) {
| children.push({
| id: `${index}-${j}`,
| type: '1',
| menuName: ['菜单1', '菜单2', '菜单3', '菜单4'][j],
| icon: 'ion:document',
| permission: ['menu1:view', 'menu2:add', 'menu3:update', 'menu4:del'][index],
| component: [
| '/dashboard/welcome/index',
| '/dashboard/Analysis/index',
| '/dashboard/workbench/index',
| '/dashboard/test/index',
| ][j],
| orderNo: j + 1,
| createTime: '@datetime',
| 'status|1': ['0', '1'],
| parentMenu: `${index}`,
| children: (() => {
| const children: any[] = [];
| for (let k = 0; k < 4; k++) {
| children.push({
| id: `${index}-${j}-${k}`,
| type: '2',
| menuName: '按钮' + (j + 1) + '-' + (k + 1),
| icon: '',
| permission:
| ['menu1:view', 'menu2:add', 'menu3:update', 'menu4:del'][index] +
| ':btn' +
| (k + 1),
| component: [
| '/dashboard/welcome/index',
| '/dashboard/Analysis/index',
| '/dashboard/workbench/index',
| '/dashboard/test/index',
| ][j],
| orderNo: j + 1,
| createTime: '@datetime',
| 'status|1': ['0', '1'],
| parentMenu: `${index}-${j}`,
| children: undefined,
| });
| }
| return children;
| })(),
| });
| }
| return children;
| })(),
| });
| }
| return result;
| })();
|
| export default [
| {
| url: `${baseUrl}/system/getAccountList`,
| timeout: 100,
| method: 'get',
| response: ({ query }) => {
| const { page = 1, pageSize = 20 } = query;
| return resultPageSuccess(page, pageSize, accountList);
| },
| },
| {
| url: `${baseUrl}/sys/user/list`,
| timeout: 100,
| method: 'get',
| response: ({ query }) => {
| const { page = 1, pageSize = 20 } = query;
| return resultPageSuccess(page, pageSize, userList);
| },
| },
| {
| url: `${baseUrl}/system/getRoleListByPage`,
| timeout: 100,
| method: 'get',
| response: ({ query }) => {
| const { page = 1, pageSize = 20 } = query;
| return resultPageSuccess(page, pageSize, roleList);
| },
| },
| {
| url: `${baseUrl}/sys/role/list`,
| timeout: 100,
| method: 'get',
| response: ({ query }) => {
| const { page = 1, pageSize = 20 } = query;
| return resultPageSuccess(page, pageSize, newRoleList);
| },
| },
| {
| url: `${baseUrl}/system/getTestListByPage`,
| timeout: 100,
| method: 'get',
| response: ({ query }) => {
| const { page = 1, pageSize = 20 } = query;
| return resultPageSuccess(page, pageSize, testList);
| },
| },
| {
| url: `${baseUrl}/system/getDemoTableListByPage`,
| timeout: 100,
| method: 'get',
| response: ({ query }) => {
| const { page = 1, pageSize = 20 } = query;
| return resultPageSuccess(page, pageSize, tableDemoList);
| },
| },
| {
| url: `${baseUrl}/system/setRoleStatus`,
| timeout: 500,
| method: 'post',
| response: ({ query }) => {
| const { id, status } = query;
| return resultSuccess({ id, status });
| },
| },
| {
| url: `${baseUrl}/system/getAllRoleList`,
| timeout: 100,
| method: 'get',
| response: () => {
| return resultSuccess(roleList);
| },
| },
| {
| url: `${baseUrl}/system/getDeptList`,
| timeout: 100,
| method: 'get',
| response: () => {
| return resultSuccess(deptList);
| },
| },
| {
| url: `${baseUrl}/system/getMenuList`,
| timeout: 100,
| method: 'get',
| response: () => {
| return resultSuccess(menuList);
| },
| },
| {
| url: `${baseUrl}/system/accountExist`,
| timeout: 500,
| method: 'post',
| response: ({ body }) => {
| const { account } = body || {};
| if (account && account.indexOf('admin') !== -1) {
| return resultError('该字段不能包含admin');
| } else {
| return resultSuccess(`${account} can use`);
| }
| },
| },
| ] as MockMethod[];
|
|