JobLog.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <script lang="ts" setup>
  2. import { onMounted, ref } from 'vue'
  3. import dayjs from 'dayjs'
  4. import * as JobLogApi from '@/api/infra/jobLog'
  5. import { JobLogVO } from '@/api/infra/jobLog/types'
  6. import { DICT_TYPE } from '@/utils/dict'
  7. import { useTable } from '@/hooks/web/useTable'
  8. import { useI18n } from '@/hooks/web/useI18n'
  9. import { useRoute } from 'vue-router'
  10. import { allSchemas } from './jobLog.data'
  11. const { t } = useI18n() // 国际化
  12. const { query } = useRoute()
  13. // ========== 列表相关 ==========
  14. const { register, tableObject, methods } = useTable<JobLogVO>({
  15. getListApi: JobLogApi.getJobLogPageApi,
  16. exportListApi: JobLogApi.exportJobLogApi
  17. })
  18. const { getList, setSearchParams, exportList } = methods
  19. const getTableList = async () => {
  20. const id = (query.id as unknown as number) && (query.jobId as unknown as number)
  21. tableObject.params = {
  22. jobId: id
  23. }
  24. await getList()
  25. }
  26. // ========== CRUD 相关 ==========
  27. const dialogVisible = ref(false) // 是否显示弹出层
  28. const dialogTitle = ref('') // 弹出层标题
  29. // ========== 详情相关 ==========
  30. const detailRef = ref() // 详情 Ref
  31. // 详情操作
  32. const handleDetail = async (row: JobLogVO) => {
  33. // 设置数据
  34. const res = JobLogApi.getJobLogApi(row.id)
  35. detailRef.value = res
  36. dialogTitle.value = t('action.detail')
  37. dialogVisible.value = true
  38. }
  39. // ========== 初始化 ==========
  40. onMounted(() => {
  41. getTableList()
  42. })
  43. </script>
  44. <template>
  45. <!-- 搜索工作区 -->
  46. <ContentWrap>
  47. <Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
  48. </ContentWrap>
  49. <ContentWrap>
  50. <!-- 操作工具栏 -->
  51. <div class="mb-10px">
  52. <el-button
  53. type="warning"
  54. v-hasPermi="['infra:job:export']"
  55. :loading="tableObject.exportLoading"
  56. @click="exportList('定时任务日志.xls')"
  57. >
  58. <Icon icon="ep:download" class="mr-5px" /> {{ t('action.export') }}
  59. </el-button>
  60. </div>
  61. <!-- 列表 -->
  62. <Table
  63. :columns="allSchemas.tableColumns"
  64. :selection="false"
  65. :data="tableObject.tableList"
  66. :loading="tableObject.loading"
  67. :pagination="{
  68. total: tableObject.total
  69. }"
  70. v-model:pageSize="tableObject.pageSize"
  71. v-model:currentPage="tableObject.currentPage"
  72. @register="register"
  73. >
  74. <template #beginTime="{ row }">
  75. <span>{{
  76. dayjs(row.beginTime).format('YYYY-MM-DD HH:mm:ss') +
  77. ' ~ ' +
  78. dayjs(row.endTime).format('YYYY-MM-DD HH:mm:ss')
  79. }}</span>
  80. </template>
  81. <template #duration="{ row }">
  82. <span>{{ row.duration + ' 毫秒' }}</span>
  83. </template>
  84. <template #status="{ row }">
  85. <DictTag :type="DICT_TYPE.INFRA_JOB_LOG_STATUS" :value="row.status" />
  86. </template>
  87. <template #action="{ row }">
  88. <el-button link type="primary" v-hasPermi="['infra:job:query']" @click="handleDetail(row)">
  89. <Icon icon="ep:view" class="mr-1px" /> {{ t('action.detail') }}
  90. </el-button>
  91. </template>
  92. </Table>
  93. </ContentWrap>
  94. <XModal v-model="dialogVisible" :title="dialogTitle">
  95. <!-- 对话框(详情) -->
  96. <Descriptions :schema="allSchemas.detailSchema" :data="detailRef">
  97. <template #status="{ row }">
  98. <DictTag :type="DICT_TYPE.INFRA_JOB_LOG_STATUS" :value="row.status" />
  99. </template>
  100. <template #retryInterval="{ row }">
  101. <span>{{ row.retryInterval + '毫秒' }} </span>
  102. </template>
  103. <template #monitorTimeout="{ row }">
  104. <span>{{ row.monitorTimeout > 0 ? row.monitorTimeout + ' 毫秒' : '未开启' }}</span>
  105. </template>
  106. </Descriptions>
  107. <!-- 操作按钮 -->
  108. <template #footer>
  109. <el-button @click="dialogVisible = false">{{ t('dialog.close') }}</el-button>
  110. </template>
  111. </XModal>
  112. </template>