吴雨瞳添加了注释

master
wyt 4 months ago
parent b9d40a577d
commit 4e9903508f

@ -1,25 +1,38 @@
<template>
<!-- 使用Element UI 表单组件设置尺寸为 small -->
<el-form size="small">
<!-- 第一个单选按钮通配符模式 -->
<el-form-item>
<el-radio v-model="radioValue" :label="1"> [, - * /] </el-radio>
</el-form-item>
<!-- 第二个单选按钮周期范围模式 X Y -->
<el-form-item>
<el-radio v-model="radioValue" :label="2">
周期从
<!-- 开始秒输入框最小值 0最大值 58确保结束秒可+1 -->
<el-input-number v-model="cycle01" :min="0" :max="58" /> -
<!-- 结束秒输入框最小值为开始秒+1最大值 59 -->
<el-input-number v-model="cycle02" :min="cycle01 ? cycle01 + 1 : 1" :max="59" />
</el-radio>
</el-form-item>
<!-- 第三个单选按钮间隔执行模式 X 秒开始 Y 秒执行 -->
<el-form-item>
<el-radio v-model="radioValue" :label="3">
<!-- 开始秒输入框最小值 0最大值 58 -->
<el-input-number v-model="average01" :min="0" :max="58" /> 秒开始
<!-- 间隔秒输入框最小值 1最大值为 59-开始秒 -->
<el-input-number v-model="average02" :min="1" :max="59 - average01 || 0" /> 秒执行一次
</el-radio>
</el-form-item>
<!-- 第四个单选按钮指定秒模式多选具体秒数 -->
<el-form-item>
<el-radio v-model="radioValue" :label="4">
指定
<!-- 多选下拉框可选择 0-59 -->
<el-select clearable v-model="checkboxList" placeholder="可多选" multiple style="width: 100%">
<el-option v-for="item in 60" :key="item" :value="item - 1">{{ item - 1 }}</el-option>
</el-select>
@ -32,74 +45,96 @@
export default {
data() {
return {
radioValue: 1,
cycle01: 1,
cycle02: 2,
average01: 0,
average02: 1,
checkboxList: [],
checkNum: this.$options.propsData.check
radioValue: 1, // 1
cycle01: 1, //
cycle02: 2, //
average01: 0, //
average02: 1, //
checkboxList: [], //
checkNum: this.$options.propsData.check //
}
},
name: 'crontab-second',
props: ['check', 'radioParent'],
name: 'crontab-second', // crontab
props: ['check', 'cron'], // cron
methods: {
// cron
radioChange() {
switch (this.radioValue) {
case 1:
// '*'
this.$emit('update', 'second', '*', 'second')
break
case 2:
this.$emit('update', 'second', this.cycleTotal)
// 1-5
this.$emit('update', 'second', this.cycleTotal, 'second')
break
case 3:
this.$emit('update', 'second', this.averageTotal)
// 0/5
this.$emit('update', 'second', this.averageTotal, 'second')
break
case 4:
this.$emit('update', 'second', this.checkboxString)
// 1,3,5
this.$emit('update', 'second', this.checkboxString, 'second')
break
}
},
//
cycleChange() {
if (this.radioValue == '2') {
this.$emit('update', 'second', this.cycleTotal)
this.$emit('update', 'second', this.cycleTotal, 'second')
}
},
//
averageChange() {
if (this.radioValue == '3') {
this.$emit('update', 'second', this.averageTotal)
this.$emit('update', 'second', this.averageTotal, 'second')
}
},
//
checkboxChange() {
if (this.radioValue == '4') {
this.$emit('update', 'second', this.checkboxString)
this.$emit('update', 'second', this.checkboxString, 'second')
}
}
},
//
watch: {
radioValue: 'radioChange',
cycleTotal: 'cycleChange',
averageTotal: 'averageChange',
checkboxString: 'checkboxChange',
radioParent() {
this.radioValue = this.radioParent
}
radioValue: 'radioChange', //
cycleTotal: 'cycleChange', //
averageTotal: 'averageChange', //
checkboxString: 'checkboxChange' //
},
computed: {
// 1-5
cycleTotal: function () {
// 0-58
const cycle01 = this.checkNum(this.cycle01, 0, 58)
// +1 59
const cycle02 = this.checkNum(this.cycle02, cycle01 ? cycle01 + 1 : 1, 59)
return cycle01 + '-' + cycle02
},
// 0/5
averageTotal: function () {
// 0-58
const average01 = this.checkNum(this.average01, 0, 58)
// 1 59-
const average02 = this.checkNum(this.average02, 1, 59 - average01 || 0)
return average01 + '/' + average02
},
// 1,3,5
checkboxString: function () {
let str = this.checkboxList.join()
// '*'
return str == '' ? '*' : str
}
}
}
</script>
</script>
Loading…
Cancel
Save