REVIEW 定时任务(详细)
This commit is contained in:
parent
eace25d3a2
commit
65663df3aa
71
src/views/infra/job/JobDetail.vue
Normal file
71
src/views/infra/job/JobDetail.vue
Normal 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>
|
@ -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) {
|
||||
|
@ -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) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
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>
|
Loading…
Reference in New Issue
Block a user