1、重置功能,解决需要多次重置回复到原始状态(选择条件(0 0 0 0 0 1-2 ),需要点击3次重置,才能重置到( * * * * ?)

2、删除表达式自动填充功能,每一项都需要用户自行填写,不支持自动修改
This commit is contained in:
yjb 2021-10-23 23:25:03 +08:00
parent 7acb128111
commit cfdd623179
6 changed files with 437 additions and 411 deletions

View File

@ -1,180 +1,184 @@
<template> <template>
<el-form size="small"> <el-form size="small">
<el-form-item> <el-form-item>
<el-radio v-model='radioValue' :label="1"> <el-radio v-model='radioValue' :label="1">
允许的通配符[, - * / L M] 允许的通配符[, - * / L M]
</el-radio> </el-radio>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-radio v-model='radioValue' :label="2"> <el-radio v-model='radioValue' :label="2">
不指定 不指定
</el-radio> </el-radio>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-radio v-model='radioValue' :label="3"> <el-radio v-model='radioValue' :label="3">
周期从 周期从
<el-input-number v-model='cycle01' :min="0" :max="31"/> <el-input-number v-model='cycle01' :min="0" :max="31"/>
- -
<el-input-number v-model='cycle02' :min="0" :max="31"/> <el-input-number v-model='cycle02' :min="0" :max="31"/>
</el-radio> </el-radio>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-radio v-model='radioValue' :label="4"> <el-radio v-model='radioValue' :label="4">
<el-input-number v-model='average01' :min="0" :max="31"/> <el-input-number v-model='average01' :min="0" :max="31"/>
号开始 号开始
<el-input-number v-model='average02' :min="0" :max="31"/> <el-input-number v-model='average02' :min="0" :max="31"/>
日执行一次 日执行一次
</el-radio> </el-radio>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-radio v-model='radioValue' :label="5"> <el-radio v-model='radioValue' :label="5">
每月 每月
<el-input-number v-model='workday' :min="0" :max="31"/> <el-input-number v-model='workday' :min="0" :max="31"/>
号最近的那个工作日 号最近的那个工作日
</el-radio> </el-radio>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-radio v-model='radioValue' :label="6"> <el-radio v-model='radioValue' :label="6">
本月最后一天 本月最后一天
</el-radio> </el-radio>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-radio v-model='radioValue' :label="7"> <el-radio v-model='radioValue' :label="7">
指定 指定
<el-select clearable v-model="checkboxList" placeholder="可多选" multiple style="width:100%"> <el-select clearable v-model="checkboxList" placeholder="可多选" multiple style="width:100%"
<el-option v-for="item in 31" :key="item" :value="item">{{ item }}</el-option> @change="selectChange">
</el-select> <el-option v-for="item in 31" :key="item" :value="item">{{ item }}</el-option>
</el-radio> </el-select>
</el-form-item> </el-radio>
</el-form> </el-form-item>
</el-form>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
radioValue: 1, radioValue: 1,
workday: 1, workday: 1,
cycle01: 1, cycle01: 1,
cycle02: 2, cycle02: 2,
average01: 1, average01: 1,
average02: 1, average02: 1,
checkboxList: [], checkboxList: [],
checkNum: this.$options.propsData.check checkNum: this.$options.propsData.check
} }
}, },
name: 'crontab-day', name: 'crontab-day',
props: ['check', 'cron'], props: ['check', 'cron'],
methods: { methods: {
init() { selectChange() {
this.workday = 1 this.radioValue = 7
this.cycle01 = 1 },
this.cycle02 = 2 init() {
this.average01 = 1 this.workday = 1
this.average02 = 1 this.cycle01 = 1
this.checkboxList = [] this.cycle02 = 2
}, this.average01 = 1
// this.average02 = 1
radioChange() { this.checkboxList = []
('day rachange'); },
if (this.radioValue === 1) { //
this.$emit('update', 'day', '*', 'day'); radioChange() {
} ('day rachange');
if (this.radioValue === 1) {
this.$emit('update', 'day', '*', 'day');
}
switch (this.radioValue) { switch (this.radioValue) {
case 2: case 2:
this.$emit('update', 'day', '?'); this.$emit('update', 'day', '?');
break; break;
case 3: case 3:
this.$emit('update', 'day', this.cycle01 + '-' + this.cycle02); this.$emit('update', 'day', this.cycle01 + '-' + this.cycle02);
break; break;
case 4: case 4:
this.$emit('update', 'day', this.average01 + '/' + this.average02); this.$emit('update', 'day', this.average01 + '/' + this.average02);
break; break;
case 5: case 5:
this.$emit('update', 'day', this.workday + 'W'); this.$emit('update', 'day', this.workday + 'W');
break; break;
case 6: case 6:
this.$emit('update', 'day', 'L'); this.$emit('update', 'day', 'L');
break; break;
case 7: case 7:
this.$emit('update', 'day', this.checkboxString); this.$emit('update', 'day', this.checkboxString);
break; break;
} }
('day rachange end'); ('day rachange end');
}, },
// //
cycleChange() { cycleChange() {
if (this.radioValue == '3') { if (this.radioValue == '3') {
this.$emit('update', 'day', this.cycleTotal); this.$emit('update', 'day', this.cycleTotal);
} }
}, },
// //
averageChange() { averageChange() {
if (this.radioValue == '4') { if (this.radioValue == '4') {
this.$emit('update', 'day', this.averageTotal); this.$emit('update', 'day', this.averageTotal);
} }
}, },
// //
workdayChange() { workdayChange() {
if (this.radioValue == '5') { if (this.radioValue == '5') {
this.$emit('update', 'day', this.workday + 'W'); this.$emit('update', 'day', this.workday + 'W');
} }
}, },
// checkbox // checkbox
checkboxChange() { checkboxChange() {
if (this.radioValue == '7') { if (this.radioValue == '7') {
this.$emit('update', 'day', this.checkboxString); this.$emit('update', 'day', this.checkboxString);
} }
}, },
// week // week
weekChange() { weekChange() {
//weekday? //weekday?
if (this.cron.week == '?' && this.radioValue == '2') { if (this.cron.week == '?' && this.radioValue == '2') {
this.radioValue = '1'; this.radioValue = '1';
} else if (this.cron.week !== '?' && this.radioValue != '2') { } else if (this.cron.week !== '?' && this.radioValue != '2') {
this.radioValue = '2'; this.radioValue = '2';
} }
}, },
}, },
watch: { watch: {
"radioValue": "radioChange", "radioValue": "radioChange",
'cycleTotal': 'cycleChange', 'cycleTotal': 'cycleChange',
'averageTotal': 'averageChange', 'averageTotal': 'averageChange',
'workdayCheck': 'workdayChange', 'workdayCheck': 'workdayChange',
'checkboxString': 'checkboxChange', 'checkboxString': 'checkboxChange',
}, },
computed: { computed: {
// //
cycleTotal: function () { cycleTotal: function () {
this.cycle01 = this.checkNum(this.cycle01, 1, 31) this.cycle01 = this.checkNum(this.cycle01, 1, 31)
this.cycle02 = this.checkNum(this.cycle02, 1, 31) this.cycle02 = this.checkNum(this.cycle02, 1, 31)
return this.cycle01 + '-' + this.cycle02; return this.cycle01 + '-' + this.cycle02;
}, },
// //
averageTotal: function () { averageTotal: function () {
this.average01 = this.checkNum(this.average01, 1, 31) this.average01 = this.checkNum(this.average01, 1, 31)
this.average02 = this.checkNum(this.average02, 1, 31) this.average02 = this.checkNum(this.average02, 1, 31)
return this.average01 + '/' + this.average02; return this.average01 + '/' + this.average02;
}, },
// //
workdayCheck: function () { workdayCheck: function () {
this.workday = this.checkNum(this.workday, 1, 31) this.workday = this.checkNum(this.workday, 1, 31)
return this.workday; return this.workday;
}, },
// checkbox // checkbox
checkboxString: function () { checkboxString: function () {
let str = this.checkboxList.join(); let str = this.checkboxList.join();
return str == '' ? '*' : str; return str == '' ? '*' : str;
} }
} }
} }
</script> </script>

