|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<div class="tels-smart-record-container layout-pd">
|
|
|
- <el-card shadow="never">
|
|
|
+ <!-- <el-card shadow="never">
|
|
|
<el-form :model="state.queryParams" ref="ruleFormRef" @submit.native.prevent label-width="20px">
|
|
|
<el-row :gutter="10">
|
|
|
<el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
|
|
@@ -48,15 +48,68 @@
|
|
|
v-model:page-size="state.queryParams.pagesize"
|
|
|
:key="Math.random()"
|
|
|
>
|
|
|
- <!-- 表格操作 -->
|
|
|
+ <!– 表格操作 –>
|
|
|
<template #operation="{ row }">
|
|
|
<el-button type="primary" @click="onPlaySoundRecording(row)" title="播放录音" link v-if="row.recordUrl">播放录音</el-button>
|
|
|
<el-button link type="primary" @click="onDownload(row)" title="下载录音" v-if="row.recordUrl"> 下载录音 </el-button>
|
|
|
</template>
|
|
|
</ProTable>
|
|
|
</el-card>
|
|
|
- <!-- 播放录音 -->
|
|
|
- <play-record ref="playRecordRef" />
|
|
|
+ <!– 播放录音 –>
|
|
|
+ <play-record ref="playRecordRef" />-->
|
|
|
+ <el-card>
|
|
|
+ <div id="ola">
|
|
|
+ <el-form :model="state.testForm" @submit.native.prevent>
|
|
|
+ <el-row :gutter="10">
|
|
|
+ <el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
|
|
|
+ <el-form-item prop="serIp" label="服务器ip:">
|
|
|
+ <el-input v-model="state.testForm.serIp" placeholder="例如:114.114.114.114" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
|
|
|
+ <el-form-item prop="serPort" label="服务器端口:">
|
|
|
+ <el-input v-model="state.testForm.serPort" placeholder="例如:29003" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
|
|
|
+ <el-form-item prop="queue" label="队列:">
|
|
|
+ <el-input v-model="state.testForm.queue" placeholder="例如:10010" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
|
|
|
+ <el-form-item prop="callNumber" label="分机:">
|
|
|
+ <el-input v-model="state.testForm.agent" placeholder="例如:1001" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
|
|
|
+ <el-form-item prop="agentPwd" label="分机密码:">
|
|
|
+ <el-input v-model="state.testForm.agentPwd" placeholder="例如:!@#123Qw" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-divider>
|
|
|
+ <span class="ss_title">连接状态:{{ wsStatus }}</span>
|
|
|
+
|
|
|
+ <el-button @click="wsConnect" type="primary" class="ml10" v-if="showConnect">连接</el-button>
|
|
|
+ </el-divider>
|
|
|
+ <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
|
|
|
+ <div class="mb10">签入状态:{{ olaStatus }}</div>
|
|
|
+ <el-button @click="login" type="primary">签入</el-button>
|
|
|
+ <el-button @click="logout" type="primary">签出</el-button>
|
|
|
+ <el-button @click="ready" type="primary">示闲</el-button>
|
|
|
+ <el-button @click="unReady" type="primary">示忙</el-button>
|
|
|
+ <el-button @click="hold" type="primary">保持</el-button>
|
|
|
+ <el-button @click="unHold" type="primary">取消保持</el-button>
|
|
|
+ <el-button @click="hangup" type="primary">挂机</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
|
|
|
+ <el-form-item label="JSON数据">
|
|
|
+ {{jsonData}}
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -70,6 +123,8 @@ import { shortcuts } from '@/utils/constants';
|
|
|
import other from '@/utils/other';
|
|
|
import { fileDownload } from '@/api/public/file';
|
|
|
import { jthsRecord } from '@/api/todo/voiceAssistant';
|
|
|
+import { ola } from '@/utils/ola_api';
|
|
|
+import { forceLogout } from "@/api/tels/extension";
|
|
|
|
|
|
// 引入组件
|
|
|
const PlayRecord = defineAsyncComponent(() => import('@/views/tels/callLog/component/Play-record.vue')); // 播放录音
|
|
@@ -102,6 +157,13 @@ const state = reactive({
|
|
|
callDirection: [],
|
|
|
onState: [],
|
|
|
endByOptions: [],
|
|
|
+ testForm: {
|
|
|
+ serIp: '222.213.23.229',
|
|
|
+ serPort: '29003',
|
|
|
+ queue: '10010',
|
|
|
+ agent: '1100',
|
|
|
+ agentPwd: '!@#123Qw',
|
|
|
+ },
|
|
|
});
|
|
|
const ruleFormRef = ref<FormInstance>(); // 表单ref
|
|
|
const searchCol = ref(true); // 展开/收起
|
|
@@ -192,6 +254,116 @@ const onDownload = (row: any) => {
|
|
|
.catch(() => {});
|
|
|
};
|
|
|
onMounted(() => {
|
|
|
- queryList();
|
|
|
+ // queryList();
|
|
|
});
|
|
|
+const wsStatus = ref('Disconnected');
|
|
|
+const jsonData = ref('');
|
|
|
+const showConnect = ref(true);
|
|
|
+// 链接ws
|
|
|
+const wsConnect = () => {
|
|
|
+ const websocket_url = 'ws://' + state.testForm.serIp + ':' + state.testForm.serPort + '/ola_socket';
|
|
|
+ console.log('----00000-----');
|
|
|
+ ola.onConnect = onConnect;
|
|
|
+ console.log('-----11111----');
|
|
|
+ ola.onClose = onClose;
|
|
|
+ ola.onMessage = onMessage;
|
|
|
+ ola.connect(websocket_url, state.testForm.agent, state.testForm.agentPwd);
|
|
|
+};
|
|
|
+const onConnect = () => {
|
|
|
+ console.log('-----222222----');
|
|
|
+ console.log('websocket connected!');
|
|
|
+ ola._extn = state.testForm.agent;
|
|
|
+ showConnect.value = false;
|
|
|
+ wsStatus.value = 'Connected';
|
|
|
+ ola.subscribe('ola.agent.' + state.testForm.agent);
|
|
|
+ ola.subscribe('ola.caller.' + state.testForm.agent);
|
|
|
+ ola.get_agent_state(state.testForm.agent);
|
|
|
+ //连接之后,先登出一次,防止其他地方已经登陆
|
|
|
+ ola.logout();
|
|
|
+ login();
|
|
|
+};
|
|
|
+const login = () => {
|
|
|
+ let array_ola_queue: EmptyArrayType = []; // 队列
|
|
|
+ if (state.testForm.queue != '') {
|
|
|
+ const array = state.testForm.queue.split(',');
|
|
|
+ for (let i = 0; i < array.length; i++) {
|
|
|
+ array_ola_queue[i] = array[i];
|
|
|
+ }
|
|
|
+ ola.login(array_ola_queue, state.testForm.agent, { type: 'onhook' });
|
|
|
+ }
|
|
|
+};
|
|
|
+const logout = () => {
|
|
|
+ ola.logout();
|
|
|
+ olaStatus.value = '未签入';
|
|
|
+};
|
|
|
+const onClose = () => {
|
|
|
+ console.log('websocket closed!');
|
|
|
+ wsStatus.value = 'Disconnected';
|
|
|
+ showConnect.value = true;
|
|
|
+};
|
|
|
+const olaStatus = ref('');
|
|
|
+const onMessage = (evt: any) => {
|
|
|
+ const data = JSON.parse(evt.data);
|
|
|
+ if (data.event_type === 'agent_state') {
|
|
|
+ jsonData.value = evt.data;
|
|
|
+ if (data.state == 'login') {
|
|
|
+ olaStatus.value = '已签入';
|
|
|
+ } else if (data.state == 'logout') {
|
|
|
+ olaStatus.value = '未签入';
|
|
|
+ } else if (data.state == 'ready') {
|
|
|
+ olaStatus.value = '示闲中';
|
|
|
+ } else if (data.state == 'unready') {
|
|
|
+ olaStatus.value = '示忙中';
|
|
|
+ } else if (data.state == 'acw') {
|
|
|
+ olaStatus.value = '话后整理中';
|
|
|
+ } else if (data.state == 'busy') {
|
|
|
+ olaStatus.value = '通话中';
|
|
|
+ } else {
|
|
|
+ olaStatus.value = data.state;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (data.state == 'busy') {
|
|
|
+ if (data.call_direction == 'outbound') {
|
|
|
+ if (data.private_data == 'calling') {
|
|
|
+ olaStatus.value = '拨号中';
|
|
|
+ } else if (data.private_data == 'answered') {
|
|
|
+ if (data.other_answered == false) {
|
|
|
+ olaStatus.value = '振铃中';
|
|
|
+ } else if (data.other_answered == true) {
|
|
|
+ olaStatus.value = '通话中';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (data.private_data == 'ring') {
|
|
|
+ olaStatus.value = '振铃中';
|
|
|
+ } else if (data.private_data == 'answered') {
|
|
|
+ olaStatus.value = '通话中';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (data.old_state == 'busy') {
|
|
|
+ //挂机后系统可以返回两种状态:acw 话后整理状态 ready 示闲状态,如果不需要acw,可以联系我们后台修改配置,如果需要保留,如果需要再次
|
|
|
+ //拨打电话的话,需要手动点击示闲按钮
|
|
|
+ alert('已挂机');
|
|
|
+ olaStatus.value = '已挂机';
|
|
|
+ }
|
|
|
+ } else if (data.event_type == 'agent_caller_state') {
|
|
|
+ } else if (data.event_type == 'command/reply') {
|
|
|
+ }
|
|
|
+};
|
|
|
+const ready = () => {
|
|
|
+ ola.go_ready();
|
|
|
+};
|
|
|
+const unReady = () => {
|
|
|
+ ola.go_break('');
|
|
|
+};
|
|
|
+const hold = () => {
|
|
|
+ ola.hold();
|
|
|
+};
|
|
|
+const unHold = () => {
|
|
|
+ ola.unhold();
|
|
|
+};
|
|
|
+const hangup = () => {
|
|
|
+ ola.hangup();
|
|
|
+};
|
|
|
+
|
|
|
</script>
|