提交 | 用户 | 时间
|
0cceb6
|
1 |
<template> |
Y |
2 |
<el-form size="small"> |
|
3 |
<el-form-item> |
|
4 |
<el-radio v-model='radioValue' :label="1"> |
|
5 |
分钟,允许的通配符[, - * /] |
|
6 |
</el-radio> |
|
7 |
</el-form-item> |
|
8 |
|
|
9 |
<el-form-item> |
|
10 |
<el-radio v-model='radioValue' :label="2"> |
|
11 |
周期从 |
|
12 |
<el-input-number v-model='cycle01' :min="0" :max="58" /> - |
|
13 |
<el-input-number v-model='cycle02' :min="cycle01 ? cycle01 + 1 : 1" :max="59" /> 分钟 |
|
14 |
</el-radio> |
|
15 |
</el-form-item> |
|
16 |
|
|
17 |
<el-form-item> |
|
18 |
<el-radio v-model='radioValue' :label="3"> |
|
19 |
从 |
|
20 |
<el-input-number v-model='average01' :min="0" :max="58" /> 分钟开始,每 |
|
21 |
<el-input-number v-model='average02' :min="1" :max="59 - average01 || 0" /> 分钟执行一次 |
|
22 |
</el-radio> |
|
23 |
</el-form-item> |
|
24 |
|
|
25 |
<el-form-item> |
|
26 |
<el-radio v-model='radioValue' :label="4"> |
|
27 |
指定 |
|
28 |
<el-select clearable v-model="checkboxList" placeholder="可多选" multiple style="width:100%"> |
|
29 |
<el-option v-for="item in 60" :key="item" :value="item-1">{{item-1}}</el-option> |
|
30 |
</el-select> |
|
31 |
</el-radio> |
|
32 |
</el-form-item> |
|
33 |
</el-form> |
|
34 |
|
|
35 |
</template> |
|
36 |
|
|
37 |
<script> |
|
38 |
export default { |
|
39 |
data() { |
|
40 |
return { |
|
41 |
radioValue: 1, |
|
42 |
cycle01: 1, |
|
43 |
cycle02: 2, |
|
44 |
average01: 0, |
|
45 |
average02: 1, |
|
46 |
checkboxList: [], |
|
47 |
checkNum: this.$options.propsData.check |
|
48 |
} |
|
49 |
}, |
|
50 |
name: 'crontab-min', |
|
51 |
props: ['check', 'cron'], |
|
52 |
methods: { |
|
53 |
// 单选按钮值变化时 |
|
54 |
radioChange() { |
|
55 |
switch (this.radioValue) { |
|
56 |
case 1: |
|
57 |
this.$emit('update', 'min', '*', 'min'); |
|
58 |
break; |
|
59 |
case 2: |
|
60 |
this.$emit('update', 'min', this.cycleTotal, 'min'); |
|
61 |
break; |
|
62 |
case 3: |
|
63 |
this.$emit('update', 'min', this.averageTotal, 'min'); |
|
64 |
break; |
|
65 |
case 4: |
|
66 |
this.$emit('update', 'min', this.checkboxString, 'min'); |
|
67 |
break; |
|
68 |
} |
|
69 |
}, |
|
70 |
// 周期两个值变化时 |
|
71 |
cycleChange() { |
|
72 |
if (this.radioValue == '2') { |
|
73 |
this.$emit('update', 'min', this.cycleTotal, 'min'); |
|
74 |
} |
|
75 |
}, |
|
76 |
// 平均两个值变化时 |
|
77 |
averageChange() { |
|
78 |
if (this.radioValue == '3') { |
|
79 |
this.$emit('update', 'min', this.averageTotal, 'min'); |
|
80 |
} |
|
81 |
}, |
|
82 |
// checkbox值变化时 |
|
83 |
checkboxChange() { |
|
84 |
if (this.radioValue == '4') { |
|
85 |
this.$emit('update', 'min', this.checkboxString, 'min'); |
|
86 |
} |
|
87 |
}, |
|
88 |
|
|
89 |
}, |
|
90 |
watch: { |
|
91 |
'radioValue': 'radioChange', |
|
92 |
'cycleTotal': 'cycleChange', |
|
93 |
'averageTotal': 'averageChange', |
|
94 |
'checkboxString': 'checkboxChange', |
|
95 |
}, |
|
96 |
computed: { |
|
97 |
// 计算两个周期值 |
|
98 |
cycleTotal: function () { |
|
99 |
const cycle01 = this.checkNum(this.cycle01, 0, 58) |
|
100 |
const cycle02 = this.checkNum(this.cycle02, cycle01 ? cycle01 + 1 : 1, 59) |
|
101 |
return cycle01 + '-' + cycle02; |
|
102 |
}, |
|
103 |
// 计算平均用到的值 |
|
104 |
averageTotal: function () { |
|
105 |
const average01 = this.checkNum(this.average01, 0, 58) |
|
106 |
const average02 = this.checkNum(this.average02, 1, 59 - average01 || 0) |
|
107 |
return average01 + '/' + average02; |
|
108 |
}, |
|
109 |
// 计算勾选的checkbox值合集 |
|
110 |
checkboxString: function () { |
|
111 |
let str = this.checkboxList.join(); |
|
112 |
return str == '' ? '*' : str; |
|
113 |
} |
|
114 |
} |
|
115 |
} |
|
116 |
</script> |