Эх сурвалжийг харах

reactor:兴唐监听,强插,强拆

zhangchong 1 сар өмнө
parent
commit
a6e9f309d5

+ 101 - 1
src/views/seats/XTHeader.vue

@@ -117,7 +117,6 @@ import { computed, onMounted, onUnmounted, reactive, ref, watch } from "vue";
 import signalR from "@/utils/signalR";
 import { useNow, useTitle } from "@vueuse/core";
 import { formatDate } from "@/utils/formatTime";
-import { olaFn } from "@/utils/olaFn";
 import { getNowDateTime } from "@/utils/constants";
 import { callCenterLogout, useGlobalState } from "@/utils/callCenter";
 import { ElMessage, ElMessageBox, FormInstance } from "element-plus";
@@ -240,6 +239,22 @@ const e_TelMsgReceive = (ws: any, restMsg: any) => {
         // 三方会议
         case "ResMonConf":
           break;
+        // 监听
+        case "ResMonListen":
+          retResMonListen(data);
+          break;
+        // 取消监听返回
+        case "ResStopListen":
+          retResStopListen(data);
+          break;
+        // 强插返回
+        case "ResMonInterpose":
+          resMonInterpose(data);
+          break;
+        // 强拆返回
+        case "ResMonCut":
+          resMonCut(data);
+          break;
       }
       // 事件
       const strEvent = data.Event;
@@ -428,6 +443,11 @@ const clickOnDuty = (formEl: FormInstance | undefined) => {
     if (!valid) return;
     m_strUserNo.value = state.dutyForm.currentTel;
     m_strJobNum.value = state.dutyForm.currentTel; // 默认取用户工号
+    globalState.currentTel = {
+      telNo: m_strUserNo.value, // 分机号
+      telGroup: m_strSkillId.value, // 分机组
+      jobNum: m_strUserNo.value, // 工号
+    };
     initWs();
     state.dutyDialogVisible = false;
   });
@@ -530,6 +550,86 @@ const retSignOut = () => {
   wsRef.value.close();
   console.log(`${getNowDateTime()} 呼叫中心签出回调`);
 };
