index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <div class="message-reminder flex flex-col h-full">
  3. <div class="page-action">
  4. <div
  5. v-for="item in tabs"
  6. :key="item.value"
  7. :class="[
  8. 'page-tab',
  9. {
  10. 'is-active': params.status === item.value,
  11. 'is-mark': item.value === 'false' && workStore.counts.notice,
  12. },
  13. ]"
  14. @click="switchTab(item)"
  15. >{{ item.label }}</div
  16. >
  17. </div>
  18. <SearchForm :fields="fields" :params="params">
  19. <template #service="{ item, params }">
  20. <select-service-unit
  21. v-model="params[item.prop]"
  22. clearable
  23. ></select-service-unit>
  24. </template>
  25. </SearchForm>
  26. <div v-loading="loading" class="page-wrap flex-1">
  27. <MessageList
  28. :tableData="tableData"
  29. :pagination="pagination"
  30. :onChange="onChange"
  31. ></MessageList>
  32. </div>
  33. </div>
  34. </template>
  35. <script setup name="MessageReminder">
  36. import { reactive, computed, ref } from 'vue';
  37. import useFetchTable from '@/hooks/useFetchTable';
  38. import { getMyMessages } from '@/api/my-workbenches';
  39. import { MESSAGE_TYPE } from '@/config/constants';
  40. import { dictToOptionList } from '@/utils/tool';
  41. import MessageList from './message-list.vue';
  42. import { useWorkStore } from '@/store';
  43. const workStore = useWorkStore();
  44. const tabs = [
  45. {
  46. label: '全部',
  47. value: 'undefined',
  48. },
  49. {
  50. label: '未读',
  51. value: 'false',
  52. },
  53. {
  54. label: '已读',
  55. value: 'true',
  56. },
  57. ];
  58. const params = reactive({
  59. types: [],
  60. serviceId: '',
  61. custom: '',
  62. status: 'undefined',
  63. });
  64. const transParams = computed(() => {
  65. let types = params.types.join(',');
  66. if (!types.length && params.status === 'undefined') {
  67. types = Object.keys(MESSAGE_TYPE).join();
  68. }
  69. let status = eval(params.status);
  70. return { ...params, types, status };
  71. });
  72. const {
  73. loading: loading,
  74. pagination: pagination,
  75. tableData: tableData,
  76. onChange: onChange,
  77. search: search,
  78. } = useFetchTable(getMyMessages, {
  79. params: transParams,
  80. });
  81. const switchTab = (tab) => {
  82. params.status = tab.value;
  83. search();
  84. };
  85. const fields = ref([
  86. {
  87. prop: 'types',
  88. label: '消息类型',
  89. type: 'multipleSelect',
  90. labelWidth: 100,
  91. colSpan: 5,
  92. options: dictToOptionList(MESSAGE_TYPE),
  93. attrs: {
  94. clearable: true,
  95. },
  96. },
  97. {
  98. prop: 'serviceId',
  99. label: '服务单元',
  100. type: 'select',
  101. labelWidth: 100,
  102. colSpan: 5,
  103. cell: 'service',
  104. },
  105. {
  106. prop: 'custom',
  107. label: '客户名称',
  108. labelWidth: 100,
  109. colSpan: 5,
  110. },
  111. {
  112. type: 'buttons',
  113. colSpan: 3,
  114. children: [
  115. {
  116. type: 'button',
  117. text: '查询',
  118. onClick: () => {
  119. search();
  120. },
  121. },
  122. ],
  123. },
  124. ]);
  125. </script>