fix(定时任务): 定时任务页面开关状态优化

--bug=ID1010211 【ID1010211】【定时任务】github#10422,优化定时任务保存按钮】https://www.tapd.cn/55049933/bugtrace/bugs/view?bug_id=1155049933001010211
This commit is contained in:
limin-fit2 2022-02-16 13:44:25 +08:00 committed by jianxing
parent ab9f622870
commit 9cc51b9e56
6 changed files with 59 additions and 28 deletions

View File

@ -164,7 +164,7 @@ public class ScheduleService {
public Schedule buildApiTestSchedule(ScheduleRequest request) {
Schedule schedule = new Schedule();
schedule.setResourceId(request.getResourceId());
schedule.setEnable(true);
schedule.setEnable(request.getEnable());
schedule.setValue(request.getValue().trim());
schedule.setKey(request.getResourceId());
schedule.setUserId(SessionUtils.getUser().getId());

View File

@ -6,22 +6,29 @@
<div>
<el-tabs v-model="activeName">
<el-tab-pane :label="$t('schedule.edit_timer_task')" name="first">
<el-form :model="form" :rules="rules" ref="from">
<el-form-item
prop="cronValue">
<el-row>
<el-form :model="form" :rules="rules" ref="from" style="margin-top: 10px;">
<el-form-item :label="$t('commons.schedule_switch')">
<el-row :gutter="20">
<el-col :span="18">
<el-input :disabled="isReadOnly" v-model="form.cronValue" class="inp"
:placeholder="$t('schedule.please_input_cron_expression')"/>
<el-tooltip effect="dark" placement="bottom"
:content="schedule.enable?$t('commons.close_schedule'):$t('commons.open_schedule')">
<el-switch v-model="schedule.enable"></el-switch>
</el-tooltip>
</el-col>
<el-col :span="2">
<el-button :disabled="isReadOnly" type="primary" @click="saveCron">{{
$t('commons.save')
}}
</el-button>
</el-col>
<el-col :span="6">
<schedule-switch :schedule="schedule" :corn-value="form.cronValue"
@resultListChange="getExecuteTimeTemplate"
@scheduleChange="scheduleChange"></schedule-switch>
</el-row>
</el-form-item>
<el-form-item :label="$t('commons.schedule_cron_title')"
prop="cronValue">
<el-row>
<el-col :span="18">
<el-input :disabled="isReadOnly" v-model="form.cronValue" class="inp"
:placeholder="$t('schedule.please_input_cron_expression')"/>
</el-col>
</el-row>
@ -116,6 +123,7 @@ export default {
dialogVisible: false,
schedule: {
value: "",
enable: true
},
scheduleTaskType: "",
testId: String,
@ -211,13 +219,16 @@ export default {
this.activeName = 'first';
},
findSchedule() {
var scheduleResourceID = this.testId;
var taskType = this.scheduleTaskType;
let scheduleResourceID = this.testId;
let taskType = this.scheduleTaskType;
this.result = this.$get("/schedule/findOne/" + scheduleResourceID + "/" + taskType, response => {
if (response.data != null) {
this.schedule = response.data;
} else {
this.schedule = {};
this.schedule = {
value: '',
enable: true
};
}
});
},
@ -240,7 +251,7 @@ export default {
if (valid) {
this.intervalShortValidate();
let formCronValue = this.form.cronValue;
this.schedule.enable = true;
// this.schedule.enable = true;
this.schedule.value = formCronValue;
this.saveSchedule();
this.dialogVisible = false;

View File

@ -13,21 +13,28 @@
</div>
<span>{{ $t('schedule.edit_timer_task') }}</span>
<el-form :model="form" :rules="rules" ref="from" style="padding-top: 10px;margin-left: 20px;">
<el-form-item
prop="cronValue">
<el-row>
<el-form-item :label="$t('commons.schedule_switch')">
<el-row :gutter="20">
<el-col :span="18">
<el-input :disabled="isReadOnly" v-model="form.cronValue" class="inp"
:placeholder="$t('schedule.please_input_cron_expression')"/>
<el-tooltip effect="dark" placement="bottom"
:content="schedule.enable?$t('commons.close_schedule'):$t('commons.open_schedule')">
<el-switch v-model="schedule.enable"></el-switch>
</el-tooltip>
</el-col>
<el-col :span="2">
<el-button :disabled="isReadOnly" type="primary" @click="saveCron">{{
$t('commons.save')
}}
</el-button>
</el-col>
<el-col :span="6">
<schedule-switch :schedule="schedule" :corn-value="form.cronValue"
@resultListChange="getExecuteTimeTemplate"
@scheduleChange="scheduleChange"></schedule-switch>
</el-row>
</el-form-item>
<el-form-item :label="$t('commons.schedule_cron_title')"
prop="cronValue">
<el-row>
<el-col :span="18">
<el-input :disabled="isReadOnly" v-model="form.cronValue" class="inp"
:placeholder="$t('schedule.please_input_cron_expression')"/>
</el-col>
</el-row>
@ -192,6 +199,7 @@ export default {
dialogVisible: false,
schedule: {
value: "",
enable: true,
},
scheduleTaskType: "",
testId: String,
@ -290,8 +298,8 @@ export default {
this.getResourcePools();
},
findSchedule() {
var scheduleResourceID = this.testId;
var taskType = this.scheduleTaskType;
let scheduleResourceID = this.testId;
let taskType = this.scheduleTaskType;
this.result = this.$get("/schedule/findOne/" + scheduleResourceID + "/" + taskType, response => {
if (response.data != null) {
this.schedule = response.data;
@ -299,7 +307,10 @@ export default {
this.runConfig = JSON.parse(response.data.config);
}
} else {
this.schedule = {};
this.schedule = {
value: '',
enable: true
};
}
});
},
@ -322,7 +333,7 @@ export default {
if (valid) {
this.intervalShortValidate();
let formCronValue = this.form.cronValue;
this.schedule.enable = true;
// this.schedule.enable = true;
this.schedule.value = formCronValue;
this.saveSchedule();
this.dialogVisible = false;

View File

@ -33,6 +33,9 @@ export default {
cut_back_new_version: 'Switch back to new version',
comment: 'Comment',
close_schedule: 'Close Schedule',
open_schedule: 'Start Schedule',
schedule_switch: 'Schedule Switch',
schedule_cron_title: 'Schedule Time Expression',
review_complete: 'Review Completed',
examples: 'examples',
help_documentation: 'Help',

View File

@ -33,6 +33,9 @@ export default {
cut_back_new_version: '切回新版',
comment: '评论',
close_schedule: '关闭定时任务',
open_schedule: '开启定时任务',
schedule_switch: '定时任务开关',
schedule_cron_title: '定时任务时间表达式',
review_complete: '评审完成',
examples: '示例',
help_documentation: '帮助文档',

View File

@ -33,6 +33,9 @@ export default {
cut_back_new_version: '切回新版',
comment: '評論',
close_schedule: '關閉定時任務',
open_schedule: '開啟定時任務',
schedule_switch: '定時任務開關',
schedule_cron_title: '定時任務時間運算式',
review_complete: '評審完成',
examples: '示例',
help_documentation: '幫助文檔',