View File

@ -1,125 +1,129 @@
<template> <template>
<el-form size="small"> <el-form size="small">
<el-form-item> <el-form-item>
<el-radio v-model='radioValue' :label="1"> <el-radio v-model='radioValue' :label="1">
小时允许的通配符[, - * /] 小时允许的通配符[, - * /]
</el-radio> </el-radio>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-radio v-model='radioValue' :label="2"> <el-radio v-model='radioValue' :label="2">
周期从 周期从
<el-input-number v-model='cycle01' :min="0" :max="60"/> <el-input-number v-model='cycle01' :min="0" :max="60"/>
- -
<el-input-number v-model='cycle02' :min="0" :max="60"/> <el-input-number v-model='cycle02' :min="0" :max="60"/>
小时 小时
</el-radio> </el-radio>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-radio v-model='radioValue' :label="3"> <el-radio v-model='radioValue' :label="3">
<el-input-number v-model='average01' :min="0" :max="60"/> <el-input-number v-model='average01' :min="0" :max="60"/>
小时开始 小时开始
<el-input-number v-model='average02' :min="0" :max="60"/> <el-input-number v-model='average02' :min="0" :max="60"/>
小时执行一次 小时执行一次
</el-radio> </el-radio>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-radio v-model='radioValue' :label="4"> <el-radio v-model='radioValue' :label="4">
指定 指定
<el-select clearable v-model="checkboxList" placeholder="可多选" multiple style="width:100%"> <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> @change="selectChange">
</el-select> <el-option v-for="item in 60" :key="item" :value="item-1">{{ item - 1 }}</el-option>
</el-radio> </el-select>
</el-form-item> </el-radio>
</el-form> </el-form-item>
</el-form>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
radioValue: 1, radioValue: 1,
cycle01: 0, cycle01: 0,
cycle02: 1, cycle02: 1,
average01: 0, average01: 0,
average02: 1, average02: 1,
checkboxList: [], checkboxList: [],
checkNum: this.$options.propsData.check checkNum: this.$options.propsData.check
} }
}, },
name: 'crontab-hour', name: 'crontab-hour',
props: ['check', 'cron'], props: ['check', 'cron'],
methods: { methods: {
init() { selectChange() {
this.cycle01 = 0 this.radioValue = 4
this.cycle02 = 1 },
this.average01 = 0 init() {
this.average02 = 1 this.cycle01 = 0
this.checkboxList = [] this.cycle02 = 1
}, this.average01 = 0
// this.average02 = 1
radioChange() { this.checkboxList = []
if (this.radioValue === 1) { },
this.$emit('update', 'hour', '*', 'hour'); //
} radioChange() {
switch (this.radioValue) { if (this.radioValue === 1) {
case 2: this.$emit('update', 'hour', '*', 'hour');
this.$emit('update', 'hour', this.cycle01 + '-' + this.cycle02); }
break; switch (this.radioValue) {
case 3: case 2:
this.$emit('update', 'hour', this.average01 + '/' + this.average02); this.$emit('update', 'hour', this.cycle01 + '-' + this.cycle02);
break; break;
case 4: case 3:
this.$emit('update', 'hour', this.checkboxString); this.$emit('update', 'hour', this.average01 + '/' + this.average02);
break; break;
} case 4:
}, this.$emit('update', 'hour', this.checkboxString);
// break;
cycleChange() { }
if (this.radioValue == '2') { },
this.$emit('update', 'hour', this.cycleTotal); //
} cycleChange() {
}, if (this.radioValue == '2') {
// this.$emit('update', 'hour', this.cycleTotal);
averageChange() { }
if (this.radioValue == '3') { },
this.$emit('update', 'hour', this.averageTotal); //
} averageChange() {
}, if (this.radioValue == '3') {
// checkbox this.$emit('update', 'hour', this.averageTotal);
checkboxChange() { }
if (this.radioValue == '4') { },
this.$emit('update', 'hour', this.checkboxString); // checkbox
} checkboxChange() {
} if (this.radioValue == '4') {
}, this.$emit('update', 'hour', this.checkboxString);
watch: { }
"radioValue": "radioChange", }
'cycleTotal': 'cycleChange', },
'averageTotal': 'averageChange', watch: {
'checkboxString': 'checkboxChange' "radioValue": "radioChange",
}, 'cycleTotal': 'cycleChange',
computed: { 'averageTotal': 'averageChange',
// 'checkboxString': 'checkboxChange'
cycleTotal: function () { },
this.cycle01 = this.checkNum(this.cycle01, 0, 23) computed: {
this.cycle02 = this.checkNum(this.cycle02, 0, 23) //
return this.cycle01 + '-' + this.cycle02; cycleTotal: function () {
}, this.cycle01 = this.checkNum(this.cycle01, 0, 23)
// this.cycle02 = this.checkNum(this.cycle02, 0, 23)
averageTotal: function () { return this.cycle01 + '-' + this.cycle02;
this.average01 = this.checkNum(this.average01, 0, 23) },
this.average02 = this.checkNum(this.average02, 1, 23) //
return this.average01 + '/' + this.average02; averageTotal: function () {
}, this.average01 = this.checkNum(this.average01, 0, 23)
// checkbox this.average02 = this.checkNum(this.average02, 1, 23)
checkboxString: function () { return this.average01 + '/' + this.average02;
let str = this.checkboxList.join(); },
return str == '' ? '*' : str; // checkbox
} checkboxString: function () {
} let str = this.checkboxList.join();
return str == '' ? '*' : str;
}
}
} }
</script> </script>

View File

@ -25,7 +25,7 @@
<el-form-item> <el-form-item>
<el-radio v-model='radioValue' :label="4"> <el-radio v-model='radioValue' :label="4">
指定 指定
<el-select clearable v-model="checkboxList" placeholder="可多选" multiple style="width:100%"> <el-select clearable v-model="checkboxList" placeholder="可多选" multiple style="width:100%" @change="selectChange">
<el-option v-for="item in 60" :key="item" :value="item-1">{{item-1}}</el-option> <el-option v-for="item in 60" :key="item" :value="item-1">{{item-1}}</el-option>
</el-select> </el-select>
</el-radio> </el-radio>
@ -50,6 +50,9 @@ export default {
name: 'crontab-min', name: 'crontab-min',
props: ['check', 'cron'], props: ['check', 'cron'],
methods: { methods: {
selectChange() {
this.radioValue = 4
},
init() { init() {
this.cycle01 = 1 this.cycle01 = 1
this.cycle02 = 2 this.cycle02 = 2

View File

@ -25,7 +25,7 @@
<el-form-item> <el-form-item>
<el-radio v-model='radioValue' :label="4"> <el-radio v-model='radioValue' :label="4">
指定 指定
<el-select clearable v-model="checkboxList" placeholder="可多选" multiple style="width:100%"> <el-select clearable v-model="checkboxList" placeholder="可多选" multiple style="width:100%" @change="selectChange">
<el-option v-for="item in 12" :key="item" :value="item">{{item}}</el-option> <el-option v-for="item in 12" :key="item" :value="item">{{item}}</el-option>
</el-select> </el-select>
</el-radio> </el-radio>
@ -48,7 +48,9 @@ export default {
}, },
name: 'crontab-month', name: 'crontab-month',
props: ['check', 'cron'], props: ['check', 'cron'],
methods: { methods: { selectChange() {
this.radioValue = 4
},
init() { init() {
this.cycle01 = 1 this.cycle01 = 1
this.cycle02 = 2 this.cycle02 = 2

View File

@ -1,54 +1,62 @@
<template> <template>
<el-form size="small"> <el-form size="small">
<el-form-item> <el-form-item>
<el-radio v-model='radioValue' :label="1"> <el-radio v-model='radioValue' :label="1">
允许的通配符[, - * /] 允许的通配符[, - * /]
</el-radio> </el-radio>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-radio v-model='radioValue' :label="2"> <el-radio v-model='radioValue' :label="2">
周期从 周期从
<el-input-number v-model='cycle01' :min="0" :max="60" /> - <el-input-number v-model='cycle01' :min="0" :max="60"/>
<el-input-number v-model='cycle02' :min="0" :max="60" /> -
</el-radio> <el-input-number v-model='cycle02' :min="0" :max="60"/>
</el-form-item>
</el-radio>
</el-form-item>
<el-form-item> <el-form-item>
<el-radio v-model='radioValue' :label="3"> <el-radio v-model='radioValue' :label="3">
<el-input-number v-model='average01' :min="0" :max="60" /> 秒开始 <el-input-number v-model='average01' :min="0" :max="60"/>
<el-input-number v-model='average02' :min="0" :max="60" /> 秒执行一次 秒开始
</el-radio> <el-input-number v-model='average02' :min="0" :max="60"/>
</el-form-item> 秒执行一次
</el-radio>
</el-form-item>
<el-form-item> <el-form-item>
<el-radio v-model='radioValue' :label="4"> <el-radio v-model='radioValue' :label="4">
指定 指定
<el-select clearable v-model="checkboxList" placeholder="可多选" multiple style="width:100%" @change="ch"> <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> @change="selectChange">
</el-select> <el-option v-for="item in 60" :key="item" :value="item-1">{{ item - 1 }}</el-option>
</el-radio> </el-select>
</el-form-item> </el-radio>
</el-form> </el-form-item>
</el-form>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
radioValue: 1, radioValue: 1,
cycle01: 1, cycle01: 1,
cycle02: 2, cycle02: 2,
average01: 0, average01: 0,
average02: 1, average02: 1,
checkboxList: [], checkboxList: [],
checkNum: this.$options.propsData.check checkNum: this.$options.propsData.check
} }
}, },
name: 'crontab-second', name: 'crontab-second',
props: ['check', 'radioParent'], props: ['check', 'radioParent'],
methods: { methods: {
selectChange() {
this.radioValue = 4
},
init() { init() {
this.cycle01 = 1 this.cycle01 = 1
this.cycle02 = 2 this.cycle02 = 2
@ -56,84 +64,84 @@ export default {
this.average02 = 1 this.average02 = 1
this.checkboxList = [] this.checkboxList = []
}, },
// //
radioChange() { radioChange() {
switch (this.radioValue) { switch (this.radioValue) {
case 1: case 1:
this.$emit('update', 'second', '*', 'second'); this.$emit('update', 'second', '*', 'second');
break; break;
case 2: case 2:
this.$emit('update', 'second', this.cycle01 + '-' + this.cycle02); this.$emit('update', 'second', this.cycle01 + '-' + this.cycle02);
break; break;
case 3: case 3:
this.$emit('update', 'second', this.average01 + '/' + this.average02); this.$emit('update', 'second', this.average01 + '/' + this.average02);
break; break;
case 4: case 4:
this.$emit('update', 'second', this.checkboxString); this.$emit('update', 'second', this.checkboxString);
break; break;
} }
}, },
// //
cycleChange() { cycleChange() {
if (this.radioValue == '2') { if (this.radioValue == '2') {
this.$emit('update', 'second', this.cycleTotal); this.$emit('update', 'second', this.cycleTotal);
} }
}, },
// //
averageChange() { averageChange() {
if (this.radioValue == '3') { if (this.radioValue == '3') {
this.$emit('update', 'second', this.averageTotal); this.$emit('update', 'second', this.averageTotal);
} }
}, },
// checkbox // checkbox
checkboxChange() { checkboxChange() {
if (this.radioValue == '4') { if (this.radioValue == '4') {
this.$emit('update', 'second', this.checkboxString); this.$emit('update', 'second', this.checkboxString);
} }
}, },
othChange() { othChange() {
// //
let ins = this.cron.second let ins = this.cron.second
('反解析 second', ins); ('反解析 second', ins);
if (ins === '*') { if (ins === '*') {
this.radioValue = 1; this.radioValue = 1;
} else if (ins.indexOf('-') > -1) { } else if (ins.indexOf('-') > -1) {
this.radioValue = 2 this.radioValue = 2
} else if (ins.indexOf('/') > -1) { } else if (ins.indexOf('/') > -1) {
this.radioValue = 3 this.radioValue = 3
} else { } else {
this.radioValue = 4 this.radioValue = 4
this.checkboxList = ins.split(',') this.checkboxList = ins.split(',')
} }
} }
}, },
watch: { watch: {
"radioValue": "radioChange", "radioValue": "radioChange",
'cycleTotal': 'cycleChange', 'cycleTotal': 'cycleChange',
'averageTotal': 'averageChange', 'averageTotal': 'averageChange',
'checkboxString': 'checkboxChange', 'checkboxString': 'checkboxChange',
radioParent() { radioParent() {
this.radioValue = this.radioParent this.radioValue = this.radioParent
} }
}, },
computed: { computed: {
// //
cycleTotal: function () { cycleTotal: function () {
this.cycle01 = this.checkNum(this.cycle01, 0, 59) this.cycle01 = this.checkNum(this.cycle01, 0, 59)
this.cycle02 = this.checkNum(this.cycle02, 0, 59) this.cycle02 = this.checkNum(this.cycle02, 0, 59)
return this.cycle01 + '-' + this.cycle02; return this.cycle01 + '-' + this.cycle02;
}, },
// //
averageTotal: function () { averageTotal: function () {
this.average01 = this.checkNum(this.average01, 0, 59) this.average01 = this.checkNum(this.average01, 0, 59)
this.average02 = this.checkNum(this.average02, 1, 59) this.average02 = this.checkNum(this.average02, 1, 59)
return this.average01 + '/' + this.average02; return this.average01 + '/' + this.average02;
}, },
// checkbox // checkbox
checkboxString: function () { checkboxString: function () {
let str = this.checkboxList.join(); let str = this.checkboxList.join();
return str == '' ? '*' : str; return str == '' ? '*' : str;
} }
} }
} }
</script> </script>

View File

@ -40,7 +40,8 @@
<el-form-item> <el-form-item>
<el-radio v-model='radioValue' :label="6"> <el-radio v-model='radioValue' :label="6">
指定 指定
<el-select clearable v-model="checkboxDescribeList" placeholder="可多选" multiple style="width:100%"> <el-select clearable v-model="checkboxDescribeList" placeholder="可多选" multiple style="width:100%"
@change="selectChange">
<el-option v-for="(item,index) of weekList" :key="index" :value="index+1">{{ item }}</el-option> <el-option v-for="(item,index) of weekList" :key="index" :value="index+1">{{ item }}</el-option>
</el-select> </el-select>
</el-radio> </el-radio>
@ -68,11 +69,16 @@ export default {
name: 'crontab-week', name: 'crontab-week',
props: ['check', 'cron'], props: ['check', 'cron'],
methods: { methods: {
checkChange(data) { selectChange(data) {
console.log(data);
this.radioValue = 6
this.checkboxList = [] this.checkboxList = []
this.checkboxDescribeList = []
data.forEach(value => { data.forEach(value => {
this.weekList.find((item, index) => { this.weekList.forEach((item,index) => {
if (item === value) { if (index+1 === value) {
console.log((item));
this.checkboxDescribeList.push(this.weekList[index])
this.checkboxList.push(index + 1) this.checkboxList.push(index + 1)
} }
}) })
@ -90,7 +96,6 @@ export default {
// //
radioChange() { radioChange() {
switch (this.radioValue) { switch (this.radioValue) {
case 1: case 1:
this.$emit('update', 'week', '*'); this.$emit('update', 'week', '*');