浏览代码

reactor:坐席辅助调整;

zhangchong 1 年之前
父节点
当前提交
82e0321ed1
共有 3 个文件被更改,包括 59 次插入50 次删除
  1. 50 7
      src/layout/navBars/breadcrumb/telControl.vue
  2. 1 0
      src/types/mitt.d.ts
  3. 8 43
      src/views/todo/seats/accept/Voice-assistant.vue

+ 50 - 7
src/layout/navBars/breadcrumb/telControl.vue

@@ -1,6 +1,6 @@
 <template>
 	<div class="phoneControls" v-loading="state.loading">
-    <!-- 电话状态 -->
+		<!-- 电话状态 -->
 		<div class="infos">
 			<div class="pt5" :class="talkTime ? '' : 'mt8'"><span>分机号:</span>{{ telStatusInfo.telsNo }}</div>
 			<div class="pt5" :class="talkTime ? '' : 'mt8'">
@@ -10,7 +10,7 @@
 				<span>通话时长:</span> <el-text tag="b" type="danger">{{ formatDuration(talkTime, false) }}</el-text>
 			</div>
 		</div>
-    <!--  按钮列表  -->
+		<!--  按钮列表  -->
 		<div class="btn-container">
 			<!-- 签入 -->
 			<template v-if="telStatusInfo.isDutyOn">
@@ -235,11 +235,11 @@
 				</div>
 			</template>
 		</div>
-    <!-- 签入时长 -->
-    <div class="duty-on-time">
-      <span class="duty-on-time-label">签入时长</span>
-      <el-text class="duty-on-time-time" tag="b" type="danger" v-if="onDutyTime">{{ formatDuration(onDutyTime) }}</el-text>
-    </div>
+		<!-- 签入时长 -->
+		<div class="duty-on-time">
+			<span class="duty-on-time-label">签入时长</span>
+			<el-text class="duty-on-time-time" tag="b" type="danger" v-if="onDutyTime">{{ formatDuration(onDutyTime) }}</el-text>
+		</div>
 	</div>
 	<!-- 占位标签 -->
 	<div class="seizeSeat-box"></div>
@@ -497,6 +497,9 @@ import { Local } from '/@/utils/storage';
 import { ola } from '/@/utils/ola_api';
 import { useRouter } from 'vue-router';
 import dayjs from 'dayjs';
+import axios from 'axios';
+import { useSocket } from '/@/utils/websocket';
+import mittBus from '/@/utils/mitt';
 // 引入组件
 const CommonAdvice = defineAsyncComponent(() => import('/@/components/CommonAdvice/index.vue')); // 常用意见
 const AnnexList = defineAsyncComponent(() => import('/@/components/AnnexList/index.vue'));
@@ -1469,6 +1472,45 @@ const clickOnOutbound = (formEl: FormInstance | undefined) => {
 		}, 300);
 	});
 };
