index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <view class="page_mine">
  3. <notice-header title="我的通知" :showSearch="true" :showFilter="true" :showTabs="true" :tabs="tabs"
  4. :activeTab="activeTab" tabMode="index" @tabChange="handleTabChange" @typeChange="handleTypeChange" @timeChange="handleTimeChange" @searchChange="handleSearchChange"></notice-header>
  5. <view class="notice_content">
  6. <view class="notice_list">
  7. <scroll-view scroll-y v-for="item in noticeList" :key="item.id" class="notice_item">
  8. <view class="item_content">
  9. <view class="notice_title_row">
  10. <image class="notice_icon" :src="item.icon" mode="aspectFit"></image>
  11. <text class="notice_title">{{ item.title }}</text>
  12. </view>
  13. <view class="notice_meta">
  14. <view class="meta_left">
  15. <text class="meta_text">{{ item.category }}</text>
  16. <text class="meta_text">{{ item.department }}</text>
  17. <text class="meta_text">{{ item.time }}</text>
  18. </view>
  19. <view class="status_tag" :class="item.statusClass">
  20. <text>{{ item.status }}</text>
  21. </view>
  22. </view>
  23. </view>
  24. </scroll-view>
  25. <no-data v-if="noticeList.length === 0" text="暂无通知" />
  26. </view>
  27. </view>
  28. <common-tabbar></common-tabbar>
  29. </view>
  30. </template>
  31. <script setup>
  32. import { ref } from 'vue';
  33. import { onShow } from '@dcloudio/uni-app';
  34. import NoticeHeader from '@/components/notice-header.vue';
  35. import NoData from '@/components/no-data.vue';
  36. import overviewApi from '@/reqApi/overview.js';
  37. const tabs = ['未读', '已读', '全部'];
  38. const activeTab = ref(0);
  39. const typeId = ref('0');
  40. const timeType = ref(0);
  41. const word = ref('');
  42. const noticeList = ref([]);
  43. const getDeleteClass = (item) => {
  44. if (item.noticeStatus !== 2) {
  45. return 'delete disabled';
  46. }
  47. return 'delete';
  48. };
  49. const fetchNoticeList = async () => {
  50. try {
  51. const params = {
  52. noticeStatus: activeTab.value,
  53. pageParam: {
  54. pageNum: 1,
  55. pageSize: 9999
  56. },
  57. typeId: typeId.value,
  58. timeType: timeType.value,
  59. word: word.value
  60. };
  61. const res = await overviewApi.teacher_notices_page(params);
  62. if (res.data.records && res.data.records[0] && res.data.records[0].noticePageVOList) {
  63. noticeList.value = res.data.records[0].noticePageVOList.map(item => ({
  64. id: item.id,
  65. title: item.noticeName,
  66. status: item.readStatus === 1 ? '已读' : '未读',
  67. noticeStatus: item.readStatus,
  68. statusClass: item.readStatus === 1 ? 'status-published' : 'status-closed',
  69. category: item.typeName,
  70. department: item.createTeacherName,
  71. time: item.releaseTime,
  72. readCount: item.readNum,
  73. unreadCount: item.unReadNum,
  74. icon: '/static/image/todo/xiaoxi.png'
  75. }));
  76. } else {
  77. noticeList.value = [];
  78. }
  79. } catch (error) {
  80. console.error('获取通知列表失败:', error);
  81. }
  82. };
  83. onShow(() => {
  84. fetchNoticeList();
  85. });
  86. const goBack = () => {
  87. uni.navigateBack();
  88. };
  89. const handleTabChange = (idx) => {
  90. activeTab.value = idx;
  91. fetchNoticeList();
  92. };
  93. const handleTypeChange = (type) => {
  94. typeId.value = type;
  95. fetchNoticeList();
  96. };
  97. const handleTimeChange = (time) => {
  98. timeType.value = time;
  99. fetchNoticeList();
  100. };
  101. const handleSearchChange = (keyword) => {
  102. word.value = keyword;
  103. fetchNoticeList();
  104. };
  105. const handleDelete = (id) => {
  106. uni.showModal({
  107. title: '确认删除',
  108. content: '确定要删除这条通知吗?',
  109. success: (res) => {
  110. if (res.confirm) {
  111. noticeList.value = noticeList.value.filter(item => item.id !== id);
  112. uni.showToast({ title: '删除成功', icon: 'success' });
  113. }
  114. }
  115. });
  116. };
  117. const handleEdit = (id) => {
  118. uni.navigateTo({ url: `/pages/notice/publish/index?id=${id}` });
  119. };
  120. const handleDetail = (id) => {
  121. const item = noticeList.value.find(item => item.id === id);
  122. if (item && item.status === '待发布') {
  123. uni.showToast({ title: '待发布通知暂无法查看详情', icon: 'none' });
  124. return;
  125. }
  126. uni.showToast({ title: `查看详情: ${id}`, icon: 'none' });
  127. };
  128. </script>
  129. <style lang="scss">
  130. .page_mine {
  131. }
  132. .notice_content {
  133. padding-top: 325rpx;
  134. padding-bottom: 104px;
  135. }
  136. .notice_list {
  137. padding: 0rpx 24rpx;
  138. box-sizing: border-box;
  139. }
  140. .notice_item {
  141. background-color: #F9FAFF;
  142. border-radius: 20rpx;
  143. margin-bottom: 24rpx;
  144. border: 2rpx solid #E4E7ED;
  145. .item_content {
  146. padding: 24rpx;
  147. .notice_title_row {
  148. display: flex;
  149. align-items: center;
  150. margin-bottom: 16rpx;
  151. .notice_icon {
  152. width: 32rpx;
  153. height: 32rpx;
  154. margin-right: 16rpx;
  155. }
  156. .notice_title {
  157. flex: 1;
  158. font-weight: 500;
  159. font-size: 28rpx;
  160. color: #333333;
  161. overflow: hidden;
  162. text-overflow: ellipsis;
  163. white-space: nowrap;
  164. }
  165. }
  166. .notice_meta {
  167. display: flex;
  168. align-items: center;
  169. justify-content: space-between;
  170. .meta_left {
  171. display: flex;
  172. align-items: center;
  173. flex-wrap: wrap;
  174. gap: 16rpx;
  175. }
  176. .status_tag {
  177. font-size: 24rpx;
  178. height: 48rpx;
  179. width: 96rpx;
  180. text-align: center;
  181. line-height: 48rpx;
  182. border-radius: 8rpx;
  183. font-weight: 400;
  184. &.status-pending {
  185. background: rgba(46, 100, 250, 0.1);
  186. color: #2E64FA;
  187. }
  188. &.status-published {
  189. background: rgba(82, 196, 26, 0.1);
  190. color: #2BC644;
  191. }
  192. &.status-closed {
  193. background: rgba(245, 108, 108, 0.1);
  194. color: #F56C6C;
  195. }
  196. }
  197. .meta_text {
  198. font-size: 24rpx;
  199. color: #999999;
  200. height: 48rpx;
  201. line-height: 48rpx;
  202. }
  203. }
  204. }
  205. .item_bottom {
  206. border-top: 2rpx solid #E4E7ED;
  207. display: flex;
  208. flex-direction: row;
  209. justify-content: space-between;
  210. align-items: center;
  211. padding: 24rpx 16rpx;
  212. .notice_stats {
  213. display: flex;
  214. .stats_text {
  215. font-size: 24rpx;
  216. color: #999999;
  217. &:first-child {
  218. margin-right: 32rpx;
  219. }
  220. }
  221. }
  222. .notice_actions {
  223. display: flex;
  224. justify-content: flex-end;
  225. gap: 16rpx;
  226. .action_btn {
  227. font-size: 24rpx;
  228. padding: 12rpx 24rpx;
  229. border-radius: 8rpx;
  230. border: 2rpx solid transparent;
  231. &.delete {
  232. border-color: #F56C6C;
  233. color: #F56C6C;
  234. background-color: #FFFFFF;
  235. &.disabled {
  236. border-color: #C0C4CC;
  237. color: #C0C4CC;
  238. background-color: #FFFFFF;
  239. }
  240. }
  241. &.edit {
  242. border-color: #2E64FA;
  243. color: #2E64FA;
  244. background-color: #FFFFFF;
  245. &.disabled {
  246. border-color: #C0C4CC;
  247. color: #C0C4CC;
  248. background-color: #FFFFFF;
  249. }
  250. }
  251. &.detail {
  252. background-color: #2E64FA;
  253. color: #FFFFFF;
  254. &.disabled {
  255. border-color: #C0C4CC;
  256. color: #C0C4CC;
  257. background-color: #FFFFFF;
  258. }
  259. }
  260. }
  261. }
  262. }
  263. &:last-child {
  264. margin-bottom: 0;
  265. }
  266. }
  267. </style>