vue3-components-plus 3.0.34 → 3.0.36
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.
|
@@ -1,117 +1,117 @@
|
|
|
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
|
-
}
|
|
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
|
+
}
|