+/*
+ * 监听
+ */
+const reqMonListen = (strTargetNum: string) => {
+  const objMsg = {
+    Action: "ReqMonListen",
+    Param: {
+      Extension: m_strUserNo.value,
+      TargetExtension: strTargetNum,
+    },
+  };
+  // 发送请求
+  e_TelSendMsg(objMsg);
+};
+/*
+ * 监听返回
+ */
+const retResMonListen = (data: any) => {
+  console.log(data, "监听返回");
+};
+/*
+ * 取消监听
+ */
+const reqStopListen = (strTargetNum: string) => {
+  const objMsg = {
+    Action: "ReqStopListen",
+    Param: {
+      Extension: m_strUserNo.value,
+      TargetExtension: strTargetNum,
+    },
+  };
+  // 发送请求
+  e_TelSendMsg(objMsg);
+};
+/*
+ * 取消监听返回
+ */
+const retResStopListen = (data: any) => {
+  console.log(data, "取消监听返回");
+};
+/*
+ * 强插
+ */
+const reqMonInterpose = (strTargetNum: string) => {
+  const objMsg = {
+    Action: "ReqMonInterpose",
+    Param: {
+      Extension: m_strUserNo.value,
+      TargetExtension: strTargetNum,
+    },
+  };
+  // 发送请求
+  e_TelSendMsg(objMsg);
+};
+/*
+ * 强插返回
+ */
+const resMonInterpose = (data: any) => {
+  console.log(data, "强插返回");
+};
+/*
+ * 强拆
+ */
+const reqMonCut = (strTargetNum: string) => {
+  const objMsg = {
+    Action: "ReqMonCut",
+    Param: {
+      Extension: m_strUserNo.value,
+      TargetExtension: strTargetNum,
+    },
+  };
+  // 发送请求
+  e_TelSendMsg(objMsg);
+};
+/*
+ * 强拆返回
+ */
+const resMonCut = (data: any) => {
+  console.log(data, "强拆返回");
+};
 /**
  * 异常处理
  * @param {any} data

+ 68 - 11
src/views/seats/XTRight.vue

@@ -36,7 +36,8 @@
             <template #dropdown>
               <el-dropdown-menu>
                 <el-dropdown-item command="listen">监 听</el-dropdown-item>
-                <el-dropdown-item command="interject">插 话</el-dropdown-item>
+                <el-dropdown-item command="interject">强 插</el-dropdown-item>
+                <el-dropdown-item command="cut">强 拆</el-dropdown-item>
               </el-dropdown-menu>
             </template>
           </el-dropdown>
@@ -93,7 +94,7 @@
 import { onMounted, ref, nextTick, onBeforeUnmount, watch } from "vue";
 import { getImageUrl, throttle } from "@/utils/tools";
 import signalR from "@/utils/signalR";
-import { ClickOutside as vClickOutside } from "element-plus";
+import { ClickOutside as vClickOutside, ElMessage } from "element-plus";
 import { formatDuration } from "@/utils/formatTime";
 import dayjs from "dayjs";
 import { getExtensionStatus } from "api/seats";
@@ -101,6 +102,7 @@ import { useIntervalFn } from "@vueuse/core";
 import { useGlobalState } from "@/utils/callCenter";
 import { Operation } from "@element-plus/icons-vue";
 import mittBus from "@/utils/mitt";
+import { getNowDateTime } from "@/utils/constants";
 
 const props = defineProps({
   data: {
@@ -114,7 +116,6 @@ const textRef = ref();
 const popoverRef = ref();
 const hidePopover = ref(false);
 const call = ref<EmptyObjectType>({});
-const globalState = useGlobalState();
 // 开始签入时长
 const talkTime = ref<any>(0); // 通话时长
 const talkTimer = ref<any>(null); // 通话时长定时器
@@ -280,21 +281,77 @@ onMounted(async () => {
     }
   });
 });
+// 发送消息
+const globalState = useGlobalState();
+const e_TelSendMsg = (strObj: Object) => {
+  // 客户端当前时间
+  const strMsg = JSON.stringify(strObj);
+  console.log(
+    `${getNowDateTime()} 发送消息:`,
+    strMsg,
+    globalState.callCenterWs.status
+  );
+  if (globalState.callCenterWs.ws?.readyState === 1) {
+    // 已经链接并且可以通讯,则发放文本消息
+    globalState.callCenterWs.send(strMsg);
+  } else {
+    ElMessage.error("请先签入");
+  }
+};
+/*
+ * 监听
+ */
+const reqMonListen = (strTargetNum: string) => {
+  const objMsg = {
+    Action: "ReqMonListen",
+    Param: {
+      Extension: globalState.currentTel.telNo,
+      TargetExtension: strTargetNum,
+    },
+  };
+  // 发送请求
+  e_TelSendMsg(objMsg);
+};
+/*
+ * 强插
+ */
+const reqMonInterpose = (strTargetNum: string) => {
+  const objMsg = {
+    Action: "ReqMonInterpose",
+    Param: {
+      Extension: globalState.currentTel.telNo,
+      TargetExtension: strTargetNum,
+    },
+  };
+  // 发送请求
+  e_TelSendMsg(objMsg);
+};
+/*
+ * 强拆
+ */
+const reqMonCut = (strTargetNum: string) => {
+  const objMsg = {
+    Action: "reqMonCut",
+    Param: {
+      Extension: globalState.currentTel.telNo,
+      TargetExtension: strTargetNum,
+    },
+  };
+  // 发送请求
+  e_TelSendMsg(objMsg);
+};
 // 监听和插话消息
 const handleCommand = (command: string, item: any) => {
   console.log(command, item);
   if (command === "listen") {
     // 监听
-    globalState.callCenterWs.monitor(
-      item.telNo,
-      globalState.callCenterWs.username
-    );
+    reqMonListen(item.telNo);
   } else if (command === "interject") {
     // 强插
-    globalState.callCenterWs.intercept(
-      item.telNo,
-      globalState.callCenterWs.username
-    );
+    reqMonInterpose(item.telNo);
+  } else if (command === "cut") {
+    // 强拆
+    reqMonCut(item.telNo);
   }
 };
 onBeforeUnmount(() => {