+
+const socket = ref<any>(null);
+// 打开websocket链接
+const seatAssistOn = () => {
+	if (telStatusInfo.value.telsNo) {
+		axios
+			.get(`${import.meta.env.VITE_VOICE_ASSISTANT_API_URL}/users/getUserByAgentId/${telStatusInfo.value.telsNo}`)
+			.then((res) => {
+				const { data } = res;
+				const { result } = data;
+				const uid = `8#User-${result.uid}`;
+				const subscribe = `/trans/${result.orgCode}/${result.groupUid}/${uid}`;
+				console.log(result, '获取到的坐席辅助用户信息');
+				socket.value = useSocket(import.meta.env.VITE_VOICE_ASSISTANT_SOCKET_URL, { uid, subscribe });
+				socket.value.on('open', () => {
+					console.log('坐席辅助链接已打开');
+					socket.value.send({
+						// 调用登录
+						id: '',
+						type: 1,
+						from: uid,
+						to: 'sys',
+						timestamps: new Date().getTime(),
+						body: result.userName,
+					});
+				});
+				socket.value.on('message', wsReceive); // 接收消息
+				/* socket.value.on('error', onError); // 错误
+          socket.value.on('close', onClose); // 关闭*/
+			})
+			.catch((err) => {
+				console.log(err, '获取到的坐席辅助用户信息失败');
+			});
+	}
+};
+// 推送消息
+const wsReceive = (message: any) => {
+	mittBus.emit('wsReceive', message);
+};
 onMounted(async () => {
 	clearTimeout(talkDealTimer.value); // 清除话后整理定时器
 	signalRStart(); //开启消息监听
@@ -1491,6 +1533,7 @@ onMounted(async () => {
 			.finally(() => {
 				state.loading = false;
 			});
+		seatAssistOn(); // 坐席辅助
 	} else {
 		// 重置所有状态
 		useTelStatusStore.resetState();

+ 1 - 0
src/types/mitt.d.ts

@@ -12,4 +12,5 @@ declare type MittType = {
 	onCurrentContextmenuClick?: any; // tagsview 右键菜单每项点击时
 	scrollTopEmit?: object; //点击分页跳转滚动到顶部
 	clearCache?: any; //清除某个页面的缓存
+	wsReceive?: any; //接受坐席辅助消息
 };

+ 8 - 43
src/views/todo/seats/accept/Voice-assistant.vue

@@ -104,7 +104,7 @@
 <script setup lang="ts">
 import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
 import { useSocket } from '/@/utils/websocket';
-import { ElMessageBox, ElNotification } from 'element-plus';
+import { ElMessageBox } from 'element-plus';
 import { getImageUrl } from '/@/utils/tools';
 import axios from 'axios';
 import { storeToRefs } from 'pinia';
@@ -113,9 +113,10 @@ import { useRoute } from 'vue-router';
 import { formatDate } from '/@/utils/formatTime';
 import Empty from '/@/components/Empty/index.vue';
 const emit = defineEmits(['orderOverwrite']);
+import mittBus from '/@/utils/mitt';
 // 消息列表
 const messageList = ref<any>([
-	{
+	/*{
 		body: {
 			content: {
 				callSentenceInfo: {
@@ -140,7 +141,7 @@ const messageList = ref<any>([
 			callerNumber: '19136073037',
 		},
 		timestamps: new Date().getTime(),
-	},
+	},*/
 ]); // 消息列表
 const recognizeList = ref<EmptyObjectType>({}); // 识别信息
 
@@ -148,43 +149,12 @@ const useTelStatusStore = useTelStatus();
 const { telStatusInfo } = storeToRefs(useTelStatusStore); // 电话状态
 
 const socket = ref<any>(null);
-// 打开websocket链接
-const seatAssistOn = () => {
-	if (telStatusInfo.value.telsNo) {
-		axios
-			.get(`${import.meta.env.VITE_VOICE_ASSISTANT_API_URL}/users/getUserByAgentId/${telStatusInfo.value.telsNo}`)
-			.then((res) => {
-				const { data } = res;
-				const { result } = data;
-				const uid = `8#User-${result.uid}`;
-				const subscribe = `/trans/${result.orgCode}/${result.groupUid}/${uid}`;
-				console.log(result, '获取到的用户信息');
-				socket.value = useSocket(import.meta.env.VITE_VOICE_ASSISTANT_SOCKET_URL, { uid, subscribe });
-				socket.value.on('open', () => {
-					console.log('坐席辅助链接已打开');
-					socket.value.send({
-						// 调用登录
-						id: '',
-						type: 1,
-						from: uid,
-						to: 'sys',
-						timestamps: new Date().getTime(),
-						body: result.userName,
-					});
-				});
-				socket.value.on('message', wsReceive); // 接收消息
-				socket.value.on('error', onError); // 错误
-				socket.value.on('close', onClose); // 关闭
-				console.log(socket.value);
-			})
-			.catch((err) => {
-				console.log(err, '获取用户信息失败');
-			});
-	}
-};
 // 设置初始化,防止刷新时恢复默认
 onMounted(() => {
-	seatAssistOn();
+	// 接受消息
+	mittBus.on('wsReceive', (message: any) => {
+		wsReceive(message);
+	});
 });
 const route = useRoute();
 const talkEnd = ref(false); // 通话结束
@@ -213,8 +183,6 @@ const wsReceive = (message: any) => {
 						//通话结束
 						talkEnd.value = true;
 						getRecognize();
-						console.log('通话转写结束了');
-						socket.value.socket.ws.close(); // 关闭websocket
 					}, 1000);
 				}
 			}
@@ -280,9 +248,6 @@ const fillSingle = () => {
 watch(messageList.value, (val) => {
 	scrollToBottom();
 });
-onUnmounted(() => {
-	socket.value.socket.ws.close(); // 关闭websocket
-});
 </script>
 
 <style scoped lang="scss">