index.vue 6.8 KB

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