vue3-components-plus 3.0.30 → 3.0.33
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/dist/ComponentDemo/DialogDemo.vue +2 -2
- package/dist/ComponentDemo/NsTableDemo/NsTableDemoReadme.md +677 -0
- package/dist/ComponentDemo/NsTableDemo/index.vue +3 -4
- package/dist/ComponentDemo/NsTableDemo/mockData.js +117 -650
- package/dist/ComponentDemo/PdfDemo.vue +8 -35
- package/dist/vue3-components-plus.css +1 -1
- package/dist/vue3-components-plus.js +1170 -1175
- package/dist/vue3-components-plus.umd.cjs +1 -1
- package/package.json +1 -1
- package/dist/ComponentDemo/PdfDemo copy.vue +0 -234
- package/dist/ComponentDemo/pdfReade copy.vue +0 -369
- package/dist/ComponentDemo/pdfReade.vue +0 -590
- package/dist/favicon.ico +0 -0
|
@@ -1,650 +1,117 @@
|
|
|
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
|
-
status: 1,
|
|
119
|
-
phone: "13800138001",
|
|
120
|
-
email: "zhangsan@example.com",
|
|
121
|
-
avatar: "https://cube.elemecdn.com/0/88/03b0d39583f_87968.png",
|
|
122
|
-
createTime: "2024-01-01 10:00:00",
|
|
123
|
-
updateTime: "2024-01-10 15:30:00"
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
id: 10,
|
|
127
|
-
username: "lisi",
|
|
128
|
-
realName: "李四",
|
|
129
|
-
gender: 1,
|
|
130
|
-
department: "product",
|
|
131
|
-
status: 1,
|
|
132
|
-
phone: "13800138002",
|
|
133
|
-
email: "lisi@example.com",
|
|
134
|
-
avatar:
|
|
135
|
-
"https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png",
|
|
136
|
-
createTime: "2024-01-02 11:00:00",
|
|
137
|
-
updateTime: "2024-01-11 16:30:00"
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
id: 11,
|
|
141
|
-
username: "wangwu",
|
|
142
|
-
realName: "王五",
|
|
143
|
-
gender: 2,
|
|
144
|
-
department: "operation",
|
|
145
|
-
status: 0,
|
|
146
|
-
phone: "13800138003",
|
|
147
|
-
email: "wangwu@example.com",
|
|
148
|
-
avatar:
|
|
149
|
-
"https://cube.elemecdn.com/9/c2/f0ee8a30c0963d916c7f3d6be5fepng.png",
|
|
150
|
-
createTime: "2024-01-03 12:00:00",
|
|
151
|
-
updateTime: "2024-01-12 17:30:00"
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
id: 12,
|
|
155
|
-
username: "zhaoliu",
|
|
156
|
-
realName: "赵六",
|
|
157
|
-
gender: 1,
|
|
158
|
-
department: "tech",
|
|
159
|
-
status: 1,
|
|
160
|
-
phone: "13800138004",
|
|
161
|
-
email: "zhaoliu@example.com",
|
|
162
|
-
avatar: "https://cube.elemecdn.com/0/88/03b0d39583f_87968.png",
|
|
163
|
-
createTime: "2024-01-04 13:00:00",
|
|
164
|
-
updateTime: "2024-01-13 18:30:00"
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
id: 13,
|
|
168
|
-
username: "sunqi",
|
|
169
|
-
realName: "孙七",
|
|
170
|
-
gender: 2,
|
|
171
|
-
department: "hr",
|
|
172
|
-
status: 1,
|
|
173
|
-
phone: "13800138005",
|
|
174
|
-
email: "sunqi@example.com",
|
|
175
|
-
avatar:
|
|
176
|
-
"https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png",
|
|
177
|
-
createTime: "2024-01-05 14:00:00",
|
|
178
|
-
updateTime: "2024-01-14 19:30:00"
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
id: 14,
|
|
182
|
-
username: "zhouba",
|
|
183
|
-
realName: "周八",
|
|
184
|
-
gender: 1,
|
|
185
|
-
department: "finance",
|
|
186
|
-
status: 0,
|
|
187
|
-
phone: "13800138006",
|
|
188
|
-
email: "zhouba@example.com",
|
|
189
|
-
avatar:
|
|
190
|
-
"https://cube.elemecdn.com/9/c2/f0ee8a30c0963d916c7f3d6be5fepng.png",
|
|
191
|
-
createTime: "2024-01-06 15:00:00",
|
|
192
|
-
updateTime: "2024-01-15 20:30:00"
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
id: 15,
|
|
196
|
-
username: "wujiu",
|
|
197
|
-
realName: "吴九",
|
|
198
|
-
gender: 2,
|
|
199
|
-
department: "product",
|
|
200
|
-
status: 1,
|
|
201
|
-
phone: "13800138007",
|
|
202
|
-
email: "wujiu@example.com",
|
|
203
|
-
avatar: "https://cube.elemecdn.com/0/88/03b0d39583f_87968.png",
|
|
204
|
-
createTime: "2024-01-07 16:00:00",
|
|
205
|
-
updateTime: "2024-01-16 21:30:00"
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
id: 16,
|
|
209
|
-
username: "zhengshi",
|
|
210
|
-
realName: "郑十",
|
|
211
|
-
gender: 1,
|
|
212
|
-
department: "tech",
|
|
213
|
-
status: 1,
|
|
214
|
-
phone: "13800138008",
|
|
215
|
-
email: "zhengshi@example.com",
|
|
216
|
-
avatar:
|
|
217
|
-
"https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png",
|
|
218
|
-
createTime: "2024-01-08 17:00:00",
|
|
219
|
-
updateTime: "2024-01-17 22:30:00"
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
id: 17,
|
|
223
|
-
username: "zhangsan",
|
|
224
|
-
realName: "张三",
|
|
225
|
-
gender: 1,
|
|
226
|
-
department: "tech",
|
|
227
|
-
status: 1,
|
|
228
|
-
phone: "13800138001",
|
|
229
|
-
email: "zhangsan@example.com",
|
|
230
|
-
avatar: "https://cube.elemecdn.com/0/88/03b0d39583f_87968.png",
|
|
231
|
-
createTime: "2024-01-01 10:00:00",
|
|
232
|
-
updateTime: "2024-01-10 15:30:00"
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
id: 18,
|
|
236
|
-
username: "lisi",
|
|
237
|
-
realName: "李四",
|
|
238
|
-
gender: 1,
|
|
239
|
-
department: "product",
|
|
240
|
-
status: 1,
|
|
241
|
-
phone: "13800138002",
|
|
242
|
-
email: "lisi@example.com",
|
|
243
|
-
avatar:
|
|
244
|
-
"https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png",
|
|
245
|
-
createTime: "2024-01-02 11:00:00",
|
|
246
|
-
updateTime: "2024-01-11 16:30:00"
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
id: 19,
|
|
250
|
-
username: "wangwu",
|
|
251
|
-
realName: "王五",
|
|
252
|
-
gender: 2,
|
|
253
|
-
department: "operation",
|
|
254
|
-
status: 0,
|
|
255
|
-
phone: "13800138003",
|
|
256
|
-
email: "wangwu@example.com",
|
|
257
|
-
avatar:
|
|
258
|
-
"https://cube.elemecdn.com/9/c2/f0ee8a30c0963d916c7f3d6be5fepng.png",
|
|
259
|
-
createTime: "2024-01-03 12:00:00",
|
|
260
|
-
updateTime: "2024-01-12 17:30:00"
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
id: 20,
|
|
264
|
-
username: "zhaoliu",
|
|
265
|
-
realName: "赵六",
|
|
266
|
-
gender: 1,
|
|
267
|
-
department: "tech",
|
|
268
|
-
status: 1,
|
|
269
|
-
phone: "13800138004",
|
|
270
|
-
email: "zhaoliu@example.com",
|
|
271
|
-
avatar: "https://cube.elemecdn.com/0/88/03b0d39583f_87968.png",
|
|
272
|
-
createTime: "2024-01-04 13:00:00",
|
|
273
|
-
updateTime: "2024-01-13 18:30:00"
|
|
274
|
-
},
|
|
275
|
-
{
|
|
276
|
-
id: 21,
|
|
277
|
-
username: "sunqi",
|
|
278
|
-
realName: "孙七",
|
|
279
|
-
gender: 2,
|
|
280
|
-
department: "hr",
|
|
281
|
-
status: 1,
|
|
282
|
-
phone: "13800138005",
|
|
283
|
-
email: "sunqi@example.com",
|
|
284
|
-
avatar:
|
|
285
|
-
"https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png",
|
|
286
|
-
createTime: "2024-01-05 14:00:00",
|
|
287
|
-
updateTime: "2024-01-14 19:30:00"
|
|
288
|
-
},
|
|
289
|
-
{
|
|
290
|
-
id: 22,
|
|
291
|
-
username: "zhouba",
|
|
292
|
-
realName: "周八",
|
|
293
|
-
gender: 1,
|
|
294
|
-
department: "finance",
|
|
295
|
-
status: 0,
|
|
296
|
-
phone: "13800138006",
|
|
297
|
-
email: "zhouba@example.com",
|
|
298
|
-
avatar:
|
|
299
|
-
"https://cube.elemecdn.com/9/c2/f0ee8a30c0963d916c7f3d6be5fepng.png",
|
|
300
|
-
createTime: "2024-01-06 15:00:00",
|
|
301
|
-
updateTime: "2024-01-15 20:30:00"
|
|
302
|
-
},
|
|
303
|
-
{
|
|
304
|
-
id: 23,
|
|
305
|
-
username: "wujiu",
|
|
306
|
-
realName: "吴九",
|
|
307
|
-
gender: 2,
|
|
308
|
-
department: "product",
|
|
309
|
-
status: 1,
|
|
310
|
-
phone: "13800138007",
|
|
311
|
-
email: "wujiu@example.com",
|
|
312
|
-
avatar: "https://cube.elemecdn.com/0/88/03b0d39583f_87968.png",
|
|
313
|
-
createTime: "2024-01-07 16:00:00",
|
|
314
|
-
updateTime: "2024-01-16 21:30:00"
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
id: 24,
|
|
318
|
-
username: "zhengshi",
|
|
319
|
-
realName: "郑十",
|
|
320
|
-
gender: 1,
|
|
321
|
-
department: "tech",
|
|
322
|
-
status: 1,
|
|
323
|
-
phone: "13800138008",
|
|
324
|
-
email: "zhengshi@example.com",
|
|
325
|
-
avatar:
|
|
326
|
-
"https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png",
|
|
327
|
-
createTime: "2024-01-08 17:00:00",
|
|
328
|
-
updateTime: "2024-01-17 22:30:00"
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
id: 25,
|
|
332
|
-
username: "zhangsan",
|
|
333
|
-
realName: "张三",
|
|
334
|
-
gender: 1,
|
|
335
|
-
department: "tech",
|
|
336
|
-
status: 1,
|
|
337
|
-
phone: "13800138001",
|
|
338
|
-
email: "zhangsan@example.com",
|
|
339
|
-
avatar: "https://cube.elemecdn.com/0/88/03b0d39583f_87968.png",
|
|
340
|
-
createTime: "2024-01-01 10:00:00",
|
|
341
|
-
updateTime: "2024-01-10 15:30:00"
|
|
342
|
-
},
|
|
343
|
-
{
|
|
344
|
-
id: 26,
|
|
345
|
-
username: "lisi",
|
|
346
|
-
realName: "李四",
|
|
347
|
-
gender: 1,
|
|
348
|
-
department: "product",
|
|
349
|
-
status: 1,
|
|
350
|
-
phone: "13800138002",
|
|
351
|
-
email: "lisi@example.com",
|
|
352
|
-
avatar:
|
|
353
|
-
"https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png",
|
|
354
|
-
createTime: "2024-01-02 11:00:00",
|
|
355
|
-
updateTime: "2024-01-11 16:30:00"
|
|
356
|
-
},
|
|
357
|
-
{
|
|
358
|
-
id: 27,
|
|
359
|
-
username: "wangwu",
|
|
360
|
-
realName: "王五",
|
|
361
|
-
gender: 2,
|
|
362
|
-
department: "operation",
|
|
363
|
-
status: 0,
|
|
364
|
-
phone: "13800138003",
|
|
365
|
-
email: "wangwu@example.com",
|
|
366
|
-
avatar:
|
|
367
|
-
"https://cube.elemecdn.com/9/c2/f0ee8a30c0963d916c7f3d6be5fepng.png",
|
|
368
|
-
createTime: "2024-01-03 12:00:00",
|
|
369
|
-
updateTime: "2024-01-12 17:30:00"
|
|
370
|
-
},
|
|
371
|
-
{
|
|
372
|
-
id: 28,
|
|
373
|
-
username: "zhaoliu",
|
|
374
|
-
realName: "赵六",
|
|
375
|
-
gender: 1,
|
|
376
|
-
department: "tech",
|
|
377
|
-
status: 1,
|
|
378
|
-
phone: "13800138004",
|
|
379
|
-
email: "zhaoliu@example.com",
|
|
380
|
-
avatar: "https://cube.elemecdn.com/0/88/03b0d39583f_87968.png",
|
|
381
|
-
createTime: "2024-01-04 13:00:00",
|
|
382
|
-
updateTime: "2024-01-13 18:30:00"
|
|
383
|
-
},
|
|
384
|
-
{
|
|
385
|
-
id: 29,
|
|
386
|
-
username: "sunqi",
|
|
387
|
-
realName: "孙七",
|
|
388
|
-
gender: 2,
|
|
389
|
-
department: "hr",
|
|
390
|
-
status: 1,
|
|
391
|
-
phone: "13800138005",
|
|
392
|
-
email: "sunqi@example.com",
|
|
393
|
-
avatar:
|
|
394
|
-
"https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png",
|
|
395
|
-
createTime: "2024-01-05 14:00:00",
|
|
396
|
-
updateTime: "2024-01-14 19:30:00"
|
|
397
|
-
},
|
|
398
|
-
{
|
|
399
|
-
id: 30,
|
|
400
|
-
username: "zhouba",
|
|
401
|
-
realName: "周八",
|
|
402
|
-
gender: 1,
|
|
403
|
-
department: "finance",
|
|
404
|
-
status: 0,
|
|
405
|
-
phone: "13800138006",
|
|
406
|
-
email: "zhouba@example.com",
|
|
407
|
-
avatar:
|
|
408
|
-
"https://cube.elemecdn.com/9/c2/f0ee8a30c0963d916c7f3d6be5fepng.png",
|
|
409
|
-
createTime: "2024-01-06 15:00:00",
|
|
410
|
-
updateTime: "2024-01-15 20:30:00"
|
|
411
|
-
},
|
|
412
|
-
{
|
|
413
|
-
id: 31,
|
|
414
|
-
username: "wujiu",
|
|
415
|
-
realName: "吴九",
|
|
416
|
-
gender: 2,
|
|
417
|
-
department: "product",
|
|
418
|
-
status: 1,
|
|
419
|
-
phone: "13800138007",
|
|
420
|
-
email: "wujiu@example.com",
|
|
421
|
-
avatar: "https://cube.elemecdn.com/0/88/03b0d39583f_87968.png",
|
|
422
|
-
createTime: "2024-01-07 16:00:00",
|
|
423
|
-
updateTime: "2024-01-16 21:30:00"
|
|
424
|
-
},
|
|
425
|
-
{
|
|
426
|
-
id: 32,
|
|
427
|
-
username: "zhengshi",
|
|
428
|
-
realName: "郑十",
|
|
429
|
-
gender: 1,
|
|
430
|
-
department: "tech",
|
|
431
|
-
status: 1,
|
|
432
|
-
phone: "13800138008",
|
|
433
|
-
email: "zhengshi@example.com",
|
|
434
|
-
avatar:
|
|
435
|
-
"https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png",
|
|
436
|
-
createTime: "2024-01-08 17:00:00",
|
|
437
|
-
updateTime: "2024-01-17 22:30:00"
|
|
438
|
-
}
|
|
439
|
-
];
|
|
440
|
-
|
|
441
|
-
// 部门选项
|
|
442
|
-
export const departmentOptions = [
|
|
443
|
-
{ label: "技术部", value: "tech" },
|
|
444
|
-
{ label: "产品部", value: "product" },
|
|
445
|
-
{ label: "运营部", value: "operation" },
|
|
446
|
-
{ label: "人力资源部", value: "hr" },
|
|
447
|
-
{ label: "财务部", value: "finance" }
|
|
448
|
-
];
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
* 异步获取部门选项(模拟接口请求,延迟2秒)
|
|
452
|
-
* @returns {Promise<Array>} 部门选项数组
|
|
453
|
-
*/
|
|
454
|
-
export const fetchDepartmentOptions = () => {
|
|
455
|
-
return new Promise(resolve => {
|
|
456
|
-
setTimeout(() => {
|
|
457
|
-
resolve(departmentOptions);
|
|
458
|
-
}, 500);
|
|
459
|
-
});
|
|
460
|
-
};
|
|
461
|
-
|
|
462
|
-
// 状态选项
|
|
463
|
-
export const statusOptions = [
|
|
464
|
-
{ label: "全部", value: "" },
|
|
465
|
-
{ label: "启用", value: 1 },
|
|
466
|
-
{ label: "禁用", value: 0 }
|
|
467
|
-
];
|
|
468
|
-
|
|
469
|
-
/**
|
|
470
|
-
* 异步获取状态选项(模拟接口请求,延迟2秒)
|
|
471
|
-
* @returns {Promise<Array>} 状态选项数组
|
|
472
|
-
*/
|
|
473
|
-
export const fetchStatusOptions = () => {
|
|
474
|
-
return new Promise(resolve => {
|
|
475
|
-
setTimeout(() => {
|
|
476
|
-
resolve(statusOptions);
|
|
477
|
-
}, 500);
|
|
478
|
-
});
|
|
479
|
-
};
|
|
480
|
-
|
|
481
|
-
// 性别选项
|
|
482
|
-
export const genderOptions = [
|
|
483
|
-
{ label: "全部", value: "" },
|
|
484
|
-
{ label: "男", value: 1 },
|
|
485
|
-
{ label: "女", value: 2 }
|
|
486
|
-
];
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* 异步获取性别选项(模拟接口请求,延迟3秒)
|
|
490
|
-
* @returns {Promise<Array>} 性别选项数组
|
|
491
|
-
*/
|
|
492
|
-
export const fetchGenderOptions = () => {
|
|
493
|
-
return new Promise(resolve => {
|
|
494
|
-
setTimeout(() => {
|
|
495
|
-
resolve(genderOptions);
|
|
496
|
-
}, 3000);
|
|
497
|
-
});
|
|
498
|
-
};
|
|
499
|
-
|
|
500
|
-
import { ElMessageBox } from "element-plus";
|
|
501
|
-
|
|
502
|
-
/**
|
|
503
|
-
* 根据搜索条件过滤用户数据
|
|
504
|
-
* @param {Array} users - 用户数据数组
|
|
505
|
-
* @param {Object} searchParams - 搜索参数对象
|
|
506
|
-
* @param {Object} pagination - 分页参数对象,支持自定义 key 名称
|
|
507
|
-
* - 默认使用 currentPage 和 pageSize
|
|
508
|
-
* - 也可传入自定义 key,如 { currentPage1: 1, pageSize1: 10 }
|
|
509
|
-
* @param {Object} keyConfig - 可选,自定义分页 key 配置
|
|
510
|
-
* - pageNumberKey: 当前页码的 key 名称,默认 'currentPage'
|
|
511
|
-
* - pageSizeKey: 每页条数的 key 名称,默认 'pageSize'
|
|
512
|
-
* @returns {Object} { list: 过滤后的用户数据, total: 总数 }
|
|
513
|
-
*/
|
|
514
|
-
export const filterUsers = (users, searchParams, pagination = {}, keyConfig = {}) => {
|
|
515
|
-
// 默认 key 配置
|
|
516
|
-
const pageNumberKey = keyConfig.pageNumberKey || 'currentPage';
|
|
517
|
-
const pageSizeKey = keyConfig.pageSizeKey || 'pageSize';
|
|
518
|
-
|
|
519
|
-
// 打印并弹出查询条件信息
|
|
520
|
-
const queryInfo = {
|
|
521
|
-
搜索条件: searchParams,
|
|
522
|
-
分页参数: pagination
|
|
523
|
-
};
|
|
524
|
-
console.log("查询条件:", queryInfo);
|
|
525
|
-
|
|
526
|
-
/* ElMessageBox.alert(
|
|
527
|
-
`<pre style="max-height: 300px; overflow: auto;">${JSON.stringify(queryInfo, null, 2)}</pre>`,
|
|
528
|
-
"查询条件信息",
|
|
529
|
-
{
|
|
530
|
-
dangerouslyUseHTMLString: true,
|
|
531
|
-
confirmButtonText: "确定"
|
|
532
|
-
}
|
|
533
|
-
).catch(() => {}); */
|
|
534
|
-
|
|
535
|
-
// 先进行过滤
|
|
536
|
-
let filteredData = users;
|
|
537
|
-
|
|
538
|
-
if (searchParams && Object.keys(searchParams).length > 0) {
|
|
539
|
-
filteredData = users.filter(user => {
|
|
540
|
-
// 用户名过滤(模糊匹配)
|
|
541
|
-
if (searchParams.username && searchParams.username.trim() !== "") {
|
|
542
|
-
const username = user.username || "";
|
|
543
|
-
const searchUsername = searchParams.username.trim().toLowerCase();
|
|
544
|
-
if (!username.toLowerCase().includes(searchUsername)) {
|
|
545
|
-
return false;
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
// 真实姓名过滤(模糊匹配)
|
|
550
|
-
if (searchParams.realName && searchParams.realName.trim() !== "") {
|
|
551
|
-
const realName = user.realName || "";
|
|
552
|
-
const searchRealName = searchParams.realName.trim().toLowerCase();
|
|
553
|
-
if (!realName.toLowerCase().includes(searchRealName)) {
|
|
554
|
-
return false;
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
// 状态过滤
|
|
559
|
-
if (
|
|
560
|
-
searchParams.status !== undefined &&
|
|
561
|
-
searchParams.status !== null &&
|
|
562
|
-
searchParams.status !== ""
|
|
563
|
-
) {
|
|
564
|
-
if (user.status !== searchParams.status) {
|
|
565
|
-
return false;
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
// 部门过滤
|
|
570
|
-
if (searchParams.department && searchParams.department !== "") {
|
|
571
|
-
if (user.department !== searchParams.department) {
|
|
572
|
-
return false;
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
// 性别过滤
|
|
577
|
-
if (
|
|
578
|
-
searchParams.gender !== undefined &&
|
|
579
|
-
searchParams.gender !== null &&
|
|
580
|
-
searchParams.gender !== ""
|
|
581
|
-
) {
|
|
582
|
-
if (user.gender !== searchParams.gender) {
|
|
583
|
-
return false;
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
// 手机号过滤(模糊匹配)
|
|
588
|
-
if (searchParams.phone && searchParams.phone.trim() !== "") {
|
|
589
|
-
const phone = user.phone || "";
|
|
590
|
-
const searchPhone = searchParams.phone.trim();
|
|
591
|
-
if (!phone.includes(searchPhone)) {
|
|
592
|
-
return false;
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
// 创建时间范围过滤
|
|
597
|
-
if (
|
|
598
|
-
searchParams.createTime &&
|
|
599
|
-
Array.isArray(searchParams.createTime) &&
|
|
600
|
-
searchParams.createTime.length === 2
|
|
601
|
-
) {
|
|
602
|
-
const [startDate, endDate] = searchParams.createTime;
|
|
603
|
-
if (startDate && endDate) {
|
|
604
|
-
const userCreateTime = new Date(user.createTime).getTime();
|
|
605
|
-
const startTime = new Date(startDate).getTime();
|
|
606
|
-
const endTime = new Date(endDate).getTime();
|
|
607
|
-
|
|
608
|
-
if (userCreateTime < startTime || userCreateTime > endTime) {
|
|
609
|
-
return false;
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
// 是否激活过滤(active字段)
|
|
615
|
-
if (searchParams.active !== undefined && searchParams.active !== null) {
|
|
616
|
-
// 这里假设用户数据中没有active字段,我们可以根据status来判断
|
|
617
|
-
// 如果searchParams.active为true,只显示启用的用户(status === 1)
|
|
618
|
-
// 如果searchParams.active为false,只显示禁用的用户(status === 0)
|
|
619
|
-
const isActive =
|
|
620
|
-
searchParams.active === true || searchParams.active === "true";
|
|
621
|
-
if (isActive && user.status !== 1) {
|
|
622
|
-
return false;
|
|
623
|
-
}
|
|
624
|
-
if (!isActive && user.status !== 0) {
|
|
625
|
-
return false;
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
return true;
|
|
630
|
-
});
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
// 计算总数
|
|
634
|
-
const total = filteredData.length;
|
|
635
|
-
|
|
636
|
-
// 如果有分页参数,进行分页(支持自定义 key)
|
|
637
|
-
const currentPage = pagination[pageNumberKey] || 1;
|
|
638
|
-
const pageSize = pagination[pageSizeKey] || 10;
|
|
639
|
-
|
|
640
|
-
if (currentPage && pageSize) {
|
|
641
|
-
const start = (currentPage - 1) * pageSize;
|
|
642
|
-
const end = start + pageSize;
|
|
643
|
-
filteredData = filteredData.slice(start, end);
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
return {
|
|
647
|
-
list: filteredData,
|
|
648
|
-
total
|
|
649
|
-
};
|
|
650
|
-
};
|
|
1
|
+
export const departmentOptions = [
|
|
2
|
+
{ label: '技术部', value: 'tech' },
|
|
3
|
+
{ label: '产品部', value: 'product' },
|
|
4
|
+
{ label: '运营部', value: 'operation' },
|
|
5
|
+
{ label: '人力资源部', value: 'hr' },
|
|
6
|
+
{ label: '财务部', value: 'finance' },
|
|
7
|
+
]
|
|
8
|
+
|
|
9
|
+
export const statusOptions = [
|
|
10
|
+
{ label: '全部', value: '' },
|
|
11
|
+
{ label: '启用', value: 1 },
|
|
12
|
+
{ label: '禁用', value: 0 },
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
const nameSeed = [
|
|
16
|
+
['zhangsan', '张三'],
|
|
17
|
+
['lisi', '李四'],
|
|
18
|
+
['wangwu', '王五'],
|
|
19
|
+
['zhaoliu', '赵六'],
|
|
20
|
+
['sunqi', '孙七'],
|
|
21
|
+
['zhouba', '周八'],
|
|
22
|
+
['wujiu', '吴九'],
|
|
23
|
+
['zhengshi', '郑十'],
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
function pad(value) {
|
|
27
|
+
return String(value).padStart(2, '0')
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const mockUsers = Array.from({ length: 20 }, function (_, index) {
|
|
31
|
+
|
|
32
|
+
const id = index + 1
|
|
33
|
+
const seed = nameSeed[index % nameSeed.length]
|
|
34
|
+
const department = departmentOptions[index % departmentOptions.length]
|
|
35
|
+
const month = (index % 12) + 1
|
|
36
|
+
const day = (index % 28) + 1
|
|
37
|
+
const gender = id % 2 === 0 ? 2 : 1
|
|
38
|
+
const status = id % 5 === 0 ? 0 : 1
|
|
39
|
+
return {
|
|
40
|
+
|
|
41
|
+
id,
|
|
42
|
+
username: seed[0] + id,
|
|
43
|
+
realName: seed[1],
|
|
44
|
+
gender,
|
|
45
|
+
department: department.value,
|
|
46
|
+
status,
|
|
47
|
+
phone: '1380013' + pad(id) + pad((id * 3) % 100),
|
|
48
|
+
email: seed[0] + id + '@example.com',
|
|
49
|
+
avatar: id % 2 === 0
|
|
50
|
+
? 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'
|
|
51
|
+
: 'https://cube.elemecdn.com/0/88/03b0d39583f_87968.png',
|
|
52
|
+
createTime: '2024-' + pad(month) + '-' + pad(day) + ' 10:00:00',
|
|
53
|
+
updateTime: '2024-' + pad(month) + '-' + pad(day) + ' 18:30:00',
|
|
54
|
+
month: String(month),
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
export function fetchStatusOptions() {
|
|
59
|
+
return new Promise(function (resolve) {
|
|
60
|
+
setTimeout(function () {
|
|
61
|
+
resolve(statusOptions)
|
|
62
|
+
}, 300)
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function fetchDepartmentOptions() {
|
|
67
|
+
return new Promise(function (resolve) {
|
|
68
|
+
setTimeout(function () {
|
|
69
|
+
resolve([{ label: '全部', value: '' }].concat(departmentOptions))
|
|
70
|
+
}, 300)
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function filterUsers(users, searchParams, pagination, keyConfig) {
|
|
75
|
+
const params = searchParams || {}
|
|
76
|
+
const pager = pagination || {}
|
|
77
|
+
const config = keyConfig || {}
|
|
78
|
+
const pageNumberKey = config.pageNumberKey || 'currentPage'
|
|
79
|
+
const pageSizeKey = config.pageSizeKey || 'pageSize'
|
|
80
|
+
|
|
81
|
+
let list = (users || []).filter(function (item) {
|
|
82
|
+
if (params.month && item.month !== String(params.month)) return false
|
|
83
|
+
if (params.username && item.username.toLowerCase().indexOf(String(params.username).toLowerCase()) === -1) return false
|
|
84
|
+
if (params.realName && item.realName.indexOf(params.realName) === -1) return false
|
|
85
|
+
if (params.status !== '' && params.status !== undefined && params.status !== null && item.status !== params.status) return false
|
|
86
|
+
if (params.department && item.department !== params.department) return false
|
|
87
|
+
if (params.gender !== '' && params.gender !== undefined && params.gender !== null && item.gender !== params.gender) return false
|
|
88
|
+
if (params.phone && item.phone.indexOf(String(params.phone)) === -1) return false
|
|
89
|
+
if (params.active !== undefined && params.active !== null) {
|
|
90
|
+
const active = params.active === true || params.active === 'true'
|
|
91
|
+
if (active && item.status !== 1) return false
|
|
92
|
+
if (!active && item.status !== 0) return false
|
|
93
|
+
}
|
|
94
|
+
if (params.createTime && Array.isArray(params.createTime) && params.createTime.length === 2) {
|
|
95
|
+
const start = new Date(params.createTime[0]).getTime()
|
|
96
|
+
const end = new Date(params.createTime[1]).getTime()
|
|
97
|
+
const current = new Date(item.createTime).getTime()
|
|
98
|
+
if (!Number.isNaN(start) && !Number.isNaN(end) && (current < start || current > end)) {
|
|
99
|
+
return false
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return true
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
const total = list.length
|
|
106
|
+
const currentPage = Number(pager[pageNumberKey] || 1)
|
|
107
|
+
const pageSize = Number(pager[pageSizeKey] || 10)
|
|
108
|
+
const start = (currentPage - 1) * pageSize
|
|
109
|
+
const end = start + pageSize
|
|
110
|
+
|
|
111
|
+
list = list.slice(start, end)
|
|
112
|
+
|
|
113
|
+
return {
|
|
114
|
+
list,
|
|
115
|
+
total,
|
|
116
|
+
}
|
|
117
|
+
}
|