Sfoglia il codice sorgente

叮当国医-会话审计-区分单聊与群聊

cgp 1 giorno fa
parent
commit
ba0eed9f1c

+ 3 - 3
src/api/qw/companySession.js

@@ -21,12 +21,12 @@ export function qwSignature({ url, corpid }) {
   });
 }
 
-// 获取会话记录
-export function qwConversations({ customerId, staffUserId, limit, cursor, corpid }) {
+// 获取会话记录(支持单聊和群聊)
+export function qwConversations({ customerId, staffUserId, limit, cursor, corpid, chatId }) {
   return request({
     url: '/weChatSpace/conversations',
     method: 'get',
-    params: { customerId, staffUserId, limit, cursor, corpid }
+    params: { customerId, staffUserId, limit, cursor, corpid, chatId }
   });
 }
 

+ 9 - 1
src/views/qw/conversationNew/ContentSearchTab.vue

@@ -79,6 +79,7 @@
           :corpId="corpId"
           :customerId="currentCustomerId"
           :staffUserId="currentStaffUserId"
+          :chatId="currentChatId"
           @logout="handleLogout"
         />
       </div>
@@ -147,6 +148,7 @@ export default {
       drawerVisible: false,
       currentStaffUserId: null,
       currentCustomerId: null,
+      currentChatId: null,
       pickerOptions: {
         disabledDate(time) {
           // 只能选择最近31天内的日期
@@ -325,10 +327,15 @@ export default {
     },
 
     openContextDrawer(row) {
+      // 群聊:传 chatId 查看整个群的消息
       if (row.chatid) {
-        this.$message.info("暂不支持群聊上下文查看");
+        this.currentStaffUserId = null;
+        this.currentCustomerId = 'chat_' + row.chatid; // chat_ 前缀在 fetchConversations 中识别
+        this.currentChatId = row.chatid;
+        this.drawerVisible = true;
         return;
       }
+      // 单聊:传员工+客户
       let staffId = null, customerId = null;
       if (row.sender.type === 1) staffId = row.sender.id;
       if (row.sender.type === 2) customerId = row.sender.id;
@@ -339,6 +346,7 @@ export default {
       if (staffId && customerId) {
         this.currentStaffUserId = staffId;
         this.currentCustomerId = customerId;
+        this.currentChatId = null;
         this.drawerVisible = true;
       } else {
         this.$message.warning("无法确定会话双方");

+ 19 - 11
src/views/qw/conversationNew/ConversationPanelPure.vue

@@ -15,13 +15,13 @@
       <div class="login-tip">请扫码登录企微</div>
       <div id="login-container" ref="loginContainer" class="login-container"></div>
     </div>
-    <!-- 已登录但未选择员工 -->
-    <div v-else-if="!staffUserId" class="empty-tip">
+    <!-- 已登录但未选择员工(群聊不需要员工) -->
+    <div v-else-if="!staffUserId && !chatId" class="empty-tip">
       <i class="el-icon-info"></i>
       <p>请选择员工</p>
     </div>
-    <!-- 已登录但未选择客户 -->
-    <div v-else-if="!customerId" class="empty-tip">
+    <!-- 已登录但未选择客户(群聊不需要客户) -->
+    <div v-else-if="!customerId && !chatId" class="empty-tip">
       <i class="el-icon-info"></i>
       <p>请选择客户查看会话</p>
     </div>
@@ -69,7 +69,8 @@ export default {
   props: {
     corpId: { type: String, default: null },
     customerId: { type: String, default: null },
-    staffUserId: { type: String, default: null }
+    staffUserId: { type: String, default: null },
+    chatId: { type: String, default: null }
   },
   data() {
     return {
@@ -94,7 +95,7 @@ export default {
   },
   watch: {
     customerId(newId, oldId) {
-      if (newId && newId !== oldId && this.isLoggedIn && this.staffUserId && this.configReady && !this.configError) {
+      if (newId && newId !== oldId && this.isLoggedIn && (this.staffUserId || this.chatId) && this.configReady && !this.configError) {
         this.resetAndReload();
       }
     },
@@ -103,6 +104,11 @@ export default {
         this.resetAndReload();
       }
     },
+    chatId(newVal, oldVal) {
+      if (newVal && newVal !== oldVal && this.isLoggedIn && this.configReady && !this.configError) {
+        this.resetAndReload();
+      }
+    },
     corpId(newId, oldId) {
       if (newId !== oldId) {
         this.destroyChat();
@@ -256,7 +262,7 @@ export default {
           await this.handleLogin(code);
           this.storeLoginState(this.corpId);
           this.isLoggedIn = true;
-          if (this.customerId && this.staffUserId) await this.loadFirstPage();
+          if ((this.customerId && this.staffUserId) || this.chatId) await this.loadFirstPage();
         } catch (err) {
           this.clearLoginState(this.corpId);
           this.isLoggedIn = false;
@@ -265,7 +271,7 @@ export default {
       } else {
         if (this.checkLoginState(this.corpId)) {
           this.isLoggedIn = true;
-          if (this.customerId && this.staffUserId) await this.loadFirstPage();
+          if ((this.customerId && this.staffUserId) || this.chatId) await this.loadFirstPage();
         } else {
           this.isLoggedIn = false;
           this.safeEmitLogout();
@@ -308,7 +314,7 @@ export default {
           onLoginSuccess: async ({ code }) => {
             try {
               await this.handleLogin(code);
-              if (this.customerId && this.staffUserId) await this.loadFirstPage();
+              if ((this.customerId && this.staffUserId) || this.chatId) await this.loadFirstPage();
             } catch (e) {
               this.clearLoginState(this.corpId);
               this.isLoggedIn = false;
@@ -386,7 +392,8 @@ export default {
           staffUserId: this.staffUserId,
           limit: 100,
           cursor: this.cursor,
-          corpid: this.corpId
+          corpid: this.corpId,
+          chatId: this.chatId || undefined
         });
         const data = this._extractResponse(res);
         if (data.errcode !== 0) throw new Error(data.errmsg || '拉取失败');
@@ -414,7 +421,8 @@ export default {
           staffUserId: this.staffUserId,
           limit: 50,
           cursor: this.cursor,
-          corpid: this.corpId
+          corpid: this.corpId,
+          chatId: this.chatId || undefined
         });
         const data = this._extractResponse(res);
         if (data.errcode !== 0) throw new Error(data.errmsg || '拉取更多失败');