index.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. topActionSlots: false,
  39. getListApi: NotifyMessageApi.getNotifyMessagePageApi
  40. })
  41. // 弹窗相关的变量
  42. const modelVisible = ref(false) // 是否显示弹出层
  43. const modelTitle = ref('edit') // 弹出层标题
  44. const modelLoading = ref(false) // 弹出层loading
  45. const actionType = ref('') // 操作按钮的类型
  46. const actionLoading = ref(false) // 按钮 Loading
  47. const detailData = ref() // 详情 Ref
  48. // 设置标题
  49. const setDialogTile = (type: string) => {
  50. modelLoading.value = true
  51. modelTitle.value = t('action.' + type)
  52. actionType.value = type
  53. modelVisible.value = true
  54. }
  55. // 详情操作
  56. const handleDetail = async (rowId: number) => {
  57. setDialogTile('detail')
  58. const res = await NotifyMessageApi.getNotifyMessageApi(rowId)
  59. detailData.value = res
  60. modelLoading.value = false
  61. }
  62. </script>