lw-cdp-ui 1.4.65 → 1.4.67
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/components/lwCronSelect/cron.js +191 -191
- package/dist/components/lwFormMini/FormItem.vue +9 -0
- package/dist/components/lwFormMini/index.vue +4 -2
- package/dist/components/lwLayout/components/tags.vue +6 -2
- package/dist/lw-cdp-ui.esm.js +2664 -2674
- package/dist/lw-cdp-ui.umd.js +10 -10
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1,191 +1,191 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 完整解析Cron表达式为中文描述
|
|
3
|
-
* @param {string} cronExpression - 标准Cron表达式
|
|
4
|
-
* @returns {string} 中文描述
|
|
5
|
-
*/
|
|
6
|
-
function parseCronExpression(cronExpression) {
|
|
7
|
-
// 标准化表达式,处理可能的多空格
|
|
8
|
-
const normalized = cronExpression.trim().replace(/\s+/g, ' ')
|
|
9
|
-
const parts = normalized.split(' ')
|
|
10
|
-
|
|
11
|
-
if (parts.length < 5 || parts.length > 7) {
|
|
12
|
-
return '无效的Cron表达式'
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// 补全年份部分(可选)
|
|
16
|
-
const [second, minute, hour, dayOfMonth, month, dayOfWeek, year] = parts.length === 5 ? ['0', ...parts, '*'] : parts
|
|
17
|
-
|
|
18
|
-
// 解析各个字段
|
|
19
|
-
const timeDesc = parseTime(second, minute, hour)
|
|
20
|
-
const dateDesc = parseDate(dayOfMonth, month, dayOfWeek)
|
|
21
|
-
const yearDesc = parseYear(year)
|
|
22
|
-
|
|
23
|
-
// 组合结果
|
|
24
|
-
let result = ''
|
|
25
|
-
if (dateDesc) result += dateDesc
|
|
26
|
-
if (timeDesc) result += timeDesc
|
|
27
|
-
if (yearDesc) result += yearDesc
|
|
28
|
-
|
|
29
|
-
// 特殊处理常见表达式
|
|
30
|
-
const commonPatterns = {
|
|
31
|
-
'0 0 0 * * *': '每天午夜12点整执行',
|
|
32
|
-
'0 0 12 * * *': '每天中午12点整执行',
|
|
33
|
-
'0 0 8-18 * * 1-5': '工作日每天上午8点到下午6点每小时执行',
|
|
34
|
-
'0 0 9 * * 1': '每周一上午9点整执行',
|
|
35
|
-
'0 0 12 1 * *': '每月1日中午12点整执行',
|
|
36
|
-
'0 0 0 1 1 *': '每年1月1日午夜12点整执行'
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return commonPatterns[normalized] || result || '无法解析的Cron表达式'
|
|
40
|
-
|
|
41
|
-
// 解析时间部分
|
|
42
|
-
function parseTime(sec, min, hr) {
|
|
43
|
-
const secondDesc = parseField(sec, {
|
|
44
|
-
'*': '每秒',
|
|
45
|
-
0: '',
|
|
46
|
-
default: (val) => `每${val}秒`
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
const minuteDesc = parseField(min, {
|
|
50
|
-
'*': '每分钟',
|
|
51
|
-
0: '整',
|
|
52
|
-
default: (val) => `每${val}分`
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
const hourDesc = parseField(hr, {
|
|
56
|
-
'*': '每小时',
|
|
57
|
-
default: (val) => {
|
|
58
|
-
const num = parseInt(val, 10)
|
|
59
|
-
const period = num < 12 ? '上午' : '下午'
|
|
60
|
-
const displayHour = num % 12 === 0 ? 12 : num % 12
|
|
61
|
-
return `${period}${displayHour}点`
|
|
62
|
-
}
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
// 处理范围
|
|
66
|
-
if (hr.includes('-')) {
|
|
67
|
-
const [start, end] = hr.split('-').map(Number)
|
|
68
|
-
return `从${start}点到${end}点每小时执行`
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// 组合时间描述
|
|
72
|
-
if (secondDesc && minuteDesc && hourDesc) {
|
|
73
|
-
return `${hourDesc}${minuteDesc}${secondDesc}执行`
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return `${hourDesc}${minuteDesc}${secondDesc}`.trim() + '执行'
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// 解析日期部分
|
|
80
|
-
function parseDate(dom, mon, dow) {
|
|
81
|
-
const dayOfMonthDesc = parseField(dom, {
|
|
82
|
-
'*': '',
|
|
83
|
-
'?': '',
|
|
84
|
-
L: '最后一天',
|
|
85
|
-
default: (val) => {
|
|
86
|
-
if (val.includes(',')) {
|
|
87
|
-
return `每月${val.split(',').join('日、')}日`
|
|
88
|
-
}
|
|
89
|
-
if (val.includes('-')) {
|
|
90
|
-
const [start, end] = val.split('-')
|
|
91
|
-
return `每月${start}日到${end}日`
|
|
92
|
-
}
|
|
93
|
-
if (val.includes('/')) {
|
|
94
|
-
const [start, step] = val.split('/')
|
|
95
|
-
return `从${start || '1'}日开始每${step}天`
|
|
96
|
-
}
|
|
97
|
-
return `每月${val}日`
|
|
98
|
-
}
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
const monthDesc = parseField(mon, {
|
|
102
|
-
'*': '',
|
|
103
|
-
default: (val) => {
|
|
104
|
-
const months = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二']
|
|
105
|
-
if (val.includes(',')) {
|
|
106
|
-
return `${val
|
|
107
|
-
.split(',')
|
|
108
|
-
.map((m) => `${months[parseInt(m, 10) - 1]}月`)
|
|
109
|
-
.join('、')}`
|
|
110
|
-
}
|
|
111
|
-
if (val.includes('-')) {
|
|
112
|
-
const [start, end] = val.split('-').map((m) => months[parseInt(m, 10) - 1])
|
|
113
|
-
return `${start}月到${end}月`
|
|
114
|
-
}
|
|
115
|
-
return `${months[parseInt(val, 10) - 1]}月`
|
|
116
|
-
}
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
const dayOfWeekDesc = parseField(dow, {
|
|
120
|
-
'*': '',
|
|
121
|
-
'?': '',
|
|
122
|
-
'1-5': '工作日',
|
|
123
|
-
'6,7': '周末',
|
|
124
|
-
L: '最后一周',
|
|
125
|
-
default: (val) => {
|
|
126
|
-
const days = ['日', '一', '二', '三', '四', '五', '六']
|
|
127
|
-
if (val.includes(',')) {
|
|
128
|
-
return `每周${val
|
|
129
|
-
.split(',')
|
|
130
|
-
.map((d) => `周${days[parseInt(d, 10)]}`)
|
|
131
|
-
.join('、')}`
|
|
132
|
-
}
|
|
133
|
-
if (val.includes('-')) {
|
|
134
|
-
const [start, end] = val.split('-').map((d) => days[parseInt(d, 10)])
|
|
135
|
-
return `每周${start}到周${end}`
|
|
136
|
-
}
|
|
137
|
-
if (val.includes('#')) {
|
|
138
|
-
const [day, week] = val.split('#')
|
|
139
|
-
return `每月第${week}个周${days[parseInt(day, 10)]}`
|
|
140
|
-
}
|
|
141
|
-
return `每周${days[parseInt(val, 10)]}`
|
|
142
|
-
}
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
// 组合日期描述
|
|
146
|
-
let result = ''
|
|
147
|
-
if (monthDesc) result += monthDesc
|
|
148
|
-
if (dayOfMonthDesc) result += dayOfMonthDesc
|
|
149
|
-
if (dayOfWeekDesc) result += dayOfWeekDesc
|
|
150
|
-
|
|
151
|
-
// 默认描述
|
|
152
|
-
if (!monthDesc && !dayOfMonthDesc && !dayOfWeekDesc) {
|
|
153
|
-
return '每天'
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return result
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// 解析年份部分
|
|
160
|
-
function parseYear(yr) {
|
|
161
|
-
return parseField(yr, {
|
|
162
|
-
'*': '',
|
|
163
|
-
default: (val) => {
|
|
164
|
-
if (!val) return ''
|
|
165
|
-
if (val?.includes('/')) {
|
|
166
|
-
const [start, step] = val.split('/')
|
|
167
|
-
return `从${start}年开始每${step}年`
|
|
168
|
-
}
|
|
169
|
-
return `${val}年`
|
|
170
|
-
}
|
|
171
|
-
})
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// 通用字段解析
|
|
175
|
-
function parseField(value, options) {
|
|
176
|
-
if (value in options) {
|
|
177
|
-
return options[value]
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (options.default) {
|
|
181
|
-
if (typeof options.default === 'function') {
|
|
182
|
-
return options.default(value)
|
|
183
|
-
}
|
|
184
|
-
return options.default
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return ''
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
export default parseCronExpression
|
|
1
|
+
/**
|
|
2
|
+
* 完整解析Cron表达式为中文描述
|
|
3
|
+
* @param {string} cronExpression - 标准Cron表达式
|
|
4
|
+
* @returns {string} 中文描述
|
|
5
|
+
*/
|
|
6
|
+
function parseCronExpression(cronExpression) {
|
|
7
|
+
// 标准化表达式,处理可能的多空格
|
|
8
|
+
const normalized = cronExpression.trim().replace(/\s+/g, ' ')
|
|
9
|
+
const parts = normalized.split(' ')
|
|
10
|
+
|
|
11
|
+
if (parts.length < 5 || parts.length > 7) {
|
|
12
|
+
return '无效的Cron表达式'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 补全年份部分(可选)
|
|
16
|
+
const [second, minute, hour, dayOfMonth, month, dayOfWeek, year] = parts.length === 5 ? ['0', ...parts, '*'] : parts
|
|
17
|
+
|
|
18
|
+
// 解析各个字段
|
|
19
|
+
const timeDesc = parseTime(second, minute, hour)
|
|
20
|
+
const dateDesc = parseDate(dayOfMonth, month, dayOfWeek)
|
|
21
|
+
const yearDesc = parseYear(year)
|
|
22
|
+
|
|
23
|
+
// 组合结果
|
|
24
|
+
let result = ''
|
|
25
|
+
if (dateDesc) result += dateDesc
|
|
26
|
+
if (timeDesc) result += timeDesc
|
|
27
|
+
if (yearDesc) result += yearDesc
|
|
28
|
+
|
|
29
|
+
// 特殊处理常见表达式
|
|
30
|
+
const commonPatterns = {
|
|
31
|
+
'0 0 0 * * *': '每天午夜12点整执行',
|
|
32
|
+
'0 0 12 * * *': '每天中午12点整执行',
|
|
33
|
+
'0 0 8-18 * * 1-5': '工作日每天上午8点到下午6点每小时执行',
|
|
34
|
+
'0 0 9 * * 1': '每周一上午9点整执行',
|
|
35
|
+
'0 0 12 1 * *': '每月1日中午12点整执行',
|
|
36
|
+
'0 0 0 1 1 *': '每年1月1日午夜12点整执行'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return commonPatterns[normalized] || result || '无法解析的Cron表达式'
|
|
40
|
+
|
|
41
|
+
// 解析时间部分
|
|
42
|
+
function parseTime(sec, min, hr) {
|
|
43
|
+
const secondDesc = parseField(sec, {
|
|
44
|
+
'*': '每秒',
|
|
45
|
+
0: '',
|
|
46
|
+
default: (val) => `每${val}秒`
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const minuteDesc = parseField(min, {
|
|
50
|
+
'*': '每分钟',
|
|
51
|
+
0: '整',
|
|
52
|
+
default: (val) => `每${val}分`
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const hourDesc = parseField(hr, {
|
|
56
|
+
'*': '每小时',
|
|
57
|
+
default: (val) => {
|
|
58
|
+
const num = parseInt(val, 10)
|
|
59
|
+
const period = num < 12 ? '上午' : '下午'
|
|
60
|
+
const displayHour = num % 12 === 0 ? 12 : num % 12
|
|
61
|
+
return `${period}${displayHour}点`
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
// 处理范围
|
|
66
|
+
if (hr.includes('-')) {
|
|
67
|
+
const [start, end] = hr.split('-').map(Number)
|
|
68
|
+
return `从${start}点到${end}点每小时执行`
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 组合时间描述
|
|
72
|
+
if (secondDesc && minuteDesc && hourDesc) {
|
|
73
|
+
return `${hourDesc}${minuteDesc}${secondDesc}执行`
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return `${hourDesc}${minuteDesc}${secondDesc}`.trim() + '执行'
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// 解析日期部分
|
|
80
|
+
function parseDate(dom, mon, dow) {
|
|
81
|
+
const dayOfMonthDesc = parseField(dom, {
|
|
82
|
+
'*': '',
|
|
83
|
+
'?': '',
|
|
84
|
+
L: '最后一天',
|
|
85
|
+
default: (val) => {
|
|
86
|
+
if (val.includes(',')) {
|
|
87
|
+
return `每月${val.split(',').join('日、')}日`
|
|
88
|
+
}
|
|
89
|
+
if (val.includes('-')) {
|
|
90
|
+
const [start, end] = val.split('-')
|
|
91
|
+
return `每月${start}日到${end}日`
|
|
92
|
+
}
|
|
93
|
+
if (val.includes('/')) {
|
|
94
|
+
const [start, step] = val.split('/')
|
|
95
|
+
return `从${start || '1'}日开始每${step}天`
|
|
96
|
+
}
|
|
97
|
+
return `每月${val}日`
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
const monthDesc = parseField(mon, {
|
|
102
|
+
'*': '',
|
|
103
|
+
default: (val) => {
|
|
104
|
+
const months = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二']
|
|
105
|
+
if (val.includes(',')) {
|
|
106
|
+
return `${val
|
|
107
|
+
.split(',')
|
|
108
|
+
.map((m) => `${months[parseInt(m, 10) - 1]}月`)
|
|
109
|
+
.join('、')}`
|
|
110
|
+
}
|
|
111
|
+
if (val.includes('-')) {
|
|
112
|
+
const [start, end] = val.split('-').map((m) => months[parseInt(m, 10) - 1])
|
|
113
|
+
return `${start}月到${end}月`
|
|
114
|
+
}
|
|
115
|
+
return `${months[parseInt(val, 10) - 1]}月`
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
const dayOfWeekDesc = parseField(dow, {
|
|
120
|
+
'*': '',
|
|
121
|
+
'?': '',
|
|
122
|
+
'1-5': '工作日',
|
|
123
|
+
'6,7': '周末',
|
|
124
|
+
L: '最后一周',
|
|
125
|
+
default: (val) => {
|
|
126
|
+
const days = ['日', '一', '二', '三', '四', '五', '六']
|
|
127
|
+
if (val.includes(',')) {
|
|
128
|
+
return `每周${val
|
|
129
|
+
.split(',')
|
|
130
|
+
.map((d) => `周${days[parseInt(d, 10)]}`)
|
|
131
|
+
.join('、')}`
|
|
132
|
+
}
|
|
133
|
+
if (val.includes('-')) {
|
|
134
|
+
const [start, end] = val.split('-').map((d) => days[parseInt(d, 10)])
|
|
135
|
+
return `每周${start}到周${end}`
|
|
136
|
+
}
|
|
137
|
+
if (val.includes('#')) {
|
|
138
|
+
const [day, week] = val.split('#')
|
|
139
|
+
return `每月第${week}个周${days[parseInt(day, 10)]}`
|
|
140
|
+
}
|
|
141
|
+
return `每周${days[parseInt(val, 10)]}`
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
// 组合日期描述
|
|
146
|
+
let result = ''
|
|
147
|
+
if (monthDesc) result += monthDesc
|
|
148
|
+
if (dayOfMonthDesc) result += dayOfMonthDesc
|
|
149
|
+
if (dayOfWeekDesc) result += dayOfWeekDesc
|
|
150
|
+
|
|
151
|
+
// 默认描述
|
|
152
|
+
if (!monthDesc && !dayOfMonthDesc && !dayOfWeekDesc) {
|
|
153
|
+
return '每天'
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return result
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// 解析年份部分
|
|
160
|
+
function parseYear(yr) {
|
|
161
|
+
return parseField(yr, {
|
|
162
|
+
'*': '',
|
|
163
|
+
default: (val) => {
|
|
164
|
+
if (!val) return ''
|
|
165
|
+
if (val?.includes('/')) {
|
|
166
|
+
const [start, step] = val.split('/')
|
|
167
|
+
return `从${start}年开始每${step}年`
|
|
168
|
+
}
|
|
169
|
+
return `${val}年`
|
|
170
|
+
}
|
|
171
|
+
})
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// 通用字段解析
|
|
175
|
+
function parseField(value, options) {
|
|
176
|
+
if (value in options) {
|
|
177
|
+
return options[value]
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (options.default) {
|
|
181
|
+
if (typeof options.default === 'function') {
|
|
182
|
+
return options.default(value)
|
|
183
|
+
}
|
|
184
|
+
return options.default
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return ''
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export default parseCronExpression
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
<slot :name="item?.options?.component"></slot>
|
|
18
18
|
</div>
|
|
19
19
|
|
|
20
|
+
<!-- 物理换行 -->
|
|
21
|
+
<div v-else-if="item.component == 'dividerBr'" class="title-name-divider-br" :class="{ border: item?.border }"></div>
|
|
22
|
+
|
|
20
23
|
<!-- 表单内容 -->
|
|
21
24
|
<el-form-item
|
|
22
25
|
v-else
|
|
@@ -298,4 +301,10 @@ export default {
|
|
|
298
301
|
}
|
|
299
302
|
}
|
|
300
303
|
}
|
|
304
|
+
.title-name-divider-br {
|
|
305
|
+
&.border {
|
|
306
|
+
margin-bottom: 15px;
|
|
307
|
+
border-top: 1px var(--el-border-color) var(--el-border-style);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
301
310
|
</style>
|
|
@@ -66,7 +66,8 @@
|
|
|
66
66
|
'rate',
|
|
67
67
|
'slider',
|
|
68
68
|
'tags',
|
|
69
|
-
'divider'
|
|
69
|
+
'divider',
|
|
70
|
+
'dividerBr'
|
|
70
71
|
].includes(item.component)
|
|
71
72
|
"
|
|
72
73
|
v-slot:[item.component]>
|
|
@@ -98,7 +99,8 @@
|
|
|
98
99
|
'rate',
|
|
99
100
|
'slider',
|
|
100
101
|
'tags',
|
|
101
|
-
'divider'
|
|
102
|
+
'divider',
|
|
103
|
+
'dividerBr'
|
|
102
104
|
].includes(item.component)
|
|
103
105
|
"
|
|
104
106
|
v-slot:[item.component]>
|
|
@@ -352,9 +352,13 @@ export default {
|
|
|
352
352
|
},
|
|
353
353
|
// 关闭当前标签 并跳转
|
|
354
354
|
closeTagAndJump(path, keep) {
|
|
355
|
-
|
|
356
|
-
|
|
355
|
+
if (keep) {
|
|
356
|
+
this.$store.commit('removeKeepLive', keep)
|
|
357
|
+
}
|
|
357
358
|
this.$router.push(path)
|
|
359
|
+
if (this.$store.state.global.layoutTags) {
|
|
360
|
+
this.closeSelectedTag(this.$route, false)
|
|
361
|
+
}
|
|
358
362
|
},
|
|
359
363
|
// 显示ID
|
|
360
364
|
getIdName(tag) {
|