detail.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <xn-form-container title="详情" :width="700" :visible="visible" :destroy-on-close="true" @close="onClose">
  3. <a-descriptions :column="1" size="middle" bordered class="mb-2">
  4. <a-descriptions-item label="主题">{{ formData.subject }}</a-descriptions-item>
  5. <a-descriptions-item label="发送时间">{{ formData.createTime }}</a-descriptions-item>
  6. </a-descriptions>
  7. <a-form ref="formRef" :model="formData" layout="vertical">
  8. <a-form-item label="内容:" name="content">
  9. <span>{{ formData.content }}</span>
  10. </a-form-item>
  11. <a-form-item label="查收情况:" name="receiveInfoList">
  12. <s-table
  13. ref="table"
  14. :columns="columns"
  15. :data="loadData"
  16. :alert="false"
  17. :showPagination="false"
  18. bordered
  19. :row-key="(record) => record.id"
  20. :scroll="{x:'auto'}"
  21. >
  22. <template #bodyCell="{ column, record }">
  23. <template v-if="column.dataIndex === 'read'">
  24. <span v-if="record.read" style="color: #d9d9d9">已读</span>
  25. <span v-else style="color: #ff4d4f">未读</span>
  26. </template>
  27. </template>
  28. </s-table>
  29. </a-form-item>
  30. </a-form>
  31. </xn-form-container>
  32. </template>
  33. <script setup name="inSiteMessageDetail">
  34. import userCenterApi from '@/api/sys/userCenterApi'
  35. import EventBus from '@/utils/EventBus'
  36. const emits = defineEmits(['refresh'])
  37. const receiveInfoList = ref([])
  38. // 默认是关闭状态
  39. let visible = $ref(false)
  40. const formRef = ref()
  41. // 表单数据
  42. const formData = ref({})
  43. const table = ref()
  44. const columns = [
  45. {
  46. title: '姓名',
  47. dataIndex: 'receiveUserName'
  48. },
  49. {
  50. title: '是否已读',
  51. dataIndex: 'read',
  52. width: 120
  53. }
  54. ]
  55. // 打开抽屉
  56. const onOpen = (record) => {
  57. visible = true
  58. getMessageList(record)
  59. }
  60. // 获取站内信列表
  61. const getMessageList = (record) => {
  62. const param = {
  63. id: record.id
  64. }
  65. userCenterApi.userLoginUnreadMessageDetail(param).then((data) => {
  66. Object.assign(record, data)
  67. formData.value = record
  68. receiveInfoList.value = data.receiveInfoList
  69. table.value.refresh(true)
  70. })
  71. }
  72. const loadData = () => {
  73. return new Promise((resolve) => {
  74. resolve(receiveInfoList.value)
  75. })
  76. }
  77. // 关闭抽屉
  78. const onClose = () => {
  79. receiveInfoList.value = []
  80. visible = false
  81. emits('refresh')
  82. EventBus.emit('getReadList')
  83. }
  84. // 调用这个函数将子组件的一些数据和方法暴露出去
  85. defineExpose({
  86. onOpen
  87. })
  88. </script>