From 0c8432f4ff5c95faca4ca62d6a4ec4618feba627 Mon Sep 17 00:00:00 2001
From: tony.cheng <chengmingwei_1984122@126.com>
Date: Tue, 17 Mar 2026 15:31:29 +0800
Subject: [PATCH] feat: 完善AI调解状态控制功能及相关文档更新

---
 web-app/src/components/common/OutboundCallWidget.jsx |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/web-app/src/components/common/OutboundCallWidget.jsx b/web-app/src/components/common/OutboundCallWidget.jsx
index b629583..9bead7c 100644
--- a/web-app/src/components/common/OutboundCallWidget.jsx
+++ b/web-app/src/components/common/OutboundCallWidget.jsx
@@ -110,8 +110,14 @@
         }
       });
       
+      // 获取成功任务的 personId 集合
+      const successPersonIds = new Set(successJobs.map(job => job.personId));
+      
+      // 过滤掉已有成功任务的 personId 对应的失败任务(成功任务优先)
+      const filteredFailedJobs = uniqueFailedJobs.filter(job => !successPersonIds.has(job.personId));
+      
       // 合并所有任务
-      return [...successJobs, ...uniqueFailedJobs];
+      return [...successJobs, ...filteredFailedJobs];
     } catch (err) {
       console.error('读取外呼任务失败:', err);
       return [];
@@ -351,10 +357,22 @@
     };
     window.addEventListener('outbound-jobs-updated', handleOutboundJobsUpdated);
     
+    // 监听调解终止事件(关闭外呼气泡)
+    const handleMediationTerminated = () => {
+      console.log('收到调解终止事件,关闭外呼气泡');
+      setIsVisible(false);
+      setIsMinimized(true);
+      // 清空localStorage中的外呼任务
+      localStorage.removeItem(OUTBOUND_JOBS_KEY);
+      setCalls([]);
+    };
+    window.addEventListener('mediation-terminated', handleMediationTerminated);
+    
     // 清理函数
     return () => {
       clearInterval(interval);
       window.removeEventListener('outbound-jobs-updated', handleOutboundJobsUpdated);
+      window.removeEventListener('mediation-terminated', handleMediationTerminated);
       isMountedRef.current = false;
     };
   }, [fetchCallStatus]);

--
Gitblit v1.8.0