JobLog.vue 3.8 KB

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