index.vue 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <view class="yd-page-container">
  3. <!-- 顶部导航栏 -->
  4. <wd-navbar
  5. title="站内信详情"
  6. left-arrow placeholder safe-area-inset-top fixed
  7. @click-left="handleBack"
  8. />
  9. <!-- 详情内容 -->
  10. <view>
  11. <wd-cell-group border>
  12. <wd-cell title="编号" :value="formData?.id" />
  13. <wd-cell title="用户类型">
  14. <dict-tag :type="DICT_TYPE.USER_TYPE" :value="formData?.userType" />
  15. </wd-cell>
  16. <wd-cell title="用户编号" :value="formData?.userId" />
  17. <wd-cell title="模版编号" :value="formData?.templateId" />
  18. <wd-cell title="模板编码" :value="formData?.templateCode" />
  19. <wd-cell title="发送人名称" :value="formData?.templateNickname" />
  20. <wd-cell title="模版内容" :value="formData?.templateContent" />
  21. <wd-cell title="模版参数" :value="formatTemplateParams(formData?.templateParams)" />
  22. <wd-cell title="模版类型">
  23. <dict-tag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="formData?.templateType" />
  24. </wd-cell>
  25. <wd-cell title="是否已读">
  26. <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="formData?.readStatus" />
  27. </wd-cell>
  28. <wd-cell title="阅读时间" :value="formatDateTime(formData?.readTime) || '-'" />
  29. <wd-cell title="创建时间" :value="formatDateTime(formData?.createTime)" />
  30. </wd-cell-group>
  31. </view>
  32. </view>
  33. </template>
  34. <script lang="ts" setup>
  35. import type { NotifyMessage } from '@/api/system/notify/message'
  36. import { onMounted, ref } from 'vue'
  37. import { useToast } from 'wot-design-uni'
  38. import { getNotifyMessage } from '@/api/system/notify/message'
  39. import { navigateBackPlus } from '@/utils'
  40. import { DICT_TYPE } from '@/utils/constants'
  41. import { formatDateTime } from '@/utils/date'
  42. const props = defineProps<{
  43. id?: number | any
  44. }>()
  45. definePage({
  46. style: {
  47. navigationBarTitleText: '',
  48. navigationStyle: 'custom',
  49. },
  50. })
  51. const toast = useToast()
  52. const formData = ref<NotifyMessage>()
  53. /** 返回上一页 */
  54. function handleBack() {
  55. navigateBackPlus('/pages-system/notify/index')
  56. }
  57. /** 格式化模版参数 */
  58. function formatTemplateParams(params: any) {
  59. if (!params) {
  60. return '-'
  61. }
  62. try {
  63. return typeof params === 'string' ? params : JSON.stringify(params)
  64. } catch {
  65. return '-'
  66. }
  67. }
  68. /** 加载详情 */
  69. async function getDetail() {
  70. if (!props.id) {
  71. return
  72. }
  73. try {
  74. toast.loading('加载中...')
  75. formData.value = await getNotifyMessage(Number(props.id))
  76. } finally {
  77. toast.close()
  78. }
  79. }
  80. /** 初始化 */
  81. onMounted(() => {
  82. getDetail()
  83. })
  84. </script>
  85. <style lang="scss" scoped>
  86. </style>