index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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. padding-bottom: env(safe-area-inset-bottom);
  139. box-sizing: border-box;
  140. }
  141. .notice_content {
  142. flex: 1;
  143. display: flex;
  144. flex-direction: column;
  145. overflow: hidden;
  146. padding-top: calc(325rpx + env(safe-area-inset-top));
  147. padding-bottom: calc(208rpx + env(safe-area-inset-bottom));
  148. padding-left: 0rpx;
  149. padding-right: 0rpx;
  150. }
  151. .notice_list {
  152. flex: 1;
  153. overflow-y: auto;
  154. overflow-x: hidden;
  155. padding: 0 24rpx;
  156. }
  157. .notice_item {
  158. background-color: #F9FAFF;
  159. border-radius: 20rpx;
  160. margin-bottom: 24rpx;
  161. border: 2rpx solid #E4E7ED;
  162. .item_content {
  163. padding: 24rpx;
  164. .notice_title_row {
  165. display: flex;
  166. align-items: center;
  167. margin-bottom: 16rpx;
  168. .notice_icon {
  169. width: 32rpx;
  170. height: 32rpx;
  171. margin-right: 16rpx;
  172. }
  173. .arrow_icon {
  174. width: 24rpx;
  175. height: 24rpx;
  176. transform: rotate(-90deg);
  177. }
  178. .notice_title {
  179. flex: 1;
  180. font-weight: 500;
  181. font-size: 28rpx;
  182. color: #333333;
  183. overflow: hidden;
  184. text-overflow: ellipsis;
  185. white-space: nowrap;
  186. }
  187. }
  188. .notice_meta {
  189. display: flex;
  190. align-items: center;
  191. justify-content: space-between;
  192. .meta_left {
  193. display: flex;
  194. align-items: center;
  195. flex-wrap: wrap;
  196. gap: 16rpx;
  197. }
  198. .status_tag {
  199. font-size: 24rpx;
  200. height: 48rpx;
  201. width: 96rpx;
  202. text-align: center;
  203. line-height: 48rpx;
  204. border-radius: 8rpx;
  205. font-weight: 400;
  206. &.status-pending {
  207. background: rgba(46, 100, 250, 0.1);
  208. color: #2E64FA;
  209. }
  210. &.status-published {
  211. background: rgba(82, 196, 26, 0.1);
  212. color: #2BC644;
  213. }
  214. &.status-closed {
  215. background: rgba(245, 108, 108, 0.1);
  216. color: #F56C6C;
  217. }
  218. }
  219. .meta_text {
  220. font-size: 24rpx;
  221. color: #999999;
  222. height: 48rpx;
  223. line-height: 48rpx;
  224. }
  225. }
  226. }
  227. .item_bottom {
  228. border-top: 2rpx solid #E4E7ED;
  229. display: flex;
  230. flex-direction: row;
  231. justify-content: space-between;
  232. align-items: center;
  233. padding: 24rpx 16rpx;
  234. .notice_stats {
  235. display: flex;
  236. .stats_text {
  237. font-size: 24rpx;
  238. color: #999999;
  239. &:first-child {
  240. margin-right: 32rpx;
  241. }
  242. }
  243. }
  244. .notice_actions {
  245. display: flex;
  246. justify-content: flex-end;
  247. gap: 16rpx;
  248. .action_btn {
  249. font-size: 24rpx;
  250. padding: 12rpx 24rpx;
  251. border-radius: 8rpx;
  252. border: 2rpx solid transparent;
  253. &.delete {
  254. border-color: #F56C6C;
  255. color: #F56C6C;
  256. background-color: #FFFFFF;
  257. &.disabled {
  258. border-color: #C0C4CC;
  259. color: #C0C4CC;
  260. background-color: #FFFFFF;
  261. }
  262. }
  263. &.edit {
  264. border-color: #2E64FA;
  265. color: #2E64FA;
  266. background-color: #FFFFFF;
  267. &.disabled {
  268. border-color: #C0C4CC;
  269. color: #C0C4CC;
  270. background-color: #FFFFFF;
  271. }
  272. }
  273. &.detail {
  274. background-color: #2E64FA;
  275. color: #FFFFFF;
  276. &.disabled {
  277. border-color: #C0C4CC;
  278. color: #C0C4CC;
  279. background-color: #FFFFFF;
  280. }
  281. }
  282. }
  283. }
  284. }
  285. &:last-child {
  286. margin-bottom: 0;
  287. }
  288. }
  289. </style>