noticeDetail.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. <template>
  2. <view class="notice_detail">
  3. <view class="detail_header" :style="{ paddingTop: statusBarHeight+64 + 'rpx' }">
  4. <uni-icons type="back" size="24" color="#333333" @click="handleBack"></uni-icons>
  5. <text class="header_title">通知详情</text>
  6. <text class="header_placeholder"></text>
  7. </view>
  8. <view class="detail_content">
  9. <view class="notice_info">
  10. <text class="notice_title">{{ noticeItem.title }}</text>
  11. <view class="notice_meta">
  12. <view class="notice_left">
  13. <text class="meta_item">{{ noticeItem.category }}</text>
  14. <text class="meta_item">{{ noticeItem.department }}</text>
  15. <text class="meta_item">{{ noticeItem.time }}</text>
  16. </view>
  17. <view class="notice_right">
  18. <view class="status_tag" :class="getStatusClass(noticeItem.noticeStatus)">
  19. <text>{{ getStatusText(noticeItem.noticeStatus) }}</text>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="reader_container">
  25. <view class="tabs_bar">
  26. <view class="tabs_left">
  27. <text v-for="(tab, idx) in tabs" :key="idx" class="tab_item" :class="{ active: activeTab === idx }"
  28. @click="handleTabChange(idx)">
  29. {{ tab }}
  30. </text>
  31. </view>
  32. <view class="search_box">
  33. <image src="/static/image/overview/search.png" class="search_icon"></image>
  34. <input type="text" class="search_input" placeholder="请输入关键字搜索"
  35. placeholder-class="search_placeholder" v-model="searchWord" @input="handleSearch" />
  36. </view>
  37. </view>
  38. <view class="stats_row">
  39. <text class="stats_text">共 {{ readerList.length }} 人</text>
  40. </view>
  41. <scroll-view v-if="filteredReaders.length > 0" scroll-y class="reader_list">
  42. <view v-for="item in filteredReaders" :key="item.id" class="reader_item">
  43. <view class="reader_row reader_row_first">
  44. <text class="reader_name">{{ item.name }}</text>
  45. <view class="read_status" :class="item.readStatus === 1 ? 'read' : 'unread'">
  46. <text>{{ item.readStatus === 1 ? '已读' : '未读' }}</text>
  47. </view>
  48. </view>
  49. <view class="reader_row reader_row_second">
  50. <!-- 部门 -->
  51. <text v-if="item.departmentName" class="reader_detail">{{ item.departmentName }}</text>
  52. <text v-if="item.groupName" class="reader_detail">{{ item.groupName }}</text>
  53. <!-- 班级 -->
  54. <text v-if="item.gradeName" class="reader_detail">{{ item.gradeName }}</text>
  55. <text v-if="item.classTypeName" class="reader_detail">{{ item.classTypeName }}</text>
  56. <text v-if="item.classTypeName" class="reader_detail">{{ item.classTypeName }}</text>
  57. <!-- 科目 -->
  58. <text v-if="item.subjectName" class="reader_detail">{{ item.subjectName }}</text>
  59. <text v-if="item.readTime" class="reader_detail">{{ item.readTime }}</text>
  60. </view>
  61. </view>
  62. </scroll-view>
  63. <no-data v-else centered text="暂无数据" />
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. <script setup>
  69. import { ref, computed, onMounted } from 'vue';
  70. import { onLoad } from '@dcloudio/uni-app';
  71. import uniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue';
  72. import overviewApi from '@/reqApi/overview.js';
  73. import NoData from '@/components/no-data.vue';
  74. import { useSafeArea } from '@/common/safeArea';
  75. const { statusBarHeight, safeAreaBottom, initSafeArea } = useSafeArea();
  76. const tabs = ['全部', '已读', '未读'];
  77. const activeTab = ref(0);
  78. const searchWord = ref('');
  79. const noticeItem = ref({
  80. title: '',
  81. category: '',
  82. department: '',
  83. time: '',
  84. noticeStatus: ''
  85. });
  86. const readerList = ref([]);
  87. const noticeId = ref('');
  88. const statusMap = {
  89. 0: '待发布',
  90. 1: '已发布',
  91. 2: '已关闭'
  92. };
  93. const statusClassMap = {
  94. 0: 'status-pending',
  95. 1: 'status-published',
  96. 2: 'status-closed'
  97. };
  98. const getStatusText = (status) => {
  99. return statusMap[status] || '';
  100. };
  101. const getStatusClass = (status) => {
  102. return statusClassMap[status] || '';
  103. };
  104. const filteredReaders = computed(() => {
  105. let list = readerList.value;
  106. if (activeTab.value === 1) {
  107. list = list.filter(item => item.readStatus === 1);
  108. } else if (activeTab.value === 2) {
  109. list = list.filter(item => item.readStatus !== 1);
  110. }
  111. if (searchWord.value) {
  112. const keyword = searchWord.value.toLowerCase();
  113. list = list.filter(item => item.name && item.name.toLowerCase().includes(keyword));
  114. }
  115. return list;
  116. });
  117. const fetchNoticeInfo = async () => {
  118. if (!noticeId.value) {
  119. return;
  120. }
  121. try {
  122. const res = await overviewApi.notices_edit({ id: noticeId.value });
  123. if (res.data) {
  124. noticeItem.value = {
  125. title: res.data.noticeName || '',
  126. category: res.data.typeName || '',
  127. department: res.data.createTeacherName || '',
  128. time: res.data.releaseTime || '',
  129. noticeStatus: res.data.noticeStatus
  130. };
  131. }
  132. } catch (error) {
  133. console.error('获取通知详情失败:', error);
  134. }
  135. };
  136. const fetchReaderList = async () => {
  137. try {
  138. const readStatusMap = [-1, 1, 0];
  139. const params = {
  140. id: noticeId.value,
  141. pageNum: 1,
  142. pageSize: 20,
  143. readStatus: readStatusMap[activeTab.value],
  144. word: searchWord.value || ''
  145. };
  146. const res = await overviewApi.user_page(params);
  147. if (res.data && res.data.records && res.data.records.length > 0 && res.data.records[0].userList) {
  148. readerList.value = res.data.records[0].userList;
  149. } else {
  150. readerList.value = [];
  151. }
  152. } catch (error) {
  153. console.error('获取读者列表失败:', error);
  154. readerList.value = [];
  155. }
  156. };
  157. const handleSearch = () => {
  158. fetchReaderList();
  159. };
  160. const handleTabChange = (idx) => {
  161. activeTab.value = idx;
  162. fetchReaderList();
  163. };
  164. const handleBack = () => {
  165. const pages = getCurrentPages();
  166. if (pages.length > 1) {
  167. const prevPage = pages[pages.length - 2];
  168. if (prevPage.route === 'pages/notice/overview/index') {
  169. uni.navigateBack();
  170. } else {
  171. uni.redirectTo({ url: '/pages/notice/overview/index' });
  172. }
  173. } else {
  174. uni.redirectTo({ url: '/pages/notice/overview/index' });
  175. }
  176. };
  177. onMounted(() => {
  178. initSafeArea();
  179. });
  180. onLoad((options) => {
  181. if (options && options.id) {
  182. noticeId.value = options.id;
  183. fetchNoticeInfo();
  184. fetchReaderList();
  185. }
  186. });
  187. </script>
  188. <style lang="scss" scoped>
  189. .notice_detail {
  190. width: 100%;
  191. height: 100vh;
  192. background-color: #F5F5F5;
  193. display: flex;
  194. flex-direction: column;
  195. position: fixed;
  196. top: 0;
  197. left: 0;
  198. z-index: 1000;
  199. .detail_header {
  200. display: flex;
  201. align-items: center;
  202. justify-content: space-between;
  203. padding-left: 24rpx;
  204. padding-right: 24rpx;
  205. padding-bottom: 24rpx;
  206. background-color: #FFFFFF;
  207. border-bottom: 2rpx solid #F3F3F3;
  208. .header_title {
  209. font-size: 32rpx;
  210. font-weight: 500;
  211. color: #333333;
  212. }
  213. .header_placeholder {
  214. width: 48rpx;
  215. }
  216. }
  217. .detail_content {
  218. flex: 1;
  219. display: flex;
  220. flex-direction: column;
  221. overflow: hidden;
  222. }
  223. .notice_info {
  224. background-color: #FFFFFF;
  225. padding: 32rpx 24rpx;
  226. margin-bottom: 16rpx;
  227. .notice_title {
  228. font-size: 32rpx;
  229. font-weight: 500;
  230. color: #333333;
  231. line-height: 1.5;
  232. display: block;
  233. margin-bottom: 16rpx;
  234. }
  235. .notice_meta {
  236. display: flex;
  237. align-items: center;
  238. justify-content: space-between;
  239. .notice_left {
  240. display: flex;
  241. align-items: center;
  242. gap: 16rpx;
  243. .meta_item {
  244. font-size: 24rpx;
  245. color: #999999;
  246. line-height: 48rpx;
  247. }
  248. }
  249. .notice_right {
  250. .status_tag {
  251. font-size: 24rpx;
  252. height: 48rpx;
  253. width: 96rpx;
  254. text-align: center;
  255. line-height: 48rpx;
  256. border-radius: 8rpx;
  257. font-weight: 400;
  258. &.status-pending {
  259. background: rgba(46, 100, 250, 0.1);
  260. color: #2E64FA;
  261. }
  262. &.status-published {
  263. background: rgba(82, 196, 26, 0.1);
  264. color: #2BC644;
  265. }
  266. &.status-closed {
  267. background: rgba(245, 108, 108, 0.1);
  268. color: #F56C6C;
  269. }
  270. }
  271. }
  272. }
  273. }
  274. .reader_container {
  275. background-color: #FFFFFF;
  276. border-radius: 8rpx;
  277. overflow: hidden;
  278. padding: 24rpx;
  279. flex: 1;
  280. display: flex;
  281. flex-direction: column;
  282. .tabs_bar {
  283. display: flex;
  284. align-items: center;
  285. gap: 48rpx;
  286. // border-bottom: 2rpx solid #EBEEF5;
  287. height: 72rpx;
  288. .tabs_left {
  289. display: flex;
  290. align-items: center;
  291. gap: 48rpx;
  292. .tab_item {
  293. font-size: 28rpx;
  294. color: #999999;
  295. font-weight: 400;
  296. position: relative;
  297. // margin-right: 48rpx;
  298. &.active {
  299. color: #2E64FA;
  300. font-weight: 500;
  301. font-size: 32rpx;
  302. &::after {
  303. content: '';
  304. position: absolute;
  305. bottom: -10rpx;
  306. left: 50%;
  307. transform: translateX(-50%);
  308. width: 64rpx;
  309. height: 4rpx;
  310. background-color: #2E64FA;
  311. // border-radius: 2rpx;
  312. }
  313. }
  314. }
  315. }
  316. .search_box {
  317. flex: 1;
  318. display: flex;
  319. align-items: center;
  320. // background-color: #F5F7FA;
  321. border-radius: 8rpx;
  322. border: 2rpx solid #DCDFE6;
  323. width: 320rpx;
  324. height: 72rpx;
  325. .search_icon {
  326. width: 32rpx;
  327. height: 32rpx;
  328. margin-left: 24rpx;
  329. margin-right: 8rpx;
  330. }
  331. .search_input {
  332. flex: 1;
  333. font-size: 28rpx;
  334. color: #333;
  335. margin-right: 32rpx;
  336. }
  337. .search_placeholder {
  338. color: #C0C4CC;
  339. }
  340. }
  341. }
  342. .stats_row {
  343. // padding: 0 24rpx;
  344. margin-bottom: 16rpx;
  345. margin-top: 24rpx;
  346. .stats_text {
  347. font-weight: 400;
  348. font-size: 28rpx;
  349. color: #333333;
  350. }
  351. }
  352. .reader_list {
  353. flex: 1;
  354. overflow-y: auto;
  355. display: flex;
  356. flex-direction: column;
  357. ::-webkit-scrollbar {
  358. display: none;
  359. }
  360. .reader_item {
  361. border-top: 2rpx solid #F3F3F3;
  362. padding: 24rpx 0;
  363. .reader_row {
  364. display: flex;
  365. align-items: center;
  366. gap: 16rpx;
  367. &.reader_row_first {
  368. justify-content: space-between;
  369. margin-bottom: 16rpx;
  370. }
  371. &.reader_row_second {
  372. flex-wrap: wrap;
  373. height: 34rpx;
  374. line-height: 34rpx;
  375. }
  376. .reader_name {
  377. font-size: 24rpx;
  378. font-weight: 500;
  379. color: #333333;
  380. }
  381. .reader_detail {
  382. font-size: 24rpx;
  383. color: #999999;
  384. }
  385. .read_status {
  386. padding: 8rpx 16rpx;
  387. border-radius: 8rpx;
  388. font-size: 24rpx;
  389. &.read {
  390. background: rgba(82, 196, 26, 0.1);
  391. color: #2BC644;
  392. }
  393. &.unread {
  394. background: rgba(46, 100, 250, 0.1);
  395. color: #2E64FA;
  396. }
  397. }
  398. }
  399. }
  400. }
  401. }
  402. }
  403. </style>