|
@@ -58,55 +58,55 @@
|
|
|
<!– 播放录音 –>
|
|
|
<play-record ref="playRecordRef" />-->
|
|
|
<el-card shadow="never">
|
|
|
- <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-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>
|
|
|
+ <el-button @click="websocket_connect" 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>
|
|
|
</el-card>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -114,15 +114,13 @@
|
|
|
<script lang="tsx" setup name="telsSmartRecord">
|
|
|
import { defineAsyncComponent, onMounted, reactive, ref } from 'vue';
|
|
|
import type { FormInstance } from 'element-plus';
|
|
|
-import { ElMessageBox } from 'element-plus';
|
|
|
+import { ElMessage } from 'element-plus';
|
|
|
import { downloadFileByStream } from '@/utils/tools';
|
|
|
import { formatDate } from '@/utils/formatTime';
|
|
|
-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";
|
|
|
+import { olaFn } from '@/utils/olaFn';
|
|
|
|
|
|
// 引入组件
|
|
|
const PlayRecord = defineAsyncComponent(() => import('@/views/tels/callLog/component/Play-record.vue')); // 播放录音
|
|
@@ -257,28 +255,35 @@ onMounted(() => {
|
|
|
const wsStatus = ref('Disconnected');
|
|
|
const jsonData = ref('');
|
|
|
const showConnect = ref(true);
|
|
|
-// 链接ws
|
|
|
-const wsConnect = () => {
|
|
|
+
|
|
|
+// 链接呼叫中心
|
|
|
+const olaRef = ref();
|
|
|
+const websocket_connect = () => {
|
|
|
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);
|
|
|
+ olaRef.value = olaFn(websocket_url, {
|
|
|
+ username: state.testForm.agent,
|
|
|
+ password: state.testForm.agentPwd,
|
|
|
+ onConnected: onConnected, // 连接成功
|
|
|
+ onDisconnected: onDisconnected, // 断开链接
|
|
|
+ onMessage: onMessage, // 接收消息
|
|
|
+ heartbeat: {
|
|
|
+ message: JSON.stringify({ cmd: 'ping' }),
|
|
|
+ interval: 5000,
|
|
|
+ // pongTimeout: 1000,
|
|
|
+ },
|
|
|
+ });
|
|
|
};
|
|
|
-const onConnect = () => {
|
|
|
- console.log('-----222222----');
|
|
|
- console.log('websocket connected!');
|
|
|
- ola._extn = state.testForm.agent;
|
|
|
+const onConnected = () => {
|
|
|
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();
|
|
|
+ olaRef.value.logout();
|
|
|
+};
|
|
|
+const onDisconnected = () => {
|
|
|
+ console.log('websocket closed!');
|
|
|
+ ElMessage.warning('链接断开');
|
|
|
+ wsStatus.value = 'Disconnected';
|
|
|
+ showConnect.value = true;
|
|
|
};
|
|
|
const login = () => {
|
|
|
let array_ola_queue: EmptyArrayType = []; // 队列
|
|
@@ -287,23 +292,19 @@ const login = () => {
|
|
|
for (let i = 0; i < array.length; i++) {
|
|
|
array_ola_queue[i] = array[i];
|
|
|
}
|
|
|
- ola.login(array_ola_queue, state.testForm.agent, { type: 'onhook' });
|
|
|
+ olaRef.value.login(array_ola_queue, state.testForm.agent, { type: 'onhook' });
|
|
|
}
|
|
|
};
|
|
|
const logout = () => {
|
|
|
- ola.logout();
|
|
|
+ olaRef.value.logout();
|
|
|
+ olaRef.value.close();
|
|
|
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);
|
|
|
+ const data = JSON.parse(evt);
|
|
|
if (data.event_type === 'agent_state') {
|
|
|
- jsonData.value = evt.data;
|
|
|
+ jsonData.value = evt;
|
|
|
if (data.state == 'login') {
|
|
|
olaStatus.value = '已签入';
|
|
|
} else if (data.state == 'logout') {
|
|
@@ -349,19 +350,18 @@ const onMessage = (evt: any) => {
|
|
|
}
|
|
|
};
|
|
|
const ready = () => {
|
|
|
- ola.go_ready();
|
|
|
+ olaRef.value.go_ready();
|
|
|
};
|
|
|
const unReady = () => {
|
|
|
- ola.go_break('');
|
|
|
+ olaRef.value.go_break('');
|
|
|
};
|
|
|
const hold = () => {
|
|
|
- ola.hold();
|
|
|
+ olaRef.value.hold();
|
|
|
};
|
|
|
const unHold = () => {
|
|
|
- ola.unhold();
|
|
|
+ olaRef.value.unhold();
|
|
|
};
|
|
|
const hangup = () => {
|
|
|
- ola.hangup();
|
|
|
+ olaRef.value.hangup();
|
|
|
};
|
|
|
-
|
|
|
</script>
|