Просмотр исходного кода

fix(message):修复一键已读只能读当前显示出来的消息,未读数为空时隐藏
refactor(components/attachmentList):附件复制链接取消弹出层

HMY 1 год назад
Родитель
Сommit
0fb2a77f30
3 измененных файлов с 63 добавлено и 41 удалено
  1. 11 16
      components/ygoa/attachmentList.vue
  2. 16 2
      components/ygoa/messageList.vue
  3. 36 23
      pages/message/index.vue

+ 11 - 16
components/ygoa/attachmentList.vue

@@ -5,7 +5,7 @@
 		<uni-row :gutter="0">
 			<uni-col v-for="(attachment, index) in attachments" :key="index" :xs="{span: 24}" :sm="6">
 				<view class="attachment">
-					<text @click="seeAttachment(attachment.path)">{{ attachment.fileName.length > 10 ? attachment.fileName.substring(0, 10) + '...' : attachment.fileName || '附件名为空' }}</text>
+					<text @click="seeAttachment(attachment.path)" class="text-ellipsis">{{ attachment.fileName || '附件名为空' }}</text>
 					<view class="icon-container">
 						<uni-icons @click="shareAttachment(attachment.path)" :size="14" color="#2196f3" type="redo-filled"
 							style="margin-left:10px;">分享</uni-icons>
@@ -100,21 +100,10 @@
 
 	//复制下载链接
 	function copyAttachment(path) {
-		// 显示操作菜单,引导用户复制链接
-		wx.showActionSheet({
-			itemList: ['复制下载链接'],
-			success: function (res) {
-				if (res.tapIndex === 0) {
-					wx.setClipboardData({
-						data: config.baseUrlPre + path,
-						success: function (res) {
-							wx.showToast({
-								title: '下载链接已复制',
-								icon: 'success'
-							});
-						}
-					});
-				}
+		wx.setClipboardData({
+			data: config.baseUrlPre + path,
+			success:  (res)=> {
+				$modal.msgSuccess('下载链接已复制')
 			}
 		});
 	}
@@ -138,4 +127,10 @@
 		justify-content: flex-end;
 		/* 使图标靠右 */
 	}
+	.text-ellipsis{
+		white-space: nowrap;
+		  overflow: hidden;
+		  text-overflow: ellipsis;
+		  max-width: 22vh;
+	}
 </style>

+ 16 - 2
components/ygoa/messageList.vue

@@ -6,7 +6,7 @@
 					<uni-section :title="title" type="line" titleFontSize="1.3rem">
 						<template v-slot:right>
 							<uni-badge :text="unReadNum" style="margin-left: -10px;" v-if="unReadNum!==undefined&&unReadNum>0"></uni-badge>
-							<button @click.stop="clickReadButton" class="read_button" v-if="unReadNum!==undefined">一键阅读</button>
+							<button @click.stop="clickReadButton" class="read_button" v-if="unReadNum!==undefined" :disabled="unReadNum===0?true:false">一键阅读</button>
 						</template>
 					</uni-section>
 				</template>
@@ -110,12 +110,17 @@ function complete(list, total, pageNo) {
 		paging.value.complete([])
 	}
 }
+
+function reload() {
+	paging.value.reload()
+}
+
 // 点击分段器
 const current = ref(props.defaultCurrent)
 function onClickItem({ currentIndex }) {
 	current.value = currentIndex
 	// 重新加载数据 pageNo恢复为默认值
-	paging.value.reload()
+	reload();
 }
 
 // 刷新
@@ -182,6 +187,9 @@ function isInTimeRange(inputDate) {
 	return inputTime >= startTime && inputTime <= endTime;
 }
 
+defineExpose({
+	reload,
+});
 </script>
 
 <style lang="scss">
@@ -203,6 +211,12 @@ function isInTimeRange(inputDate) {
 		background-color: #007aff;
 		color: #fff;
 	}
+	.read_button[disabled] {
+	  background-color: #f5f5f5; 
+	  color: #666;           
+	  opacity: 0.5;             
+	}
+
 	.message_container {
 		border-left: #7b7b7b .4rem solid;
 

+ 36 - 23
pages/message/index.vue

@@ -28,7 +28,7 @@
 			title="公告"></message-list>
 
 		<!-- 消息列表 -->
-		<message-list @readMsg="setMsgRead" :unReadNum="unReadNum" :list="messages" @clickSegment="getMessageData"
+		<message-list ref="msgListRef" @readMsg="setMsgRead" :unReadNum="unReadNum" :list="messages" @clickSegment="getMessageData"
 			@clickItem="handleToMessageDetail" @scrollToBottom="getMessagePage" :defaultCurrent="1" :pSize="5"
 			:pageNo="1" :anime="true" :open="true" :segments="{ '全部': '', '未读': '0', '已读': '1' }"
 			title="消息"></message-list>
@@ -43,7 +43,7 @@
 </template>
 
 <script setup lang="ts">
-	import { onMounted, ref } from 'vue';
+	import { onBeforeMount, onMounted, ref } from 'vue';
 	import { onLoad } from '@dcloudio/uni-app'
 	import { getMessageList, getNoticeList, getUnReadMessageNum, setMsgIsRead } from '@/api/message.js';
 	import { getUserProcess, getUnProcessNum } from '@/api/process';
@@ -57,6 +57,9 @@
 	onLoad((options) => {
 		// 是否跳转打卡页
 		if (options.to == 'clockIn') toClockIn()
+	})
+	onBeforeMount(()=>{
+		
 	})
 	onMounted(() => {
 		showTarBarBadge();
@@ -69,30 +72,41 @@
 		})
 	}
 
-	//所有未读消息的ids
-	const unReadMsgIds = ref('')
+//子组件
+	const msgListRef=ref(null)
 	//设置消息已读
 	function setMsgRead() {
-		setMsgIsRead(unReadMsgIds.value).then((res) => {
-			if (Number.isInteger(res)) {
-				switch (res) {
-					case -1:
-						$modal.msgError('操作失败')
-						break
-					case -2:
-						$modal.msg('不存在未读消息')
-						break
-					default:
-						$modal.msgSuccess('操作成功')
-						//刷新页面
-						setTimeout(() => {
-							$tab.reLaunch('/pages/message/index')
-						}, 1000)
+		const params = {
+			currentUser: userStore.user.useId,
+			isRead: "0",
+			pSize: unReadNum.value,
+			type: "",
+			p: 1,
+		}
+		getMessageList(params).then(({ returnParams }) => {
+			const unReadMsgIds= returnParams.ids === "" ? "" : returnParams.ids + ",";
+			setMsgIsRead(unReadMsgIds).then((res) => {
+				if (Number.isInteger(res)) {
+					switch (res) {
+						case -1:
+							$modal.msgError('操作失败')
+							break
+						case -2:
+						case 0:
+							$modal.msg('不存在未读消息')
+							break
+						default:
+							$modal.msgSuccess('操作成功')
+							//刷新页面
+							msgListRef.value.reload();// 调用子组件刷新数据
+							showTarBarBadge();
+					}
+				} else {
+					$modal.msgError('jssesionid失效')
 				}
-			} else {
-				$modal.msgError('jssesionid失效,请重新登录')
-			}
+			})
 		})
+		
 	}
 
 	// 待办列表
@@ -191,7 +205,6 @@
 				// return item
 			})
 			messages.value = returnParams.list;
-			unReadMsgIds.value = returnParams.ids === "" ? "" : returnParams.ids + ",";
 			// 通知子组件加载完成
 			callback(returnParams.list, returnParams.total, pageNo)
 		})