JobLog.vue 3.8 KB

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