cron表达式周期任务正解析
onChange() {
this.getExpress()
},
getExpress() {
var min
var hour
var week
var nth
if (this.datavalue == '天') {
min = this.minValue
hour = this.hourValue
this.cron = `0 ${min} ${hour} * * ?`
} else if (this.datavalue == "周") {
min = this.minValue
hour = this.hourValue
week = this.weekValue
this.cron = `0 ${min} ${hour} ? * ${week}`
} else if (this.datavalue == '月') {
min = this.minValue
hour = this.hourValue
nth = this.nthValue
this.cron = `0 ${min} ${hour} ${nth} * ?`
}
},
cron表达式周期任务反解析
this.cronArray = data.execPlanCron.split(" ")
if (this.cronArray[5] == '?') {
if (this.cronArray[4] == '*') {
this.datavalue = '天'
this.minValue = this.cronArray[1]
this.hourValue = this.cronArray[2]
} else {
this.datavalue = '月'
this.minValue = this.cronArray[1]
this.hourValue = this.cronArray[2]
this.nthValue = this.cronArray[3]
this.monthValue = this.cronArray[4]
}
} else {
this.datavalue = "周"
this.minValue = this.cronArray[1]
this.hourValue = this.cronArray[2]
this.weekValue = this.cronArray[5]