This commit is contained in:
BianLzhaoMin 2026-02-10 17:14:33 +08:00
parent 3bc10cb2de
commit 25150fa8d7
2 changed files with 55 additions and 12 deletions

View File

@ -12,7 +12,6 @@
class="period-btn"
>
{{ period.label }}
<span v-if="period.value === 'hour'"> 0-23 </span>
</el-button>
</div>
</div>

View File

@ -343,6 +343,7 @@ const getInitFormData = () => ({
sex: '', // 0-1-
recipientList: [], //
groupList: [], //
remark: '', //
})
const formData = ref(getInitFormData())
@ -476,6 +477,60 @@ const parseCronToChinese = (cronExpression) => {
year = parts[6] || ''
}
//
const getSingleValue = (value) => {
if (value.includes(',')) {
return value.split(',')[0]
}
return value
}
// *
if (
minute === '*' &&
hour === '*' &&
day === '*' &&
month === '*' &&
(week === '?' || week === '*') &&
(!year || year === '*') &&
(second === '*' || second === '0' || second === '?' || !second)
) {
//
const hasMinuteStep = minute.includes('/')
const hasHourStep = hour.includes('/')
const hasSecondStep = second && second.includes('/')
if (!hasMinuteStep && !hasHourStep && !hasSecondStep) {
const result = '每分钟执行'
formData.value.remark = result
formData.value.cronExpressionMsg = result
return result
}
}
// *
const isHourWildcard = hour === '*' || (hour.includes('/') && hour.split('/')[0] === '*')
const hasMinuteValue = minute !== '*' && minute !== '?' && !minute.includes('/')
const isSecondZero = !second || second === '*' || second === '0' || second === '?'
if (
isHourWildcard &&
hasMinuteValue &&
isSecondZero &&
day === '*' &&
month === '*' &&
(week === '?' || week === '*') &&
(!year || year === '*')
) {
const m = getSingleValue(minute)
//
const mNum = parseInt(String(m).replace(/\*/g, '0'), 10)
const result = `每小时的${mNum}分执行`
formData.value.remark = result
formData.value.cronExpressionMsg = result
return result
}
//
const formatTime = (h, m, s) => {
// *0
@ -488,14 +543,6 @@ const parseCronToChinese = (cronExpression) => {
return `${hStr}${mStr}${sStr}`
}
//
const getSingleValue = (value) => {
if (value.includes(',')) {
return value.split(',')[0]
}
return value
}
//
const parseWeek = (weekValue) => {
if (!weekValue || weekValue === '?' || weekValue === '*') return ''
@ -729,9 +776,6 @@ const parseCronToChinese = (cronExpression) => {
//
if (partsDesc.length === 0) {
if (minute === '*' && hour === '*' && day === '*' && month === '*' && week === '?') {
return '每分钟执行'
}
return `Cron表达式${cronExpression}`
}