userMessage.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <a-row :gutter="10">
  3. <a-col :span="4">
  4. <a-menu id="userMessage" v-model:selected-keys="selectedKeys" mode="inline" @click="handleClick">
  5. <a-menu-item :key="messageCategory.value" v-for="messageCategory in messageCategoryList">{{
  6. messageCategory.label
  7. }}</a-menu-item>
  8. </a-menu>
  9. </a-col>
  10. <a-col :span="20">
  11. <div style="margin-top: -16px">
  12. <s-table ref="table" :columns="columns" :data="loadData" bordered :row-key="(record) => record.id">
  13. <template #bodyCell="{ column, record }">
  14. <template v-if="column.dataIndex === 'subject'">
  15. <ellipsis :length="40" tooltip>
  16. {{ record.subject }}
  17. </ellipsis>
  18. </template>
  19. <template v-if="column.dataIndex === 'read'">
  20. <span v-if="record.read" style="color: #d9d9d9">已读</span>
  21. <span v-else style="color: #ff4d4f">未读</span>
  22. </template>
  23. <template v-if="column.dataIndex === 'action'">
  24. <a-space>
  25. <a @click="detailRef.onOpen(record)">详情</a>
  26. </a-space>
  27. </template>
  28. </template>
  29. </s-table>
  30. </div>
  31. </a-col>
  32. <detail ref="detailRef" @refresh="refresh" />
  33. </a-row>
  34. </template>
  35. <script setup name="userMessage">
  36. import detail from './userMessage/detail.vue'
  37. import userCenterApi from '@/api/sys/userCenterApi'
  38. import tool from '@/utils/tool'
  39. import { nextTick } from 'vue'
  40. const messageCategoryList = tool.dictList('MESSAGE_CATEGORY')
  41. const selectedKeys = ref(new Array(messageCategoryList[0].value))
  42. const table = ref()
  43. const detailRef = ref()
  44. const columns = [
  45. {
  46. title: '主题',
  47. dataIndex: 'subject',
  48. width: '60px'
  49. },
  50. {
  51. title: '发送时间',
  52. dataIndex: 'createTime',
  53. width: '60px',
  54. sorter: true
  55. },
  56. {
  57. title: '是否已读',
  58. dataIndex: 'read',
  59. width: '60px'
  60. },
  61. {
  62. title: '操作',
  63. dataIndex: 'action',
  64. width: '60px'
  65. }
  66. ]
  67. const loadData = (parameter) => {
  68. parameter.category = selectedKeys.value[0]
  69. return userCenterApi.userLoginUnreadMessagePage(parameter).then((data) => {
  70. return data
  71. })
  72. }
  73. const refresh = () => {
  74. table.value.refresh(false)
  75. }
  76. // 点击左侧菜单切换数据查询
  77. const handleClick = () => {
  78. // 先让上面的变量赋值,咱在查询
  79. nextTick(() => {
  80. table.value.refresh(true)
  81. })
  82. }
  83. </script>