JobLog.vue 3.9 KB

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