聊天室创建工单

This commit is contained in:
2025-12-24 19:50:38 +08:00
parent a613eb4fa1
commit 41bc41cfcd
18 changed files with 519 additions and 108 deletions

View File

@@ -106,6 +106,7 @@
<script setup lang="ts">
import { ref, reactive, computed, nextTick, onMounted, onUnmounted, watch } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import type { ChatRoomMessageVO, CustomerVO, ChatMemberVO, TbChatRoomMessageDTO } from '@/types/workcase'
import { workcaseChatAPI } from '@/api/workcase'
import { wsClient } from '@/utils/websocket'
@@ -232,6 +233,11 @@ onMounted(() => {
initWebSocket()
})
// 页面显示时重新查询聊天室信息(从工单页返回时会自动刷新)
onShow(() => {
refreshChatRoomInfo()
})
// 组件卸载时断开WebSocket
onUnmounted(() => {
disconnectWebSocket()
@@ -253,6 +259,21 @@ watch(roomId, (newRoomId, oldRoomId) => {
const PAGE_SIZE = 20
const messageTotal = ref<number>(0)
// 刷新聊天室信息(仅更新 workcaseId 等基本信息,不重新加载消息)
async function refreshChatRoomInfo() {
if (!roomId.value) return
try {
const roomRes = await workcaseChatAPI.getChatRoomById(roomId.value)
if (roomRes.success && roomRes.data) {
roomName.value = roomRes.data.roomName || '聊天室'
workcaseId.value = roomRes.data.workcaseId || ''
messageTotal.value = roomRes.data.messageCount || 0
}
} catch (e) {
console.error('刷新聊天室信息失败:', e)
}
}
async function loadChatRoom() {
if (!roomId.value) return
loading.value = true