vue-pro/yudao-ui-admin-vue3/src/views/infra/job/JobLog.vue

114 lines
3.6 KiB
Vue
Raw Normal View History

2022-11-16 09:30:57 +08:00
<script setup lang="ts">
2022-07-18 19:06:37 +08:00
import { onMounted, ref } from 'vue'
import dayjs from 'dayjs'
import * as JobLogApi from '@/api/infra/jobLog'
import { JobLogVO } from '@/api/infra/jobLog/types'
import { DICT_TYPE } from '@/utils/dict'
import { useTable } from '@/hooks/web/useTable'
import { useI18n } from '@/hooks/web/useI18n'
import { useRoute } from 'vue-router'
import { allSchemas } from './jobLog.data'
const { t } = useI18n() // 国际化
const { query } = useRoute()
// ========== 列表相关 ==========
2022-07-19 22:33:54 +08:00
const { register, tableObject, methods } = useTable<JobLogVO>({
2022-07-18 19:06:37 +08:00
getListApi: JobLogApi.getJobLogPageApi,
exportListApi: JobLogApi.exportJobLogApi
})
const { getList, setSearchParams, exportList } = methods
const getTableList = async () => {
const id = (query.id as unknown as number) && (query.jobId as unknown as number)
2022-07-19 22:33:54 +08:00
tableObject.params = {
2022-07-18 19:06:37 +08:00
jobId: id
}
await getList()
}
// ========== CRUD 相关 ==========
const dialogVisible = ref(false) // 是否显示弹出层
const dialogTitle = ref('') // 弹出层标题
// ========== 详情相关 ==========
const detailRef = ref() // 详情 Ref
// 详情操作
const handleDetail = async (row: JobLogVO) => {
// 设置数据
const res = JobLogApi.getJobLogApi(row.id)
detailRef.value = res
dialogTitle.value = t('action.detail')
dialogVisible.value = true
}
// ========== 初始化 ==========
onMounted(() => {
getTableList()
})
</script>
<template>
<!-- 搜索工作区 -->
<ContentWrap>
<Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
</ContentWrap>
<ContentWrap>
<!-- 操作工具栏 -->
<div class="mb-10px">
<el-button
type="warning"
v-hasPermi="['infra:job:export']"
:loading="tableObject.exportLoading"
2022-07-28 18:23:09 +08:00
@click="exportList('定时任务日志.xls')"
2022-07-18 19:06:37 +08:00
>
<Icon icon="ep:download" class="mr-5px" /> {{ t('action.export') }}
</el-button>
</div>
<!-- 列表 -->
<Table
:columns="allSchemas.tableColumns"
:selection="false"
:data="tableObject.tableList"
:loading="tableObject.loading"
:pagination="{
total: tableObject.total
}"
v-model:pageSize="tableObject.pageSize"
v-model:currentPage="tableObject.currentPage"
@register="register"
>
<template #beginTime="{ row }">
<span>{{
dayjs(row.beginTime).format('YYYY-MM-DD HH:mm:ss') +
' ~ ' +
dayjs(row.endTime).format('YYYY-MM-DD HH:mm:ss')
}}</span>
</template>
<template #duration="{ row }">
<span>{{ row.duration + ' 毫秒' }}</span>
</template>
<template #status="{ row }">
<DictTag :type="DICT_TYPE.INFRA_JOB_LOG_STATUS" :value="row.status" />
</template>
<template #action="{ row }">
<el-button link type="primary" v-hasPermi="['infra:job:query']" @click="handleDetail(row)">
2022-07-20 10:50:55 +08:00
<Icon icon="ep:view" class="mr-1px" /> {{ t('action.detail') }}
2022-07-18 19:06:37 +08:00
</el-button>
</template>
</Table>
</ContentWrap>
2022-11-15 12:25:19 +08:00
<XModal v-model="dialogVisible" :title="dialogTitle">
2022-07-18 19:06:37 +08:00
<!-- 对话框(详情) -->
<Descriptions :schema="allSchemas.detailSchema" :data="detailRef">
<template #retryInterval="{ row }">
<span>{{ row.retryInterval + '毫秒' }} </span>
</template>
<template #monitorTimeout="{ row }">
<span>{{ row.monitorTimeout > 0 ? row.monitorTimeout + ' 毫秒' : '未开启' }}</span>
</template>
</Descriptions>
<!-- 操作按钮 -->
<template #footer>
<el-button @click="dialogVisible = false">{{ t('dialog.close') }}</el-button>
</template>
2022-11-15 12:25:19 +08:00
</XModal>
2022-07-18 19:06:37 +08:00
</template>