index.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <ContentWrap>
  3. <!-- 列表 -->
  4. <XTable @register="registerTable">
  5. <template #actionbtns_default="{ row }">
  6. <!-- 操作:详情 -->
  7. <XTextButton
  8. preIcon="ep:view"
  9. :title="t('action.detail')"
  10. v-hasPermi="['system:notify-message:query']"
  11. @click="handleDetail(row.id)"
  12. />
  13. </template>
  14. </XTable>
  15. </ContentWrap>
  16. <!-- 弹窗 -->
  17. <XModal id="messageModel" :loading="modelLoading" v-model="modelVisible" :title="modelTitle">
  18. <!-- 表单:详情 -->
  19. <Descriptions
  20. v-if="actionType === 'detail'"
  21. :schema="allSchemas.detailSchema"
  22. :data="detailData"
  23. />
  24. <template #footer>
  25. <!-- 按钮:关闭 -->
  26. <XButton :loading="actionLoading" :title="t('dialog.close')" @click="modelVisible = false" />
  27. </template>
  28. </XModal>
  29. </template>
  30. <script setup lang="ts" name="NotifyMessage">
  31. // 业务相关的 import
  32. import { allSchemas } from './message.data'
  33. import * as NotifyMessageApi from '@/api/system/notify/message'
  34. const { t } = useI18n() // 国际化
  35. // 列表相关的变量
  36. const [registerTable] = useXTable({
  37. allSchemas: allSchemas,
  38. getListApi: NotifyMessageApi.getNotifyMessagePageApi
  39. })
  40. // 弹窗相关的变量
  41. const modelVisible = ref(false) // 是否显示弹出层
  42. const modelTitle = ref('edit') // 弹出层标题
  43. const modelLoading = ref(false) // 弹出层loading
  44. const actionType = ref('') // 操作按钮的类型
  45. const actionLoading = ref(false) // 按钮 Loading
  46. const detailData = ref() // 详情 Ref
  47. // 设置标题
  48. const setDialogTile = (type: string) => {
  49. modelLoading.value = true
  50. modelTitle.value = t('action.' + type)
  51. actionType.value = type
  52. modelVisible.value = true
  53. }
  54. // 详情操作
  55. const handleDetail = async (rowId: number) => {
  56. setDialogTile('detail')
  57. const res = await NotifyMessageApi.getNotifyMessageApi(rowId)
  58. detailData.value = res
  59. modelLoading.value = false
  60. }
  61. </script>