fix:执行时间定时刷新

This commit is contained in:
wenyann 2020-09-18 14:56:58 +08:00
parent 18c300f85e
commit a363074c16
1 changed files with 86 additions and 67 deletions

View File

@ -6,7 +6,8 @@
<span class="character">SCHEDULER</span> <span class="character">SCHEDULER</span>
</span> </span>
<el-switch :disabled="!schedule.value || isReadOnly" v-model="schedule.enable" @change="scheduleChange"/> <el-switch :disabled="!schedule.value || isReadOnly" v-model="schedule.enable" @change="scheduleChange"/>
<ms-schedule-edit :is-read-only="isReadOnly" :schedule="schedule" :test-id="testId" :save="save" :custom-validate="customValidate" <ms-schedule-edit :is-read-only="isReadOnly" :schedule="schedule" :test-id="testId" :save="save"
:custom-validate="customValidate"
ref="scheduleEdit"/> ref="scheduleEdit"/>
</div> </div>
@ -22,90 +23,108 @@
</template> </template>
<script> <script>
import MsScheduleEdit from "./MsScheduleEdit"; import MsScheduleEdit from "./MsScheduleEdit";
import CrontabResult from "../cron/CrontabResult"; import CrontabResult from "../cron/CrontabResult";
function defaultCustomValidate() { function defaultCustomValidate() {
return {pass: true}; return {pass: true};
} }
export default { export default {
name: "MsScheduleConfig", name: "MsScheduleConfig",
components: {CrontabResult, MsScheduleEdit}, components: {CrontabResult, MsScheduleEdit},
data() { data() {
return { return {
recentList: [], recentList: [],
} refreshScheduler: null,
}, }
props: { },
testId:String, props: {
save: Function, testId: String,
schedule: {}, save: Function,
checkOpen: { schedule: {},
type: Function, checkOpen: {
default() { type: Function,
return { default() {
checkOpen() { return {
return true; checkOpen() {
return true;
}
} }
} }
},
customValidate: {
type: Function,
default: defaultCustomValidate
},
isReadOnly: {
type: Boolean,
default: false
}
},
methods: {
scheduleEdit() {
if (!this.checkOpen()) {
return;
}
this.$refs.scheduleEdit.open();
},
scheduleChange() {
this.$emit('scheduleChange');
},
flashResultList() {
this.$refs.crontabResult.expressionChange();
},
cancelRefresh() {
if (this.refreshScheduler) {
clearInterval(this.refreshScheduler);
}
} }
}, },
customValidate: { beforeDestroy() {
type: Function, this.cancelRefresh();
default: defaultCustomValidate
}, },
isReadOnly: { watch: {
type: Boolean, schedule() {
default: false if (this.schedule.enable) {
} this.refreshScheduler = setInterval(this.flashResultList, 2000);
}, } else {
methods: { this.cancelRefresh();
scheduleEdit() { }
if (!this.checkOpen()) {
return;
} }
this.$refs.scheduleEdit.open();
},
scheduleChange() {
this.$emit('scheduleChange');
},
flashResultList() {
this.$refs.crontabResult.expressionChange();
} }
} }
}
</script> </script>
<style scoped> <style scoped>
.schedule-config { .schedule-config {
float: right; float: right;
width: 250px; width: 250px;
height: 15px; height: 15px;
line-height: 25px; line-height: 25px;
} }
.el-icon-date { .el-icon-date {
font-size: 20px; font-size: 20px;
margin-left: 5px; margin-left: 5px;
} }
.character { .character {
font-weight: bold; font-weight: bold;
margin: 0 5px; margin: 0 5px;
} }
.disable-character { .disable-character {
color: #cccccc; color: #cccccc;
} }
.el-switch { .el-switch {
margin: 0 5px; margin: 0 5px;
} }
.cron-ico { .cron-ico {
cursor: pointer; cursor: pointer;
} }
</style> </style>