REVIEW 定时任务(详细)

This commit is contained in:
YunaiV 2023-04-01 13:41:21 +08:00
parent eace25d3a2
commit 65663df3aa
3 changed files with 80 additions and 97 deletions

View File

@ -0,0 +1,71 @@
<template>
<Dialog title="任务详细" v-model="modelVisible" width="700px">
<el-descriptions border :column="1">
<el-descriptions-item label="任务编号" min-width="60">
{{ detailData.id }}
</el-descriptions-item>
<el-descriptions-item label="任务名称">
{{ detailData.name }}
</el-descriptions-item>
<el-descriptions-item label="任务名称">
<dict-tag :type="DICT_TYPE.INFRA_JOB_STATUS" :value="detailData.status" />
</el-descriptions-item>
<el-descriptions-item label="处理器的名字">
{{ detailData.handlerName }}
</el-descriptions-item>
<el-descriptions-item label="处理器的参数">
{{ detailData.handlerParam }}
</el-descriptions-item>
<el-descriptions-item label="Cron 表达式">
{{ detailData.cronExpression }}
</el-descriptions-item>
<el-descriptions-item label="重试次数">
{{ detailData.retryCount }}
</el-descriptions-item>
<el-descriptions-item label="重试间隔">
{{ detailData.retryInterval + ' 毫秒' }}
</el-descriptions-item>
<el-descriptions-item label="监控超时时间">
{{ detailData.monitorTimeout > 0 ? detailData.monitorTimeout + ' 毫秒' : '未开启' }}
</el-descriptions-item>
<el-descriptions-item label="后续执行时间">
<el-timeline>
<el-timeline-item
v-for="(nextTime, index) in nextTimes"
:key="index"
:timestamp="formatDate(nextTime)"
>
{{ index + 1 }}
</el-timeline-item>
</el-timeline>
</el-descriptions-item>
</el-descriptions>
</Dialog>
</template>
<script setup lang="ts">
import { DICT_TYPE } from '@/utils/dict'
import { formatDate } from '@/utils/formatTime'
import * as JobApi from '@/api/infra/job'
const modelVisible = ref(false) //
const detailLoading = ref(false) //
const detailData = ref({}) //
const nextTimes = ref([]) //
/** 打开弹窗 */
const open = async (id: number) => {
modelVisible.value = true
//
if (id) {
detailLoading.value = true
try {
detailData.value = await JobApi.getJobApi(id)
//
nextTimes.value = await JobApi.getJobNextTimesApi(id)
} finally {
detailLoading.value = false
}
}
}
defineExpose({ open }) // open
</script>

View File

@ -117,7 +117,7 @@
<el-dropdown-item command="handleRun" v-if="checkPermi(['infra:job:trigger'])">
执行一次
</el-dropdown-item>
<el-dropdown-item command="handleView" v-if="checkPermi(['infra:job:query'])">
<el-dropdown-item command="openDetail" v-if="checkPermi(['infra:job:query'])">
任务详细
</el-dropdown-item>
<el-dropdown-item command="handleJobLog" v-if="checkPermi(['infra:job:query'])">
@ -141,13 +141,13 @@
<!-- 表单弹窗添加/修改 -->
<JobForm ref="formRef" @success="getList" />
<!-- 表单弹窗查看 -->
<job-view ref="viewModalRef" @success="getList" />
<JobDetail ref="detailRef" />
</template>
<script setup lang="ts" name="Job">
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { checkPermi } from '@/utils/permission'
import JobForm from './JobForm.vue'
import JobView from './view.vue'
import JobDetail from './JobDetail.vue'
import download from '@/utils/download'
import * as JobApi from '@/api/infra/job'
import { InfraJobStatusEnum } from '@/utils/constants'
@ -254,8 +254,8 @@ const handleCommand = (command, row) => {
case 'handleRun':
handleRun(row)
break
case 'handleView':
handleView(row?.id)
case 'openDetail':
openDetail(row.id)
break
case 'handleJobLog':
handleJobLog(row?.id)
@ -279,10 +279,11 @@ const handleRun = async (row: JobApi.JobVO) => {
}
/** 查看操作 */
const viewModalRef = ref()
const handleView = (rowId?: number) => {
viewModalRef.value.openForm(rowId)
const detailRef = ref()
const openDetail = (id: number) => {
detailRef.value.open(id)
}
//
const handleJobLog = (rowId?: number) => {
if (rowId) {

View File

@ -1,89 +0,0 @@
<template>
<!-- 任务详细 -->
<Dialog title="任务详细" v-model="modelVisible" width="700px" append-to-body>
<el-form ref="formRef" :model="formData" label-width="200px">
<el-row>
<el-col :span="24">
<el-form-item label="任务编号:">{{ formData.id }}</el-form-item>
<el-form-item label="任务名称:">{{ formData.name }}</el-form-item>
<el-form-item label="任务名称:">
<dict-tag :type="DICT_TYPE.INFRA_JOB_STATUS" :value="formData.status" />
</el-form-item>
<el-form-item label="处理器的名字:">{{ formData.handlerName }}</el-form-item>
<el-form-item label="处理器的参数:">{{ formData.handlerParam }}</el-form-item>
<el-form-item label="cron表达式">{{ formData.cronExpression }}</el-form-item>
<el-form-item label="重试次数:">{{ formData.retryCount }}</el-form-item>
<el-form-item label="重试间隔:">{{ formData.retryInterval + ' 毫秒' }}</el-form-item>
<el-form-item label="监控超时时间:">{{
formData.monitorTimeout > 0 ? formData.monitorTimeout + ' 毫秒' : '未开启'
}}</el-form-item>
<el-form-item label="后续执行时间:">
<el-timeline class="pt-3">
<el-timeline-item
v-for="(activity, index) in nextTimes"
:key="index"
:timestamp="parseTime(activity)"
>
{{ index + 1 }}
</el-timeline-item>
</el-timeline>
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button @click="close"> </el-button>
</div>
</template>
</Dialog>
</template>
<script setup lang="ts" name="JobView">
import * as JobApi from '@/api/infra/job'
import { parseTime } from '@/utils/formatTime'
import { DICT_TYPE } from '@/utils/dict'
const emit = defineEmits(['success']) // success
const { t } = useI18n() //
const formRef = ref() // Ref
const modelVisible = ref(false) //
const modelTitle = ref('') //
const formLoading = ref(false) // 12
const formData = ref({
id: undefined,
name: '',
handlerParam: '',
handlerName: '',
cronExpression: '',
retryCount: true,
retryInterval: '',
monitorTimeout: 0,
status: 0
})
const nextTimes = ref([])
/** 打开弹窗 */
const openModal = async (id?: number) => {
modelVisible.value = true
modelTitle.value = t('action.detail')
//
if (id) {
formLoading.value = true
try {
formData.value = await JobApi.getJobApi(id)
//
nextTimes.value = await JobApi.getJobNextTimesApi(id)
} finally {
formLoading.value = false
}
}
}
defineExpose({ openModal }) // openModal
const close = () => {
modelVisible.value = false
emit('success')
}
</script>