index.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <ContentWrap>
  3. <!-- 列表 -->
  4. <XTable @register="registerTable">
  5. <template #toolbar_buttons>
  6. <!-- 操作:标记已读 -->
  7. <XButton type="primary" preIcon="ep:zoom-in" title="标记已读" @click="handleUpdateList" />
  8. <!-- 操作:全部已读 -->
  9. <XButton type="primary" preIcon="ep:zoom-in" title="全部已读" @click="handleUpdateAll" />
  10. </template>
  11. <template #actionbtns_default="{ row }">
  12. <!-- 操作:已读 -->
  13. <XTextButton
  14. preIcon="ep:view"
  15. title="已读"
  16. v-hasPermi="['system:notify-message:query']"
  17. v-if="!row.readStatus"
  18. @click="handleUpdate([row.id])"
  19. />
  20. </template>
  21. </XTable>
  22. </ContentWrap>
  23. </template>
  24. <script setup lang="ts" name="MyNotifyMessage">
  25. // 业务相关的 import
  26. import { allSchemas } from './my.data'
  27. import * as NotifyMessageApi from '@/api/system/notify/message'
  28. const message = useMessage() // 消息
  29. // 列表相关的变量
  30. const [registerTable, { reload, getCheckboxRecords }] = useXTable({
  31. allSchemas: allSchemas,
  32. getListApi: NotifyMessageApi.getMyNotifyMessagePage
  33. })
  34. const handleUpdateList = async () => {
  35. const list = getCheckboxRecords() as any as any[]
  36. if (list.length === 0) {
  37. return
  38. }
  39. await handleUpdate(list.map((v) => v.id))
  40. }
  41. // 标记指定 id 已读
  42. const handleUpdate = async (ids) => {
  43. await NotifyMessageApi.updateNotifyMessageRead(ids)
  44. message.success('标记已读成功!')
  45. reload()
  46. }
  47. // 标记全部已读
  48. const handleUpdateAll = async () => {
  49. await NotifyMessageApi.updateAllNotifyMessageRead()
  50. message.success('全部已读成功!')
  51. reload()
  52. }
  53. </script>