tony.cheng
2026-03-16 38a38d54c66dfe6b85e26ba7f4f3cc3c70ad1814
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 [];
@@ -335,15 +341,26 @@
  // 定时轮询通话状态
  useEffect(() => {
    // 组件挂载时设置为 true
    isMountedRef.current = true;
    // 初始加载
    fetchCallStatus();
    
    // 设置轮询定时器(10秒间隔)
    const interval = setInterval(fetchCallStatus, POLL_INTERVAL);
    
    // 监听外呼任务更新事件(立即刷新)
    const handleOutboundJobsUpdated = () => {
      console.log('收到外呼任务更新事件,立即刷新');
      fetchCallStatus();
    };
    window.addEventListener('outbound-jobs-updated', handleOutboundJobsUpdated);
    // 清理函数
    return () => {
      clearInterval(interval);
      window.removeEventListener('outbound-jobs-updated', handleOutboundJobsUpdated);
      isMountedRef.current = false;
    };
  }, [fetchCallStatus]);
@@ -384,6 +401,11 @@
    // 其他状态的任务正常显示
    return true;
  });
  // 如果没有活跃任务且不可见,不渲染任何内容
  if (activeCalls.length === 0 && !isVisible) {
    return null;
  }
  // 如果最小化,显示AI客服图标
  if (isMinimized) {
@@ -555,14 +577,14 @@
              {call.errorCode > 0 ? (
                // 失败任务显示
                <span>
                  {call.perClassName || '联系人'}
                  {call.perTypeName || '联系人'}
                  {call.trueName && `(${call.trueName})`}:
                  {call.message}
                </span>
              ) : (
                // 成功任务显示
                // 成功任务显示 - 使用 perTypeName 字段(申请方当事人/被申请方当事人)
                <span>
                  正在与{call.perClassName || '申请方'}({call.trueName || call.personId})电话沟通中...
                  正在与{call.perTypeName || '申请方当事人'}({call.trueName || call.personId})电话沟通中...
                </span>
              )}
            </div>