| | |
| | | <div class="documentf"> |
| | | <div class="document"> |
| | | <el-button type="success" size="medium" @click="onthatday()" |
| | | >彿¥æå¡</el-button |
| | | >仿¥æå¡</el-button |
| | | > |
| | | </div> |
| | | </div> |
| | |
| | | <div class="documentf"> |
| | | <div class="document"> |
| | | <el-button type="success" size="medium" @click="onthatday()" |
| | | >彿¥æå¡</el-button |
| | | >仿¥æå¡</el-button |
| | | > |
| | | </div> |
| | | </div> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div class="websocket-demo"> |
| | | <div> |
| | | <h3>Websocketæ¥å£æµè¯DEMO</h3> |
| | | <div class="config-area"> |
| | | <div class="input-group"> |
| | | <label>CTI_WS_URL</label> |
| | | <input |
| | | type="text" |
| | | v-model="config.cti_ws_url" |
| | | placeholder="ws://40.78.0.169:6688" |
| | | /> |
| | | |
| | | <label>åå¸å·¥å·</label> |
| | | <input type="text" v-model="config.seatname" placeholder="8000" /> |
| | | |
| | | <label>åå¸åæº</label> |
| | | <input type="text" v-model="config.seatnum" placeholder="8000" /> |
| | | |
| | | <label>å¯ç </label> |
| | | <input type="text" v-model="config.password" placeholder="123456" /> |
| | | </div> |
| | | |
| | | <div class="input-group"> |
| | | <label>å¤çº¿å·ç </label> |
| | | <input type="text" v-model="config.phone" placeholder="10086" /> |
| | | |
| | | <label>UUID</label> |
| | | <input type="text" v-model="config.uuid" /> |
| | | |
| | | <label>å
¶ä»åå¸</label> |
| | | <input type="text" v-model="config.other" placeholder="8001" /> |
| | | |
| | | <label>æè½ç»</label> |
| | | <input type="text" v-model="config.group" placeholder="a3" /> |
| | | |
| | | <label>å¤å¼åæ°id</label> |
| | | <input type="text" v-model="config.paramid" placeholder="3" /> |
| | | </div> |
| | | </div> |
| | | |
| | | <!-- æä½æé®åºå --> |
| | | <div class="button-area"> |
| | | <!-- 第ä¸è¡æé® --> |
| | | <div class="button-row"> |
| | | <button @click="seatlogin">ç¾å
¥</button> |
| | | <button @click="seatlogout">ç¾åº</button> |
| | | <button @click="afk">示å¿</button> |
| | | <button @click="online">示é²</button> |
| | | <button @click="pickup">代ç</button> |
| | | </div> |
| | | |
| | | <!-- 第äºè¡æé® --> |
| | | <div class="button-row"> |
| | | <button @click="hangup">ææº</button> |
| | | <button @click="callout">å¤å¼</button> |
| | | <button @click="transfer">éè¯è½¬ç§»</button> |
| | | <button @click="transferresume">éè¯è½¬ç§»æ¶å</button> |
| | | <button @click="hold">éè¯ä¿æ</button> |
| | | <button @click="holdresume">éè¯ä¿ææ¶å</button> |
| | | <button @click="remove">éè¯å¼ºæ</button> |
| | | <button @click="insert">éè¯å¼ºæ</button> |
| | | <button @click="monitor">çå¬</button> |
| | | <button @click="monitor_to_talk">çå¬è½¬éè¯</button> |
| | | <button @click="monitor_end">çå¬ç»æ</button> |
| | | <button @click="choosecall">éæ©</button> |
| | | <button @click="replacecall">代æ¥</button> |
| | | <button @click="three">䏿¹éè¯</button> |
| | | </div> |
| | | |
| | | <!-- 第ä¸è¡æé® --> |
| | | <div class="button-row"> |
| | | <button @click="handoff_ready">å¨è¯¢å¼å§</button> |
| | | <button @click="handoff_call">å¨è¯¢å¼å«</button> |
| | | <button @click="handoff_resume">å¨è¯¢æ¶å</button> |
| | | <button @click="handoff_transfer">å¨è¯¢è½¬ç§»</button> |
| | | <button @click="handoff_three">å¨è¯¢ä¸æ¹</button> |
| | | <button @click="record_start">å¼å§éè¯å½é³</button> |
| | | <button @click="record_stop">忢éè¯å½é³</button> |
| | | </div> |
| | | |
| | | <!-- 第åè¡æé® --> |
| | | <div class="button-row"> |
| | | <button @click="openseatlist">æå¼åå¸ç¶æ</button> |
| | | <button @click="closeseatlist">å
³éåå¸ç¶æ</button> |
| | | <button @click="openqueues">æå¼éåä¿¡æ¯</button> |
| | | <button @click="closequeues">å
³ééåä¿¡æ¯</button> |
| | | <button @click="opencalllist">æå¼éè¯ä¿¡æ¯</button> |
| | | <button @click="closecalllist">å
³ééè¯ä¿¡æ¯</button> |
| | | <button @click="openroutelist">æå¼è·¯ç±ä¿¡æ¯</button> |
| | | <button @click="closeroutelist">å
³éè·¯ç±ä¿¡æ¯</button> |
| | | </div> |
| | | |
| | | <!-- 第äºè¡æé® --> |
| | | <div class="button-row"> |
| | | <button @click="seatlist">è·ååå¸ä¿¡æ¯</button> |
| | | <button @click="queues">è·åéåä¿¡æ¯</button> |
| | | <button @click="calllist">è·åéè¯ä¿¡æ¯</button> |
| | | <button @click="routelist">è·åè·¯ç±ä¿¡æ¯</button> |
| | | <button @click="batch">è·åå¤å¼åæ°ä¿¡æ¯</button> |
| | | <button @click="batch_start">å¼å§å¤å¼ä»»å¡</button> |
| | | <button @click="batch_stop">忢å¤å¼ä»»å¡</button> |
| | | </div> |
| | | </div> |
| | | |
| | | <!-- æ¥å¿æ¾ç¤ºåºå --> |
| | | <h3>åè®®æ¥å¿åº<button @click="testclear">æ¸
é¤</button></h3> |
| | | <div id="msg" class="log-area">{{ logs }}</div> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | name: "WebsocketDemo", |
| | | |
| | | data() { |
| | | return { |
| | | config: { |
| | | cti_ws_url: "wss://9.208.2.190:8092/cal-api/", |
| | | seatname: "8000", |
| | | seatnum: "8000", |
| | | password: "123456", |
| | | phone: "10086", |
| | | uuid: "", |
| | | other: "8001", |
| | | group: "a3", |
| | | paramid: "3", |
| | | }, |
| | | logs: "", |
| | | ws: null, |
| | | isConnected: false, |
| | | }; |
| | | }, |
| | | |
| | | mounted() { |
| | | this.initializeWebSocket(); |
| | | }, |
| | | |
| | | beforeUnmount() { |
| | | this.disconnectWebSocket(); |
| | | }, |
| | | |
| | | methods: { |
| | | // åå§åWebSocketè¿æ¥ |
| | | initializeWebSocket() { |
| | | try { |
| | | // æ ¹æ®å½å页é¢åè®®èªå¨éæ©WSåè®® |
| | | const isHttps = window.location.protocol === "https:"; |
| | | this.config.cti_ws_url = isHttps |
| | | ? "wss://9.208.2.190:8092/cal-api/" |
| | | : "ws://40.78.0.169:6688"; |
| | | |
| | | if (typeof window.WebSocket === "undefined") { |
| | | this.addLog("é误: æµè§å¨ä¸æ¯æWebSocket"); |
| | | return; |
| | | } |
| | | |
| | | this.connectWebSocket(); |
| | | } catch (error) { |
| | | this.addLog(`åå§åWebSocketé误: ${error.message}`); |
| | | // å°è¯ä½¿ç¨å¤ç¨å°å |
| | | this.config.cti_ws_url = "wss://9.208.2.190:8092/cal-api/"; |
| | | setTimeout(() => this.connectWebSocket(), 2000); |
| | | } |
| | | }, |
| | | |
| | | // è¿æ¥WebSocket |
| | | connectWebSocket() { |
| | | if (this.ws && this.ws.readyState === WebSocket.OPEN) { |
| | | this.addLog("WebSocketå·²è¿æ¥"); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | let wsUrl = this.config.cti_ws_url; |
| | | // ç¡®ä¿HTTPS页é¢ä½¿ç¨WSS |
| | | if ( |
| | | window.location.protocol === "https:" && |
| | | wsUrl.startsWith("ws://") |
| | | ) { |
| | | wsUrl = wsUrl.replace("ws://", "wss://"); |
| | | } |
| | | |
| | | this.ws = new WebSocket(wsUrl); |
| | | |
| | | this.ws.onopen = () => { |
| | | this.isConnected = true; |
| | | this.addLog("WebSocketè¿æ¥æå"); |
| | | }; |
| | | |
| | | this.ws.onmessage = (event) => { |
| | | this.handleWebSocketMessage(event); |
| | | }; |
| | | |
| | | this.ws.onclose = (event) => { |
| | | this.isConnected = false; |
| | | this.addLog(`WebSocketè¿æ¥å
³é: ${event.code} ${event.reason}`); |
| | | // èªå¨éè¿ |
| | | setTimeout(() => this.connectWebSocket(), 3000); |
| | | }; |
| | | |
| | | this.ws.onerror = (error) => { |
| | | this.addLog(`WebSocketé误: ${error.message}`); |
| | | // å°è¯å¤ç¨URL |
| | | if (!wsUrl.includes("9.208.2.190")) { |
| | | this.config.cti_ws_url = "wss://9.208.2.190:8092/cal-api/"; |
| | | setTimeout(() => this.connectWebSocket(), 3000); |
| | | } |
| | | }; |
| | | } catch (error) { |
| | | this.addLog(`è¿æ¥WebSocket失败: ${error.message}`); |
| | | // å°è¯å¤ç¨URL |
| | | this.config.cti_ws_url = "wss://9.208.2.190:8092/cal-api/"; |
| | | setTimeout(() => this.connectWebSocket(), 3000); |
| | | } |
| | | }, |
| | | |
| | | // å¤çWebSocketæ¶æ¯ |
| | | handleWebSocketMessage(event) { |
| | | const reader = new FileReader(); |
| | | reader.onloadend = (e) => { |
| | | const message = reader.result; |
| | | this.addLog(`æ¶å°æ¶æ¯: ${message}`); |
| | | |
| | | try { |
| | | const obj = JSON.parse(message); |
| | | |
| | | // å¤çå¿è·³å
|
| | | if (obj.cmd === "system" && obj.action === "keepalive") { |
| | | this.keepalive(obj.seatname, obj.seatnum); |
| | | } |
| | | |
| | | // èªå¨è®¾ç½®UUID |
| | | if (obj.cmd === "control" && obj.action === "tp_callin") { |
| | | this.config.uuid = obj.uuid; |
| | | this.addLog(`èªå¨è®¾ç½®UUID: ${obj.uuid}`); |
| | | } |
| | | } catch (error) { |
| | | this.addLog(`æ¶æ¯è§£æé误: ${error.message}`); |
| | | } |
| | | }; |
| | | reader.readAsText(event.data); |
| | | }, |
| | | |
| | | // æå¼WebSocketè¿æ¥ |
| | | disconnectWebSocket() { |
| | | if (this.ws) { |
| | | this.ws.close(); |
| | | this.ws = null; |
| | | this.isConnected = false; |
| | | this.addLog("WebSocketå·²æå¼"); |
| | | } |
| | | }, |
| | | |
| | | // åéWebSocketæ¶æ¯ |
| | | sendWebSocketMessage(message) { |
| | | if (!this.isConnected || !this.ws) { |
| | | this.addLog("é误: WebSocketæªè¿æ¥"); |
| | | return false; |
| | | } |
| | | |
| | | try { |
| | | const messageStr = |
| | | typeof message === "string" ? message : JSON.stringify(message); |
| | | this.ws.send(messageStr); |
| | | this.addLog(`åéæ¶æ¯: ${messageStr}`); |
| | | return true; |
| | | } catch (error) { |
| | | this.addLog(`åéæ¶æ¯å¤±è´¥: ${error.message}`); |
| | | return false; |
| | | } |
| | | }, |
| | | |
| | | // éªè¯åæ° |
| | | validateParams(params, requiredFields) { |
| | | for (const field of requiredFields) { |
| | | if (!params[field] || params[field].toString().trim() === "") { |
| | | this.addLog(`é误: ${field} ä¸è½ä¸ºç©º`); |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | }, |
| | | |
| | | // ==================== WebSocket.js åè½æ´å ==================== |
| | | |
| | | // ç¾å
¥ |
| | | seatlogin() { |
| | | const { seatname, seatnum, password, cti_ws_url } = this.config; |
| | | |
| | | if ( |
| | | !this.validateParams({ seatname, seatnum }, ["seatname", "seatnum"]) |
| | | ) { |
| | | return; |
| | | } |
| | | |
| | | // éæ°è¿æ¥WebSocketï¼åjsæä»¶ä¸çé»è¾ï¼ |
| | | this.connectWebSocket(); |
| | | setTimeout(() => { |
| | | const protocol = { |
| | | cmd: "system", |
| | | action: "seatlogin", |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | password: password, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, 1000); |
| | | }, |
| | | |
| | | // ç¾åº |
| | | seatlogout() { |
| | | const { seatname, seatnum } = this.config; |
| | | |
| | | if ( |
| | | !this.validateParams({ seatname, seatnum }, ["seatname", "seatnum"]) |
| | | ) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "system", |
| | | action: "seatlogout", |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | this.ws.close(); |
| | | }, |
| | | |
| | | // ç¤ºå¿ |
| | | afk() { |
| | | const { seatname, seatnum } = this.config; |
| | | |
| | | if ( |
| | | !this.validateParams({ seatname, seatnum }, ["seatname", "seatnum"]) |
| | | ) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "system", |
| | | action: "afk", |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // ç¤ºé² |
| | | online() { |
| | | const { seatname, seatnum } = this.config; |
| | | |
| | | if ( |
| | | !this.validateParams({ seatname, seatnum }, ["seatname", "seatnum"]) |
| | | ) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "system", |
| | | action: "online", |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // 代ç |
| | | pickup() { |
| | | const { seatname, seatnum } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum }, ["seatnum"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "control", |
| | | action: "pickup", |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // ææº |
| | | hangup() { |
| | | const { seatname, seatnum } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum }, ["seatnum"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "control", |
| | | action: "hangup", |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // å¤å¼ |
| | | callout() { |
| | | const { seatname, seatnum, phone } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum, phone }, ["seatnum", "phone"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "control", |
| | | action: "callout", |
| | | phone: phone, |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // éè¯è½¬ç§» |
| | | transfer() { |
| | | const { seatname, seatnum, phone, uuid } = this.config; |
| | | |
| | | if ( |
| | | !this.validateParams({ seatnum, phone, uuid }, [ |
| | | "seatnum", |
| | | "phone", |
| | | "uuid", |
| | | ]) |
| | | ) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "control", |
| | | action: "transfer", |
| | | uuid: uuid, |
| | | phone: phone, |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // éè¯è½¬ç§»æ¶å |
| | | transferresume() { |
| | | const { seatname, seatnum, phone, uuid } = this.config; |
| | | |
| | | if ( |
| | | !this.validateParams({ seatnum, phone, uuid }, [ |
| | | "seatnum", |
| | | "phone", |
| | | "uuid", |
| | | ]) |
| | | ) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "control", |
| | | action: "transferresume", |
| | | uuid: uuid, |
| | | phone: phone, |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // éè¯ä¿æ |
| | | hold() { |
| | | const { seatname, seatnum, uuid } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum, uuid }, ["seatnum", "uuid"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "control", |
| | | action: "hold", |
| | | uuid: uuid, |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // éè¯ä¿ææ¶å |
| | | holdresume() { |
| | | const { seatname, seatnum, uuid } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum, uuid }, ["seatnum", "uuid"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "control", |
| | | action: "holdresume", |
| | | uuid: uuid, |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // éè¯å¼ºæ |
| | | remove() { |
| | | const { seatname, seatnum, phone } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum, phone }, ["seatnum", "phone"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "control", |
| | | action: "remove", |
| | | phone: phone, |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // éè¯å¼ºæ |
| | | insert() { |
| | | const { seatname, seatnum, phone } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum, phone }, ["seatnum", "phone"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "control", |
| | | action: "insert", |
| | | phone: phone, |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // çå¬ |
| | | monitor() { |
| | | const { seatname, seatnum, phone } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum, phone }, ["seatnum", "phone"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "control", |
| | | action: "monitor", |
| | | phone: phone, |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // çå¬è½¬éè¯ |
| | | monitor_to_talk() { |
| | | const { seatname, seatnum, phone } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum, phone }, ["seatnum", "phone"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "control", |
| | | action: "monitor_to_talk", |
| | | phone: phone, |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // çå¬ç»æ |
| | | monitor_end() { |
| | | const { seatname, seatnum, phone } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum, phone }, ["seatnum", "phone"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "control", |
| | | action: "monitor_end", |
| | | phone: phone, |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // éæ©éè¯ |
| | | choosecall() { |
| | | const { seatname, seatnum, uuid } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum, uuid }, ["seatnum", "uuid"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "control", |
| | | action: "choosecall", |
| | | uuid: uuid, |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // ä»£æ¥ |
| | | replacecall() { |
| | | const { seatname, seatnum, phone } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum, phone }, ["seatnum", "phone"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "control", |
| | | action: "replacecall", |
| | | phone: phone, |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // 䏿¹éè¯ |
| | | three() { |
| | | const { seatname, seatnum, phone } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum, phone }, ["seatnum", "phone"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "control", |
| | | action: "three", |
| | | phone: phone, |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // å¨è¯¢å¼å§ |
| | | handoff_ready() { |
| | | const { seatname, seatnum, uuid } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum, uuid }, ["seatnum", "uuid"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "control", |
| | | action: "handoff_ready", |
| | | uuid: uuid, |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // å¨è¯¢å¼å« |
| | | handoff_call() { |
| | | const { seatname, seatnum, other, uuid } = this.config; |
| | | |
| | | if ( |
| | | !this.validateParams({ seatnum, other, uuid }, [ |
| | | "seatnum", |
| | | "other", |
| | | "uuid", |
| | | ]) |
| | | ) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "control", |
| | | action: "handoff_call", |
| | | uuid: uuid, |
| | | phone: other, |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // å¨è¯¢æ¶å |
| | | handoff_resume() { |
| | | const { seatname, seatnum, uuid } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum, uuid }, ["seatnum", "uuid"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "control", |
| | | action: "handoff_resume", |
| | | uuid: uuid, |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // å¨è¯¢è½¬ç§» |
| | | handoff_transfer() { |
| | | const { seatname, seatnum, other, uuid } = this.config; |
| | | |
| | | if ( |
| | | !this.validateParams({ seatnum, other, uuid }, [ |
| | | "seatnum", |
| | | "other", |
| | | "uuid", |
| | | ]) |
| | | ) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "control", |
| | | action: "handoff_transfer", |
| | | uuid: uuid, |
| | | phone: other, |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // å¨è¯¢ä¸æ¹ |
| | | handoff_three() { |
| | | const { seatname, seatnum, uuid } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum, uuid }, ["seatnum", "uuid"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "control", |
| | | action: "handoff_three", |
| | | uuid: uuid, |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // å¼å§éè¯å½é³ |
| | | record_start() { |
| | | const { seatname, seatnum, uuid } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum, uuid }, ["seatnum", "uuid"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "control", |
| | | action: "record_start", |
| | | uuid: uuid, |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // 忢éè¯å½é³ |
| | | record_stop() { |
| | | const { seatname, seatnum, uuid } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum, uuid }, ["seatnum", "uuid"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "control", |
| | | action: "record_stop", |
| | | uuid: uuid, |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // æå¼åå¸ç¶æ |
| | | openseatlist() { |
| | | const { seatname, seatnum } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum }, ["seatnum"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "status", |
| | | action: "openseatlist", |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // å
³éåå¸ç¶æ |
| | | closeseatlist() { |
| | | const { seatname, seatnum } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum }, ["seatnum"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "status", |
| | | action: "closeseatlist", |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // æå¼éåä¿¡æ¯ |
| | | openqueues() { |
| | | const { seatname, seatnum } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum }, ["seatnum"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "status", |
| | | action: "openqueues", |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // å
³ééåä¿¡æ¯ |
| | | closequeues() { |
| | | const { seatname, seatnum } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum }, ["seatnum"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "status", |
| | | action: "closequeues", |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // æå¼éè¯ä¿¡æ¯ |
| | | opencalllist() { |
| | | const { seatname, seatnum } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum }, ["seatnum"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "status", |
| | | action: "opencalllist", |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // å
³ééè¯ä¿¡æ¯ |
| | | closecalllist() { |
| | | const { seatname, seatnum } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum }, ["seatnum"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "status", |
| | | action: "closecalllist", |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // æå¼è·¯ç±ä¿¡æ¯ |
| | | openroutelist() { |
| | | const { seatname, seatnum } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum }, ["seatnum"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "status", |
| | | action: "openroutelist", |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // å
³éè·¯ç±ä¿¡æ¯ |
| | | closeroutelist() { |
| | | const { seatname, seatnum } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum }, ["seatnum"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "status", |
| | | action: "closeroutelist", |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // è·ååå¸ä¿¡æ¯ |
| | | seatlist() { |
| | | const { group } = this.config; |
| | | |
| | | if (!this.validateParams({ group }, ["group"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "status", |
| | | action: "seatlist", |
| | | group: group, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // è·åéåä¿¡æ¯ |
| | | queues() { |
| | | const protocol = { |
| | | cmd: "status", |
| | | action: "queues", |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // è·åéè¯ä¿¡æ¯ |
| | | calllist() { |
| | | const protocol = { |
| | | cmd: "status", |
| | | action: "calllist", |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // è·åè·¯ç±ä¿¡æ¯ |
| | | routelist() { |
| | | const protocol = { |
| | | cmd: "status", |
| | | action: "routelist", |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // è·åå¤å¼åæ°ä¿¡æ¯ |
| | | batch() { |
| | | const { paramid } = this.config; |
| | | |
| | | if (!this.validateParams({ paramid }, ["paramid"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "status", |
| | | action: "batch", |
| | | paramid: paramid, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // å¼å§å¤å¼ä»»å¡ |
| | | batch_start() { |
| | | const { seatname, seatnum } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum }, ["seatnum"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "system", |
| | | action: "batch_start", |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // 忢å¤å¼ä»»å¡ |
| | | batch_stop() { |
| | | const { seatname, seatnum } = this.config; |
| | | |
| | | if (!this.validateParams({ seatnum }, ["seatnum"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "system", |
| | | action: "batch_stop", |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // å¿è·³å
|
| | | keepalive(seatname, seatnum) { |
| | | if (!this.validateParams({ seatnum }, ["seatnum"])) { |
| | | return; |
| | | } |
| | | |
| | | const protocol = { |
| | | cmd: "system", |
| | | action: "keepalive", |
| | | seatname: seatname, |
| | | seatnum: seatnum, |
| | | timestamp: Date.now(), |
| | | }; |
| | | this.sendWebSocketMessage(protocol); |
| | | }, |
| | | |
| | | // æ¸
餿¥å¿ |
| | | testclear() { |
| | | this.logs = ""; |
| | | this.addLog("æ¥å¿å·²æ¸
é¤"); |
| | | }, |
| | | |
| | | // æ·»å æ¥å¿ |
| | | addLog(message) { |
| | | const timestamp = new Date().toLocaleTimeString(); |
| | | this.logs += `[${timestamp}] ${message}\n`; |
| | | |
| | | // éå¶æ¥å¿é¿åº¦ï¼é²æ¢å
åæº¢åº |
| | | const logLines = this.logs.split("\n"); |
| | | if (logLines.length > 100) { |
| | | this.logs = logLines.slice(-50).join("\n"); |
| | | } |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .websocket-demo { |
| | | font-family: Arial, sans-serif; |
| | | padding: 20px; |
| | | max-width: 1200px; |
| | | margin: 0 auto; |
| | | } |
| | | |
| | | .config-area { |
| | | margin-bottom: 20px; |
| | | padding: 15px; |
| | | border: 1px solid #ddd; |
| | | border-radius: 4px; |
| | | background-color: #f9f9f9; |
| | | } |
| | | |
| | | .input-group { |
| | | display: flex; |
| | | flex-wrap: wrap; |
| | | align-items: center; |
| | | gap: 10px; |
| | | margin-bottom: 10px; |
| | | } |
| | | |
| | | .input-group label { |
| | | font-weight: bold; |
| | | min-width: 80px; |
| | | } |
| | | |
| | | .input-group input { |
| | | padding: 5px 10px; |
| | | border: 1px solid #ccc; |
| | | border-radius: 3px; |
| | | width: 120px; |
| | | } |
| | | |
| | | .button-area { |
| | | margin-bottom: 20px; |
| | | } |
| | | |
| | | .button-row { |
| | | display: flex; |
| | | flex-wrap: wrap; |
| | | gap: 5px; |
| | | margin-bottom: 10px; |
| | | } |
| | | |
| | | .button-row button { |
| | | padding: 8px 15px; |
| | | border: 1px solid #ccc; |
| | | border-radius: 3px; |
| | | background-color: #f0f0f0; |
| | | cursor: pointer; |
| | | transition: background-color 0.3s; |
| | | font-size: 12px; |
| | | } |
| | | |
| | | .button-row button:hover { |
| | | background-color: #e0e0e0; |
| | | } |
| | | |
| | | .button-row button:active { |
| | | background-color: #d0d0d0; |
| | | transform: translateY(1px); |
| | | } |
| | | |
| | | .log-area { |
| | | height: 300px; |
| | | overflow-y: auto; |
| | | border: 1px solid #ccc; |
| | | padding: 10px; |
| | | background-color: #f5f5f5; |
| | | white-space: pre-wrap; |
| | | font-family: "Courier New", monospace; |
| | | font-size: 12px; |
| | | line-height: 1.4; |
| | | } |
| | | |
| | | h3 { |
| | | color: #333; |
| | | border-bottom: 2px solid #eee; |
| | | padding-bottom: 10px; |
| | | display: flex; |
| | | justify-content: space-between; |
| | | align-items: center; |
| | | } |
| | | |
| | | h3 button { |
| | | padding: 5px 10px; |
| | | font-size: 12px; |
| | | background-color: #f0f0f0; |
| | | border: 1px solid #ccc; |
| | | border-radius: 3px; |
| | | cursor: pointer; |
| | | } |
| | | |
| | | /* ååºå¼è®¾è®¡ */ |
| | | @media (max-width: 768px) { |
| | | .websocket-demo { |
| | | padding: 10px; |
| | | } |
| | | |
| | | .input-group { |
| | | flex-direction: column; |
| | | align-items: flex-start; |
| | | } |
| | | |
| | | .input-group input { |
| | | width: 100%; |
| | | } |
| | | |
| | | .button-row { |
| | | flex-direction: column; |
| | | } |
| | | |
| | | .button-row button { |
| | | width: 100%; |
| | | margin-bottom: 5px; |
| | | } |
| | | } |
| | | </style> |
| | |
| | | placeholder="请è¾å
¥ä¸»æ²»å»ç" |
| | | ></el-input> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="æ¥æéå¶" prop="status"> |
| | | <el-select v-model="endOut" placeholder="è¯·éæ©"> |
| | | <el-option |
| | | v-for="item in endOuts" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | > |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="æ£è
èå´" prop="status"> |
| | | <el-cascader |
| | | v-model="topqueryParams.scopetype" |
| | |
| | | <div class="documentf"> |
| | | <div class="document"> |
| | | <el-button type="success" size="medium" @click="onthatday()" |
| | | >彿¥æå¡</el-button |
| | | >仿¥æå¡</el-button |
| | | > |
| | | </div> |
| | | </div> |
| | |
| | | prop="drname" |
| | | /> |
| | | <el-table-column |
| | | v-if="orgname != '丽水å¸ä¸å»é¢'" |
| | | label="é访人å" |
| | | align="center" |
| | | key="updateBy" |
| | |
| | | width="120" |
| | | /> |
| | | <el-table-column |
| | | v-if="orgname != '丽水å¸ä¸å»é¢'" |
| | | label="ç»ç®¡å»ç" |
| | | align="center" |
| | | key="managementDoctor" |
| | |
| | | qystatus: "", |
| | | btstatus: "", |
| | | }, |
| | | endOut: 1, |
| | | endOuts: [ |
| | | { |
| | | value: 0, |
| | | label: "æªæ¢è³å½æ¥æå¡", |
| | | }, |
| | | { |
| | | value: 1, |
| | | label: "å
¨é¨æå¡", |
| | | }, |
| | | ], |
| | | topicoptionssort: [ |
| | | { |
| | | value: 0, |
| | |
| | | leaveldeptcodes: [], |
| | | leavehospitaldistrictcodes: [], |
| | | }, |
| | | orgname: "", |
| | | propss: { multiple: true }, |
| | | options: [], |
| | | |
| | |
| | | this.serviceState = store.getters.serviceState; |
| | | this.checkboxlist = store.getters.checkboxlist; |
| | | this.errtype = this.$route.query.errtype; |
| | | this.orgname = localStorage.getItem("orgname"); |
| | | this.leavehospitaldistrictcode = |
| | | this.$route.query.leavehospitaldistrictcode; |
| | | this.sourcetype[0].children = store.getters.belongDepts.map((dept) => { |
| | |
| | | /** æ¥è¯¢é访æå¡å表 */ |
| | | getList(refresh) { |
| | | // é»è®¤å
¨é¨ |
| | | |
| | | if (this.topqueryParams.searchscope == 3) { |
| | | this.topqueryParams.leaveldeptcodes = store.getters.belongDepts.map( |
| | | (obj) => obj.deptCode |
| | | ); |
| | | this.topqueryParams.leavehospitaldistrictcodes = |
| | | store.getters.belongWards.map((obj) => obj.districtCode); |
| | | } |
| | | console.log(this.endOut); |
| | | |
| | | if (this.endOut == 0) { |
| | | this.topqueryParams.endOutHospTime = this.formatDateToYYYYMMDDHHMMSS( |
| | | this.getEndOfDay() |
| | | ); |
| | | } else { |
| | | this.topqueryParams.endOutHospTime = null; |
| | | } |
| | | // æ¥åå¼å¸¸è·³è½¬ |
| | | if (this.errtype) { |
| | |
| | | }); |
| | | this.total = response.total; |
| | | }); |
| | | }, |
| | | // æ¶é´ |
| | | getEndOfDay() { |
| | | const date = new Date(); // å建ä¸ä¸ªè¡¨ç¤ºå½åæ¶é´çDate对象 |
| | | date.setHours(23, 59, 59, 0); // å°æ¶é´è®¾ç½®ä¸º23:59:59.000 |
| | | return date; |
| | | }, |
| | | formatDateToYYYYMMDDHHMMSS(date) { |
| | | const year = date.getFullYear(); |
| | | const month = String(date.getMonth() + 1).padStart(2, "0"); // æä»½è¡¥é¶ |
| | | const day = String(date.getDate()).padStart(2, "0"); // æ¥æè¡¥é¶ |
| | | const hours = String(date.getHours()).padStart(2, "0"); |
| | | const minutes = String(date.getMinutes()).padStart(2, "0"); |
| | | const seconds = String(date.getSeconds()).padStart(2, "0"); |
| | | |
| | | return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; |
| | | }, |
| | | affiliation() { |
| | | this.topqueryParams.managementDoctorCode = store.getters.hisUserId; |
| | |
| | | let type = ""; |
| | | console.log(row, "rwo"); |
| | | if (row.preachformson) { |
| | | if (row.preachformson.includes("3")) { |
| | | if (row.preachformson.includes("3") || row.type == 1) { |
| | | type = 1; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | // cti-manager.js - ç§»é¤prototypeä¾èµççæ¬ |
| | | (function(root, factory) { |
| | | if (typeof define === 'function' && define.amd) { |
| | | define([], factory); |
| | | } else if (typeof module === 'object' && module.exports) { |
| | | module.exports = factory(); |
| | | } else { |
| | | root.CTIManager = factory(); |
| | | } |
| | | }(this, function() { |
| | | 'use strict'; |
| | | |
| | | // ç®åç对象æ©å±æ¹æ³ |
| | | function extend(target, source) { |
| | | if (!source) return target; |
| | | for (var key in source) { |
| | | if (source.hasOwnProperty(key)) { |
| | | target[key] = source[key]; |
| | | } |
| | | } |
| | | return target; |
| | | } |
| | | |
| | | function CTIManager(options) { |
| | | var defaultOptions = { |
| | | autoReconnect: true, |
| | | maxReconnectAttempts: 5, |
| | | debug: true |
| | | }; |
| | | |
| | | this.options = extend({}, defaultOptions); |
| | | this.options = extend(this.options, options || {}); |
| | | |
| | | this.websocket = null; |
| | | this.isLoggedIn = false; |
| | | this.currentCall = null; |
| | | this.seatInfo = {}; |
| | | this.eventHandlers = {}; |
| | | |
| | | this.init(); |
| | | } |
| | | |
| | | CTIManager.prototype = { |
| | | init: function() { |
| | | this.setupEventHandlers(); |
| | | }, |
| | | |
| | | setupEventHandlers: function() { |
| | | // é»è®¤äºä»¶å¤çå¨ |
| | | this.on('login_success', this.handleLoginSuccess.bind(this)); |
| | | this.on('login_failed', this.handleLoginFailed.bind(this)); |
| | | this.on('call_start', this.handleCallStart.bind(this)); |
| | | this.on('call_end', this.handleCallEnd.bind(this)); |
| | | this.on('seat_status_change', this.handleSeatStatusChange.bind(this)); |
| | | }, |
| | | |
| | | connect: function(url) { |
| | | try { |
| | | // ç¡®ä¿CTIWebSocketå·²å
¨å±å¯ç¨ |
| | | if (typeof CTIWebSocket === 'undefined') { |
| | | this.trigger('error', { type: 'dependency_error', message: 'CTIWebSocketæªå®ä¹' }); |
| | | return false; |
| | | } |
| | | |
| | | this.websocket = new CTIWebSocket({ |
| | | url: url, |
| | | debug: this.options.debug, |
| | | reconnectInterval: 3000, |
| | | maxReconnectAttempts: this.options.maxReconnectAttempts |
| | | }); |
| | | |
| | | this.bindWebSocketEvents(); |
| | | return true; |
| | | } catch (error) { |
| | | this.trigger('error', { type: 'connection_error', error: error }); |
| | | return false; |
| | | } |
| | | }, |
| | | |
| | | bindWebSocketEvents: function() { |
| | | var self = this; |
| | | |
| | | this.websocket.on('open', function() { |
| | | self.trigger('connected'); |
| | | }); |
| | | |
| | | this.websocket.on('close', function() { |
| | | self.isLoggedIn = false; |
| | | self.trigger('disconnected'); |
| | | }); |
| | | |
| | | this.websocket.on('error', function(error) { |
| | | self.trigger('error', error); |
| | | }); |
| | | |
| | | // çå¬ç¹å®çCTIæ¶æ¯ |
| | | this.websocket.on('cti:system:keepalive', function(data) { |
| | | self.trigger('keepalive', data); |
| | | }); |
| | | |
| | | this.websocket.on('cti:control:tp_callin', function(data) { |
| | | self.trigger('call_incoming', data); |
| | | if (data.uuid) { |
| | | self.trigger('uuid_received', data.uuid); |
| | | } |
| | | }); |
| | | }, |
| | | |
| | | // ç»å½ç¸å
³æ¹æ³ |
| | | login: function(seatname, seatnum, password) { |
| | | if (!this.websocket || !this.websocket.isConnected) { |
| | | this.trigger('error', { type: 'not_connected', message: 'WebSocketæªè¿æ¥' }); |
| | | return false; |
| | | } |
| | | |
| | | return this.websocket.seatlogin(seatname, seatnum, password); |
| | | }, |
| | | |
| | | logout: function() { |
| | | if (this.websocket && this.isLoggedIn) { |
| | | var result = this.websocket.seatlogout(this.seatInfo.seatname, this.seatInfo.seatnum); |
| | | if (result) { |
| | | this.isLoggedIn = false; |
| | | this.seatInfo = {}; |
| | | } |
| | | return result; |
| | | } |
| | | return false; |
| | | }, |
| | | |
| | | // å¼å«æ§å¶æ¹æ³ |
| | | makeCall: function(phoneNumber) { |
| | | if (!this.isLoggedIn) { |
| | | this.trigger('error', { type: 'not_logged_in', message: 'å叿ªç»å½' }); |
| | | return false; |
| | | } |
| | | |
| | | return this.websocket.callout(this.seatInfo.seatname, this.seatInfo.seatnum, phoneNumber); |
| | | }, |
| | | |
| | | hangupCall: function(uuid) { |
| | | if (!this.isLoggedIn) { |
| | | return false; |
| | | } |
| | | |
| | | var callUuid = uuid || (this.currentCall ? this.currentCall.uuid : ''); |
| | | return this.websocket.hangup(this.seatInfo.seatname, this.seatInfo.seatnum, callUuid); |
| | | }, |
| | | |
| | | // åå¸ç¶ææ§å¶ |
| | | setAfk: function() { |
| | | if (this.isLoggedIn) { |
| | | return this.websocket.afk(this.seatInfo.seatname, this.seatInfo.seatnum); |
| | | } |
| | | return false; |
| | | }, |
| | | |
| | | setOnline: function() { |
| | | if (this.isLoggedIn) { |
| | | return this.websocket.online(this.seatInfo.seatname, this.seatInfo.seatnum); |
| | | } |
| | | return false; |
| | | }, |
| | | |
| | | // äºä»¶ç®¡ç |
| | | on: function(event, handler) { |
| | | if (!this.eventHandlers[event]) { |
| | | this.eventHandlers[event] = []; |
| | | } |
| | | this.eventHandlers[event].push(handler); |
| | | }, |
| | | |
| | | off: function(event, handler) { |
| | | if (this.eventHandlers[event]) { |
| | | var index = this.eventHandlers[event].indexOf(handler); |
| | | if (index > -1) { |
| | | this.eventHandlers[event].splice(index, 1); |
| | | } |
| | | } |
| | | }, |
| | | |
| | | trigger: function(event, data) { |
| | | if (this.eventHandlers[event]) { |
| | | this.eventHandlers[event].forEach(function(handler) { |
| | | if (typeof handler === 'function') { |
| | | handler(data); |
| | | } |
| | | }); |
| | | } |
| | | }, |
| | | |
| | | destroy: function() { |
| | | if (this.websocket) { |
| | | this.websocket.close(); |
| | | this.websocket = null; |
| | | } |
| | | this.eventHandlers = {}; |
| | | } |
| | | }; |
| | | |
| | | return CTIManager; |
| | | })); |
¶Ô±ÈÐÂÎļþ |
| | |
| | | // json2.js |
| | | // 2016-05-01 |
| | | // Public Domain. |
| | | // NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. |
| | | // See http://www.JSON.org/js.html |
| | | // This code should be minified before deployment. |
| | | // See http://javascript.crockford.com/jsmin.html |
| | | |
| | | // USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO |
| | | // NOT CONTROL. |
| | | |
| | | // This file creates a global JSON object containing two methods: stringify |
| | | // and parse. This file is provides the ES5 JSON capability to ES3 systems. |
| | | // If a project might run on IE8 or earlier, then this file should be included. |
| | | // This file does nothing on ES5 systems. |
| | | |
| | | // JSON.stringify(value, replacer, space) |
| | | // value any JavaScript value, usually an object or array. |
| | | // replacer an optional parameter that determines how object |
| | | // values are stringified for objects. It can be a |
| | | // function or an array of strings. |
| | | // space an optional parameter that specifies the indentation |
| | | // of nested structures. If it is omitted, the text will |
| | | // be packed without extra whitespace. If it is a number, |
| | | // it will specify the number of spaces to indent at each |
| | | // level. If it is a string (such as "\t" or " "), |
| | | // it contains the characters used to indent at each level. |
| | | // This method produces a JSON text from a JavaScript value. |
| | | // When an object value is found, if the object contains a toJSON |
| | | // method, its toJSON method will be called and the result will be |
| | | // stringified. A toJSON method does not serialize: it returns the |
| | | // value represented by the name/value pair that should be serialized, |
| | | // or undefined if nothing should be serialized. The toJSON method |
| | | // will be passed the key associated with the value, and this will be |
| | | // bound to the value. |
| | | |
| | | // For example, this would serialize Dates as ISO strings. |
| | | |
| | | // Date.prototype.toJSON = function (key) { |
| | | // function f(n) { |
| | | // // Format integers to have at least two digits. |
| | | // return (n < 10) |
| | | // ? "0" + n |
| | | // : n; |
| | | // } |
| | | // return this.getUTCFullYear() + "-" + |
| | | // f(this.getUTCMonth() + 1) + "-" + |
| | | // f(this.getUTCDate()) + "T" + |
| | | // f(this.getUTCHours()) + ":" + |
| | | // f(this.getUTCMinutes()) + ":" + |
| | | // f(this.getUTCSeconds()) + "Z"; |
| | | // }; |
| | | |
| | | // You can provide an optional replacer method. It will be passed the |
| | | // key and value of each member, with this bound to the containing |
| | | // object. The value that is returned from your method will be |
| | | // serialized. If your method returns undefined, then the member will |
| | | // be excluded from the serialization. |
| | | |
| | | // If the replacer parameter is an array of strings, then it will be |
| | | // used to select the members to be serialized. It filters the results |
| | | // such that only members with keys listed in the replacer array are |
| | | // stringified. |
| | | |
| | | // Values that do not have JSON representations, such as undefined or |
| | | // functions, will not be serialized. Such values in objects will be |
| | | // dropped; in arrays they will be replaced with null. You can use |
| | | // a replacer function to replace those with JSON values. |
| | | |
| | | // JSON.stringify(undefined) returns undefined. |
| | | |
| | | // The optional space parameter produces a stringification of the |
| | | // value that is filled with line breaks and indentation to make it |
| | | // easier to read. |
| | | |
| | | // If the space parameter is a non-empty string, then that string will |
| | | // be used for indentation. If the space parameter is a number, then |
| | | // the indentation will be that many spaces. |
| | | |
| | | // Example: |
| | | |
| | | // text = JSON.stringify(["e", {pluribus: "unum"}]); |
| | | // // text is '["e",{"pluribus":"unum"}]' |
| | | |
| | | // text = JSON.stringify(["e", {pluribus: "unum"}], null, "\t"); |
| | | // // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]' |
| | | |
| | | // text = JSON.stringify([new Date()], function (key, value) { |
| | | // return this[key] instanceof Date |
| | | // ? "Date(" + this[key] + ")" |
| | | // : value; |
| | | // }); |
| | | // // text is '["Date(---current time---)"]' |
| | | |
| | | // JSON.parse(text, reviver) |
| | | // This method parses a JSON text to produce an object or array. |
| | | // It can throw a SyntaxError exception. |
| | | |
| | | // The optional reviver parameter is a function that can filter and |
| | | // transform the results. It receives each of the keys and values, |
| | | // and its return value is used instead of the original value. |
| | | // If it returns what it received, then the structure is not modified. |
| | | // If it returns undefined then the member is deleted. |
| | | |
| | | // Example: |
| | | |
| | | // // Parse the text. Values that look like ISO date strings will |
| | | // // be converted to Date objects. |
| | | |
| | | // myData = JSON.parse(text, function (key, value) { |
| | | // var a; |
| | | // if (typeof value === "string") { |
| | | // a = |
| | | // /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value); |
| | | // if (a) { |
| | | // return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], |
| | | // +a[5], +a[6])); |
| | | // } |
| | | // } |
| | | // return value; |
| | | // }); |
| | | |
| | | // myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) { |
| | | // var d; |
| | | // if (typeof value === "string" && |
| | | // value.slice(0, 5) === "Date(" && |
| | | // value.slice(-1) === ")") { |
| | | // d = new Date(value.slice(5, -1)); |
| | | // if (d) { |
| | | // return d; |
| | | // } |
| | | // } |
| | | // return value; |
| | | // }); |
| | | |
| | | // This is a reference implementation. You are free to copy, modify, or |
| | | // redistribute. |
| | | |
| | | /*jslint |
| | | eval, for, this |
| | | */ |
| | | |
| | | /*property |
| | | JSON, apply, call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours, |
| | | getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join, |
| | | lastIndex, length, parse, prototype, push, replace, slice, stringify, |
| | | test, toJSON, toString, valueOf |
| | | */ |
| | | |
| | | |
| | | // Create a JSON object only if one does not already exist. We create the |
| | | // methods in a closure to avoid creating global variables. |
| | | |
| | | if (typeof JSON !== "object") { |
| | | JSON = {}; |
| | | } |
| | | |
| | | (function () { |
| | | "use strict"; |
| | | |
| | | var rx_one = /^[\],:{}\s]*$/; |
| | | var rx_two = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g; |
| | | var rx_three = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g; |
| | | var rx_four = /(?:^|:|,)(?:\s*\[)+/g; |
| | | var rx_escapable = /[\\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; |
| | | var rx_dangerous = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; |
| | | |
| | | function f(n) { |
| | | // Format integers to have at least two digits. |
| | | return n < 10 |
| | | ? "0" + n |
| | | : n; |
| | | } |
| | | |
| | | function this_value() { |
| | | return this.valueOf(); |
| | | } |
| | | |
| | | if (typeof Date.prototype.toJSON !== "function") { |
| | | |
| | | Date.prototype.toJSON = function () { |
| | | |
| | | return isFinite(this.valueOf()) |
| | | ? this.getUTCFullYear() + "-" + |
| | | f(this.getUTCMonth() + 1) + "-" + |
| | | f(this.getUTCDate()) + "T" + |
| | | f(this.getUTCHours()) + ":" + |
| | | f(this.getUTCMinutes()) + ":" + |
| | | f(this.getUTCSeconds()) + "Z" |
| | | : null; |
| | | }; |
| | | |
| | | Boolean.prototype.toJSON = this_value; |
| | | Number.prototype.toJSON = this_value; |
| | | String.prototype.toJSON = this_value; |
| | | } |
| | | |
| | | var gap; |
| | | var indent; |
| | | var meta; |
| | | var rep; |
| | | |
| | | |
| | | function quote(string) { |
| | | |
| | | // If the string contains no control characters, no quote characters, and no |
| | | // backslash characters, then we can safely slap some quotes around it. |
| | | // Otherwise we must also replace the offending characters with safe escape |
| | | // sequences. |
| | | |
| | | rx_escapable.lastIndex = 0; |
| | | return rx_escapable.test(string) |
| | | ? "\"" + string.replace(rx_escapable, function (a) { |
| | | var c = meta[a]; |
| | | return typeof c === "string" |
| | | ? c |
| | | : "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4); |
| | | }) + "\"" |
| | | : "\"" + string + "\""; |
| | | } |
| | | |
| | | |
| | | function str(key, holder) { |
| | | |
| | | // Produce a string from holder[key]. |
| | | |
| | | var i; // The loop counter. |
| | | var k; // The member key. |
| | | var v; // The member value. |
| | | var length; |
| | | var mind = gap; |
| | | var partial; |
| | | var value = holder[key]; |
| | | |
| | | // If the value has a toJSON method, call it to obtain a replacement value. |
| | | |
| | | if (value && typeof value === "object" && |
| | | typeof value.toJSON === "function") { |
| | | value = value.toJSON(key); |
| | | } |
| | | |
| | | // If we were called with a replacer function, then call the replacer to |
| | | // obtain a replacement value. |
| | | |
| | | if (typeof rep === "function") { |
| | | value = rep.call(holder, key, value); |
| | | } |
| | | |
| | | // What happens next depends on the value's type. |
| | | |
| | | switch (typeof value) { |
| | | case "string": |
| | | return quote(value); |
| | | |
| | | case "number": |
| | | |
| | | // JSON numbers must be finite. Encode non-finite numbers as null. |
| | | |
| | | return isFinite(value) |
| | | ? String(value) |
| | | : "null"; |
| | | |
| | | case "boolean": |
| | | case "null": |
| | | |
| | | // If the value is a boolean or null, convert it to a string. Note: |
| | | // typeof null does not produce "null". The case is included here in |
| | | // the remote chance that this gets fixed someday. |
| | | |
| | | return String(value); |
| | | |
| | | // If the type is "object", we might be dealing with an object or an array or |
| | | // null. |
| | | |
| | | case "object": |
| | | |
| | | // Due to a specification blunder in ECMAScript, typeof null is "object", |
| | | // so watch out for that case. |
| | | |
| | | if (!value) { |
| | | return "null"; |
| | | } |
| | | |
| | | // Make an array to hold the partial results of stringifying this object value. |
| | | |
| | | gap += indent; |
| | | partial = []; |
| | | |
| | | // Is the value an array? |
| | | |
| | | if (Object.prototype.toString.apply(value) === "[object Array]") { |
| | | |
| | | // The value is an array. Stringify every element. Use null as a placeholder |
| | | // for non-JSON values. |
| | | |
| | | length = value.length; |
| | | for (i = 0; i < length; i += 1) { |
| | | partial[i] = str(i, value) || "null"; |
| | | } |
| | | |
| | | // Join all of the elements together, separated with commas, and wrap them in |
| | | // brackets. |
| | | |
| | | v = partial.length === 0 |
| | | ? "[]" |
| | | : gap |
| | | ? "[\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "]" |
| | | : "[" + partial.join(",") + "]"; |
| | | gap = mind; |
| | | return v; |
| | | } |
| | | |
| | | // If the replacer is an array, use it to select the members to be stringified. |
| | | |
| | | if (rep && typeof rep === "object") { |
| | | length = rep.length; |
| | | for (i = 0; i < length; i += 1) { |
| | | if (typeof rep[i] === "string") { |
| | | k = rep[i]; |
| | | v = str(k, value); |
| | | if (v) { |
| | | partial.push(quote(k) + ( |
| | | gap |
| | | ? ": " |
| | | : ":" |
| | | ) + v); |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | |
| | | // Otherwise, iterate through all of the keys in the object. |
| | | |
| | | for (k in value) { |
| | | if (Object.prototype.hasOwnProperty.call(value, k)) { |
| | | v = str(k, value); |
| | | if (v) { |
| | | partial.push(quote(k) + ( |
| | | gap |
| | | ? ": " |
| | | : ":" |
| | | ) + v); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // Join all of the member texts together, separated with commas, |
| | | // and wrap them in braces. |
| | | |
| | | v = partial.length === 0 |
| | | ? "{}" |
| | | : gap |
| | | ? "{\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "}" |
| | | : "{" + partial.join(",") + "}"; |
| | | gap = mind; |
| | | return v; |
| | | } |
| | | } |
| | | |
| | | // If the JSON object does not yet have a stringify method, give it one. |
| | | |
| | | if (typeof JSON.stringify !== "function") { |
| | | meta = { // table of character substitutions |
| | | "\b": "\\b", |
| | | "\t": "\\t", |
| | | "\n": "\\n", |
| | | "\f": "\\f", |
| | | "\r": "\\r", |
| | | "\"": "\\\"", |
| | | "\\": "\\\\" |
| | | }; |
| | | JSON.stringify = function (value, replacer, space) { |
| | | |
| | | // The stringify method takes a value and an optional replacer, and an optional |
| | | // space parameter, and returns a JSON text. The replacer can be a function |
| | | // that can replace values, or an array of strings that will select the keys. |
| | | // A default replacer method can be provided. Use of the space parameter can |
| | | // produce text that is more easily readable. |
| | | |
| | | var i; |
| | | gap = ""; |
| | | indent = ""; |
| | | |
| | | // If the space parameter is a number, make an indent string containing that |
| | | // many spaces. |
| | | |
| | | if (typeof space === "number") { |
| | | for (i = 0; i < space; i += 1) { |
| | | indent += " "; |
| | | } |
| | | |
| | | // If the space parameter is a string, it will be used as the indent string. |
| | | |
| | | } else if (typeof space === "string") { |
| | | indent = space; |
| | | } |
| | | |
| | | // If there is a replacer, it must be a function or an array. |
| | | // Otherwise, throw an error. |
| | | |
| | | rep = replacer; |
| | | if (replacer && typeof replacer !== "function" && |
| | | (typeof replacer !== "object" || |
| | | typeof replacer.length !== "number")) { |
| | | throw new Error("JSON.stringify"); |
| | | } |
| | | |
| | | // Make a fake root object containing our value under the key of "". |
| | | // Return the result of stringifying the value. |
| | | |
| | | return str("", {"": value}); |
| | | }; |
| | | } |
| | | |
| | | |
| | | // If the JSON object does not yet have a parse method, give it one. |
| | | |
| | | if (typeof JSON.parse !== "function") { |
| | | JSON.parse = function (text, reviver) { |
| | | |
| | | // The parse method takes a text and an optional reviver function, and returns |
| | | // a JavaScript value if the text is a valid JSON text. |
| | | |
| | | var j; |
| | | |
| | | function walk(holder, key) { |
| | | |
| | | // The walk method is used to recursively walk the resulting structure so |
| | | // that modifications can be made. |
| | | |
| | | var k; |
| | | var v; |
| | | var value = holder[key]; |
| | | if (value && typeof value === "object") { |
| | | for (k in value) { |
| | | if (Object.prototype.hasOwnProperty.call(value, k)) { |
| | | v = walk(value, k); |
| | | if (v !== undefined) { |
| | | value[k] = v; |
| | | } else { |
| | | delete value[k]; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return reviver.call(holder, key, value); |
| | | } |
| | | |
| | | |
| | | // Parsing happens in four stages. In the first stage, we replace certain |
| | | // Unicode characters with escape sequences. JavaScript handles many characters |
| | | // incorrectly, either silently deleting them, or treating them as line endings. |
| | | |
| | | text = String(text); |
| | | rx_dangerous.lastIndex = 0; |
| | | if (rx_dangerous.test(text)) { |
| | | text = text.replace(rx_dangerous, function (a) { |
| | | return "\\u" + |
| | | ("0000" + a.charCodeAt(0).toString(16)).slice(-4); |
| | | }); |
| | | } |
| | | |
| | | // In the second stage, we run the text against regular expressions that look |
| | | // for non-JSON patterns. We are especially concerned with "()" and "new" |
| | | // because they can cause invocation, and "=" because it can cause mutation. |
| | | // But just to be safe, we want to reject all unexpected forms. |
| | | |
| | | // We split the second stage into 4 regexp operations in order to work around |
| | | // crippling inefficiencies in IE's and Safari's regexp engines. First we |
| | | // replace the JSON backslash pairs with "@" (a non-JSON character). Second, we |
| | | // replace all simple value tokens with "]" characters. Third, we delete all |
| | | // open brackets that follow a colon or comma or that begin the text. Finally, |
| | | // we look to see that the remaining characters are only whitespace or "]" or |
| | | // "," or ":" or "{" or "}". If that is so, then the text is safe for eval. |
| | | |
| | | if ( |
| | | rx_one.test( |
| | | text |
| | | .replace(rx_two, "@") |
| | | .replace(rx_three, "]") |
| | | .replace(rx_four, "") |
| | | ) |
| | | ) { |
| | | |
| | | // In the third stage we use the eval function to compile the text into a |
| | | // JavaScript structure. The "{" operator is subject to a syntactic ambiguity |
| | | // in JavaScript: it can begin a block or an object literal. We wrap the text |
| | | // in parens to eliminate the ambiguity. |
| | | |
| | | j = eval("(" + text + ")"); |
| | | |
| | | // In the optional fourth stage, we recursively walk the new structure, passing |
| | | // each name/value pair to a reviver function for possible transformation. |
| | | |
| | | return (typeof reviver === "function") |
| | | ? walk({"": j}, "") |
| | | : j; |
| | | } |
| | | |
| | | // If the text is not JSON parseable, then a SyntaxError is thrown. |
| | | |
| | | throw new SyntaxError("JSON.parse"); |
| | | }; |
| | | } |
| | | }()); |
¶Ô±ÈÐÂÎļþ |
| | |
| | | var ws; |
| | | //--------------------------------��������websocket-----------------------------------------// |
| | | function initwebsocket(cti_ws_url) { |
| | | if ('WebSocket' in window) { |
| | | ws = new WebSocket(cti_ws_url); |
| | | } else { |
| | | alert("do not suports websocket"); |
| | | } |
| | | ws.onopen = function(evt) { |
| | | alert("open websocket success"); |
| | | } |
| | | ws.onclose = function(evt) { |
| | | alert("websocket close"); |
| | | } |
| | | //�������� |
| | | ws.onmessage = function(evt) { |
| | | var reader = new FileReader(); |
| | | reader.onloadend = function(e) { |
| | | console.log(this.result); |
| | | var msgdiv = document.getElementById("msg"); |
| | | var span = document.createElement("span"); |
| | | span.innerHTML = "receive_msg:"+this.result + "<br />"; |
| | | msgdiv.appendChild(span); |
| | | var obj = eval('(' + this.result + ')'); |
| | | if(obj.cmd=="system"&&obj.action=="keepalive"){ |
| | | keepalive(obj.seatname,obj.seatnum); |
| | | } |
| | | var uuid = document.getElementById("uuid"); |
| | | if(obj.cmd=="control"&&obj.action=="tp_callin"){ |
| | | uuid.value=obj.uuid; |
| | | } |
| | | }; |
| | | reader.readAsText(event.data); |
| | | } |
| | | ws.onerror = function(evt) { |
| | | alert("websocket error"); |
| | | } |
| | | } |
| | | function sendmessage(protocolStr){ |
| | | console.log(); |
| | | var msgdiv = document.getElementById("msg"); |
| | | var span = document.createElement("span"); |
| | | span.innerHTML = "send_msg:"+protocolStr + "<br />"; |
| | | msgdiv.appendChild(span); |
| | | ws.send(protocolStr); |
| | | } |
| | | function testclear(){ |
| | | var msgdiv = document.getElementById("msg"); |
| | | msgdiv.innerHTML=""; |
| | | } |
| | | //--------------------------------command send-----------------------------------------// |
| | | //��ϯǩ�� |
| | | function seatlogin(seatname,seatnum,password,cti_ws_url) { |
| | | if ('WebSocket' in window) { |
| | | ws = new WebSocket(cti_ws_url); |
| | | } else { |
| | | alert("do not suports websocket"); |
| | | } |
| | | ws.onopen = function(evt) { |
| | | alert("open websocket success"); |
| | | if(seatname=="") |
| | | { |
| | | alert("seatname is null"); |
| | | return; |
| | | } |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"system","action":"seatlogin","seatname":"<seatname>","seatnum":"<seatnum>","password":"<password>","timestamp":"<timestamp>"}; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | protocol.password=password; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | } |
| | | ws.onclose = function(evt) { |
| | | alert("websocket close"); |
| | | } |
| | | //�������� |
| | | ws.onmessage = function(evt) { |
| | | var reader = new FileReader(); |
| | | reader.onloadend = function(e) { |
| | | console.log(this.result); |
| | | var msgdiv = document.getElementById("msg"); |
| | | var span = document.createElement("span"); |
| | | span.innerHTML = "receive_msg:"+this.result + "<br />"; |
| | | msgdiv.appendChild(span); |
| | | var obj = eval('(' + this.result + ')'); |
| | | if(obj.cmd=="system"&&obj.action=="keepalive"){ |
| | | keepalive(obj.seatname,obj.seatnum); |
| | | } |
| | | var uuid = document.getElementById("uuid"); |
| | | if(obj.cmd=="control"&&obj.action=="tp_callin"){ |
| | | uuid.value=obj.uuid; |
| | | } |
| | | }; |
| | | reader.readAsText(event.data); |
| | | } |
| | | ws.onerror = function(evt) { |
| | | alert("websocket error"); |
| | | } |
| | | |
| | | //ws.send(protocolStr); |
| | | } |
| | | //��ϯǩ�� |
| | | function seatlogout(seatname,seatnum) { |
| | | if(seatname=="") |
| | | { |
| | | alert("seatname is null"); |
| | | return; |
| | | } |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"system","action":"seatlogout","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | ws.close(); |
| | | } |
| | | //���� |
| | | function afk(seatname,seatnum) { |
| | | if(seatname=="") |
| | | { |
| | | alert("seatname is null"); |
| | | return; |
| | | } |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"system","action":"afk","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //���� |
| | | function online(seatname,seatnum) { |
| | | if(seatname=="") |
| | | { |
| | | alert("seatname is null"); |
| | | return; |
| | | } |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"system","action":"online","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //��� |
| | | function callout(seatname,seatnum,phone) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | if(phone=="") |
| | | { |
| | | alert("phone is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"control","action":"callout","phone":"<phone>","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.phone=phone; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //ת�� |
| | | function transfer(seatname,seatnum,phone,uuid) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | if(phone=="") |
| | | { |
| | | alert("phone is null"); |
| | | return; |
| | | } |
| | | if(uuid=="") |
| | | { |
| | | alert("uuid is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"control","action":"transfer","uuid":"<uuid>","phone":"<phone>","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.phone=phone; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | protocol.uuid=uuid; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //ת���ջ� |
| | | function transferresume(seatname,seatnum,phone,uuid) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | if(phone=="") |
| | | { |
| | | alert("phone is null"); |
| | | return; |
| | | } |
| | | if(uuid=="") |
| | | { |
| | | alert("uuid is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"control","action":"transferresume","uuid":"<uuid>","phone":"<phone>","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.phone=phone; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | protocol.uuid=uuid; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | |
| | | //ͨ������ |
| | | function hold(seatname,seatnum,uuid) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | if(uuid=="") |
| | | { |
| | | alert("uuid is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"control","action":"hold","uuid":"<uuid>","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.uuid=uuid; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //ͨ�������ջ� |
| | | function holdresume(seatname,seatnum,uuid) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | if(uuid=="") |
| | | { |
| | | alert("uuid is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"control","action":"holdresume","uuid":"<uuid>","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.uuid=uuid; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //���� |
| | | function pickup(seatname,seatnum) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"control","action":"pickup","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.seatnum=seatnum; |
| | | protocol.seatname=seatname; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //�Ҷ� |
| | | function hangup(seatname,seatnum) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"control","action":"hangup","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.seatnum=seatnum; |
| | | protocol.seatname=seatname; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | |
| | | //ͨ��ǿ�� |
| | | function remove(seatname,seatnum,phone) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | if(phone=="") |
| | | { |
| | | alert("phone is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"control","action":"remove","phone":"<phone>","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.phone=phone; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //ͨ��ǿ�� |
| | | function insert(seatname,seatnum,phone) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | if(phone=="") |
| | | { |
| | | alert("phone is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"control","action":"insert","phone":"<phone>","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.phone=phone; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //���� |
| | | function monitor(seatname,seatnum,phone) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | if(phone=="") |
| | | { |
| | | alert("phone is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"control","action":"monitor","phone":"<phone>","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.phone=phone; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //����תͨ�� |
| | | function monitor_to_talk(seatname,seatnum,phone) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | if(phone=="") |
| | | { |
| | | alert("phone is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"control","action":"monitor_to_talk","phone":"<phone>","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.phone=phone; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //�������� |
| | | function monitor_end(seatname,seatnum,phone) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | if(phone=="") |
| | | { |
| | | alert("phone is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"control","action":"monitor_end","phone":"<phone>","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.phone=phone; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //ѡ�� |
| | | function choosecall(seatname,seatnum,uuid) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | if(uuid=="") |
| | | { |
| | | alert("uuid is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"control","action":"choosecall","uuid":"<uuid>","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.uuid=uuid; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //���� |
| | | function replacecall(seatname,seatnum,phone) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | if(phone=="") |
| | | { |
| | | alert("phone is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"control","action":"replacecall","phone":"<phone>","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.phone=phone; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //����ͨ�� |
| | | function three(seatname,seatnum,phone) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | if(phone=="") |
| | | { |
| | | alert("phone is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"control","action":"three","phone":"<phone>","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.phone=phone; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //������ϯ״̬ |
| | | function openseatlist(seatname,seatnum) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"status","action":"openseatlist","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.seatnum=seatnum; |
| | | protocol.seatname=seatname; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //�ر���ϯ״̬ |
| | | function closeseatlist(seatname,seatnum) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"status","action":"closeseatlist","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.seatnum=seatnum; |
| | | protocol.seatname=seatname; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //�����Ŷ���Ϣ |
| | | function openqueues(seatname,seatnum) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"status","action":"openqueues","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.seatnum=seatnum; |
| | | protocol.seatname=seatname; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //�ر��Ŷ���Ϣ |
| | | function closequeues(seatname,seatnum) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"status","action":"closequeues","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.seatnum=seatnum; |
| | | protocol.seatname=seatname; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //����ͨ����Ϣ |
| | | function opencalllist(seatname,seatnum) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"status","action":"opencalllist","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.seatnum=seatnum; |
| | | protocol.seatname=seatname; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //�ر�ͨ����Ϣ |
| | | function closecalllist(seatname,seatnum) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"status","action":"closecalllist","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.seatnum=seatnum; |
| | | protocol.seatname=seatname; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //�����м���Ϣ |
| | | function openroutelist(seatname,seatnum) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"status","action":"openroutelist","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.seatnum=seatnum; |
| | | protocol.seatname=seatname; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //�ر��м���Ϣ |
| | | function closeroutelist(seatname,seatnum) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"status","action":"closeroutelist","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.seatnum=seatnum; |
| | | protocol.seatname=seatname; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | |
| | | |
| | | |
| | | //��ȡ��ϯ��Ϣ |
| | | function seatlist(group) { |
| | | if(group=="") |
| | | { |
| | | alert("group is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"status","action":"seatlist","group":"<group>","timestamp":"<timestamp>"}; |
| | | protocol.group=group; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | |
| | | //��ȡ�Ŷ���Ϣ |
| | | function queues() { |
| | | var protocol={"cmd":"status","action":"queues","timestamp":"<timestamp>"}; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //��ȡͨ����Ϣ |
| | | function calllist() { |
| | | var protocol={"cmd":"status","action":"calllist","timestamp":"<timestamp>"}; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //��ȡ�м���Ϣ |
| | | function routelist() { |
| | | var protocol={"cmd":"status","action":"routelist","timestamp":"<timestamp>"}; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //��ȡ�������������Ϣ |
| | | function batch(paramid) { |
| | | if(paramid=="") |
| | | { |
| | | alert("paramid is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"status","action":"batch","paramid":"<paramid>","timestamp":"<timestamp>"}; |
| | | protocol.paramid=paramid; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //��ʼ������� |
| | | function batch_start(seatname,seatnum) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"system","action":"batch_start","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.seatnum=seatnum; |
| | | protocol.seatname=seatname; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //�ر�������� |
| | | function batch_stop(seatname,seatnum) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"system","action":"batch_stop","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.seatnum=seatnum; |
| | | protocol.seatname=seatname; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //ͨ����ѯ��ʼ |
| | | function handoff_ready(seatname,seatnum,uuid) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | if(uuid=="") |
| | | { |
| | | alert("uuid is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"control","action":"handoff_ready","uuid":"<uuid>","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.uuid=uuid; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //��ѯ |
| | | function handoff_call(seatname,seatnum,phone,uuid) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | if(phone=="") |
| | | { |
| | | alert("phone is null"); |
| | | return; |
| | | } |
| | | if(uuid=="") |
| | | { |
| | | alert("uuid is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"control","action":"handoff_call","uuid":"<uuid>","phone":"<phone>","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.phone=phone; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | protocol.uuid=uuid; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //��ѯ�ջ� |
| | | function handoff_resume(seatname,seatnum,uuid) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | if(uuid=="") |
| | | { |
| | | alert("uuid is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"control","action":"handoff_resume","uuid":"<uuid>","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | protocol.uuid=uuid; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //��ѯת�� |
| | | function handoff_transfer(seatname,seatnum,phone,uuid) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | if(phone=="") |
| | | { |
| | | alert("phone is null"); |
| | | return; |
| | | } |
| | | if(uuid=="") |
| | | { |
| | | alert("uuid is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"control","action":"handoff_transfer","uuid":"<uuid>","phone":"<phone>","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.phone=phone; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | protocol.uuid=uuid; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //��ѯ���� |
| | | function handoff_three(seatname,seatnum,uuid) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | if(uuid=="") |
| | | { |
| | | alert("uuid is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"control","action":"handoff_three","uuid":"<uuid>","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | protocol.uuid=uuid; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //���� |
| | | function keepalive(seatname,seatnum) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"system","action":"keepalive","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.seatnum=seatnum; |
| | | protocol.seatname=seatname; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | } |
| | | //ͨ������¼�� |
| | | function record_start(seatname,seatnum,uuid) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | if(uuid=="") |
| | | { |
| | | alert("uuid is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"control","action":"record_start","uuid":"<uuid>","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.uuid=uuid; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | //ͨ��ֹͣ¼�� |
| | | function record_stop(seatname,seatnum,uuid) { |
| | | if(seatnum=="") |
| | | { |
| | | alert("seatnum is null"); |
| | | return; |
| | | } |
| | | if(uuid=="") |
| | | { |
| | | alert("uuid is null"); |
| | | return; |
| | | } |
| | | var protocol={"cmd":"control","action":"record_stop","uuid":"<uuid>","seatname":"<seatname>","seatnum":"<seatnum>","timestamp":"<timestamp>"}; |
| | | protocol.uuid=uuid; |
| | | protocol.seatname=seatname; |
| | | protocol.seatnum=seatnum; |
| | | var protocolStr=JSON.stringify(protocol); |
| | | sendmessage(protocolStr); |
| | | //ws.send(protocolStr); |
| | | } |
| | | |
| | | //---------------------------------------------------------------------------------// |
| | | |
| | | |
| | |
| | | <div class="documentf"> |
| | | <div class="document"> |
| | | <el-button type="success" size="medium" @click="onthatday()" |
| | | >彿¥æå¡</el-button |
| | | >仿¥æå¡</el-button |
| | | > |
| | | </div> |
| | | </div> |
| | |
| | | <div class="documentf"> |
| | | <div class="document"> |
| | | <el-button type="success" size="medium" @click="onthatday()" |
| | | >彿¥æå¡</el-button |
| | | >仿¥æå¡</el-button |
| | | > |
| | | </div> |
| | | </div> |
| | |
| | | }, 3000); |
| | | }, |
| | | yuyingetdetail() { |
| | | this.tableDatatop.forEach((item, index) => { |
| | | item.scriptResult = item.scriptResult.join("&"); |
| | | item.templatequestionnum = index + 1; |
| | | item.subId = this.id; |
| | | item.taskid = this.taskid; |
| | | item.asrtext = item.matchedtext; |
| | | if (!item.id) { |
| | | item.isoperation = 1; |
| | | } |
| | | item.patid = this.patid; |
| | | item.templateid = item.templateID; |
| | | }); |
| | | let obj = { |
| | | serviceSubtaskDetailList: this.tableDatatop, |
| | | param1: this.taskid, |
| | | param2: this.patid, |
| | | subId: this.id, |
| | | }; |
| | | const dataToSubmit = JSON.parse(JSON.stringify(this.tableDatatop)); |
| | | |
| | | dataToSubmit.forEach((item, index) => { |
| | | // 对æ·è´çæ°æ®è¿è¡æä½ï¼ä¸å½±ååå§ç scriptResult æ°ç» |
| | | item.scriptResult = item.scriptResult.join("&"); |
| | | item.templatequestionnum = index + 1; |
| | | item.subId = this.id; |
| | | item.taskid = this.taskid; |
| | | item.asrtext = item.matchedtext; |
| | | if (!item.id) { |
| | | item.isoperation = 1; |
| | | } |
| | | item.patid = this.patid; |
| | | item.templateid = item.templateID; |
| | | }); |
| | | |
| | | let obj = { |
| | | serviceSubtaskDetailList: dataToSubmit, // æäº¤å¤çåç坿¬ |
| | | param1: this.taskid, |
| | | param2: this.patid, |
| | | subId: this.id, |
| | | }; |
| | | |
| | | addPersonVoices(obj).then((res) => { |
| | | if (res.code == 200) { |
| | |
| | | <div class="documentf"> |
| | | <div class="document"> |
| | | <el-button type="success" size="medium" @click="onthatday()" |
| | | >彿¥æå¡</el-button |
| | | >仿¥æå¡</el-button |
| | | > |
| | | </div> |
| | | </div> |
| | |
| | | <div class="documentf"> |
| | | <div class="document"> |
| | | <el-button type="success" size="medium" @click="onthatday()" |
| | | >彿¥æå¡</el-button |
| | | >仿¥æå¡</el-button |
| | | > |
| | | </div> |
| | | </div> |
| | |
| | | <div class="documentf"> |
| | | <div class="document"> |
| | | <el-button type="success" size="medium" @click="onthatday()" |
| | | >彿¥æå¡</el-button |
| | | >仿¥æå¡</el-button |
| | | > |
| | | </div> |
| | | </div> |
| | |
| | | this.leavehospitaldistrictcodes[0] || |
| | | this.diagglist[0] || |
| | | this.operationcodes[0] || |
| | | this.form.longTask == 2 |
| | | this.form.longTask == 2||this.serviceType==14 |
| | | ) { |
| | | } else { |
| | | this.$modal.msgError("è¯·éæ©ä»»å¡å
³èæ¡ä»¶"); |
| | |
| | | this.deptcodesWards[0] || |
| | | this.leavehospitaldistrictcodes[0] || |
| | | this.diagglist[0] || |
| | | this.operationcodes[0] |
| | | this.operationcodes[0] || |
| | | this.form.longTask == 2 || |
| | | this.serviceType == 14 |
| | | ) { |
| | | } else { |
| | | this.$modal.msgError("è¯·éæ©ä»»å¡å
³èæ¡ä»¶"); |
| | |
| | | pathRewrite: { |
| | | ['^' + process.env.VUE_APP_BASE_API]: '' |
| | | } |
| | | } |
| | | }, |
| | | |
| | | }, |
| | | disableHostCheck: true |
| | | }, |