Browse Source

软电话版本

吴树波 2 weeks ago
parent
commit
839be548c2

+ 25 - 5
src/components/FloatingSoftPhone/index.vue

@@ -420,6 +420,7 @@ export default {
       _ccReconnectTimer: null,
       _ccReconnectAttempts: 0,
       _isDestroying: false,
+      _ccEventsBoundFor: null,
 
       // ===== 坐席状态 =====
       isCallingReady: false,
@@ -1054,6 +1055,8 @@ export default {
       }
     },
     _bindCCEvents() {
+      if (this._ccEventsBoundFor === this.ccPhoneBar) return;
+      this._ccEventsBoundFor = this.ccPhoneBar;
       this.ccPhoneBar.on(EventList.WS_CONNECTED, () => {
         // 注册为共享实例,供其他组件复用
         window.__sharedCCPhoneBar = this.ccPhoneBar;
@@ -1402,11 +1405,27 @@ export default {
         this._scheduleCCReconnect();
         return;
       }
-      // 通知弹窗组件通过其phoneBar执行外呼(走弹窗完整的通话记录、客户信息流程)
-      // 不再通过浮动电话自己的ccPhoneBar.call()拨号,避免创建独立通话
-      this.$root.$emit('floating-softphone-call-triggered', phoneNumber);
-      this.delegatedCallActive = true;
-      this.showStatus('拨号中...', 'info');
+      if (!this.isCallingReady) {
+        this.showStatus('坐席未就绪,请稍候', 'warn');
+        return;
+      }
+
+      // 人工外呼弹窗打开时,委托弹窗 phoneBar(含通话记录、工作流等业务逻辑)
+      if (window.__floatingPhoneCallDelegateActive) {
+        this.$root.$emit('floating-softphone-call-triggered', phoneNumber);
+        this.delegatedCallActive = true;
+        this.showStatus('拨号中...', 'info');
+        return;
+      }
+
+      // 普通页面:使用浮动软电话自身的 ccPhoneBar 直接外呼
+      try {
+        this.delegatedCallActive = false;
+        this.ccPhoneBar.call(phoneNumber, 'audio', VideoLevels.HD.levelId);
+      } catch (err) {
+        console.error('[FloatingSoftPhone] 外呼失败:', err);
+        this.showStatus('拨号失败', 'error');
+      }
     },
     endCall() {
       if (this.callStatus === UI_STATE.IDLE) { this.showStatus('当前无通话', 'warn'); return; }
@@ -1669,6 +1688,7 @@ export default {
           }
         }
         this.ccPhoneBar = null;
+        this._ccEventsBoundFor = null;
       }
       this.callUuidMap = {};
       this.currentCallUuid = '';

+ 5 - 0
src/components/ManualCallDialog/index.vue

@@ -49,6 +49,9 @@ export default {
       workflowInstanceId: null
     };
   },
+  beforeDestroy() {
+    window.__floatingPhoneCallDelegateActive = false;
+  },
   methods: {
     /**
      * 打开外呼弹窗
@@ -71,6 +74,7 @@ export default {
       this.title = `人工外呼 - ${options.customerName || '未知客户'}`;
       this.dialogKey += 1;
       this.dialogVisible = true;
+      window.__floatingPhoneCallDelegateActive = !!this.useFloatingPhone;
 
       // 浮动软电话模式:同步弹出浮动电话并填充号码
       if (this.useFloatingPhone && this.phone) {
@@ -81,6 +85,7 @@ export default {
       }
     },
     handleClose() {
+      window.__floatingPhoneCallDelegateActive = false;
       this.phone = '';
       this.customerId = null;
       this.companyId = null;

+ 7 - 5
src/views/aiSipCall/aiSipCallManualOutbound.vue

@@ -1513,11 +1513,13 @@ export default {
                     return;
                 }
             }
-            // 检查外呼按钮状态
-            const callBtn = document.getElementById('callBtn');
-            if (!callBtn || !callBtn.classList.contains('on')) {
-                this.$message.warning('当前无法外呼,请先置忙');
-                return;
+            // 工具条可见时依赖 DOM 按钮状态;浮动软电话模式下 UI 隐藏,改由连接状态判断
+            if (!this.hidePhoneBar) {
+                const callBtn = document.getElementById('callBtn');
+                if (!callBtn || !callBtn.classList.contains('on')) {
+                    this.$message.warning('当前无法外呼,请先置忙');
+                    return;
+                }
             }
             // 检查当前是否有通话
             if (this.phoneBar.getCallConnected()) {