From ca285f5e53aea0dae4fb1db8e46a0c0cb70afa29 Mon Sep 17 00:00:00 2001
From: fuzui <73400@163.com>
Date: 星期二, 30 十一月 2021 00:22:23 +0800
Subject: [PATCH] fix: crontab组件周显示及计算bug
---
ruoyi-ui/src/components/Crontab/week.vue | 74 +++++++++++++++++++++++++++++++------
ruoyi-ui/src/components/Crontab/result.vue | 21 +++-------
2 files changed, 69 insertions(+), 26 deletions(-)
diff --git a/ruoyi-ui/src/components/Crontab/result.vue b/ruoyi-ui/src/components/Crontab/result.vue
index 07b963b..aea6e0e 100644
--- a/ruoyi-ui/src/components/Crontab/result.vue
+++ b/ruoyi-ui/src/components/Crontab/result.vue
@@ -179,7 +179,7 @@
// 鑾峰彇杈惧埌鏉′欢鐨勬棩鏈熸槸鏄熸湡X
let thisWeek = this.formatDate(new Date(YY + '-' + MM + '-' + thisDD + ' 00:00:00'), 'week');
// 褰撴槦鏈熸棩鏃�
- if (thisWeek == 0) {
+ if (thisWeek == 1) {
// 鍏堟壘涓嬩竴涓棩锛屽苟鍒ゆ柇鏄惁涓烘湀搴�
DD++;
thisDD = DD < 10 ? '0' + DD : DD;
@@ -187,7 +187,7 @@
if (this.checkDate(YY + '-' + MM + '-' + thisDD + ' 00:00:00') !== true) {
DD -= 3;
}
- } else if (thisWeek == 6) {
+ } else if (thisWeek == 7) {
// 褰撴槦鏈�6鏃跺彧闇�鍒ゆ柇涓嶆槸1鍙峰氨鍙繘琛屾搷浣�
if (this.dayRuleSup !== 1) {
DD--;
@@ -200,7 +200,7 @@
// 鑾峰彇褰撳墠鏃ユ湡鏄睘浜庢槦鏈熷嚑
let thisWeek = this.formatDate(new Date(YY + '-' + MM + '-' + DD + ' 00:00:00'), 'week');
// 鏍¢獙褰撳墠鏄熸湡鏄惁鍦ㄦ槦鏈熸睜锛坉ayRuleSup锛変腑
- if (Array.indexOf(this.dayRuleSup, thisWeek) < 0) {
+ if (this.dayRuleSup.indexOf(thisWeek) < 0) {
// 濡傛灉鍒拌揪鏈�澶у�兼椂
if (Di == DDate.length - 1) {
resetDay();
@@ -385,7 +385,7 @@
} else if (rule.indexOf('#') >= 0) {
this.dayRule = 'assWeek';
let matchRule = rule.match(/[0-9]{1}/g);
- this.dayRuleSup = [Number(matchRule[0]), Number(matchRule[1])];
+ this.dayRuleSup = [Number(matchRule[1]), Number(matchRule[0])];
this.dateArr[3] = [1];
if (this.dayRuleSup[1] == 7) {
this.dayRuleSup[1] = 0;
@@ -400,14 +400,6 @@
} else if (rule !== '*' && rule !== '?') {
this.dayRule = 'weekDay';
this.dayRuleSup = this.getAssignArr(rule)
- }
- // 濡傛灉weekDay鏃跺皢7璋冩暣涓�0銆恮eek鍊�0鍗虫槸鏄熸湡鏃ャ��
- if (this.dayRule == 'weekDay') {
- for (let i = 0; i < this.dayRuleSup.length; i++) {
- if (this.dayRuleSup[i] == 7) {
- this.dayRuleSup[i] = 0;
- }
- }
}
}
},
@@ -543,14 +535,15 @@
if (type == undefined) {
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);
} else if (type == 'week') {
- return week;
+ // 鍦╭uartz涓� 1涓烘槦鏈熸棩
+ return week + 1;
}
},
// 妫�鏌ユ棩鏈熸槸鍚﹀瓨鍦�
checkDate(value) {
let time = new Date(value);
let format = this.formatDate(time)
- return value == format ? true : false;
+ return value === format;
}
},
watch: {
diff --git a/ruoyi-ui/src/components/Crontab/week.vue b/ruoyi-ui/src/components/Crontab/week.vue
index 8cc82e2..4485bc4 100644
--- a/ruoyi-ui/src/components/Crontab/week.vue
+++ b/ruoyi-ui/src/components/Crontab/week.vue
@@ -15,8 +15,25 @@
<el-form-item>
<el-radio v-model='radioValue' :label="3">
鍛ㄦ湡浠庢槦鏈�
- <el-input-number v-model='cycle01' :min="1" :max="7" /> -
- <el-input-number v-model='cycle02' :min="1" :max="7" />
+ <el-select clearable v-model="cycle01">
+ <el-option
+ v-for="(item,index) of weekList"
+ :key="index"
+ :label="item.value"
+ :value="item.key"
+ :disabled="item.key === 1"
+ >{{item.value}}</el-option>
+ </el-select>
+ -
+ <el-select clearable v-model="cycle02">
+ <el-option
+ v-for="(item,index) of weekList"
+ :key="index"
+ :label="item.value"
+ :value="item.key"
+ :disabled="item.key < cycle01 && item.key !== 1"
+ >{{item.value}}</el-option>
+ </el-select>
</el-radio>
</el-form-item>
@@ -24,14 +41,18 @@
<el-radio v-model='radioValue' :label="4">
绗�
<el-input-number v-model='average01' :min="1" :max="4" /> 鍛ㄧ殑鏄熸湡
- <el-input-number v-model='average02' :min="1" :max="7" />
+ <el-select clearable v-model="average02">
+ <el-option v-for="(item,index) of weekList" :key="index" :label="item.value" :value="item.key">{{item.value}}</el-option>
+ </el-select>
</el-radio>
</el-form-item>
<el-form-item>
<el-radio v-model='radioValue' :label="5">
鏈湀鏈�鍚庝竴涓槦鏈�
- <el-input-number v-model='weekday' :min="1" :max="7" />
+ <el-select clearable v-model="weekday">
+ <el-option v-for="(item,index) of weekList" :key="index" :label="item.value" :value="item.key">{{item.value}}</el-option>
+ </el-select>
</el-radio>
</el-form-item>
@@ -39,7 +60,7 @@
<el-radio v-model='radioValue' :label="6">
鎸囧畾
<el-select clearable v-model="checkboxList" placeholder="鍙閫�" multiple style="width:100%">
- <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" :label="item.value" :value="item.key">{{item.value}}</el-option>
</el-select>
</el-radio>
</el-form-item>
@@ -52,13 +73,42 @@
data() {
return {
radioValue: 2,
- weekday: 1,
- cycle01: 1,
- cycle02: 2,
+ weekday: 2,
+ cycle01: 2,
+ cycle02: 3,
average01: 1,
- average02: 1,
+ average02: 2,
checkboxList: [],
- weekList: ['鍛ㄤ竴', '鍛ㄤ簩', '鍛ㄤ笁', '鍛ㄥ洓', '鍛ㄤ簲', '鍛ㄥ叚', '鍛ㄦ棩'],
+ weekList: [
+ {
+ key: 2,
+ value: '鏄熸湡涓�'
+ },
+ {
+ key: 3,
+ value: '鏄熸湡浜�'
+ },
+ {
+ key: 4,
+ value: '鏄熸湡涓�'
+ },
+ {
+ key: 5,
+ value: '鏄熸湡鍥�'
+ },
+ {
+ key: 6,
+ value: '鏄熸湡浜�'
+ },
+ {
+ key: 7,
+ value: '鏄熸湡鍏�'
+ },
+ {
+ key: 1,
+ value: '鏄熸湡鏃�'
+ }
+ ],
checkNum: this.$options.propsData.check
}
},
@@ -81,7 +131,7 @@
this.$emit('update', 'week', this.cycle01 + '-' + this.cycle02);
break;
case 4:
- this.$emit('update', 'week', this.average01 + '#' + this.average02);
+ this.$emit('update', 'week', this.average02 + '#' + this.average01);
break;
case 5:
this.$emit('update', 'week', this.weekday + 'L');
@@ -135,7 +185,7 @@
averageTotal: function () {
this.average01 = this.checkNum(this.average01, 1, 4)
this.average02 = this.checkNum(this.average02, 1, 7)
- return this.average01 + '#' + this.average02;
+ return this.average02 + '#' + this.average01;
},
// 鏈�杩戠殑宸ヤ綔鏃ワ紙鏍煎紡锛�
weekdayCheck: function () {
--
Gitblit v1.9.3