noticeDetail.vue 9.8 KB

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