This commit is contained in:
parent
3bc10cb2de
commit
25150fa8d7
|
|
@ -12,7 +12,6 @@
|
||||||
class="period-btn"
|
class="period-btn"
|
||||||
>
|
>
|
||||||
{{ period.label }}
|
{{ period.label }}
|
||||||
<span v-if="period.value === 'hour'"> 0-23 </span>
|
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -343,6 +343,7 @@ const getInitFormData = () => ({
|
||||||
sex: '', // 群发短信群体:0-男,1-女
|
sex: '', // 群发短信群体:0-男,1-女
|
||||||
recipientList: [], // 接收人员列表
|
recipientList: [], // 接收人员列表
|
||||||
groupList: [], // 接收分组列表
|
groupList: [], // 接收分组列表
|
||||||
|
remark: '', // 备注
|
||||||
})
|
})
|
||||||
|
|
||||||
const formData = ref(getInitFormData())
|
const formData = ref(getInitFormData())
|
||||||
|
|
@ -476,6 +477,60 @@ const parseCronToChinese = (cronExpression) => {
|
||||||
year = parts[6] || ''
|
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) => {
|
const formatTime = (h, m, s) => {
|
||||||
// 如果值是*,替换为0
|
// 如果值是*,替换为0
|
||||||
|
|
@ -488,14 +543,6 @@ const parseCronToChinese = (cronExpression) => {
|
||||||
return `${hStr}:${mStr}:${sStr}`
|
return `${hStr}:${mStr}:${sStr}`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取单个值(如果是列表,取第一个)
|
|
||||||
const getSingleValue = (value) => {
|
|
||||||
if (value.includes(',')) {
|
|
||||||
return value.split(',')[0]
|
|
||||||
}
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
|
|
||||||
// 解析星期
|
// 解析星期
|
||||||
const parseWeek = (weekValue) => {
|
const parseWeek = (weekValue) => {
|
||||||
if (!weekValue || weekValue === '?' || weekValue === '*') return ''
|
if (!weekValue || weekValue === '?' || weekValue === '*') return ''
|
||||||
|
|
@ -729,9 +776,6 @@ const parseCronToChinese = (cronExpression) => {
|
||||||
|
|
||||||
// 构建最终描述
|
// 构建最终描述
|
||||||
if (partsDesc.length === 0) {
|
if (partsDesc.length === 0) {
|
||||||
if (minute === '*' && hour === '*' && day === '*' && month === '*' && week === '?') {
|
|
||||||
return '每分钟执行'
|
|
||||||
}
|
|
||||||
return `Cron表达式:${cronExpression}`
|
return `Cron表达式:${cronExpression}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue