canghailong 6 месяцев назад
Родитель
Сommit
96ee719b66

+ 15 - 4
src/views/student/In-site-message/detail.vue

@@ -2,7 +2,7 @@
 	<xn-form-container title="详情" :width="700" :visible="visible" :destroy-on-close="true" @close="onClose">
 		<a-descriptions :column="1" size="middle" bordered class="mb-2">
 			<a-descriptions-item label="主题">{{ formData.subject }}</a-descriptions-item>
-			<a-descriptions-item label="发送时间">{{ formData.createTime }}</a-descriptions-item>
+			<a-descriptions-item label="发送时间">{{ formatDateTime(formData.createTime) }}</a-descriptions-item>
 		</a-descriptions>
 		<a-form ref="formRef" :model="formData" layout="vertical">
 			<a-form-item label="内容:" name="content">
@@ -17,7 +17,7 @@
 					:showPagination="false"
 					bordered
 					:row-key="(record) => record.id"
-					:scroll="{x:'auto'}"
+					:scroll="{ x: 'auto' }"
 				>
 					<template #bodyCell="{ column, record }">
 						<template v-if="column.dataIndex === 'read'">
@@ -33,9 +33,15 @@
 
 <script setup name="inSiteMessageDetail">
 	import userCenterApi from '@/api/sys/userCenterApi'
+	import classCentre from '@/api/student/classCentre'
 	import EventBus from '@/utils/EventBus'
 	const emits = defineEmits(['refresh'])
 	const receiveInfoList = ref([])
+	import { parseTime } from '@/utils/exam'
+	function formatDateTime(val) {
+		if (!val) return ''
+		return parseTime(val, '{y}-{m}-{d} {h}:{i}:{s}')
+	}
 
 	// 默认是关闭状态
 	let visible = $ref(false)
@@ -65,10 +71,12 @@
 			id: record.id
 		}
 		userCenterApi.userLoginUnreadMessageDetail(param).then((data) => {
-			Object.assign(record, data)
-			formData.value = record
+			formData.value = Object.assign(record, data)
 			receiveInfoList.value = data.receiveInfoList
 			table.value.refresh(true)
+			if (!formData.value.read) {
+				addRead()
+			}
 		})
 	}
 	const loadData = () => {
@@ -76,6 +84,9 @@
 			resolve(receiveInfoList.value)
 		})
 	}
+	const addRead = () => {
+		classCentre.readAdd({ funcType: 2, mainId: formData.value.id })
+	}
 	// 关闭抽屉
 	const onClose = () => {
 		receiveInfoList.value = []

+ 7 - 10
src/views/student/classNotice/detail.vue

@@ -8,7 +8,7 @@
 				<span v-else style="color: #ff4d4f">未读</span>
 			</a-descriptions-item>
 			<a-descriptions-item label="内容">
-				<div style="width: 450px;">{{ formData.content }}</div>
+				<div style="width: 450px">{{ formData.content }}</div>
 			</a-descriptions-item>
 		</a-descriptions>
 	</xn-form-container>
@@ -18,14 +18,12 @@
 	import classCentre from '@/api/student/classCentre'
 	import EventBus from '@/utils/EventBus'
 	const emits = defineEmits(['refresh'])
-	const detailObj = ref()
 	// 默认是关闭状态
 	let visible = $ref(false)
 	const formData = ref({})
 	// 打开抽屉
 	const onOpen = (record) => {
 		visible = true
-		detailObj.value = record
 		getMessageList(record)
 	}
 	// 获取站内信列表
@@ -34,15 +32,14 @@
 			noticeId: record.noticeId
 		}
 		classCentre.classNoticeDetail(param).then((data) => {
-			Object.assign(record, data)
-			formData.value = record
+			formData.value = Object.assign(record, data)
+			if (!formData.value.read) {
+				addRead()
+			}
 		})
-		if(!formData.value.read){
-			addRead()
-		}
 	}
-	const addRead =()=>{
-		classCentre.readAdd({funcType:2,mainId:detailObj.value.noticeId})
+	const addRead = () => {
+		classCentre.readAdd({ funcType: 2, mainId: formData.value.noticeId })
 	}
 	// 关闭抽屉
 	const onClose = () => {