notice.vue 4.6 KB

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