index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <script setup lang="ts">
  2. import { ref } from 'vue'
  3. import dayjs from 'dayjs'
  4. import { DICT_TYPE } from '@/utils/dict'
  5. import { useTable } from '@/hooks/web/useTable'
  6. import { useI18n } from '@/hooks/web/useI18n'
  7. import type { SmsLogVO } from '@/api/system/sms/smsLog/types'
  8. import { allSchemas } from './sms.log.data'
  9. import * as SmsLoglApi from '@/api/system/sms/smsLog'
  10. const { t } = useI18n() // 国际化
  11. // ========== 列表相关 ==========
  12. const { register, tableObject, methods } = useTable<SmsLogVO>({
  13. getListApi: SmsLoglApi.getSmsLogPageApi
  14. })
  15. const { getList, setSearchParams } = methods
  16. // ========== CRUD 相关 ==========
  17. const actionType = ref('') // 操作按钮的类型
  18. const dialogVisible = ref(false) // 是否显示弹出层
  19. const dialogTitle = ref(t('action.detail')) // 弹出层标题
  20. // ========== 详情相关 ==========
  21. const detailRef = ref() // 详情 Ref
  22. const handleDetail = (row: SmsLogVO) => {
  23. // 设置数据
  24. detailRef.value = row
  25. dialogVisible.value = true
  26. }
  27. // ========== 初始化 ==========
  28. getList()
  29. </script>
  30. <template>
  31. <!-- 搜索工作区 -->
  32. <ContentWrap>
  33. <Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
  34. </ContentWrap>
  35. <ContentWrap>
  36. <!-- 列表 -->
  37. <Table
  38. :columns="allSchemas.tableColumns"
  39. :selection="false"
  40. :data="tableObject.tableList"
  41. :loading="tableObject.loading"
  42. :pagination="{
  43. total: tableObject.total
  44. }"
  45. v-model:pageSize="tableObject.pageSize"
  46. v-model:currentPage="tableObject.currentPage"
  47. @register="register"
  48. >
  49. <template #code="{ row }">
  50. <DictTag :type="DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE" :value="row.code" />
  51. </template>
  52. <template #status="{ row }">
  53. <DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" />
  54. </template>
  55. <template #createTime="{ row }">
  56. <span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
  57. </template>
  58. <template #receiveTime="{ row }">
  59. <span>{{ dayjs(row.receiveTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
  60. </template>
  61. <template #action="{ row }">
  62. <el-button
  63. link
  64. type="primary"
  65. v-hasPermi="['system:sms-channel:update']"
  66. @click="handleDetail(row)"
  67. >
  68. <Icon icon="ep:view" class="mr-1px" /> {{ t('action.detail') }}
  69. </el-button>
  70. </template>
  71. </Table>
  72. </ContentWrap>
  73. <Dialog v-model="dialogVisible" :title="dialogTitle">
  74. <!-- 对话框(详情) -->
  75. <Descriptions
  76. v-if="actionType === 'detail'"
  77. :schema="allSchemas.detailSchema"
  78. :data="detailRef"
  79. >
  80. <template #code="{ row }">
  81. <DictTag :type="DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE" :value="row.code" />
  82. </template>
  83. <template #status="{ row }">
  84. <DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" />
  85. </template>
  86. <template #createTime="{ row }">
  87. <span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
  88. </template>
  89. </Descriptions>
  90. <!-- 操作按钮 -->
  91. <template #footer>
  92. <el-button @click="dialogVisible = false">{{ t('dialog.close') }}</el-button>
  93. </template>
  94. </Dialog>
  95. </template>