notice.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <cwg-page-wrapper class="create-page" :isHeaderFixed="true">
  3. <cwg-header :title="t('News.Notice')" />
  4. <view class="info-card">
  5. <view class="search-bar">
  6. <cwg-combox v-model:value="search.read" :options="readOptions"
  7. :placeholder="t('Custom.PaymentHistory.StatusPlaceholder')" />
  8. </view>
  9. <cwg-tabel ref="tableRef" :columns="columns" :mobilePrimaryFields="mobilePrimaryFields" :isPages="true"
  10. :queryParams="search" :api="listApi" @go-pages="goPages">
  11. <template #status="{ row }">
  12. {{readOptions.find(item => item.value === row.read)?.text}}
  13. </template>
  14. </cwg-tabel>
  15. </view>
  16. </cwg-page-wrapper>
  17. </template>
  18. <script setup lang="ts">
  19. import { computed, ref, watch } from 'vue';
  20. import { useI18n } from 'vue-i18n';
  21. const { t, locale } = useI18n();
  22. import { newsApi } from '@/service/news';
  23. import useRouter from "@/hooks/useRouter";
  24. const router = useRouter();
  25. const search = ref({
  26. read: null,
  27. lang: locale.value
  28. })
  29. const readOptions = computed(() => [
  30. { value: null, text: t('State.All') },
  31. { value: 0, text: t('News.Unread') },
  32. { value: 1, text: t('News.Read') }
  33. ]);
  34. const tableRef = ref(null)
  35. watch(locale, () => {
  36. search.value.lang = locale.value
  37. tableRef.value.reload()
  38. })
  39. // 表格列配置(支持插槽和格式化)
  40. const columns = computed(() => [
  41. {
  42. prop: 'subject',
  43. label: t('News.Title'),
  44. align: 'left',
  45. slot: 'subject' // 使用插槽自定义标题点击
  46. },
  47. {
  48. prop: 'addTime',
  49. label: t('Drawer.Label.Date'),
  50. align: 'center',
  51. formatter: ({ row }) => row.addTime || '--'
  52. },
  53. {
  54. prop: 'read',
  55. label: t('Custom.Recording.Status'),
  56. align: 'right',
  57. slot: 'status' // 使用插槽显示未读/已读状态
  58. },
  59. {
  60. prop: 'more',
  61. type: 'more',
  62. width: 20,
  63. align: 'right'
  64. },
  65. ])
  66. const mobilePrimaryFields = ref([
  67. {
  68. prop: 'subject',
  69. label: t('News.Title'),
  70. align: 'left',
  71. slot: 'subject' // 使用插槽自定义标题点击
  72. },
  73. {
  74. prop: 'addTime',
  75. label: t('Drawer.Label.Date'),
  76. align: 'center',
  77. formatter: ({ row }) => row.addTime || '--'
  78. },
  79. {
  80. prop: 'read',
  81. label: t('Custom.Recording.Status'),
  82. align: 'right',
  83. slot: 'status' // 使用插槽显示未读/已读状态
  84. },
  85. {
  86. prop: 'more',
  87. type: 'more',
  88. width: 20,
  89. align: 'right'
  90. },
  91. ])
  92. const goPages = (e) => {
  93. router.push({
  94. path: '/pages/analytics/detail',
  95. query: {
  96. id: e.id,
  97. type: 7
  98. }
  99. })
  100. }
  101. const listApi = ref(null)
  102. listApi.value = newsApi.newsNoticeList
  103. </script>
  104. <style scoped lang="scss">
  105. @import "@/uni.scss";
  106. .avatar {
  107. width: px2rpx(60);
  108. height: px2rpx(60);
  109. border-radius: 4px;
  110. }
  111. .content-title {
  112. display: flex;
  113. justify-content: space-between;
  114. align-items: center;
  115. font-size: px2rpx(20);
  116. font-weight: 500;
  117. .content-title-btns {
  118. margin: px2rpx(8) 0;
  119. display: flex;
  120. align-items: center;
  121. justify-content: center;
  122. gap: px2rpx(12);
  123. .btn-primary {
  124. min-width: px2rpx(120);
  125. background-color: var(--color-error);
  126. color: white;
  127. padding: 0 px2rpx(12);
  128. border: none;
  129. font-size: px2rpx(14);
  130. text-align: center;
  131. cursor: pointer;
  132. display: flex;
  133. align-items: center;
  134. justify-content: center;
  135. gap: px2rpx(8);
  136. }
  137. .btn-primary:active {
  138. background-color: var(--color-navy-700);
  139. }
  140. }
  141. }
  142. .operation-btn {
  143. :deep(span) {
  144. display: flex;
  145. align-items: center;
  146. justify-content: center;
  147. gap: px2rpx(4);
  148. cursor: pointer;
  149. background-color: var(--color-slate-150);
  150. padding: px2rpx(8) 0;
  151. }
  152. }
  153. .operation-btn.disabled {
  154. cursor: not-allowed;
  155. opacity: 0.5;
  156. }
  157. .search-bar {
  158. display: flex;
  159. align-items: center;
  160. justify-content: flex-start;
  161. flex-wrap: wrap;
  162. gap: px2rpx(16);
  163. margin: px2rpx(16) 0;
  164. .cwg-combox,
  165. .uni-easyinput,
  166. .uni-date {
  167. width: px2rpx(240) !important;
  168. flex: none;
  169. }
  170. }
  171. </style>