noticeDetail.vue 9.5 KB

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