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) { public Schedule buildApiTestSchedule(ScheduleRequest request) {
Schedule schedule = new Schedule(); Schedule schedule = new Schedule();
schedule.setResourceId(request.getResourceId()); schedule.setResourceId(request.getResourceId());
schedule.setEnable(true); schedule.setEnable(request.getEnable());
schedule.setValue(request.getValue().trim()); schedule.setValue(request.getValue().trim());
schedule.setKey(request.getResourceId()); schedule.setKey(request.getResourceId());
schedule.setUserId(SessionUtils.getUser().getId()); schedule.setUserId(SessionUtils.getUser().getId());

View File

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

View File

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

View File

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

View File

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

View File

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