From 8a1c08baaf0ee002b471996b195e7da180b90209 Mon Sep 17 00:00:00 2001 From: feige <791364011@qq.com> Date: 星期一, 21 七月 2025 09:38:47 +0800 Subject: [PATCH] 增加了前端代码库 --- src/components/Crontab/week.vue | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 202 insertions(+), 0 deletions(-) diff --git a/src/components/Crontab/week.vue b/src/components/Crontab/week.vue new file mode 100644 index 0000000..75c42ed --- /dev/null +++ b/src/components/Crontab/week.vue @@ -0,0 +1,202 @@ +<template> + <el-form size='small'> + <el-form-item> + <el-radio v-model='radioValue' :label="1"> + 鍛紝鍏佽鐨勯�氶厤绗, - * ? / L #] + </el-radio> + </el-form-item> + + <el-form-item> + <el-radio v-model='radioValue' :label="2"> + 涓嶆寚瀹� + </el-radio> + </el-form-item> + + <el-form-item> + <el-radio v-model='radioValue' :label="3"> + 鍛ㄦ湡浠庢槦鏈� + <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> + + <el-form-item> + <el-radio v-model='radioValue' :label="4"> + 绗� + <el-input-number v-model='average01' :min="1" :max="4" /> 鍛ㄧ殑鏄熸湡 + <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-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> + + <el-form-item> + <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" :label="item.value" :value="String(item.key)">{{item.value}}</el-option> + </el-select> + </el-radio> + </el-form-item> + + </el-form> +</template> + +<script> +export default { + data() { + return { + radioValue: 2, + weekday: 2, + cycle01: 2, + cycle02: 3, + average01: 1, + average02: 2, + checkboxList: [], + 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 + } + }, + name: 'crontab-week', + props: ['check', 'cron'], + methods: { + // 鍗曢�夋寜閽�煎彉鍖栨椂 + radioChange() { + if (this.radioValue !== 2 && this.cron.day !== '?') { + this.$emit('update', 'day', '?', 'week') + } + switch (this.radioValue) { + case 1: + this.$emit('update', 'week', '*') + break + case 2: + this.$emit('update', 'week', '?') + break + case 3: + this.$emit('update', 'week', this.cycleTotal) + break + case 4: + this.$emit('update', 'week', this.averageTotal) + break + case 5: + this.$emit('update', 'week', this.weekdayCheck + 'L') + break + case 6: + this.$emit('update', 'week', this.checkboxString) + break + } + }, + + // 鍛ㄦ湡涓や釜鍊煎彉鍖栨椂 + cycleChange() { + if (this.radioValue == '3') { + this.$emit('update', 'week', this.cycleTotal) + } + }, + // 骞冲潎涓や釜鍊煎彉鍖栨椂 + averageChange() { + if (this.radioValue == '4') { + this.$emit('update', 'week', this.averageTotal) + } + }, + // 鏈�杩戝伐浣滄棩鍊煎彉鍖栨椂 + weekdayChange() { + if (this.radioValue == '5') { + this.$emit('update', 'week', this.weekday + 'L') + } + }, + // checkbox鍊煎彉鍖栨椂 + checkboxChange() { + if (this.radioValue == '6') { + this.$emit('update', 'week', this.checkboxString) + } + }, + }, + watch: { + 'radioValue': 'radioChange', + 'cycleTotal': 'cycleChange', + 'averageTotal': 'averageChange', + 'weekdayCheck': 'weekdayChange', + 'checkboxString': 'checkboxChange', + }, + computed: { + // 璁$畻涓や釜鍛ㄦ湡鍊� + cycleTotal: function () { + this.cycle01 = this.checkNum(this.cycle01, 1, 7) + this.cycle02 = this.checkNum(this.cycle02, 1, 7) + return this.cycle01 + '-' + this.cycle02 + }, + // 璁$畻骞冲潎鐢ㄥ埌鐨勫�� + averageTotal: function () { + this.average01 = this.checkNum(this.average01, 1, 4) + this.average02 = this.checkNum(this.average02, 1, 7) + return this.average02 + '#' + this.average01 + }, + // 鏈�杩戠殑宸ヤ綔鏃ワ紙鏍煎紡锛� + weekdayCheck: function () { + this.weekday = this.checkNum(this.weekday, 1, 7) + return this.weekday + }, + // 璁$畻鍕鹃�夌殑checkbox鍊煎悎闆� + checkboxString: function () { + let str = this.checkboxList.join() + return str == '' ? '*' : str + } + } +} +</script> -- Gitblit v1.9.1