notice.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. 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. }
  104. const listApi = ref(null)
  105. listApi.value = newsApi.newsNoticeList
  106. </script>
  107. <style scoped lang="scss">
  108. @import "@/uni.scss";
  109. .avatar {
  110. width: px2rpx(60);
  111. height: px2rpx(60);
  112. border-radius: 4px;
  113. }
  114. .content-title {
  115. display: flex;
  116. justify-content: space-between;
  117. align-items: center;
  118. font-size: px2rpx(20);
  119. font-weight: 500;
  120. .content-title-btns {
  121. margin: px2rpx(8) 0;
  122. display: flex;
  123. align-items: center;
  124. justify-content: center;
  125. gap: px2rpx(12);
  126. .btn-primary {
  127. min-width: px2rpx(120);
  128. background-color: var(--color-error);
  129. color: white;
  130. padding: 0 px2rpx(12);
  131. border: none;
  132. font-size: px2rpx(14);
  133. text-align: center;
  134. cursor: pointer;
  135. display: flex;
  136. align-items: center;
  137. justify-content: center;
  138. gap: px2rpx(8);
  139. }
  140. .btn-primary:active {
  141. background-color: #cf1322;
  142. ;
  143. }
  144. }
  145. }
  146. .operation-btn {
  147. :deep(span) {
  148. display: flex;
  149. align-items: center;
  150. justify-content: center;
  151. gap: px2rpx(4);
  152. cursor: pointer;
  153. background-color: var(--color-slate-150);
  154. padding: px2rpx(8) 0;
  155. }
  156. }
  157. .operation-btn.disabled {
  158. cursor: not-allowed;
  159. opacity: 0.5;
  160. }
  161. .search-bar {
  162. display: flex;
  163. align-items: center;
  164. justify-content: flex-start;
  165. flex-wrap: wrap;
  166. gap: px2rpx(16);
  167. margin: px2rpx(16) 0;
  168. .cwg-combox,
  169. .uni-easyinput,
  170. .uni-date {
  171. width: px2rpx(240) !important;
  172. flex: none;
  173. }
  174. }
  175. </style>