Commit ac7b0e9f authored by 水落(YangLei)'s avatar 水落(YangLei)

feat: 任务管理完成

parent c351dac8
import { request, METHOD } from '@/utils';
export * from './menu';
export * from './system';
export * from './task';
export function getUserDetailInfoApi() {
return request('/api/v1/detail', METHOD.GET);
......
import { postReq, putReq } from '@/utils';
export function addTaskApi(data) {
return postReq('/api/v1/schedules', data);
}
export function updateTaskApi(data) {
return putReq('/api/v1/schedules', data);
}
<template>
<div class="components-input-demo-presuffix">
<a-input :placeholder="placeholder" :value="cron" @input="handleinput">
<a-icon slot="prefix" type="schedule" title="corn控件" @click="openModal" />
<a-icon v-if="cron" slot="suffix" type="close-circle" @click="handleEmpty" title="清空" />
</a-input>
<AntCron ref="innerVueCron" :data="afterCron" @ok="handleOK"></AntCron>
</div>
<div class="components-input-demo-presuffix">
<a-input :placeholder="placeholder" :value="cron" @input="handleinput" :disabled="disabled">
<a-icon slot="prefix" type="schedule" title="corn控件" @click="openModal" />
<a-icon v-if="cron" slot="suffix" type="close-circle" @click="handleEmpty" title="清空" />
</a-input>
<AntCron ref="innerVueCron" :data="afterCron" @ok="handleOK"></AntCron>
</div>
</template>
<script>
import AntCron from "./AntCron";
import { replaceWeekName } from "./validator";
import AntCron from './AntCron';
import { replaceWeekName } from './validator';
export default {
name: "ACron",
components: {
AntCron
},
props: {
value: {
required: false,
type: String,
default: ""
name: 'ACron',
components: {
AntCron,
},
placeholder: {
required: false,
type: String,
default: ""
}
},
data() {
return {
cron: this.value,
afterCron: ""
};
},
watch: {
value(val) {
this.cron = val;
props: {
value: {
required: false,
type: String,
default: '',
},
placeholder: {
required: false,
type: String,
default: '',
},
disabled: Boolean,
},
cron(val) {
console.log(replaceWeekName(val));
this.afterCron = replaceWeekName(val);
console.log(val);
this.$emit("input", val);
}
},
methods: {
openModal() {
this.$refs.innerVueCron.show();
data() {
return {
cron: this.value,
afterCron: '',
};
},
handleOK(val) {
this.cron = val;
this.$emit("change", this.cron);
watch: {
value(val) {
this.cron = val;
},
cron(val) {
console.log(replaceWeekName(val));
this.afterCron = replaceWeekName(val);
console.log(val);
this.$emit('input', val);
},
},
handleinput(evt) {
this.cron = evt.target.value;
if (this.cron !== "") {
this.$emit("change", this.cron);
} else {
this.$emit("change", undefined);
}
methods: {
openModal() {
if (this.disabled) return;
this.$refs.innerVueCron.show();
},
handleOK(val) {
this.cron = val;
this.$emit('change', this.cron);
},
handleinput(evt) {
this.cron = evt.target.value;
if (this.cron !== '') {
this.$emit('change', this.cron);
} else {
this.$emit('change', undefined);
}
},
handleEmpty() {
if (this.disabled) return;
this.handleOK('');
},
},
model: {
prop: 'value',
event: 'change',
},
handleEmpty() {
this.handleOK("");
}
},
model: {
prop: "value",
event: "change"
}
};
</script>
<style scoped>
.components-input-demo-presuffix .anticon-close-circle {
cursor: pointer;
color: #ccc;
transition: color 0.3s;
font-size: 12px;
cursor: pointer;
color: #ccc;
transition: color 0.3s;
font-size: 12px;
}
.components-input-demo-presuffix .anticon-close-circle:hover {
color: #f5222d;
color: #f5222d;
}
.components-input-demo-presuffix .anticon-close-circle:active {
color: #666;
color: #666;
}
</style>
\ No newline at end of file
</style>
<template>
<a-modal
title="corn表达式"
:width="modalWidth"
:visible="visible"
:confirmLoading="confirmLoading"
@ok="handleSubmit"
@cancel="close"
cancelText="关闭"
>
<div class="card-container">
<a-tabs type="card">
<a-tab-pane key="1" type="card">
<span slot="tab">
<a-icon type="schedule" />
</span>
<a-radio-group v-model="result.second.cronEvery">
<a-row>
<a-radio value="1">每一秒钟</a-radio>
</a-row>
<a-row>
<a-radio value="2">
每隔
<a-input-number
size="small"
v-model="result.second.incrementIncrement"
:min="1"
:max="60"
></a-input-number>秒执行 从
<a-input-number
size="small"
v-model="result.second.incrementStart"
:min="0"
:max="59"
></a-input-number>秒开始
</a-radio>
</a-row>
<a-row>
<a-radio value="3">具体秒数(可多选)</a-radio>
<a-select
style="width:354px;"
size="small"
mode="multiple"
v-model="result.second.specificSpecific"
>
<a-select-option v-for="(val,index) in 60" :key="index" :value="index">{{ index }}</a-select-option>
</a-select>
</a-row>
<a-row>
<a-radio value="4">
周期从
<a-input-number size="small" v-model="result.second.rangeStart" :min="1" :max="60"></a-input-number>
<a-input-number size="small" v-model="result.second.rangeEnd" :min="0" :max="59"></a-input-number>
</a-radio>
</a-row>
</a-radio-group>
</a-tab-pane>
<a-tab-pane key="2">
<span slot="tab">
<a-icon type="schedule" />
</span>
<div class="tabBody">
<a-radio-group v-model="result.minute.cronEvery">
<a-row>
<a-radio value="1">每一分钟</a-radio>
</a-row>
<a-row>
<a-radio value="2">
每隔
<a-input-number
size="small"
v-model="result.minute.incrementIncrement"
:min="1"
:max="60"
></a-input-number>分执行 从
<a-input-number
size="small"
v-model="result.minute.incrementStart"
:min="0"
:max="59"
></a-input-number>分开始
</a-radio>
</a-row>
<a-row>
<a-radio value="3">具体分钟数(可多选)</a-radio>
<a-select
style="width:340px;"
size="small"
mode="multiple"
v-model="result.minute.specificSpecific"
>
<a-select-option
v-for="(val,index) in Array(60)"
:key="index"
:value="index"
>{{ index }}</a-select-option>
</a-select>
</a-row>
<a-row>
<a-radio value="4">
周期从
<a-input-number
size="small"
v-model="result.minute.rangeStart"
:min="1"
:max="60"
></a-input-number>
<a-input-number size="small" v-model="result.minute.rangeEnd" :min="0" :max="59"></a-input-number>
</a-radio>
</a-row>
</a-radio-group>
</div>
</a-tab-pane>
<a-tab-pane key="3">
<span slot="tab">
<a-icon type="schedule" />
</span>
<div class="tabBody">
<a-radio-group v-model="result.hour.cronEvery">
<a-row>
<a-radio value="1">每一小时</a-radio>
</a-row>
<a-row>
<a-radio value="2">
每隔
<a-input-number
size="small"
v-model="result.hour.incrementIncrement"
:min="0"
:max="23"
></a-input-number>小时执行 从
<a-input-number
size="small"
v-model="result.hour.incrementStart"
:min="0"
:max="23"
></a-input-number>小时开始
</a-radio>
</a-row>
<a-row>
<a-radio class="long" value="3">具体小时数(可多选)</a-radio>
<a-select
style="width:340px;"
size="small"
mode="multiple"
v-model="result.hour.specificSpecific"
>
<a-select-option v-for="(val,index) in Array(24)" :key="index">{{ index }}</a-select-option>
</a-select>
</a-row>
<a-row>
<a-radio value="4">
周期从
<a-input-number size="small" v-model="result.hour.rangeStart" :min="0" :max="23"></a-input-number>
<a-input-number size="small" v-model="result.hour.rangeEnd" :min="0" :max="23"></a-input-number>小时
</a-radio>
</a-row>
</a-radio-group>
</div>
</a-tab-pane>
<a-tab-pane key="4">
<span slot="tab">
<a-icon type="schedule" />
</span>
<div class="tabBody">
<a-radio-group v-model="result.day.cronEvery">
<a-row>
<a-radio value="1">每一天</a-radio>
</a-row>
<a-row>
<a-radio value="2">
每隔
<a-input-number
size="small"
v-model="result.week.incrementIncrement"
:min="1"
:max="7"
></a-input-number>周执行 从
<a-select size="small" v-model="result.week.incrementStart">
<a-select-option
v-for="(val,index) in Array(7)"
:key="index"
:value="index-1"
>{{ weekDays[index-1] }}</a-select-option>
</a-select>开始
</a-radio>
</a-row>
<a-row>
<a-radio value="3">
每隔
<a-input-number
size="small"
v-model="result.day.incrementIncrement"
:min="1"
:max="31"
></a-input-number>天执行 从
<a-input-number
size="small"
v-model="result.day.incrementStart"
:min="1"
:max="31"
></a-input-number>日开始
</a-radio>
</a-row>
<a-row>
<a-radio class="long" value="4">具体星期几(可多选)</a-radio>
<a-select
style="width:340px;"
size="small"
mode="multiple"
v-model="result.week.specificSpecific"
>
<a-select-option
v-for="(val,index) in Array(7)"
:key="index"
:value="index-1"
>{{ weekDays[index-1] }}</a-select-option>
</a-select>
</a-row>
<a-row>
<a-radio class="long" value="5">具体天数(可多选)</a-radio>
<a-select
style="width:354px;"
size="small"
mode="multiple"
v-model="result.day.specificSpecific"
>
<a-select-option
v-for="(val,index) in Array(31)"
:key="index"
:value="index+1"
>{{ index+1 }}</a-select-option>
</a-select>
</a-row>
<a-row>
<a-radio value="6">在这个月的最后一天</a-radio>
</a-row>
<a-row>
<a-radio value="7">在这个月的最后一个工作日</a-radio>
</a-row>
<a-row>
<a-radio value="8">
在这个月的最后一个
<a-select size="small" v-model="result.day.cronLastSpecificDomDay">
<a-select-option
v-for="(val,index) in Array(7)"
:key="index"
:value="index+1"
>{{ weekDays[index] }}</a-select-option>
</a-select>
</a-radio>
</a-row>
<a-row>
<a-radio value="9">
在本月底前
<a-input-number
size="small"
v-model="result.day.cronDaysBeforeEomMinus"
:min="1"
:max="31"
></a-input-number>
</a-radio>
</a-row>
<a-row>
<a-radio value="10">
最近的工作日(周一至周五)至本月
<a-input-number
size="small"
v-model="result.day.cronDaysNearestWeekday"
:min="1"
:max="31"
></a-input-number>
</a-radio>
</a-row>
<a-row>
<a-radio value="11">
在这个月的第
<a-input-number
size="small"
v-model="result.week.cronNthDayNth"
:min="1"
:max="5"
></a-input-number>
<a-select size="small" v-model="result.week.cronNthDayDay">
<a-select-option
v-for="(val,index) in Array(7)"
:key="index"
:value="index"
>{{ weekDays[index] }}</a-select-option>
</a-select>
</a-radio>
</a-row>
</a-radio-group>
</div>
</a-tab-pane>
<a-tab-pane key="5">
<span slot="tab">
<a-icon type="schedule" />
</span>
<div class="tabBody">
<a-radio-group v-model="result.month.cronEvery">
<a-row>
<a-radio value="1">每一月</a-radio>
</a-row>
<a-row>
<a-radio value="2">
每隔
<a-input-number
size="small"
v-model="result.month.incrementIncrement"
:min="0"
:max="12"
></a-input-number>月执行 从
<a-input-number
size="small"
v-model="result.month.incrementStart"
:min="0"
:max="12"
></a-input-number>月开始
</a-radio>
</a-row>
<a-row>
<a-radio class="long" value="3">具体月数(可多选)</a-radio>
<a-select
style="width:354px;"
size="small"
filterable
mode="multiple"
v-model="result.month.specificSpecific"
>
<a-select-option
v-for="(val,index) in Array(12)"
:key="index"
:value="index+1"
>{{ index+1 }}</a-select-option>
</a-select>
</a-row>
<a-row>
<a-radio value="4">
<a-input-number size="small" v-model="result.month.rangeStart" :min="1" :max="12"></a-input-number>
<a-input-number size="small" v-model="result.month.rangeEnd" :min="1" :max="12"></a-input-number>月之间的每个月
</a-radio>
</a-row>
</a-radio-group>
</div>
</a-tab-pane>
<a-tab-pane key="6">
<span slot="tab">
<a-icon type="schedule" />
</span>
<div class="tabBody">
<a-radio-group v-model="result.year.cronEvery">
<a-row>
<a-radio value="1">每一年</a-radio>
</a-row>
<a-row>
<a-radio value="2">
每隔
<a-input-number
size="small"
v-model="result.year.incrementIncrement"
:min="1"
:max="99"
></a-input-number>年执行 从
<a-input-number
size="small"
v-model="result.year.incrementStart"
:min="curYear"
:max="curYear+100"
></a-input-number>年开始
</a-radio>
</a-row>
<a-row>
<a-radio class="long" value="3">具体年份(可多选)</a-radio>
<a-select
style="width:354px;"
size="small"
filterable
mode="multiple"
v-model="result.year.specificSpecific"
>
<a-select-option
v-for="(val,index) in Array(100)"
:key="index"
:value="curYear+index-1"
>{{ curYear+index-1 }}</a-select-option>
</a-select>
</a-row>
<a-row>
<a-radio value="4">
<a-input-number
size="small"
v-model="result.year.rangeStart"
:min="curYear"
:max="curYear+100"
></a-input-number>
<a-input-number
size="small"
v-model="result.year.rangeEnd"
:min="curYear"
:max="curYear+100"
></a-input-number>年之间的每一年
</a-radio>
</a-row>
</a-radio-group>
</div>
</a-tab-pane>
</a-tabs>
<div class="bottom">
<span class="value">{{this.cron }}</span>
</div>
</div>
</a-modal>
<a-modal
title="corn表达式"
:width="modalWidth"
:visible="visible"
:confirmLoading="confirmLoading"
@ok="handleSubmit"
@cancel="close"
cancelText="关闭"
:getContainer="getContainer"
>
<div class="card-container">
<a-tabs type="card">
<a-tab-pane key="1" type="card">
<span slot="tab"> <a-icon type="schedule" /></span>
<a-radio-group v-model="result.second.cronEvery">
<a-row>
<a-radio value="1">每一秒钟</a-radio>
</a-row>
<a-row>
<a-radio value="2">
每隔
<a-input-number
size="small"
v-model="result.second.incrementIncrement"
:min="1"
:max="60"
></a-input-number
>秒执行 从
<a-input-number
size="small"
v-model="result.second.incrementStart"
:min="0"
:max="59"
></a-input-number
>秒开始
</a-radio>
</a-row>
<a-row>
<a-radio value="3">具体秒数(可多选)</a-radio>
<a-select
style="width:354px;"
size="small"
mode="multiple"
v-model="result.second.specificSpecific"
>
<a-select-option v-for="(val, index) in 60" :key="index" :value="index">{{
index
}}</a-select-option>
</a-select>
</a-row>
<a-row>
<a-radio value="4">
周期从
<a-input-number
size="small"
v-model="result.second.rangeStart"
:min="1"
:max="60"
></a-input-number
>
<a-input-number
size="small"
v-model="result.second.rangeEnd"
:min="0"
:max="59"
></a-input-number
>
</a-radio>
</a-row>
</a-radio-group>
</a-tab-pane>
<a-tab-pane key="2">
<span slot="tab"> <a-icon type="schedule" /></span>
<div class="tabBody">
<a-radio-group v-model="result.minute.cronEvery">
<a-row>
<a-radio value="1">每一分钟</a-radio>
</a-row>
<a-row>
<a-radio value="2">
每隔
<a-input-number
size="small"
v-model="result.minute.incrementIncrement"
:min="1"
:max="60"
></a-input-number
>分执行 从
<a-input-number
size="small"
v-model="result.minute.incrementStart"
:min="0"
:max="59"
></a-input-number
>分开始
</a-radio>
</a-row>
<a-row>
<a-radio value="3">具体分钟数(可多选)</a-radio>
<a-select
style="width:340px;"
size="small"
mode="multiple"
v-model="result.minute.specificSpecific"
>
<a-select-option
v-for="(val, index) in Array(60)"
:key="index"
:value="index"
>{{ index }}</a-select-option
>
</a-select>
</a-row>
<a-row>
<a-radio value="4">
周期从
<a-input-number
size="small"
v-model="result.minute.rangeStart"
:min="1"
:max="60"
></a-input-number
>
<a-input-number
size="small"
v-model="result.minute.rangeEnd"
:min="0"
:max="59"
></a-input-number
>
</a-radio>
</a-row>
</a-radio-group>
</div>
</a-tab-pane>
<a-tab-pane key="3">
<span slot="tab"> <a-icon type="schedule" /></span>
<div class="tabBody">
<a-radio-group v-model="result.hour.cronEvery">
<a-row>
<a-radio value="1">每一小时</a-radio>
</a-row>
<a-row>
<a-radio value="2">
每隔
<a-input-number
size="small"
v-model="result.hour.incrementIncrement"
:min="0"
:max="23"
></a-input-number
>小时执行 从
<a-input-number
size="small"
v-model="result.hour.incrementStart"
:min="0"
:max="23"
></a-input-number
>小时开始
</a-radio>
</a-row>
<a-row>
<a-radio class="long" value="3">具体小时数(可多选)</a-radio>
<a-select
style="width:340px;"
size="small"
mode="multiple"
v-model="result.hour.specificSpecific"
>
<a-select-option v-for="(val, index) in Array(24)" :key="index">{{
index
}}</a-select-option>
</a-select>
</a-row>
<a-row>
<a-radio value="4">
周期从
<a-input-number
size="small"
v-model="result.hour.rangeStart"
:min="0"
:max="23"
></a-input-number
>
<a-input-number
size="small"
v-model="result.hour.rangeEnd"
:min="0"
:max="23"
></a-input-number
>小时
</a-radio>
</a-row>
</a-radio-group>
</div>
</a-tab-pane>
<a-tab-pane key="4">
<span slot="tab"> <a-icon type="schedule" /></span>
<div class="tabBody">
<a-radio-group v-model="result.day.cronEvery">
<a-row>
<a-radio value="1">每一天</a-radio>
</a-row>
<a-row>
<a-radio value="2">
每隔
<a-input-number
size="small"
v-model="result.week.incrementIncrement"
:min="1"
:max="7"
></a-input-number
>周执行 从
<a-select size="small" v-model="result.week.incrementStart">
<a-select-option
v-for="(val, index) in Array(7)"
:key="index"
:value="index - 1"
>{{ weekDays[index - 1] }}</a-select-option
> </a-select
>开始
</a-radio>
</a-row>
<a-row>
<a-radio value="3">
每隔
<a-input-number
size="small"
v-model="result.day.incrementIncrement"
:min="1"
:max="31"
></a-input-number
>天执行 从
<a-input-number
size="small"
v-model="result.day.incrementStart"
:min="1"
:max="31"
></a-input-number
>日开始
</a-radio>
</a-row>
<a-row>
<a-radio class="long" value="4">具体星期几(可多选)</a-radio>
<a-select
style="width:340px;"
size="small"
mode="multiple"
v-model="result.week.specificSpecific"
>
<a-select-option
v-for="(val, index) in Array(7)"
:key="index"
:value="index - 1"
>{{ weekDays[index - 1] }}</a-select-option
>
</a-select>
</a-row>
<a-row>
<a-radio class="long" value="5">具体天数(可多选)</a-radio>
<a-select
style="width:354px;"
size="small"
mode="multiple"
v-model="result.day.specificSpecific"
>
<a-select-option
v-for="(val, index) in Array(31)"
:key="index"
:value="index + 1"
>{{ index + 1 }}</a-select-option
>
</a-select>
</a-row>
<a-row>
<a-radio value="6">在这个月的最后一天</a-radio>
</a-row>
<a-row>
<a-radio value="7">在这个月的最后一个工作日</a-radio>
</a-row>
<a-row>
<a-radio value="8">
在这个月的最后一个
<a-select size="small" v-model="result.day.cronLastSpecificDomDay">
<a-select-option
v-for="(val, index) in Array(7)"
:key="index"
:value="index + 1"
>{{ weekDays[index] }}</a-select-option
>
</a-select>
</a-radio>
</a-row>
<a-row>
<a-radio value="9">
在本月底前
<a-input-number
size="small"
v-model="result.day.cronDaysBeforeEomMinus"
:min="1"
:max="31"
></a-input-number
>
</a-radio>
</a-row>
<a-row>
<a-radio value="10">
最近的工作日(周一至周五)至本月
<a-input-number
size="small"
v-model="result.day.cronDaysNearestWeekday"
:min="1"
:max="31"
></a-input-number
>
</a-radio>
</a-row>
<a-row>
<a-radio value="11">
在这个月的第
<a-input-number
size="small"
v-model="result.week.cronNthDayNth"
:min="1"
:max="5"
></a-input-number
>
<a-select size="small" v-model="result.week.cronNthDayDay">
<a-select-option
v-for="(val, index) in Array(7)"
:key="index"
:value="index"
>{{ weekDays[index] }}</a-select-option
>
</a-select>
</a-radio>
</a-row>
</a-radio-group>
</div>
</a-tab-pane>
<a-tab-pane key="5">
<span slot="tab"> <a-icon type="schedule" /></span>
<div class="tabBody">
<a-radio-group v-model="result.month.cronEvery">
<a-row>
<a-radio value="1">每一月</a-radio>
</a-row>
<a-row>
<a-radio value="2">
每隔
<a-input-number
size="small"
v-model="result.month.incrementIncrement"
:min="0"
:max="12"
></a-input-number
>月执行 从
<a-input-number
size="small"
v-model="result.month.incrementStart"
:min="0"
:max="12"
></a-input-number
>月开始
</a-radio>
</a-row>
<a-row>
<a-radio class="long" value="3">具体月数(可多选)</a-radio>
<a-select
style="width:354px;"
size="small"
filterable
mode="multiple"
v-model="result.month.specificSpecific"
>
<a-select-option
v-for="(val, index) in Array(12)"
:key="index"
:value="index + 1"
>{{ index + 1 }}</a-select-option
>
</a-select>
</a-row>
<a-row>
<a-radio value="4">
<a-input-number
size="small"
v-model="result.month.rangeStart"
:min="1"
:max="12"
></a-input-number
>
<a-input-number
size="small"
v-model="result.month.rangeEnd"
:min="1"
:max="12"
></a-input-number
>月之间的每个月
</a-radio>
</a-row>
</a-radio-group>
</div>
</a-tab-pane>
<a-tab-pane key="6">
<span slot="tab"> <a-icon type="schedule" /></span>
<div class="tabBody">
<a-radio-group v-model="result.year.cronEvery">
<a-row>
<a-radio value="1">每一年</a-radio>
</a-row>
<a-row>
<a-radio value="2">
每隔
<a-input-number
size="small"
v-model="result.year.incrementIncrement"
:min="1"
:max="99"
></a-input-number
>年执行 从
<a-input-number
size="small"
v-model="result.year.incrementStart"
:min="curYear"
:max="curYear + 100"
></a-input-number
>年开始
</a-radio>
</a-row>
<a-row>
<a-radio class="long" value="3">具体年份(可多选)</a-radio>
<a-select
style="width:354px;"
size="small"
filterable
mode="multiple"
v-model="result.year.specificSpecific"
>
<a-select-option
v-for="(val, index) in Array(100)"
:key="index"
:value="curYear + index - 1"
>{{ curYear + index - 1 }}</a-select-option
>
</a-select>
</a-row>
<a-row>
<a-radio value="4">
<a-input-number
size="small"
v-model="result.year.rangeStart"
:min="curYear"
:max="curYear + 100"
></a-input-number
>
<a-input-number
size="small"
v-model="result.year.rangeEnd"
:min="curYear"
:max="curYear + 100"
></a-input-number
>年之间的每一年
</a-radio>
</a-row>
</a-radio-group>
</div>
</a-tab-pane>
</a-tabs>
<div class="bottom">
<span class="value">{{ this.cron }}</span>
</div>
</div>
</a-modal>
</template>
<script>
const now = new Date();
const curYear = now.getFullYear();
export default {
name: "AntCron",
props: ["data"],
data() {
return {
curYear,
visible: false,
confirmLoading: false,
size: "large",
weekDays: ["", "", "", "", "", "", ""].map(
val => "星期" + val
),
result: {
second: {},
minute: {},
hour: {},
day: {},
week: {},
month: {},
year: {}
},
defaultValue: {
second: {
cronEvery: "",
incrementStart: 3,
incrementIncrement: 5,
rangeStart: 1,
rangeEnd: 0,
specificSpecific: []
name: 'AntCron',
props: ['data'],
data() {
return {
curYear,
visible: false,
confirmLoading: false,
size: 'large',
weekDays: ['', '', '', '', '', '', ''].map(val => '星期' + val),
result: {
second: {},
minute: {},
hour: {},
day: {},
week: {},
month: {},
year: {},
},
defaultValue: {
second: {
cronEvery: '',
incrementStart: 3,
incrementIncrement: 5,
rangeStart: 1,
rangeEnd: 0,
specificSpecific: [],
},
minute: {
cronEvery: '',
incrementStart: 3,
incrementIncrement: 5,
rangeStart: 1,
rangeEnd: '0',
specificSpecific: [],
},
hour: {
cronEvery: '',
incrementStart: 3,
incrementIncrement: 5,
rangeStart: '0',
rangeEnd: '0',
specificSpecific: [],
},
day: {
cronEvery: '',
incrementStart: 1,
incrementIncrement: '1',
rangeStart: '',
rangeEnd: '',
specificSpecific: [],
cronLastSpecificDomDay: 1,
cronDaysBeforeEomMinus: 1,
cronDaysNearestWeekday: 1,
},
week: {
cronEvery: '',
incrementStart: 1,
incrementIncrement: 1,
specificSpecific: [],
cronNthDayDay: 1,
cronNthDayNth: 1,
},
month: {
cronEvery: '',
incrementStart: 3,
incrementIncrement: 5,
rangeStart: 1,
rangeEnd: 1,
specificSpecific: [],
},
year: {
cronEvery: '',
incrementStart: curYear,
incrementIncrement: 1,
rangeStart: curYear,
rangeEnd: curYear,
specificSpecific: [],
},
label: '',
},
};
},
computed: {
modalWidth() {
return 608;
},
minute: {
cronEvery: "",
incrementStart: 3,
incrementIncrement: 5,
rangeStart: 1,
rangeEnd: "0",
specificSpecific: []
secondsText() {
let seconds = '';
let cronEvery = this.result.second.cronEvery || '';
switch (cronEvery.toString()) {
case '1':
seconds = '*';
break;
case '2':
seconds = this.result.second.incrementStart + '/' + this.result.second.incrementIncrement;
break;
case '3':
this.result.second.specificSpecific.map(val => {
seconds += val + ',';
});
seconds = seconds.slice(0, -1);
break;
case '4':
seconds = this.result.second.rangeStart + '-' + this.result.second.rangeEnd;
break;
}
return seconds;
},
hour: {
cronEvery: "",
incrementStart: 3,
incrementIncrement: 5,
rangeStart: "0",
rangeEnd: "0",
specificSpecific: []
minutesText() {
let minutes = '';
let cronEvery = this.result.minute.cronEvery || '';
switch (cronEvery.toString()) {
case '1':
minutes = '*';
break;
case '2':
minutes = this.result.minute.incrementStart + '/' + this.result.minute.incrementIncrement;
break;
case '3':
this.result.minute.specificSpecific.map(val => {
minutes += val + ',';
});
minutes = minutes.slice(0, -1);
break;
case '4':
minutes = this.result.minute.rangeStart + '-' + this.result.minute.rangeEnd;
break;
}
return minutes;
},
day: {
cronEvery: "",
incrementStart: 1,
incrementIncrement: "1",
rangeStart: "",
rangeEnd: "",
specificSpecific: [],
cronLastSpecificDomDay: 1,
cronDaysBeforeEomMinus: 1,
cronDaysNearestWeekday: 1
hoursText() {
let hours = '';
let cronEvery = this.result.hour.cronEvery || '';
switch (cronEvery.toString()) {
case '1':
hours = '*';
break;
case '2':
hours = this.result.hour.incrementStart + '/' + this.result.hour.incrementIncrement;
break;
case '3':
this.result.hour.specificSpecific.map(val => {
hours += val + ',';
});
hours = hours.slice(0, -1);
break;
case '4':
hours = this.result.hour.rangeStart + '-' + this.result.hour.rangeEnd;
break;
}
return hours;
},
week: {
cronEvery: "",
incrementStart: 1,
incrementIncrement: 1,
specificSpecific: [],
cronNthDayDay: 1,
cronNthDayNth: 1
daysText() {
let days = '';
let cronEvery = this.result.day.cronEvery || '';
switch (cronEvery.toString()) {
case '1':
break;
case '2':
case '4':
case '11':
days = '?';
break;
case '3':
days = this.result.day.incrementStart + '/' + this.result.day.incrementIncrement;
break;
case '5':
this.result.day.specificSpecific.map(val => {
days += val + ',';
});
days = days.slice(0, -1);
break;
case '6':
days = 'L';
break;
case '7':
days = 'LW';
break;
case '8':
days = this.result.day.cronLastSpecificDomDay + 'L';
break;
case '9':
days = 'L-' + this.result.day.cronDaysBeforeEomMinus;
break;
case '10':
days = this.result.day.cronDaysNearestWeekday + 'W';
break;
}
return days;
},
month: {
cronEvery: "",
incrementStart: 3,
incrementIncrement: 5,
rangeStart: 1,
rangeEnd: 1,
specificSpecific: []
weeksText() {
let weeks = '';
let cronEvery = this.result.day.cronEvery || '';
switch (cronEvery.toString()) {
case '1':
case '3':
case '5':
weeks = '?';
break;
case '2':
weeks = this.result.week.incrementStart + '/' + this.result.week.incrementIncrement;
break;
case '4':
this.result.week.specificSpecific.map(val => {
weeks += val + ',';
});
weeks = weeks.slice(0, -1);
break;
case '6':
case '7':
case '8':
case '9':
case '10':
weeks = '?';
break;
case '11':
weeks = this.result.week.cronNthDayDay + '#' + this.result.week.cronNthDayNth;
break;
}
return weeks;
},
year: {
cronEvery: "",
incrementStart: curYear,
incrementIncrement: 1,
rangeStart: curYear,
rangeEnd: curYear,
specificSpecific: []
monthsText() {
let months = '';
let cronEvery = this.result.month.cronEvery || '';
switch (cronEvery.toString()) {
case '1':
months = '*';
break;
case '2':
months = this.result.month.incrementStart + '/' + this.result.month.incrementIncrement;
break;
case '3':
this.result.month.specificSpecific.map(val => {
months += val + ',';
});
months = months.slice(0, -1);
break;
case '4':
months = this.result.month.rangeStart + '-' + this.result.month.rangeEnd;
break;
}
return months;
},
yearsText() {
let years = '';
let cronEvery = this.result.year.cronEvery || '';
switch (cronEvery.toString()) {
case '1':
years = '*';
break;
case '2':
years = this.result.year.incrementStart + '/' + this.result.year.incrementIncrement;
break;
case '3':
this.result.year.specificSpecific.map(val => {
years += val + ',';
});
years = years.slice(0, -1);
break;
case '4':
years = this.result.year.rangeStart + '-' + this.result.year.rangeEnd;
break;
}
return years;
},
cron() {
return `${this.secondsText || '*'} ${this.minutesText || '*'} ${this.hoursText || '*'} ${this
.daysText || '*'} ${this.monthsText || '*'} ${this.weeksText || '?'} ${this.yearsText ||
'*'}`;
},
label: ""
}
};
},
computed: {
modalWidth() {
return 608;
},
secondsText() {
let seconds = "";
let cronEvery = this.result.second.cronEvery || "";
switch (cronEvery.toString()) {
case "1":
seconds = "*";
break;
case "2":
seconds =
this.result.second.incrementStart +
"/" +
this.result.second.incrementIncrement;
break;
case "3":
this.result.second.specificSpecific.map(val => {
seconds += val + ",";
});
seconds = seconds.slice(0, -1);
break;
case "4":
seconds =
this.result.second.rangeStart + "-" + this.result.second.rangeEnd;
break;
}
return seconds;
},
minutesText() {
let minutes = "";
let cronEvery = this.result.minute.cronEvery || "";
switch (cronEvery.toString()) {
case "1":
minutes = "*";
break;
case "2":
minutes =
this.result.minute.incrementStart +
"/" +
this.result.minute.incrementIncrement;
break;
case "3":
this.result.minute.specificSpecific.map(val => {
minutes += val + ",";
});
minutes = minutes.slice(0, -1);
break;
case "4":
minutes =
this.result.minute.rangeStart + "-" + this.result.minute.rangeEnd;
break;
}
return minutes;
},
hoursText() {
let hours = "";
let cronEvery = this.result.hour.cronEvery || "";
switch (cronEvery.toString()) {
case "1":
hours = "*";
break;
case "2":
hours =
this.result.hour.incrementStart +
"/" +
this.result.hour.incrementIncrement;
break;
case "3":
this.result.hour.specificSpecific.map(val => {
hours += val + ",";
});
hours = hours.slice(0, -1);
break;
case "4":
hours = this.result.hour.rangeStart + "-" + this.result.hour.rangeEnd;
break;
}
return hours;
},
daysText() {
let days = "";
let cronEvery = this.result.day.cronEvery || "";
switch (cronEvery.toString()) {
case "1":
break;
case "2":
case "4":
case "11":
days = "?";
break;
case "3":
days =
this.result.day.incrementStart +
"/" +
this.result.day.incrementIncrement;
break;
case "5":
this.result.day.specificSpecific.map(val => {
days += val + ",";
});
days = days.slice(0, -1);
break;
case "6":
days = "L";
break;
case "7":
days = "LW";
break;
case "8":
days = this.result.day.cronLastSpecificDomDay + "L";
break;
case "9":
days = "L-" + this.result.day.cronDaysBeforeEomMinus;
break;
case "10":
days = this.result.day.cronDaysNearestWeekday + "W";
break;
}
return days;
},
weeksText() {
let weeks = "";
let cronEvery = this.result.day.cronEvery || "";
switch (cronEvery.toString()) {
case "1":
case "3":
case "5":
weeks = "?";
break;
case "2":
weeks =
this.result.week.incrementStart +
"/" +
this.result.week.incrementIncrement;
break;
case "4":
this.result.week.specificSpecific.map(val => {
weeks += val + ",";
});
weeks = weeks.slice(0, -1);
break;
case "6":
case "7":
case "8":
case "9":
case "10":
weeks = "?";
break;
case "11":
weeks =
this.result.week.cronNthDayDay +
"#" +
this.result.week.cronNthDayNth;
break;
}
return weeks;
},
monthsText() {
let months = "";
let cronEvery = this.result.month.cronEvery || "";
switch (cronEvery.toString()) {
case "1":
months = "*";
break;
case "2":
months =
this.result.month.incrementStart +
"/" +
this.result.month.incrementIncrement;
break;
case "3":
this.result.month.specificSpecific.map(val => {
months += val + ",";
});
months = months.slice(0, -1);
break;
case "4":
months =
this.result.month.rangeStart + "-" + this.result.month.rangeEnd;
break;
}
return months;
},
yearsText() {
let years = "";
let cronEvery = this.result.year.cronEvery || "";
switch (cronEvery.toString()) {
case "1":
years = "*";
break;
case "2":
years =
this.result.year.incrementStart +
"/" +
this.result.year.incrementIncrement;
break;
case "3":
this.result.year.specificSpecific.map(val => {
years += val + ",";
});
years = years.slice(0, -1);
break;
case "4":
years = this.result.year.rangeStart + "-" + this.result.year.rangeEnd;
break;
}
return years;
},
cron() {
return `${this.secondsText || "*"} ${this.minutesText || "*"} ${this
.hoursText || "*"} ${this.daysText || "*"} ${this.monthsText ||
"*"} ${this.weeksText || "?"} ${this.yearsText || "*"}`;
}
},
watch: {
visible: {
handler() {
let label = this.data;
if (label) {
label = label.trim();
const len = label.split(" ").length;
switch (true) {
case len > 0:
this.secondsReverseExp(label);
case len > 1:
this.minutesReverseExp(label);
case len > 2:
this.hoursReverseExp(label);
case len > 3:
this.daysReverseExp(label);
case len > 4:
this.daysReverseExp(label);
case len > 5:
this.monthsReverseExp(label);
case len > 6:
this.yearReverseExp(label);
}
} else {
this.result = JSON.parse(JSON.stringify(this.defaultValue));
}
}
}
},
methods: {
show() {
this.visible = true;
},
handleSubmit() {
this.$emit("ok", this.cron);
this.close();
this.visible = false;
},
close() {
this.visible = false;
},
secondsReverseExp(seconds) {
let val = seconds.split(" ")[0];
let second = {
cronEvery: "",
incrementStart: 3,
incrementIncrement: 5,
rangeStart: 1,
rangeEnd: 0,
specificSpecific: []
};
switch (true) {
case val.includes("*"):
second.cronEvery = "1";
break;
case val.includes("/"):
second.cronEvery = "2";
second.incrementStart = val.split("/")[0];
second.incrementIncrement = val.split("/")[1];
break;
case val.includes(","):
second.cronEvery = "3";
second.specificSpecific = val
.split(",")
.map(Number)
.sort();
break;
case val.includes("-"):
second.cronEvery = "4";
second.rangeStart = val.split("-")[0];
second.rangeEnd = val.split("-")[1];
break;
default:
second.cronEvery = "3";
second.specificSpecific = [val];
}
this.result.second = second;
},
minutesReverseExp(minutes) {
let val = minutes.split(" ")[1];
let minute = {
cronEvery: "",
incrementStart: 3,
incrementIncrement: 5,
rangeStart: 1,
rangeEnd: 0,
specificSpecific: []
};
switch (true) {
case val.includes("*"):
minute.cronEvery = "1";
break;
case val.includes("/"):
minute.cronEvery = "2";
minute.incrementStart = val.split("/")[0];
minute.incrementIncrement = val.split("/")[1];
break;
case val.includes(","):
minute.cronEvery = "3";
minute.specificSpecific = val
.split(",")
.map(Number)
.sort();
break;
case val.includes("-"):
minute.cronEvery = "4";
minute.rangeStart = val.split("-")[0];
minute.rangeEnd = val.split("-")[1];
break;
default:
minute.cronEvery = "3";
minute.specificSpecific = [val];
}
this.result.minute = minute;
},
hoursReverseExp(hours) {
let val = hours.split(" ")[2];
let hour = {
cronEvery: "",
incrementStart: 3,
incrementIncrement: 5,
rangeStart: 1,
rangeEnd: "0",
specificSpecific: []
};
switch (true) {
case val.includes("*"):
hour.cronEvery = "1";
break;
case val.includes("/"):
hour.cronEvery = "2";
hour.incrementStart = val.split("/")[0];
hour.incrementIncrement = val.split("/")[1];
break;
case val.includes(","):
hour.cronEvery = "3";
hour.specificSpecific = val
.split(",")
.map(Number)
.sort();
break;
case val.includes("-"):
hour.cronEvery = "4";
hour.rangeStart = val.split("-")[0];
hour.rangeEnd = val.split("-")[1];
break;
default:
hour.cronEvery = "3";
hour.specificSpecific = [val];
}
this.result.hour = hour;
watch: {
visible: {
handler() {
let label = this.data;
if (label) {
label = label.trim();
const len = label.split(' ').length;
switch (true) {
case len > 0:
this.secondsReverseExp(label);
break;
case len > 1:
this.minutesReverseExp(label);
break;
case len > 2:
this.hoursReverseExp(label);
break;
case len > 3:
this.daysReverseExp(label);
break;
case len > 4:
this.daysReverseExp(label);
break;
case len > 5:
this.monthsReverseExp(label);
break;
case len > 6:
this.yearReverseExp(label);
}
} else {
this.result = JSON.parse(JSON.stringify(this.defaultValue));
}
},
},
},
daysReverseExp(cron) {
let days = cron.split(" ")[3];
let weeks = cron.split(" ")[5];
let day = {
cronEvery: "",
incrementStart: 1,
incrementIncrement: 1,
rangeStart: 1,
rangeEnd: 1,
specificSpecific: [],
cronLastSpecificDomDay: 1,
cronDaysBeforeEomMinus: 1,
cronDaysNearestWeekday: 1
};
let week = {
cronEvery: "",
incrementStart: 1,
incrementIncrement: 1,
specificSpecific: [],
cronNthDayDay: 1,
cronNthDayNth: 1
};
if (!days.includes("?")) {
switch (true) {
case days.includes("*"):
day.cronEvery = "1";
break;
case days.includes("?"):
break;
case days.includes("/"):
day.cronEvery = "3";
day.incrementStart = days.split("/")[0];
day.incrementIncrement = days.split("/")[1];
break;
case days.includes(","):
day.cronEvery = "5";
day.specificSpecific = days
.split(",")
.map(Number)
.sort();
break;
case days.includes("LW"):
day.cronEvery = "7";
break;
case days.includes("L-"):
day.cronEvery = "9";
day.cronDaysBeforeEomMinus = days.split("L-")[1];
break;
case days.includes("L"):
if (days.len == 1) {
day.cronEvery = "6";
day.cronLastSpecificDomDay = "1";
methods: {
getContainer(e) {
return window.document.body;
},
show() {
this.visible = true;
},
handleSubmit() {
this.$emit('ok', this.cron);
this.close();
this.visible = false;
},
close() {
this.visible = false;
},
secondsReverseExp(seconds) {
let val = seconds.split(' ')[0];
let second = {
cronEvery: '',
incrementStart: 3,
incrementIncrement: 5,
rangeStart: 1,
rangeEnd: 0,
specificSpecific: [],
};
switch (true) {
case val.includes('*'):
second.cronEvery = '1';
break;
case val.includes('/'):
second.cronEvery = '2';
second.incrementStart = val.split('/')[0];
second.incrementIncrement = val.split('/')[1];
break;
case val.includes(','):
second.cronEvery = '3';
second.specificSpecific = val
.split(',')
.map(Number)
.sort();
break;
case val.includes('-'):
second.cronEvery = '4';
second.rangeStart = val.split('-')[0];
second.rangeEnd = val.split('-')[1];
break;
default:
second.cronEvery = '3';
second.specificSpecific = [val];
}
this.result.second = second;
},
minutesReverseExp(minutes) {
let val = minutes.split(' ')[1];
let minute = {
cronEvery: '',
incrementStart: 3,
incrementIncrement: 5,
rangeStart: 1,
rangeEnd: 0,
specificSpecific: [],
};
switch (true) {
case val.includes('*'):
minute.cronEvery = '1';
break;
case val.includes('/'):
minute.cronEvery = '2';
minute.incrementStart = val.split('/')[0];
minute.incrementIncrement = val.split('/')[1];
break;
case val.includes(','):
minute.cronEvery = '3';
minute.specificSpecific = val
.split(',')
.map(Number)
.sort();
break;
case val.includes('-'):
minute.cronEvery = '4';
minute.rangeStart = val.split('-')[0];
minute.rangeEnd = val.split('-')[1];
break;
default:
minute.cronEvery = '3';
minute.specificSpecific = [val];
}
this.result.minute = minute;
},
hoursReverseExp(hours) {
let val = hours.split(' ')[2];
let hour = {
cronEvery: '',
incrementStart: 3,
incrementIncrement: 5,
rangeStart: 1,
rangeEnd: '0',
specificSpecific: [],
};
switch (true) {
case val.includes('*'):
hour.cronEvery = '1';
break;
case val.includes('/'):
hour.cronEvery = '2';
hour.incrementStart = val.split('/')[0];
hour.incrementIncrement = val.split('/')[1];
break;
case val.includes(','):
hour.cronEvery = '3';
hour.specificSpecific = val
.split(',')
.map(Number)
.sort();
break;
case val.includes('-'):
hour.cronEvery = '4';
hour.rangeStart = val.split('-')[0];
hour.rangeEnd = val.split('-')[1];
break;
default:
hour.cronEvery = '3';
hour.specificSpecific = [val];
}
this.result.hour = hour;
},
daysReverseExp(cron) {
let days = cron.split(' ')[3];
let weeks = cron.split(' ')[5];
let day = {
cronEvery: '',
incrementStart: 1,
incrementIncrement: 1,
rangeStart: 1,
rangeEnd: 1,
specificSpecific: [],
cronLastSpecificDomDay: 1,
cronDaysBeforeEomMinus: 1,
cronDaysNearestWeekday: 1,
};
let week = {
cronEvery: '',
incrementStart: 1,
incrementIncrement: 1,
specificSpecific: [],
cronNthDayDay: 1,
cronNthDayNth: 1,
};
if (!days.includes('?')) {
switch (true) {
case days.includes('*'):
day.cronEvery = '1';
break;
case days.includes('?'):
break;
case days.includes('/'):
day.cronEvery = '3';
day.incrementStart = days.split('/')[0];
day.incrementIncrement = days.split('/')[1];
break;
case days.includes(','):
day.cronEvery = '5';
day.specificSpecific = days
.split(',')
.map(Number)
.sort();
break;
case days.includes('LW'):
day.cronEvery = '7';
break;
case days.includes('L-'):
day.cronEvery = '9';
day.cronDaysBeforeEomMinus = days.split('L-')[1];
break;
case days.includes('L'):
if (days.len == 1) {
day.cronEvery = '6';
day.cronLastSpecificDomDay = '1';
} else {
day.cronEvery = '8';
day.cronLastSpecificDomDay = Number(days.split('L')[0]);
}
break;
case days.includes('W'):
day.cronEvery = '10';
day.cronDaysNearestWeekday = days.split('W')[0];
break;
default:
day.cronEvery = '5';
day.specificSpecific = [days];
}
} else {
day.cronEvery = "8";
day.cronLastSpecificDomDay = Number(days.split("L")[0]);
switch (true) {
case weeks.includes('/'):
day.cronEvery = '2';
week.incrementStart = parseInt(weeks.split('/')[0]);
week.incrementIncrement = parseInt(weeks.split('/')[1]);
break;
case weeks.includes(','):
day.cronEvery = '4';
week.specificSpecific = weeks
.split(',')
.map(Number)
.sort();
break;
case weeks.includes('#'):
day.cronEvery = '11';
week.cronNthDayDay = parseInt(weeks.split('#')[0]);
week.cronNthDayNth = parseInt(weeks.split('#')[1]);
break;
// case weeks.includes("-"):
// day.cronEvery = "11";
// week.cronNthDayDay = parseInt(weeks.split("#")[0]);
// week.cronNthDayNth = parseInt(weeks.split("#")[1]);
// break;
default:
day.cronEvery = '4';
week.cronEvery = '4';
week.specificSpecific = [parseInt(weeks)];
}
}
break;
case days.includes("W"):
day.cronEvery = "10";
day.cronDaysNearestWeekday = days.split("W")[0];
break;
default:
day.cronEvery = "5";
day.specificSpecific = [days];
}
} else {
switch (true) {
case weeks.includes("/"):
day.cronEvery = "2";
week.incrementStart = parseInt(weeks.split("/")[0]);
week.incrementIncrement = parseInt(weeks.split("/")[1]);
break;
case weeks.includes(","):
day.cronEvery = "4";
week.specificSpecific = weeks
.split(",")
.map(Number)
.sort();
break;
case weeks.includes("#"):
day.cronEvery = "11";
week.cronNthDayDay = parseInt(weeks.split("#")[0]);
week.cronNthDayNth = parseInt(weeks.split("#")[1]);
break;
// case weeks.includes("-"):
// day.cronEvery = "11";
// week.cronNthDayDay = parseInt(weeks.split("#")[0]);
// week.cronNthDayNth = parseInt(weeks.split("#")[1]);
// break;
default:
day.cronEvery = "4";
week.cronEvery = "4";
week.specificSpecific = [parseInt(weeks)];
}
}
this.result.day = day;
this.result.week = week;
},
monthsReverseExp(cron) {
let months = cron.split(" ")[4];
let month = {
cronEvery: "",
incrementStart: 3,
incrementIncrement: 5,
rangeStart: 1,
rangeEnd: 1,
specificSpecific: []
};
switch (true) {
case months.includes("*"):
month.cronEvery = "1";
break;
case months.includes("/"):
month.cronEvery = "2";
month.incrementStart = months.split("/")[0];
month.incrementIncrement = months.split("/")[1];
break;
case months.includes(","):
month.cronEvery = "3";
month.specificSpecific = months
.split(",")
.map(Number)
.sort();
break;
case months.includes("-"):
month.cronEvery = "4";
month.rangeStart = months.split("-")[0];
month.rangeEnd = months.split("-")[1];
break;
default:
month.cronEvery = "3";
month.specificSpecific = [months];
}
this.result.month = month;
this.result.day = day;
this.result.week = week;
},
monthsReverseExp(cron) {
let months = cron.split(' ')[4];
let month = {
cronEvery: '',
incrementStart: 3,
incrementIncrement: 5,
rangeStart: 1,
rangeEnd: 1,
specificSpecific: [],
};
switch (true) {
case months.includes('*'):
month.cronEvery = '1';
break;
case months.includes('/'):
month.cronEvery = '2';
month.incrementStart = months.split('/')[0];
month.incrementIncrement = months.split('/')[1];
break;
case months.includes(','):
month.cronEvery = '3';
month.specificSpecific = months
.split(',')
.map(Number)
.sort();
break;
case months.includes('-'):
month.cronEvery = '4';
month.rangeStart = months.split('-')[0];
month.rangeEnd = months.split('-')[1];
break;
default:
month.cronEvery = '3';
month.specificSpecific = [months];
}
this.result.month = month;
},
yearReverseExp(cron) {
let years = cron.split(' ')[6];
let year = {
cronEvery: '',
incrementStart: curYear,
incrementIncrement: 5,
rangeStart: curYear,
rangeEnd: curYear,
specificSpecific: [],
};
if (years !== undefined) {
switch (true) {
case years.includes('*'):
year.cronEvery = '1';
break;
case years.includes('/'):
year.cronEvery = '2';
year.incrementStart = years.split('/')[0];
year.incrementIncrement = years.split('/')[1];
break;
case years.includes(','):
year.cronEvery = '3';
year.specificSpecific = years
.split(',')
.map(Number)
.sort();
break;
case years.includes('-'):
year.cronEvery = '4';
year.rangeStart = years.split('-')[0];
year.rangeEnd = years.split('-')[1];
break;
default:
year.cronEvery = '3';
year.specificSpecific = [years];
}
} else {
year.cronEvery = '1';
}
this.result.year = year;
},
},
yearReverseExp(cron) {
let years = cron.split(" ")[6];
let year = {
cronEvery: "",
incrementStart: curYear,
incrementIncrement: 5,
rangeStart: curYear,
rangeEnd: curYear,
specificSpecific: []
};
if (years !== undefined) {
switch (true) {
case years.includes("*"):
year.cronEvery = "1";
break;
case years.includes("/"):
year.cronEvery = "2";
year.incrementStart = years.split("/")[0];
year.incrementIncrement = years.split("/")[1];
break;
case years.includes(","):
year.cronEvery = "3";
year.specificSpecific = years
.split(",")
.map(Number)
.sort();
break;
case years.includes("-"):
year.cronEvery = "4";
year.rangeStart = years.split("-")[0];
year.rangeEnd = years.split("-")[1];
break;
default:
year.cronEvery = "3";
year.specificSpecific = [years];
}
} else {
year.cronEvery = "1";
}
this.result.year = year;
}
}
};
</script>
<style lang="scss">
<style lang="less">
.card-container {
background: #fff;
overflow: hidden;
padding: 12px;
position: relative;
width: 100%;
.ant-tabs {
border: 1px solid #e6ebf5;
padding: 0;
.ant-tabs-bar {
margin: 0;
outline: none;
border-bottom: none;
.ant-tabs-nav-container {
margin: 0;
.ant-tabs-tab {
padding: 0 24px !important;
background-color: #f5f7fa !important;
margin-right: 0px !important;
border-radius: 0;
line-height: 38px;
border: 1px solid transparent !important;
border-bottom: 1px solid #e6ebf5 !important;
background: #fff;
overflow: hidden;
padding: 12px;
position: relative;
width: 100%;
.ant-tabs {
border: 1px solid #e6ebf5;
padding: 0;
.ant-tabs-bar {
margin: 0;
outline: none;
border-bottom: none;
.ant-tabs-nav-container {
margin: 0;
.ant-tabs-tab {
padding: 0 24px !important;
background-color: #f5f7fa !important;
margin-right: 0px !important;
border-radius: 0;
line-height: 38px;
border: 1px solid transparent !important;
border-bottom: 1px solid #e6ebf5 !important;
}
.ant-tabs-tab-active.ant-tabs-tab {
color: #409eff;
background-color: #fff !important;
border-right: 1px solid #e6ebf5 !important;
border-left: 1px solid #e6ebf5 !important;
border-bottom: 1px solid #fff !important;
font-weight: normal;
transition: none !important;
}
}
}
.ant-tabs-tab-active.ant-tabs-tab {
color: #409eff;
background-color: #fff !important;
border-right: 1px solid #e6ebf5 !important;
border-left: 1px solid #e6ebf5 !important;
border-bottom: 1px solid #fff !important;
font-weight: normal;
transition: none !important;
.ant-tabs-tabpane {
padding: 15px;
.ant-row {
margin: 10px 0;
}
.ant-select,
.ant-input-number {
width: 100px;
}
}
}
}
.ant-tabs-tabpane {
padding: 15px;
.ant-row {
margin: 10px 0;
}
.ant-select,
.ant-input-number {
width: 100px;
}
}
}
}
</style>
<style lang="scss" scoped>
<style lang="less" scoped>
.container-widthEn {
width: 755px;
width: 755px;
}
.container-widthCn {
width: 608px;
width: 608px;
}
.language {
text-align: center;
position: absolute;
right: 13px;
top: 13px;
border: 1px solid transparent;
height: 40px;
line-height: 38px;
font-size: 16px;
color: #409eff;
z-index: 1;
background: #f5f7fa;
outline: none;
width: 47px;
border-bottom: 1px solid #e6ebf5;
border-radius: 0;
text-align: center;
position: absolute;
right: 13px;
top: 13px;
border: 1px solid transparent;
height: 40px;
line-height: 38px;
font-size: 16px;
color: #409eff;
z-index: 1;
background: #f5f7fa;
outline: none;
width: 47px;
border-bottom: 1px solid #e6ebf5;
border-radius: 0;
}
.card-container {
.bottom {
display: flex;
justify-content: center;
padding: 10px 0 0 0;
.cronButton {
margin: 0 10px;
line-height: 40px;
.bottom {
display: flex;
justify-content: center;
padding: 10px 0 0 0;
.cronButton {
margin: 0 10px;
line-height: 40px;
}
}
}
}
.tabBody {
.a-row {
margin: 10px 0;
.long {
.a-select {
width: 354px;
}
}
.a-input-number {
width: 110px;
.a-row {
margin: 10px 0;
.long {
.a-select {
width: 354px;
}
}
.a-input-number {
width: 110px;
}
}
}
}
</style>
\ No newline at end of file
</style>
......@@ -20,15 +20,16 @@ export default {
async submit() {
await this.$refs.DrawerForm.validate();
if (this.isAdd) {
return this?.add();
return this.add();
}
if (this.isEdit) {
return this?.edit();
return this.edit();
}
},
setData(data, type) {
this.form = { ...data };
this.type = type;
console.log(data, type);
},
},
};
......@@ -62,7 +62,6 @@ export default {
},
created() {
this.init();
console.log(this.buttonsArr);
},
computed: {
basicBtns() {
......
......@@ -180,6 +180,7 @@ export default {
this.addVisible = true;
this.type = 0;
this.noFooter = false;
this.title = '新增';
},
addDrawerClose() {
this.addVisible = false;
......
......@@ -37,7 +37,6 @@ export default {
addBtn: {
text: '新建',
onOk() {
console.log(vm.addCom);
return vm.addCom ? vm.$refs['addCom']?.submit() : vm.$refs['addForm']?.submit();
},
onCancel() {
......@@ -50,7 +49,7 @@ export default {
{
label: '新增组件',
option: {
type: 'danger',
style: 'color: #ff4d4f',
},
click(row) {
vm.show();
......
<template>
<a-form-model layout="vertical" :model="form" :rules="rules" ref="DrawerForm">
<a-form-model-item label="任务名称" prop="jobName">
<a-input v-model="form.jobName" :disabled="isView" />
<a-form-model-item label="任务名称" prop="taskName">
<a-input v-model="form.taskName" :disabled="isView" />
</a-form-model-item>
<a-form-model-item label="调度规则" prop="jobDescription">
<a-textarea v-model="form.jobDescription" :disabled="isView" :rows="4" />
<a-form-model-item label="调度规则" prop="taskRule">
<ACron v-model="form.taskRule" :disabled="isView" />
</a-form-model-item>
<a-form-model-item label="实现类" prop="jobDescription">
<a-input v-model="form.jobDescription" :disabled="isView" />
<a-form-model-item label="实现类" prop="implementClass">
<a-input v-model="form.implementClass" :disabled="isView" />
</a-form-model-item>
<a-form-model-item label="说明" prop="jobDescription">
<a-textarea v-model="form.jobDescription" :disabled="isView" :rows="4" />
<a-form-model-item label="说明" prop="remark">
<a-textarea v-model="form.remark" :disabled="isView" :rows="4" />
</a-form-model-item>
</a-form-model>
</template>
<script>
import JobsApi from '@/api/organization';
import { addTaskApi, updateTaskApi } from '@/api';
import FormMixin from '@/components/FormMixin';
import ACron from '@/components/Acron/ACron.vue';
export default {
components: { ACron },
props: ['row'],
mixins: [FormMixin],
data() {
return {
rules: {
jobName: [{ required: true, message: 'Please select Activity zone', trigger: 'change' }],
jobDescription: [
{ required: true, message: 'Please select Activity zone', trigger: 'change' },
],
taskName: [{ required: true }],
taskRule: [{ required: true }],
},
};
},
methods: {
add() {
return JobsApi.add({ ...this.form });
return addTaskApi({ ...this.form });
},
edit() {
return JobsApi.update({ ...this.form });
return updateTaskApi({ ...this.form });
},
},
};
......
<template>
<my-table url="/api/v1/schedules" rowKey="taskId" :addBtn="addBtn" ref="table">
<template #drawer>
<Form ref="form" />
<Form ref="form" :row="currentClickRow" />
</template>
<a-table-column title="任务名称" data-index="taskName" />
<a-table-column title="调度规则" data-index="taskRule" />
......@@ -23,7 +23,12 @@ export default {
components: { ActionButton, Form },
data() {
return {
addBtn: {},
addBtn: {
onOk: () => {
return this.$refs.form.submit();
},
},
currentClickRow: null,
buttons: [
{
label: '查看',
......@@ -47,8 +52,9 @@ export default {
type: 'confirm',
label: '失效',
title: '确认是否失效?',
url: row => `/api/v1/schedules/${row.taskId}`,
url: row => ({ url: `/api/v1/schedules/${row.taskId}/pause`, method: 'del' }),
after: () => this.refreshTable(),
isHidden: row => row.isPaused === 1,
},
{
type: 'confirm',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment