|
|
@@ -0,0 +1,112 @@
|
|
|
+<template>
|
|
|
+ <confirm-dialog
|
|
|
+ ref="configDialog"
|
|
|
+ title="定时任务"
|
|
|
+ size="fixed"
|
|
|
+ @confirm="onSave"
|
|
|
+ >
|
|
|
+ <template #default>
|
|
|
+ <div class="l-flex--row c-sibling-item--v">
|
|
|
+ <span class="c-sibling-item">启用</span>
|
|
|
+ <el-switch
|
|
|
+ v-model="config.status"
|
|
|
+ class="c-sibling-item"
|
|
|
+ :active-value="1"
|
|
|
+ :inactive-value="0"
|
|
|
+ active-color="#13ce66"
|
|
|
+ inactive-color="#ff4949"
|
|
|
+ />
|
|
|
+ <span class="c-sibling-item farther u-required">触发时间</span>
|
|
|
+ <el-time-picker
|
|
|
+ v-model="config.executeTime"
|
|
|
+ class="c-sibling-item"
|
|
|
+ placeholder="请选择触发时间"
|
|
|
+ value-format="HH:mm:ss"
|
|
|
+ :clearable="false"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <schema-table
|
|
|
+ class="c-sibling-item--v"
|
|
|
+ :schema="schema"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </confirm-dialog>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import {
|
|
|
+ getTimeTask,
|
|
|
+ updateTimeTask,
|
|
|
+ addTimeTask,
|
|
|
+ getTaskHistory
|
|
|
+} from '../api'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'TimeTaskDialog',
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ config: {
|
|
|
+ status: false,
|
|
|
+ executeTime: '00:00:00'
|
|
|
+ },
|
|
|
+ schema: {
|
|
|
+ list: getTaskHistory,
|
|
|
+ condition: { functionKey: '' },
|
|
|
+ cols: [
|
|
|
+ { type: 'refresh' },
|
|
|
+ { prop: 'executeTime', label: '触发时间' },
|
|
|
+ { label: '结果', type: 'tag', render: ({ status }) => {
|
|
|
+ return {
|
|
|
+ type: ['primary', 'success', 'danger'][status],
|
|
|
+ label: ['未知', '成功', '失败'][status]
|
|
|
+ }
|
|
|
+ } }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ show (functionKey) {
|
|
|
+ getTimeTask(functionKey).then(({ data }) => {
|
|
|
+ this.schema.condition.functionKey = functionKey
|
|
|
+ if (data) {
|
|
|
+ const { taskId, executeTime, status } = data
|
|
|
+ this.config = {
|
|
|
+ taskId,
|
|
|
+ status,
|
|
|
+ executeTime,
|
|
|
+ freq: 0
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.config = {
|
|
|
+ functionKey,
|
|
|
+ status: 0,
|
|
|
+ freq: 0,
|
|
|
+ executeTime: '00:00:00'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.$refs.configDialog.show()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onSave (done) {
|
|
|
+ const { status, executeTime } = this.config
|
|
|
+ if (status && !executeTime) {
|
|
|
+ this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '请选择触发时间'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.config.taskId) {
|
|
|
+ updateTimeTask({
|
|
|
+ ...this.config
|
|
|
+ }).then(done)
|
|
|
+ } else {
|
|
|
+ addTimeTask({
|
|
|
+ ...this.config
|
|
|
+ }).then(done)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|