|  |  |  | 
|---|
|  |  |  | :key="item.aaa" | 
|---|
|  |  |  | > | 
|---|
|  |  |  | <div class="dev-text"> | 
|---|
|  |  |  | {{ index + 1 }}、<span>{{ item.questionText }}</span> | 
|---|
|  |  |  | {{ index + 1 }}、<span>{{ item.scriptContent }}</span> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | <div class="dev-xx"> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <div class="dev-xx" v-if="item.valueType == 1"> | 
|---|
|  |  |  | <el-radio-group v-model="item.radio"> | 
|---|
|  |  |  | <el-radio | 
|---|
|  |  |  | v-for="(items, index) in item.ivrLibaScriptTargetoptionList" | 
|---|
|  |  |  | 
|---|
|  |  |  | >{{ items.targetvalue }}</el-radio | 
|---|
|  |  |  | > | 
|---|
|  |  |  | </el-radio-group> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | <div v-else> | 
|---|
|  |  |  | <el-input | 
|---|
|  |  |  | type="textarea" | 
|---|
|  |  |  | placeholder="未获取到信息" | 
|---|
|  |  |  | v-model.sync="item.questionResult" | 
|---|
|  |  |  | :rows="2" | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | 
|---|
|  |  |  | websocketSend, | 
|---|
|  |  |  | closeWebsocket, | 
|---|
|  |  |  | } from "@/websocket/websocket.js"; | 
|---|
|  |  |  | import store from "@/store"; | 
|---|
|  |  |  | export default { | 
|---|
|  |  |  | data() { | 
|---|
|  |  |  | return { | 
|---|
|  |  |  | answer: "", //回答 | 
|---|
|  |  |  | id: null, | 
|---|
|  |  |  | TemplateName: "随访模版名称", //模版名 | 
|---|
|  |  |  | TemplateName: "随访模板名称", //模板名 | 
|---|
|  |  |  | radio: "1", | 
|---|
|  |  |  | userid: "", | 
|---|
|  |  |  | input: "还不错", | 
|---|
|  |  |  | drawer: false, | 
|---|
|  |  |  | radio: "2", | 
|---|
|  |  |  | code: "", | 
|---|
|  |  |  | timeout: "5", | 
|---|
|  |  |  | Answerline: [], | 
|---|
|  |  |  | questionList: [], | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | created() { | 
|---|
|  |  |  | this.TemplateName = this.$route.query.name; | 
|---|
|  |  |  | this.userid = store.getters.Id; | 
|---|
|  |  |  | console.log(store.getters.Id,'11'); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | this.requstWs(); //进入页面创建连接 | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | mounted() { | 
|---|
|  |  |  | // 获取class为borderdiv的元素 | 
|---|
|  |  |  | const borderdiv = document.querySelector(".borderdiv"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 创建一个MutationObserver实例,用于监听元素的变化 | 
|---|
|  |  |  | const observer = new MutationObserver(() => { | 
|---|
|  |  |  | // 当元素高度变化时,将滚动条滚动到最下方 | 
|---|
|  |  |  | borderdiv.scrollTop = borderdiv.scrollHeight; | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 配置MutationObserver实例的观察目标和观察选项 | 
|---|
|  |  |  | observer.observe(borderdiv, { | 
|---|
|  |  |  | attributes: true, | 
|---|
|  |  |  | childList: true, | 
|---|
|  |  |  | subtree: true, | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 当不再需要监听时,可以使用disconnect方法停止观察 | 
|---|
|  |  |  | // observer.disconnect(); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | methods: { | 
|---|
|  |  |  | 
|---|
|  |  |  | requstWs(message, next, file) { | 
|---|
|  |  |  | console.log("连接"); | 
|---|
|  |  |  | this.id = this.$route.query.id; | 
|---|
|  |  |  | this.timeout = this.$route.query.timeout; | 
|---|
|  |  |  | // 防止用户多次连续点击发起请求,所以要先关闭上次的ws请求。 | 
|---|
|  |  |  | closeWebsocket(); | 
|---|
|  |  |  | console.log(this.id); | 
|---|
|  |  |  | const obj = { | 
|---|
|  |  |  | type: "text", | 
|---|
|  |  |  | userId: "1", | 
|---|
|  |  |  | userId: this.userid, | 
|---|
|  |  |  | templateId: this.id, | 
|---|
|  |  |  | content: null, | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | // 发起ws请求 | 
|---|
|  |  |  | sendWebsocket( | 
|---|
|  |  |  | "ws://192.168.2.8:8089/chat?userId=1", | 
|---|
|  |  |  | "ws://9.208.2.190:8095/chat?userId="+this.userid, | 
|---|
|  |  |  | obj, | 
|---|
|  |  |  | this.wsMessage, | 
|---|
|  |  |  | this.wsError | 
|---|
|  |  |  | 
|---|
|  |  |  | // 接收ws返回的数据 | 
|---|
|  |  |  | wsMessage(data) { | 
|---|
|  |  |  | let dataJson = data; | 
|---|
|  |  |  | let timerId = null; | 
|---|
|  |  |  | dataJson = JSON.parse(dataJson); | 
|---|
|  |  |  | dataJson = JSON.parse(dataJson); | 
|---|
|  |  |  | console.log(dataJson, "数据"); | 
|---|
|  |  |  | // 首次接收数据 | 
|---|
|  |  |  | if (!this.Answerline[0]) { | 
|---|
|  |  |  | this.Answerline.push({ | 
|---|
|  |  |  | value: dataJson.kcb, | 
|---|
|  |  |  | isEat: 1, | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // if (!this.Answerline[0]) { | 
|---|
|  |  |  | //   this.Answerline.push({ | 
|---|
|  |  |  | //     value: dataJson.kcb, | 
|---|
|  |  |  | //     isEat: 1, | 
|---|
|  |  |  | //   }); | 
|---|
|  |  |  | // } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 优先加入通用库匹配文本 | 
|---|
|  |  |  | if (dataJson.nowQuestion.submoduleText) { | 
|---|
|  |  |  | this.Answerline.push({ | 
|---|
|  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 是否结束 | 
|---|
|  |  |  | if (!dataJson.jsy) { | 
|---|
|  |  |  | this.Answerline.push({ | 
|---|
|  |  |  | value: dataJson.nowQuestion.questionText, | 
|---|
|  |  |  | isEat: 1, | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | if (dataJson.jsy) { | 
|---|
|  |  |  | this.Answerline.push({ | 
|---|
|  |  |  | value: dataJson.jsy, | 
|---|
|  |  |  | isEat: 1, | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } else if (dataJson.nowQuestion.scriptContent) { | 
|---|
|  |  |  | this.Answerline.push({ | 
|---|
|  |  |  | value: dataJson.nowQuestion.scriptContent, | 
|---|
|  |  |  | isEat: 1, | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | return item; | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | if (!dataJson.jsy) { | 
|---|
|  |  |  | timerId = setTimeout(() => { | 
|---|
|  |  |  | if (!this.answer) { | 
|---|
|  |  |  | this.sendFn(); // 后调用 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, this.timeout * 1000); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | clearTimeout(timerId) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | console.log(this.questionList); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // IMUI.appendMessage(data); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | 
|---|
|  |  |  | }, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sendFn() { | 
|---|
|  |  |  | console.log("发送"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 消息发送 | 
|---|
|  |  |  | const obj = { | 
|---|
|  |  |  | type: "text", | 
|---|
|  |  |  | userId: "1", | 
|---|
|  |  |  | userId: this.userid, | 
|---|
|  |  |  | templateId: "", | 
|---|
|  |  |  | questionMessage: { content: this.answer }, | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | console.log(obj, "入参"); | 
|---|
|  |  |  | // 发起ws请求 | 
|---|
|  |  |  | sendWebsocket( | 
|---|
|  |  |  | "ws://192.168.2.8:8089/chat?userId=1", | 
|---|
|  |  |  | "ws://9.208.2.190:8095/chat?userId="+this.userid, | 
|---|
|  |  |  | obj, | 
|---|
|  |  |  | this.wsMessage, | 
|---|
|  |  |  | this.wsError | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | .borderdiv { | 
|---|
|  |  |  | min-height: 60vh; | 
|---|
|  |  |  | height: 100vh; | 
|---|
|  |  |  | font-size: 20px; | 
|---|
|  |  |  | padding: 30px; | 
|---|
|  |  |  | max-height: 700px; | 
|---|
|  |  |  | overflow: auto; | 
|---|
|  |  |  | .leftside { | 
|---|
|  |  |  | margin-bottom: 30px; | 
|---|
|  |  |  | max-width: 566px; | 
|---|
|  |  |  | margin-left: 20px; | 
|---|
|  |  |  | padding: 10px; | 
|---|
|  |  |  | color: #fff; | 
|---|
|  |  |  | background: rgb(110, 196, 247); | 
|---|
|  |  |  | border-radius: 10px; | 
|---|
|  |  |  | span { | 
|---|
|  |  |  | width: 400px; | 
|---|
|  |  |  | margin-left: 20px; | 
|---|
|  |  |  | padding: 10px; | 
|---|
|  |  |  | color: #fff; | 
|---|
|  |  |  | background: rgb(110, 196, 247); | 
|---|
|  |  |  | border-radius: 10px; | 
|---|
|  |  |  | word-wrap: break-word; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | .offside { | 
|---|