|
@@ -1,5 +1,5 @@
|
|
|
import { ref } from 'vue';
|
|
|
-import { Timer } from '@/utils/timer';
|
|
|
+// import { Timer } from '@/utils/timer';
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
import usePermissionStore from './permission';
|
|
|
|
|
@@ -29,7 +29,7 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
|
|
|
// 通话时长
|
|
|
const callTime = ref('00:00:00');
|
|
|
- const timer = new Timer(callTime);
|
|
|
+ // const timer = new Timer(callTime);
|
|
|
|
|
|
// 开始时间
|
|
|
const startTime = '';
|
|
@@ -40,6 +40,15 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
// 是否有拨打电话权限
|
|
|
const isAuthPane = computed(() => usePermission.routes.findIndex(({ name }) => name === 'Console') !== -1);
|
|
|
|
|
|
+ // 重置
|
|
|
+ const reset = () => {
|
|
|
+ noiceBarVisibleState.value = false;
|
|
|
+ noiceBoxVisibleState.value = false;
|
|
|
+ callAnswered.value = false;
|
|
|
+ callDialing.value = false;
|
|
|
+ // timer.resetTimer();
|
|
|
+ }
|
|
|
+
|
|
|
// 拨打电话
|
|
|
const onMakingCall = async (phoneNum) => {
|
|
|
if ( callAnswered.value ) {
|
|
@@ -56,6 +65,7 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+
|
|
|
callAnswered.value = true;
|
|
|
|
|
|
const { data } = await makeCall(phoneNum);
|
|
@@ -66,7 +76,7 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
|
|
|
isMakingCall.value = true;
|
|
|
|
|
|
- noiceBarVisibleState.value = true;
|
|
|
+ // noiceBarVisibleState.value = true;
|
|
|
}
|
|
|
|
|
|
// 接听电话
|
|
@@ -74,16 +84,13 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
callDialing.value = true;
|
|
|
callAnswered.value = true;
|
|
|
await answer();
|
|
|
- timer.start();
|
|
|
+ // timer.start();
|
|
|
// TODO 这里需要补充其他逻辑
|
|
|
}
|
|
|
|
|
|
// 挂断电话
|
|
|
const onCallDisconnected = async () => {
|
|
|
- noiceBarVisibleState.value = false;
|
|
|
- noiceBoxVisibleState.value = false;
|
|
|
- callAnswered.value = false;
|
|
|
- timer.resetTimer();
|
|
|
+ reset();
|
|
|
// const currentTimer = timer.updateDisplay();
|
|
|
|
|
|
// 挂断
|
|
@@ -94,8 +101,6 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
type: 'success',
|
|
|
plain: true,
|
|
|
})
|
|
|
-
|
|
|
- // TODO 这里需要补充其他逻辑
|
|
|
}
|
|
|
|
|
|
// 置忙
|
|
@@ -116,7 +121,7 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
}
|
|
|
|
|
|
// 主动外呼
|
|
|
- const makeCall = called => HS_CTI.makeCall({ called })
|
|
|
+ const makeCall = called => HS_CTI.makeCall({ called, caller: "待定" })
|
|
|
|
|
|
// 接听电话
|
|
|
const answer = () => {
|
|
@@ -137,7 +142,12 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
const listenScoketEvent = (CTIEvent) => {
|
|
|
HS_CTI.on(CTIEvent.OnAgentWorkReport, ({ workStatus, description, callId, phone }) => {
|
|
|
|
|
|
+ console.log( "-----------------------" );
|
|
|
+ console.log( "-----------------------" );
|
|
|
console.log( "workStatus", workStatus );
|
|
|
+ console.log( "phone", phone );
|
|
|
+ console.log( "-----------------------" );
|
|
|
+ console.log( "-----------------------" );
|
|
|
|
|
|
// 销毁实例调用签出接口成功后 - 坐席签出
|
|
|
if ( workStatus === -1 ) {
|
|
@@ -150,38 +160,18 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
|
|
|
// 登录CTI 成功
|
|
|
if ( workStatus === 0 ) {
|
|
|
- // ElMessage({
|
|
|
- // message: '坐席登入成功',
|
|
|
- // type: 'success',
|
|
|
- // plain: true,
|
|
|
- // })
|
|
|
}
|
|
|
|
|
|
// 登录CTI 成功
|
|
|
if ( workStatus === 2 ) {
|
|
|
- // ElMessage({
|
|
|
- // message: '登入成功',
|
|
|
- // type: 'success',
|
|
|
- // plain: true,
|
|
|
- // })
|
|
|
}
|
|
|
|
|
|
// 调用置闲接口成功后
|
|
|
if ( workStatus === 2 ) {
|
|
|
- // ElMessage({
|
|
|
- // message: '坐席状态变更为:置闲',
|
|
|
- // type: 'success',
|
|
|
- // plain: true,
|
|
|
- // })
|
|
|
}
|
|
|
|
|
|
// 调用置忙接口成功后
|
|
|
if ( workStatus === 3 ) {
|
|
|
- // ElMessage({
|
|
|
- // message: '当前坐席状态:置忙',
|
|
|
- // type: 'warning',
|
|
|
- // plain: true,
|
|
|
- // })
|
|
|
}
|
|
|
|
|
|
// 座席振铃
|
|
@@ -195,22 +185,27 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
|
|
|
noiceBarVisibleState.value = true;
|
|
|
|
|
|
- ElMessage({
|
|
|
- message: '来电话了',
|
|
|
- type: 'warning',
|
|
|
- plain: true,
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- // 挂断 任意一方挂断
|
|
|
- if ( workStatus === 7 ) {
|
|
|
-
|
|
|
// ElMessage({
|
|
|
- // message: '当前坐席状态:置忙',
|
|
|
+ // message: '来电话了',
|
|
|
// type: 'warning',
|
|
|
// plain: true,
|
|
|
// })
|
|
|
}
|
|
|
+
|
|
|
+ // 挂断 任意一方挂断
|
|
|
+ if ( workStatus === 7 ) {
|
|
|
+ reset();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 座席接通呼入电话
|
|
|
+ if ( workStatus === 10 ) {
|
|
|
+ // timer.start();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 挂断 任意一方挂断
|
|
|
+ // if ( workStatus === 7 ) {
|
|
|
+ // reset();
|
|
|
+ // }
|
|
|
})
|
|
|
}
|
|
|
|