作者 若依
提交者 Gitee

!378 fix: crontab组件bug

Merge pull request !378 from fuzui/fix_cron_tool
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 <el-form size="small"> 2 <el-form size="small">
3 <el-form-item> 3 <el-form-item>
4 <el-radio v-model='radioValue' :label="1"> 4 <el-radio v-model='radioValue' :label="1">
5 - 日,允许的通配符[, - * / L M] 5 + 日,允许的通配符[, - * ? / L W]
6 </el-radio> 6 </el-radio>
7 </el-form-item> 7 </el-form-item>
8 8
@@ -15,23 +15,23 @@ @@ -15,23 +15,23 @@
15 <el-form-item> 15 <el-form-item>
16 <el-radio v-model='radioValue' :label="3"> 16 <el-radio v-model='radioValue' :label="3">
17 周期从 17 周期从
18 - <el-input-number v-model='cycle01' :min="0" :max="31" /> -  
19 - <el-input-number v-model='cycle02' :min="0" :max="31" /> 日 18 + <el-input-number v-model='cycle01' :min="1" :max="30" /> -
  19 + <el-input-number v-model='cycle02' :min="cycle01 ? cycle01 + 1 : 2" :max="31" /> 日
20 </el-radio> 20 </el-radio>
21 </el-form-item> 21 </el-form-item>
22 22
23 <el-form-item> 23 <el-form-item>
24 <el-radio v-model='radioValue' :label="4"> 24 <el-radio v-model='radioValue' :label="4">
25 25
26 - <el-input-number v-model='average01' :min="0" :max="31" /> 号开始,每  
27 - <el-input-number v-model='average02' :min="0" :max="31" /> 日执行一次 26 + <el-input-number v-model='average01' :min="1" :max="30" /> 号开始,每
  27 + <el-input-number v-model='average02' :min="1" :max="31 - average01 || 1" /> 日执行一次
28 </el-radio> 28 </el-radio>
29 </el-form-item> 29 </el-form-item>
30 30
31 <el-form-item> 31 <el-form-item>
32 <el-radio v-model='radioValue' :label="5"> 32 <el-radio v-model='radioValue' :label="5">
33 每月 33 每月
34 - <el-input-number v-model='workday' :min="0" :max="31" /> 号最近的那个工作日 34 + <el-input-number v-model='workday' :min="1" :max="31" /> 号最近的那个工作日
35 </el-radio> 35 </el-radio>
36 </el-form-item> 36 </el-form-item>
37 37
@@ -72,31 +72,22 @@ export default { @@ -72,31 +72,22 @@ export default {
72 // 单选按钮值变化时 72 // 单选按钮值变化时
73 radioChange() { 73 radioChange() {
74 ('day rachange'); 74 ('day rachange');
75 - if (this.radioValue === 1) {  
76 - this.$emit('update', 'day', '*', 'day');  
77 - this.$emit('update', 'week', '?', 'day');  
78 - this.$emit('update', 'month', '*', 'day');  
79 - } else {  
80 - if (this.cron.hour === '*') {  
81 - this.$emit('update', 'hour', '0', 'day');  
82 - }  
83 - if (this.cron.min === '*') {  
84 - this.$emit('update', 'min', '0', 'day');  
85 - }  
86 - if (this.cron.second === '*') {  
87 - this.$emit('update', 'second', '0', 'day');  
88 - } 75 + if (this.radioValue !== 2 && this.cron.week !== '?') {
  76 + this.$emit('update', 'week', '?', 'day')
89 } 77 }
90 78
91 switch (this.radioValue) { 79 switch (this.radioValue) {
  80 + case 1:
  81 + this.$emit('update', 'day', '*');
  82 + break;
92 case 2: 83 case 2:
93 this.$emit('update', 'day', '?'); 84 this.$emit('update', 'day', '?');
94 break; 85 break;
95 case 3: 86 case 3:
96 - this.$emit('update', 'day', this.cycle01 + '-' + this.cycle02); 87 + this.$emit('update', 'day', this.cycleTotal);
97 break; 88 break;
98 case 4: 89 case 4:
99 - this.$emit('update', 'day', this.average01 + '/' + this.average02); 90 + this.$emit('update', 'day', this.averageTotal);
100 break; 91 break;
101 case 5: 92 case 5:
102 this.$emit('update', 'day', this.workday + 'W'); 93 this.$emit('update', 'day', this.workday + 'W');
@@ -125,7 +116,7 @@ export default { @@ -125,7 +116,7 @@ export default {
125 // 最近工作日值变化时 116 // 最近工作日值变化时
126 workdayChange() { 117 workdayChange() {
127 if (this.radioValue == '5') { 118 if (this.radioValue == '5') {
128 - this.$emit('update', 'day', this.workday + 'W'); 119 + this.$emit('update', 'day', this.workdayCheck + 'W');
129 } 120 }
130 }, 121 },
131 // checkbox值变化时 122 // checkbox值变化时
@@ -133,19 +124,10 @@ export default { @@ -133,19 +124,10 @@ export default {
133 if (this.radioValue == '7') { 124 if (this.radioValue == '7') {
134 this.$emit('update', 'day', this.checkboxString); 125 this.$emit('update', 'day', this.checkboxString);
135 } 126 }
136 - },  
137 - // 父组件传递的week发生变化触发  
138 - weekChange() {  
139 - //判断week值与day不能同时为“?”  
140 - if (this.cron.week == '?' && this.radioValue == '2') {  
141 - this.radioValue = '1';  
142 - } else if (this.cron.week !== '?' && this.radioValue != '2') {  
143 - this.radioValue = '2';  
144 - }  
145 - }, 127 + }
146 }, 128 },
147 watch: { 129 watch: {
148 - "radioValue": "radioChange", 130 + 'radioValue': 'radioChange',
149 'cycleTotal': 'cycleChange', 131 'cycleTotal': 'cycleChange',
150 'averageTotal': 'averageChange', 132 'averageTotal': 'averageChange',
151 'workdayCheck': 'workdayChange', 133 'workdayCheck': 'workdayChange',
@@ -154,20 +136,20 @@ export default { @@ -154,20 +136,20 @@ export default {
154 computed: { 136 computed: {
155 // 计算两个周期值 137 // 计算两个周期值
156 cycleTotal: function () { 138 cycleTotal: function () {
157 - this.cycle01 = this.checkNum(this.cycle01, 1, 31)  
158 - this.cycle02 = this.checkNum(this.cycle02, 1, 31)  
159 - return this.cycle01 + '-' + this.cycle02; 139 + const cycle01 = this.checkNum(this.cycle01, 1, 30)
  140 + const cycle02 = this.checkNum(this.cycle02, cycle01 ? cycle01 + 1 : 2, 31, 31)
  141 + return cycle01 + '-' + cycle02;
160 }, 142 },
161 // 计算平均用到的值 143 // 计算平均用到的值
162 averageTotal: function () { 144 averageTotal: function () {
163 - this.average01 = this.checkNum(this.average01, 1, 31)  
164 - this.average02 = this.checkNum(this.average02, 1, 31)  
165 - return this.average01 + '/' + this.average02; 145 + const average01 = this.checkNum(this.average01, 1, 30)
  146 + const average02 = this.checkNum(this.average02, 1, 31 - average01 || 0)
  147 + return average01 + '/' + average02;
166 }, 148 },
167 // 计算工作日格式 149 // 计算工作日格式
168 workdayCheck: function () { 150 workdayCheck: function () {
169 - this.workday = this.checkNum(this.workday, 1, 31)  
170 - return this.workday; 151 + const workday = this.checkNum(this.workday, 1, 31)
  152 + return workday;
171 }, 153 },
172 // 计算勾选的checkbox值合集 154 // 计算勾选的checkbox值合集
173 checkboxString: function () { 155 checkboxString: function () {
@@ -9,16 +9,16 @@ @@ -9,16 +9,16 @@
9 <el-form-item> 9 <el-form-item>
10 <el-radio v-model='radioValue' :label="2"> 10 <el-radio v-model='radioValue' :label="2">
11 周期从 11 周期从
12 - <el-input-number v-model='cycle01' :min="0" :max="60" /> -  
13 - <el-input-number v-model='cycle02' :min="0" :max="60" /> 小时 12 + <el-input-number v-model='cycle01' :min="0" :max="22" /> -
  13 + <el-input-number v-model='cycle02' :min="cycle01 ? cycle01 + 1 : 1" :max="23" /> 小时
14 </el-radio> 14 </el-radio>
15 </el-form-item> 15 </el-form-item>
16 16
17 <el-form-item> 17 <el-form-item>
18 <el-radio v-model='radioValue' :label="3"> 18 <el-radio v-model='radioValue' :label="3">
19 19
20 - <el-input-number v-model='average01' :min="0" :max="60" /> 小时开始,每  
21 - <el-input-number v-model='average02' :min="0" :max="60" /> 小时执行一次 20 + <el-input-number v-model='average01' :min="0" :max="22" /> 小时开始,每
  21 + <el-input-number v-model='average02' :min="1" :max="23 - average01 || 0" /> 小时执行一次
22 </el-radio> 22 </el-radio>
23 </el-form-item> 23 </el-form-item>
24 24
@@ -51,23 +51,15 @@ export default { @@ -51,23 +51,15 @@ export default {
51 methods: { 51 methods: {
52 // 单选按钮值变化时 52 // 单选按钮值变化时
53 radioChange() { 53 radioChange() {
54 - if (this.radioValue === 1) {  
55 - this.$emit('update', 'hour', '*', 'hour');  
56 - this.$emit('update', 'day', '*', 'hour');  
57 - } else {  
58 - if (this.cron.min === '*') {  
59 - this.$emit('update', 'min', '0', 'hour');  
60 - }  
61 - if (this.cron.second === '*') {  
62 - this.$emit('update', 'second', '0', 'hour');  
63 - }  
64 - }  
65 switch (this.radioValue) { 54 switch (this.radioValue) {
  55 + case 1:
  56 + this.$emit('update', 'hour', '*')
  57 + break;
66 case 2: 58 case 2:
67 - this.$emit('update', 'hour', this.cycle01 + '-' + this.cycle02); 59 + this.$emit('update', 'hour', this.cycleTotal);
68 break; 60 break;
69 case 3: 61 case 3:
70 - this.$emit('update', 'hour', this.average01 + '/' + this.average02); 62 + this.$emit('update', 'hour', this.averageTotal);
71 break; 63 break;
72 case 4: 64 case 4:
73 this.$emit('update', 'hour', this.checkboxString); 65 this.$emit('update', 'hour', this.checkboxString);
@@ -94,7 +86,7 @@ export default { @@ -94,7 +86,7 @@ export default {
94 } 86 }
95 }, 87 },
96 watch: { 88 watch: {
97 - "radioValue": "radioChange", 89 + 'radioValue': 'radioChange',
98 'cycleTotal': 'cycleChange', 90 'cycleTotal': 'cycleChange',
99 'averageTotal': 'averageChange', 91 'averageTotal': 'averageChange',
100 'checkboxString': 'checkboxChange' 92 'checkboxString': 'checkboxChange'
@@ -102,15 +94,15 @@ export default { @@ -102,15 +94,15 @@ export default {
102 computed: { 94 computed: {
103 // 计算两个周期值 95 // 计算两个周期值
104 cycleTotal: function () { 96 cycleTotal: function () {
105 - this.cycle01 = this.checkNum(this.cycle01, 0, 23)  
106 - this.cycle02 = this.checkNum(this.cycle02, 0, 23)  
107 - return this.cycle01 + '-' + this.cycle02; 97 + const cycle01 = this.checkNum(this.cycle01, 0, 22)
  98 + const cycle02 = this.checkNum(this.cycle02, cycle01 ? cycle01 + 1 : 1, 23)
  99 + return cycle01 + '-' + cycle02;
108 }, 100 },
109 // 计算平均用到的值 101 // 计算平均用到的值
110 averageTotal: function () { 102 averageTotal: function () {
111 - this.average01 = this.checkNum(this.average01, 0, 23)  
112 - this.average02 = this.checkNum(this.average02, 1, 23)  
113 - return this.average01 + '/' + this.average02; 103 + const average01 = this.checkNum(this.average01, 0, 22)
  104 + const average02 = this.checkNum(this.average02, 1, 23 - average01 || 0)
  105 + return average01 + '/' + average02;
114 }, 106 },
115 // 计算勾选的checkbox值合集 107 // 计算勾选的checkbox值合集
116 checkboxString: function () { 108 checkboxString: function () {
@@ -2,7 +2,12 @@ @@ -2,7 +2,12 @@
2 <div> 2 <div>
3 <el-tabs type="border-card"> 3 <el-tabs type="border-card">
4 <el-tab-pane label="秒" v-if="shouldHide('second')"> 4 <el-tab-pane label="秒" v-if="shouldHide('second')">
5 - <CrontabSecond @update="updateCrontabValue" :check="checkNumber" ref="cronsecond" /> 5 + <CrontabSecond
  6 + @update="updateCrontabValue"
  7 + :check="checkNumber"
  8 + :cron="crontabValueObj"
  9 + ref="cronsecond"
  10 + />
6 </el-tab-pane> 11 </el-tab-pane>
7 12
8 <el-tab-pane label="分钟" v-if="shouldHide('min')"> 13 <el-tab-pane label="分钟" v-if="shouldHide('min')">
@@ -9,16 +9,16 @@ @@ -9,16 +9,16 @@
9 <el-form-item> 9 <el-form-item>
10 <el-radio v-model='radioValue' :label="2"> 10 <el-radio v-model='radioValue' :label="2">
11 周期从 11 周期从
12 - <el-input-number v-model='cycle01' :min="0" :max="60" /> -  
13 - <el-input-number v-model='cycle02' :min="0" :max="60" /> 分钟 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> 14 </el-radio>
15 </el-form-item> 15 </el-form-item>
16 16
17 <el-form-item> 17 <el-form-item>
18 <el-radio v-model='radioValue' :label="3"> 18 <el-radio v-model='radioValue' :label="3">
19 19
20 - <el-input-number v-model='average01' :min="0" :max="60" /> 分钟开始,每  
21 - <el-input-number v-model='average02' :min="0" :max="60" /> 分钟执行一次 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> 22 </el-radio>
23 </el-form-item> 23 </el-form-item>
24 24
@@ -52,19 +52,15 @@ export default { @@ -52,19 +52,15 @@ export default {
52 methods: { 52 methods: {
53 // 单选按钮值变化时 53 // 单选按钮值变化时
54 radioChange() { 54 radioChange() {
55 - if (this.radioValue !== 1 && this.cron.second === '*') {  
56 - this.$emit('update', 'second', '0', 'min');  
57 - }  
58 switch (this.radioValue) { 55 switch (this.radioValue) {
59 case 1: 56 case 1:
60 this.$emit('update', 'min', '*', 'min'); 57 this.$emit('update', 'min', '*', 'min');
61 - this.$emit('update', 'hour', '*', 'min');  
62 break; 58 break;
63 case 2: 59 case 2:
64 - this.$emit('update', 'min', this.cycle01 + '-' + this.cycle02, 'min'); 60 + this.$emit('update', 'min', this.cycleTotal, 'min');
65 break; 61 break;
66 case 3: 62 case 3:
67 - this.$emit('update', 'min', this.average01 + '/' + this.average02, 'min'); 63 + this.$emit('update', 'min', this.averageTotal, 'min');
68 break; 64 break;
69 case 4: 65 case 4:
70 this.$emit('update', 'min', this.checkboxString, 'min'); 66 this.$emit('update', 'min', this.checkboxString, 'min');
@@ -92,7 +88,7 @@ export default { @@ -92,7 +88,7 @@ export default {
92 88
93 }, 89 },
94 watch: { 90 watch: {
95 - "radioValue": "radioChange", 91 + 'radioValue': 'radioChange',
96 'cycleTotal': 'cycleChange', 92 'cycleTotal': 'cycleChange',
97 'averageTotal': 'averageChange', 93 'averageTotal': 'averageChange',
98 'checkboxString': 'checkboxChange', 94 'checkboxString': 'checkboxChange',
@@ -100,15 +96,15 @@ export default { @@ -100,15 +96,15 @@ export default {
100 computed: { 96 computed: {
101 // 计算两个周期值 97 // 计算两个周期值
102 cycleTotal: function () { 98 cycleTotal: function () {
103 - this.cycle01 = this.checkNum(this.cycle01, 0, 59)  
104 - this.cycle02 = this.checkNum(this.cycle02, 0, 59)  
105 - return this.cycle01 + '-' + this.cycle02; 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;
106 }, 102 },
107 // 计算平均用到的值 103 // 计算平均用到的值
108 averageTotal: function () { 104 averageTotal: function () {
109 - this.average01 = this.checkNum(this.average01, 0, 59)  
110 - this.average02 = this.checkNum(this.average02, 1, 59)  
111 - return this.average01 + '/' + this.average02; 105 + const average01 = this.checkNum(this.average01, 0, 58)
  106 + const average02 = this.checkNum(this.average02, 1, 59 - average01 || 0)
  107 + return average01 + '/' + average02;
112 }, 108 },
113 // 计算勾选的checkbox值合集 109 // 计算勾选的checkbox值合集
114 checkboxString: function () { 110 checkboxString: function () {
@@ -9,16 +9,16 @@ @@ -9,16 +9,16 @@
9 <el-form-item> 9 <el-form-item>
10 <el-radio v-model='radioValue' :label="2"> 10 <el-radio v-model='radioValue' :label="2">
11 周期从 11 周期从
12 - <el-input-number v-model='cycle01' :min="1" :max="12" /> -  
13 - <el-input-number v-model='cycle02' :min="1" :max="12" /> 月 12 + <el-input-number v-model='cycle01' :min="1" :max="11" /> -
  13 + <el-input-number v-model='cycle02' :min="cycle01 ? cycle01 + 1 : 2" :max="12" /> 月
14 </el-radio> 14 </el-radio>
15 </el-form-item> 15 </el-form-item>
16 16
17 <el-form-item> 17 <el-form-item>
18 <el-radio v-model='radioValue' :label="3"> 18 <el-radio v-model='radioValue' :label="3">
19 19
20 - <el-input-number v-model='average01' :min="1" :max="12" /> 月开始,每  
21 - <el-input-number v-model='average02' :min="1" :max="12" /> 月月执行一次 20 + <el-input-number v-model='average01' :min="1" :max="11" /> 月开始,每
  21 + <el-input-number v-model='average02' :min="1" :max="12 - average01 || 0" /> 月月执行一次
22 </el-radio> 22 </el-radio>
23 </el-form-item> 23 </el-form-item>
24 24
@@ -51,29 +51,15 @@ export default { @@ -51,29 +51,15 @@ export default {
51 methods: { 51 methods: {
52 // 单选按钮值变化时 52 // 单选按钮值变化时
53 radioChange() { 53 radioChange() {
54 - if (this.radioValue === 1) {  
55 - this.$emit('update', 'month', '*');  
56 - this.$emit('update', 'year', '*');  
57 - } else {  
58 - if (this.cron.day === '*') {  
59 - this.$emit('update', 'day', '0', 'month');  
60 - }  
61 - if (this.cron.hour === '*') {  
62 - this.$emit('update', 'hour', '0', 'month');  
63 - }  
64 - if (this.cron.min === '*') {  
65 - this.$emit('update', 'min', '0', 'month');  
66 - }  
67 - if (this.cron.second === '*') {  
68 - this.$emit('update', 'second', '0', 'month');  
69 - }  
70 - }  
71 switch (this.radioValue) { 54 switch (this.radioValue) {
  55 + case 1:
  56 + this.$emit('update', 'month', '*');
  57 + break;
72 case 2: 58 case 2:
73 - this.$emit('update', 'month', this.cycle01 + '-' + this.cycle02); 59 + this.$emit('update', 'month', this.cycleTotal);
74 break; 60 break;
75 case 3: 61 case 3:
76 - this.$emit('update', 'month', this.average01 + '/' + this.average02); 62 + this.$emit('update', 'month', this.averageTotal);
77 break; 63 break;
78 case 4: 64 case 4:
79 this.$emit('update', 'month', this.checkboxString); 65 this.$emit('update', 'month', this.checkboxString);
@@ -100,7 +86,7 @@ export default { @@ -100,7 +86,7 @@ export default {
100 } 86 }
101 }, 87 },
102 watch: { 88 watch: {
103 - "radioValue": "radioChange", 89 + 'radioValue': 'radioChange',
104 'cycleTotal': 'cycleChange', 90 'cycleTotal': 'cycleChange',
105 'averageTotal': 'averageChange', 91 'averageTotal': 'averageChange',
106 'checkboxString': 'checkboxChange' 92 'checkboxString': 'checkboxChange'
@@ -108,15 +94,15 @@ export default { @@ -108,15 +94,15 @@ export default {
108 computed: { 94 computed: {
109 // 计算两个周期值 95 // 计算两个周期值
110 cycleTotal: function () { 96 cycleTotal: function () {
111 - this.cycle01 = this.checkNum(this.cycle01, 1, 12)  
112 - this.cycle02 = this.checkNum(this.cycle02, 1, 12)  
113 - return this.cycle01 + '-' + this.cycle02; 97 + const cycle01 = this.checkNum(this.cycle01, 1, 11)
  98 + const cycle02 = this.checkNum(this.cycle02, cycle01 ? cycle01 + 1 : 2, 12)
  99 + return cycle01 + '-' + cycle02;
114 }, 100 },
115 // 计算平均用到的值 101 // 计算平均用到的值
116 averageTotal: function () { 102 averageTotal: function () {
117 - this.average01 = this.checkNum(this.average01, 1, 12)  
118 - this.average02 = this.checkNum(this.average02, 1, 12)  
119 - return this.average01 + '/' + this.average02; 103 + const average01 = this.checkNum(this.average01, 1, 11)
  104 + const average02 = this.checkNum(this.average02, 1, 12 - average01 || 0)
  105 + return average01 + '/' + average02;
120 }, 106 },
121 // 计算勾选的checkbox值合集 107 // 计算勾选的checkbox值合集
122 checkboxString: function () { 108 checkboxString: function () {
@@ -179,7 +179,7 @@ export default { @@ -179,7 +179,7 @@ export default {
179 // 获取达到条件的日期是星期X 179 // 获取达到条件的日期是星期X
180 let thisWeek = this.formatDate(new Date(YY + '-' + MM + '-' + thisDD + ' 00:00:00'), 'week'); 180 let thisWeek = this.formatDate(new Date(YY + '-' + MM + '-' + thisDD + ' 00:00:00'), 'week');
181 // 当星期日时 181 // 当星期日时
182 - if (thisWeek == 0) { 182 + if (thisWeek == 1) {
183 // 先找下一个日,并判断是否为月底 183 // 先找下一个日,并判断是否为月底
184 DD++; 184 DD++;
185 thisDD = DD < 10 ? '0' + DD : DD; 185 thisDD = DD < 10 ? '0' + DD : DD;
@@ -187,7 +187,7 @@ export default { @@ -187,7 +187,7 @@ export default {
187 if (this.checkDate(YY + '-' + MM + '-' + thisDD + ' 00:00:00') !== true) { 187 if (this.checkDate(YY + '-' + MM + '-' + thisDD + ' 00:00:00') !== true) {
188 DD -= 3; 188 DD -= 3;
189 } 189 }
190 - } else if (thisWeek == 6) { 190 + } else if (thisWeek == 7) {
191 // 当星期6时只需判断不是1号就可进行操作 191 // 当星期6时只需判断不是1号就可进行操作
192 if (this.dayRuleSup !== 1) { 192 if (this.dayRuleSup !== 1) {
193 DD--; 193 DD--;
@@ -200,7 +200,7 @@ export default { @@ -200,7 +200,7 @@ export default {
200 // 获取当前日期是属于星期几 200 // 获取当前日期是属于星期几
201 let thisWeek = this.formatDate(new Date(YY + '-' + MM + '-' + DD + ' 00:00:00'), 'week'); 201 let thisWeek = this.formatDate(new Date(YY + '-' + MM + '-' + DD + ' 00:00:00'), 'week');
202 // 校验当前星期是否在星期池(dayRuleSup)中 202 // 校验当前星期是否在星期池(dayRuleSup)中
203 - if (Array.indexOf(this.dayRuleSup, thisWeek) < 0) { 203 + if (this.dayRuleSup.indexOf(thisWeek) < 0) {
204 // 如果到达最大值时 204 // 如果到达最大值时
205 if (Di == DDate.length - 1) { 205 if (Di == DDate.length - 1) {
206 resetDay(); 206 resetDay();
@@ -385,7 +385,7 @@ export default { @@ -385,7 +385,7 @@ export default {
385 } else if (rule.indexOf('#') >= 0) { 385 } else if (rule.indexOf('#') >= 0) {
386 this.dayRule = 'assWeek'; 386 this.dayRule = 'assWeek';
387 let matchRule = rule.match(/[0-9]{1}/g); 387 let matchRule = rule.match(/[0-9]{1}/g);
388 - this.dayRuleSup = [Number(matchRule[0]), Number(matchRule[1])]; 388 + this.dayRuleSup = [Number(matchRule[1]), Number(matchRule[0])];
389 this.dateArr[3] = [1]; 389 this.dateArr[3] = [1];
390 if (this.dayRuleSup[1] == 7) { 390 if (this.dayRuleSup[1] == 7) {
391 this.dayRuleSup[1] = 0; 391 this.dayRuleSup[1] = 0;
@@ -401,14 +401,6 @@ export default { @@ -401,14 +401,6 @@ export default {
401 this.dayRule = 'weekDay'; 401 this.dayRule = 'weekDay';
402 this.dayRuleSup = this.getAssignArr(rule) 402 this.dayRuleSup = this.getAssignArr(rule)
403 } 403 }
404 - // 如果weekDay时将7调整为0【week值0即是星期日】  
405 - if (this.dayRule == 'weekDay') {  
406 - for (let i = 0; i < this.dayRuleSup.length; i++) {  
407 - if (this.dayRuleSup[i] == 7) {  
408 - this.dayRuleSup[i] = 0;  
409 - }  
410 - }  
411 - }  
412 } 404 }
413 }, 405 },
414 // 获取"日"数组-少量为日期规则 406 // 获取"日"数组-少量为日期规则
@@ -543,14 +535,15 @@ export default { @@ -543,14 +535,15 @@ export default {
543 if (type == undefined) { 535 if (type == undefined) {
544 return Y + '-' + (M < 10 ? '0' + M : M) + '-' + (D < 10 ? '0' + D : D) + ' ' + (h < 10 ? '0' + h : h) + ':' + (m < 10 ? '0' + m : m) + ':' + (s < 10 ? '0' + s : s); 536 return Y + '-' + (M < 10 ? '0' + M : M) + '-' + (D < 10 ? '0' + D : D) + ' ' + (h < 10 ? '0' + h : h) + ':' + (m < 10 ? '0' + m : m) + ':' + (s < 10 ? '0' + s : s);
545 } else if (type == 'week') { 537 } else if (type == 'week') {
546 - return week; 538 + // 在quartz中 1为星期日
  539 + return week + 1;
547 } 540 }
548 }, 541 },
549 // 检查日期是否存在 542 // 检查日期是否存在
550 checkDate(value) { 543 checkDate(value) {
551 let time = new Date(value); 544 let time = new Date(value);
552 let format = this.formatDate(time) 545 let format = this.formatDate(time)
553 - return value == format ? true : false; 546 + return value === format;
554 } 547 }
555 }, 548 },
556 watch: { 549 watch: {
@@ -9,16 +9,16 @@ @@ -9,16 +9,16 @@
9 <el-form-item> 9 <el-form-item>
10 <el-radio v-model='radioValue' :label="2"> 10 <el-radio v-model='radioValue' :label="2">
11 周期从 11 周期从
12 - <el-input-number v-model='cycle01' :min="0" :max="60" /> -  
13 - <el-input-number v-model='cycle02' :min="0" :max="60" /> 秒 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> 14 </el-radio>
15 </el-form-item> 15 </el-form-item>
16 16
17 <el-form-item> 17 <el-form-item>
18 <el-radio v-model='radioValue' :label="3"> 18 <el-radio v-model='radioValue' :label="3">
19 19
20 - <el-input-number v-model='average01' :min="0" :max="60" /> 秒开始,每  
21 - <el-input-number v-model='average02' :min="0" :max="60" /> 秒执行一次 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> 22 </el-radio>
23 </el-form-item> 23 </el-form-item>
24 24
@@ -54,13 +54,12 @@ export default { @@ -54,13 +54,12 @@ export default {
54 switch (this.radioValue) { 54 switch (this.radioValue) {
55 case 1: 55 case 1:
56 this.$emit('update', 'second', '*', 'second'); 56 this.$emit('update', 'second', '*', 'second');
57 - this.$emit('update', 'min', '*', 'second');  
58 break; 57 break;
59 case 2: 58 case 2:
60 - this.$emit('update', 'second', this.cycle01 + '-' + this.cycle02); 59 + this.$emit('update', 'second', this.cycleTotal);
61 break; 60 break;
62 case 3: 61 case 3:
63 - this.$emit('update', 'second', this.average01 + '/' + this.average02); 62 + this.$emit('update', 'second', this.averageTotal);
64 break; 63 break;
65 case 4: 64 case 4:
66 this.$emit('update', 'second', this.checkboxString); 65 this.$emit('update', 'second', this.checkboxString);
@@ -84,25 +83,10 @@ export default { @@ -84,25 +83,10 @@ export default {
84 if (this.radioValue == '4') { 83 if (this.radioValue == '4') {
85 this.$emit('update', 'second', this.checkboxString); 84 this.$emit('update', 'second', this.checkboxString);
86 } 85 }
87 - },  
88 - othChange() {  
89 - // 反解析  
90 - let ins = this.cron.second  
91 - ('反解析 second', ins);  
92 - if (ins === '*') {  
93 - this.radioValue = 1;  
94 - } else if (ins.indexOf('-') > -1) {  
95 - this.radioValue = 2  
96 - } else if (ins.indexOf('/') > -1) {  
97 - this.radioValue = 3  
98 - } else {  
99 - this.radioValue = 4  
100 - this.checkboxList = ins.split(',')  
101 - }  
102 } 86 }
103 }, 87 },
104 watch: { 88 watch: {
105 - "radioValue": "radioChange", 89 + 'radioValue': 'radioChange',
106 'cycleTotal': 'cycleChange', 90 'cycleTotal': 'cycleChange',
107 'averageTotal': 'averageChange', 91 'averageTotal': 'averageChange',
108 'checkboxString': 'checkboxChange', 92 'checkboxString': 'checkboxChange',
@@ -113,15 +97,15 @@ export default { @@ -113,15 +97,15 @@ export default {
113 computed: { 97 computed: {
114 // 计算两个周期值 98 // 计算两个周期值
115 cycleTotal: function () { 99 cycleTotal: function () {
116 - this.cycle01 = this.checkNum(this.cycle01, 0, 59)  
117 - this.cycle02 = this.checkNum(this.cycle02, 0, 59)  
118 - return this.cycle01 + '-' + this.cycle02; 100 + const cycle01 = this.checkNum(this.cycle01, 0, 58)
  101 + const cycle02 = this.checkNum(this.cycle02, cycle01 ? cycle01 + 1 : 1, 59)
  102 + return cycle01 + '-' + cycle02;
119 }, 103 },
120 // 计算平均用到的值 104 // 计算平均用到的值
121 averageTotal: function () { 105 averageTotal: function () {
122 - this.average01 = this.checkNum(this.average01, 0, 59)  
123 - this.average02 = this.checkNum(this.average02, 1, 59)  
124 - return this.average01 + '/' + this.average02; 106 + const average01 = this.checkNum(this.average01, 0, 58)
  107 + const average02 = this.checkNum(this.average02, 1, 59 - average01 || 0)
  108 + return average01 + '/' + average02;
125 }, 109 },
126 // 计算勾选的checkbox值合集 110 // 计算勾选的checkbox值合集
127 checkboxString: function () { 111 checkboxString: function () {
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 <el-form size='small'> 2 <el-form size='small'>
3 <el-form-item> 3 <el-form-item>
4 <el-radio v-model='radioValue' :label="1"> 4 <el-radio v-model='radioValue' :label="1">
5 - 周,允许的通配符[, - * / L #] 5 + 周,允许的通配符[, - * ? / L #]
6 </el-radio> 6 </el-radio>
7 </el-form-item> 7 </el-form-item>
8 8
@@ -15,8 +15,25 @@ @@ -15,8 +15,25 @@
15 <el-form-item> 15 <el-form-item>
16 <el-radio v-model='radioValue' :label="3"> 16 <el-radio v-model='radioValue' :label="3">
17 周期从星期 17 周期从星期
18 - <el-input-number v-model='cycle01' :min="1" :max="7" /> -  
19 - <el-input-number v-model='cycle02' :min="1" :max="7" /> 18 + <el-select clearable v-model="cycle01">
  19 + <el-option
  20 + v-for="(item,index) of weekList"
  21 + :key="index"
  22 + :label="item.value"
  23 + :value="item.key"
  24 + :disabled="item.key === 1"
  25 + >{{item.value}}</el-option>
  26 + </el-select>
  27 + -
  28 + <el-select clearable v-model="cycle02">
  29 + <el-option
  30 + v-for="(item,index) of weekList"
  31 + :key="index"
  32 + :label="item.value"
  33 + :value="item.key"
  34 + :disabled="item.key < cycle01 && item.key !== 1"
  35 + >{{item.value}}</el-option>
  36 + </el-select>
20 </el-radio> 37 </el-radio>
21 </el-form-item> 38 </el-form-item>
22 39
@@ -24,14 +41,18 @@ @@ -24,14 +41,18 @@
24 <el-radio v-model='radioValue' :label="4"> 41 <el-radio v-model='radioValue' :label="4">
25 42
26 <el-input-number v-model='average01' :min="1" :max="4" /> 周的星期 43 <el-input-number v-model='average01' :min="1" :max="4" /> 周的星期
27 - <el-input-number v-model='average02' :min="1" :max="7" /> 44 + <el-select clearable v-model="average02">
  45 + <el-option v-for="(item,index) of weekList" :key="index" :label="item.value" :value="item.key">{{item.value}}</el-option>
  46 + </el-select>
28 </el-radio> 47 </el-radio>
29 </el-form-item> 48 </el-form-item>
30 49
31 <el-form-item> 50 <el-form-item>
32 <el-radio v-model='radioValue' :label="5"> 51 <el-radio v-model='radioValue' :label="5">
33 本月最后一个星期 52 本月最后一个星期
34 - <el-input-number v-model='weekday' :min="1" :max="7" /> 53 + <el-select clearable v-model="weekday">
  54 + <el-option v-for="(item,index) of weekList" :key="index" :label="item.value" :value="item.key">{{item.value}}</el-option>
  55 + </el-select>
35 </el-radio> 56 </el-radio>
36 </el-form-item> 57 </el-form-item>
37 58
@@ -39,7 +60,7 @@ @@ -39,7 +60,7 @@
39 <el-radio v-model='radioValue' :label="6"> 60 <el-radio v-model='radioValue' :label="6">
40 指定 61 指定
41 <el-select clearable v-model="checkboxList" placeholder="可多选" multiple style="width:100%"> 62 <el-select clearable v-model="checkboxList" placeholder="可多选" multiple style="width:100%">
42 - <el-option v-for="(item,index) of weekList" :key="index" :value="index+1">{{item}}</el-option> 63 + <el-option v-for="(item,index) of weekList" :key="index" :label="item.value" :value="item.key">{{item.value}}</el-option>
43 </el-select> 64 </el-select>
44 </el-radio> 65 </el-radio>
45 </el-form-item> 66 </el-form-item>
@@ -52,13 +73,42 @@ export default { @@ -52,13 +73,42 @@ export default {
52 data() { 73 data() {
53 return { 74 return {
54 radioValue: 2, 75 radioValue: 2,
55 - weekday: 1,  
56 - cycle01: 1,  
57 - cycle02: 2, 76 + weekday: 2,
  77 + cycle01: 2,
  78 + cycle02: 3,
58 average01: 1, 79 average01: 1,
59 - average02: 1, 80 + average02: 2,
60 checkboxList: [], 81 checkboxList: [],
61 - weekList: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'], 82 + weekList: [
  83 + {
  84 + key: 2,
  85 + value: '星期一'
  86 + },
  87 + {
  88 + key: 3,
  89 + value: '星期二'
  90 + },
  91 + {
  92 + key: 4,
  93 + value: '星期三'
  94 + },
  95 + {
  96 + key: 5,
  97 + value: '星期四'
  98 + },
  99 + {
  100 + key: 6,
  101 + value: '星期五'
  102 + },
  103 + {
  104 + key: 7,
  105 + value: '星期六'
  106 + },
  107 + {
  108 + key: 1,
  109 + value: '星期日'
  110 + }
  111 + ],
62 checkNum: this.$options.propsData.check 112 checkNum: this.$options.propsData.check
63 } 113 }
64 }, 114 },
@@ -67,45 +117,30 @@ export default { @@ -67,45 +117,30 @@ export default {
67 methods: { 117 methods: {
68 // 单选按钮值变化时 118 // 单选按钮值变化时
69 radioChange() { 119 radioChange() {
70 - if (this.radioValue === 1) {  
71 - this.$emit('update', 'week', '*');  
72 - this.$emit('update', 'year', '*');  
73 - } else {  
74 - if (this.cron.month === '*') {  
75 - this.$emit('update', 'month', '0', 'week');  
76 - }  
77 - if (this.cron.day === '*') {  
78 - this.$emit('update', 'day', '0', 'week');  
79 - }  
80 - if (this.cron.hour === '*') {  
81 - this.$emit('update', 'hour', '0', 'week');  
82 - }  
83 - if (this.cron.min === '*') {  
84 - this.$emit('update', 'min', '0', 'week');  
85 - }  
86 - if (this.cron.second === '*') {  
87 - this.$emit('update', 'second', '0', 'week');  
88 - } 120 + if (this.radioValue !== 2 && this.cron.day !== '?') {
  121 + this.$emit('update', 'day', '?', 'week');
89 } 122 }
90 switch (this.radioValue) { 123 switch (this.radioValue) {
  124 + case 1:
  125 + this.$emit('update', 'week', '*');
  126 + break;
91 case 2: 127 case 2:
92 this.$emit('update', 'week', '?'); 128 this.$emit('update', 'week', '?');
93 break; 129 break;
94 case 3: 130 case 3:
95 - this.$emit('update', 'week', this.cycle01 + '-' + this.cycle02); 131 + this.$emit('update', 'week', this.cycleTotal);
96 break; 132 break;
97 case 4: 133 case 4:
98 - this.$emit('update', 'week', this.average01 + '#' + this.average02); 134 + this.$emit('update', 'week', this.averageTotal);
99 break; 135 break;
100 case 5: 136 case 5:
101 - this.$emit('update', 'week', this.weekday + 'L'); 137 + this.$emit('update', 'week', this.weekdayCheck + 'L');
102 break; 138 break;
103 case 6: 139 case 6:
104 this.$emit('update', 'week', this.checkboxString); 140 this.$emit('update', 'week', this.checkboxString);
105 break; 141 break;
106 } 142 }
107 }, 143 },
108 - // 根据互斥事件,更改radio的值  
109 144
110 // 周期两个值变化时 145 // 周期两个值变化时
111 cycleChange() { 146 cycleChange() {
@@ -133,7 +168,7 @@ export default { @@ -133,7 +168,7 @@ export default {
133 }, 168 },
134 }, 169 },
135 watch: { 170 watch: {
136 - "radioValue": "radioChange", 171 + 'radioValue': 'radioChange',
137 'cycleTotal': 'cycleChange', 172 'cycleTotal': 'cycleChange',
138 'averageTotal': 'averageChange', 173 'averageTotal': 'averageChange',
139 'weekdayCheck': 'weekdayChange', 174 'weekdayCheck': 'weekdayChange',
@@ -150,7 +185,7 @@ export default { @@ -150,7 +185,7 @@ export default {
150 averageTotal: function () { 185 averageTotal: function () {
151 this.average01 = this.checkNum(this.average01, 1, 4) 186 this.average01 = this.checkNum(this.average01, 1, 4)
152 this.average02 = this.checkNum(this.average02, 1, 7) 187 this.average02 = this.checkNum(this.average02, 1, 7)
153 - return this.average01 + '#' + this.average02; 188 + return this.average02 + '#' + this.average01;
154 }, 189 },
155 // 最近的工作日(格式) 190 // 最近的工作日(格式)
156 weekdayCheck: function () { 191 weekdayCheck: function () {
@@ -15,16 +15,16 @@ @@ -15,16 +15,16 @@
15 <el-form-item> 15 <el-form-item>
16 <el-radio :label="3" v-model='radioValue'> 16 <el-radio :label="3" v-model='radioValue'>
17 周期从 17 周期从
18 - <el-input-number v-model='cycle01' :min='fullYear' /> -  
19 - <el-input-number v-model='cycle02' :min='fullYear' /> 18 + <el-input-number v-model='cycle01' :min='fullYear' :max="2098" /> -
  19 + <el-input-number v-model='cycle02' :min="cycle01 ? cycle01 + 1 : fullYear + 1" :max="2099" />
20 </el-radio> 20 </el-radio>
21 </el-form-item> 21 </el-form-item>
22 22
23 <el-form-item> 23 <el-form-item>
24 <el-radio :label="4" v-model='radioValue'> 24 <el-radio :label="4" v-model='radioValue'>
25 25
26 - <el-input-number v-model='average01' :min='fullYear' /> 年开始,每  
27 - <el-input-number v-model='average02' :min='fullYear' /> 年执行一次 26 + <el-input-number v-model='average01' :min='fullYear' :max="2098"/> 年开始,每
  27 + <el-input-number v-model='average02' :min="1" :max="2099 - average01 || fullYear" /> 年执行一次
28 </el-radio> 28 </el-radio>
29 29
30 </el-form-item> 30 </el-form-item>
@@ -59,21 +59,6 @@ export default { @@ -59,21 +59,6 @@ export default {
59 methods: { 59 methods: {
60 // 单选按钮值变化时 60 // 单选按钮值变化时
61 radioChange() { 61 radioChange() {
62 - if (this.cron.month === '*') {  
63 - this.$emit('update', 'month', '0', 'year');  
64 - }  
65 - if (this.cron.day === '*') {  
66 - this.$emit('update', 'day', '0', 'year');  
67 - }  
68 - if (this.cron.hour === '*') {  
69 - this.$emit('update', 'hour', '0', 'year');  
70 - }  
71 - if (this.cron.min === '*') {  
72 - this.$emit('update', 'min', '0', 'year');  
73 - }  
74 - if (this.cron.second === '*') {  
75 - this.$emit('update', 'second', '0', 'year');  
76 - }  
77 switch (this.radioValue) { 62 switch (this.radioValue) {
78 case 1: 63 case 1:
79 this.$emit('update', 'year', ''); 64 this.$emit('update', 'year', '');
@@ -82,10 +67,10 @@ export default { @@ -82,10 +67,10 @@ export default {
82 this.$emit('update', 'year', '*'); 67 this.$emit('update', 'year', '*');
83 break; 68 break;
84 case 3: 69 case 3:
85 - this.$emit('update', 'year', this.cycle01 + '-' + this.cycle02); 70 + this.$emit('update', 'year', this.cycleTotal);
86 break; 71 break;
87 case 4: 72 case 4:
88 - this.$emit('update', 'year', this.average01 + '/' + this.average02); 73 + this.$emit('update', 'year', this.averageTotal);
89 break; 74 break;
90 case 5: 75 case 5:
91 this.$emit('update', 'year', this.checkboxString); 76 this.$emit('update', 'year', this.checkboxString);
@@ -112,7 +97,7 @@ export default { @@ -112,7 +97,7 @@ export default {
112 } 97 }
113 }, 98 },
114 watch: { 99 watch: {
115 - "radioValue": "radioChange", 100 + 'radioValue': 'radioChange',
116 'cycleTotal': 'cycleChange', 101 'cycleTotal': 'cycleChange',
117 'averageTotal': 'averageChange', 102 'averageTotal': 'averageChange',
118 'checkboxString': 'checkboxChange' 103 'checkboxString': 'checkboxChange'
@@ -120,15 +105,15 @@ export default { @@ -120,15 +105,15 @@ export default {
120 computed: { 105 computed: {
121 // 计算两个周期值 106 // 计算两个周期值
122 cycleTotal: function () { 107 cycleTotal: function () {
123 - this.cycle01 = this.checkNum(this.cycle01, this.fullYear, this.fullYear + 100)  
124 - this.cycle02 = this.checkNum(this.cycle02, this.fullYear + 1, this.fullYear + 101)  
125 - return this.cycle01 + '-' + this.cycle02; 108 + const cycle01 = this.checkNum(this.cycle01, this.fullYear, 2098)
  109 + const cycle02 = this.checkNum(this.cycle02, cycle01 ? cycle01 + 1 : this.fullYear + 1, 2099)
  110 + return cycle01 + '-' + cycle02;
126 }, 111 },
127 // 计算平均用到的值 112 // 计算平均用到的值
128 averageTotal: function () { 113 averageTotal: function () {
129 - this.average01 = this.checkNum(this.average01, this.fullYear, this.fullYear + 100)  
130 - this.average02 = this.checkNum(this.average02, 1, 10)  
131 - return this.average01 + '/' + this.average02; 114 + const average01 = this.checkNum(this.average01, this.fullYear, 2098)
  115 + const average02 = this.checkNum(this.average02, 1, 2099 - average01 || this.fullYear)
  116 + return average01 + '/' + average02;
132 }, 117 },
133 // 计算勾选的checkbox值合集 118 // 计算勾选的checkbox值合集
134 checkboxString: function () { 119 checkboxString: function () {
@@ -139,6 +124,8 @@ export default { @@ -139,6 +124,8 @@ export default {
139 mounted: function () { 124 mounted: function () {
140 // 仅获取当前年份 125 // 仅获取当前年份
141 this.fullYear = Number(new Date().getFullYear()); 126 this.fullYear = Number(new Date().getFullYear());
  127 + this.cycle01 = this.fullYear
  128 + this.average01 = this.fullYear
142 } 129 }
143 } 130 }
144 </script> 131 </script>