|
@@ -3,6 +3,9 @@
|
|
|
<div class="smart_content">
|
|
|
<el-row>
|
|
|
<!-- <el-col :span="1"> </el-col> -->
|
|
|
+ <div style="text-align: right">
|
|
|
+ <i class="el-icon-refresh" style='cursor:pointer;color:blue' @click='init()'></i>
|
|
|
+ </div>
|
|
|
<el-col :span="24">
|
|
|
<div
|
|
|
class="chat-window"
|
|
@@ -13,6 +16,9 @@
|
|
|
<div v-if="echoFlag" style="text-align: center">
|
|
|
<i class="el-icon-loading"></i>
|
|
|
</div>
|
|
|
+ <!-- <div style="text-align: right">
|
|
|
+ <i class="el-icon-loading"></i>
|
|
|
+ </div> -->
|
|
|
<div
|
|
|
class="chat-msg-content"
|
|
|
id="rongqi"
|
|
@@ -203,21 +209,6 @@
|
|
|
>
|
|
|
</span>
|
|
|
</el-dialog>
|
|
|
-
|
|
|
- <el-dialog
|
|
|
- title=""
|
|
|
- :visible.sync="openDialogFlag"
|
|
|
- width="30%"
|
|
|
- center
|
|
|
- >
|
|
|
- <span>需要注意的是内容是默认不居中的</span>
|
|
|
- <span slot="footer" class="dialog-footer">
|
|
|
- <el-button @click="openDialogFlag = false">取 消</el-button>
|
|
|
- <el-button type="primary" @click="openDialogFlag = false"
|
|
|
- >确 定</el-button
|
|
|
- >
|
|
|
- </span>
|
|
|
- </el-dialog>
|
|
|
<!-- <el-button @click="centerDialogVisible = true">打开窗口</el-button> -->
|
|
|
</div>
|
|
|
</template>
|
|
@@ -287,6 +278,10 @@ export default {
|
|
|
printIndex: 0,
|
|
|
flagTime: null,
|
|
|
openDialogFlag: true,
|
|
|
+ isTimeout: false,
|
|
|
+ timeoutDes: "",
|
|
|
+ //获取下一题问题的编号
|
|
|
+ preQuestion: "",
|
|
|
};
|
|
|
},
|
|
|
created() {},
|
|
@@ -364,6 +359,24 @@ export default {
|
|
|
{},
|
|
|
(res) => {
|
|
|
if (res.code == 200) {
|
|
|
+ //res.data.greetings==
|
|
|
+ // console.log(res.data.greetings==null)
|
|
|
+ //
|
|
|
+ if (that.pageNum == 1) {
|
|
|
+ if (res.data.greetings == null) {
|
|
|
+ that.isTimeout = false;
|
|
|
+ that.timeoutDes = "";
|
|
|
+ } else {
|
|
|
+ that.isTimeout = true;
|
|
|
+ that.timeoutDes = res.data.greetings;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ that.isTimeout = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // that.isTimeout = true;
|
|
|
+ // that.timeoutDes = "三天没见了,你最近好吗";
|
|
|
+
|
|
|
that.echoFlag = false;
|
|
|
// res.data.
|
|
|
if (res.data.intelligentDialogueEntities.content.length > 0) {
|
|
@@ -381,7 +394,12 @@ export default {
|
|
|
) {
|
|
|
//当是第一页第一个时,不取了
|
|
|
|
|
|
+ //判断最后一个是不是填空还是选择
|
|
|
+ //如果时填空或选择则后两个都不如库
|
|
|
+
|
|
|
if (!(that.pageNum == 1 && i == 0)) {
|
|
|
+ //当满足条件时
|
|
|
+
|
|
|
this.chatContents.unshift({
|
|
|
from: 1,
|
|
|
//是否是量表的信息
|
|
@@ -396,6 +414,9 @@ export default {
|
|
|
//头像
|
|
|
from1: HeadImg,
|
|
|
});
|
|
|
+ } else {
|
|
|
+ that.preQuestion =
|
|
|
+ res.data.intelligentDialogueEntities.content[0].questionNo;
|
|
|
}
|
|
|
} else {
|
|
|
if (!(that.pageNum == 1 && i == 0)) {
|
|
@@ -419,20 +440,52 @@ export default {
|
|
|
console.log(this.chatContents);
|
|
|
}
|
|
|
|
|
|
- //当是第一页
|
|
|
- //且总条数为0时
|
|
|
- if (that.pageNum == 1) {
|
|
|
- //当是第一次进来时,需要调用question 获取第一次问答信息,但是传输的是type为5
|
|
|
- if (res.data.intelligentDialogueEntities.content.length == 0) {
|
|
|
- //将当前的设置为5
|
|
|
- that.interveneId = 5;
|
|
|
- that.getQuestion("", false);
|
|
|
- } else {
|
|
|
- let id =
|
|
|
- res.data.intelligentDialogueEntities.content[0].questionNo;
|
|
|
- that.getQuestion(id, false);
|
|
|
+ //如满足条件//应还有一个参数--用来表示是否需要显示提示几天不见的话语
|
|
|
+ if (that.isTimeout) {
|
|
|
+ debugger;
|
|
|
+ that.chatContents.push({
|
|
|
+ //是问题还是答案
|
|
|
+ from: 1,
|
|
|
+ //是否是量表的信息
|
|
|
+ isScale: false,
|
|
|
+ //是单选还是文字 0单选 1填空 -1描述
|
|
|
+ isType: -1,
|
|
|
+ //可点击可不点击 0单选 1填空
|
|
|
+ disabled: false,
|
|
|
+ //问题
|
|
|
+ question: "",
|
|
|
+ //头像
|
|
|
+ from1: HeadImg,
|
|
|
+ });
|
|
|
+ that.pFun(that.timeoutDes, true, "", false, true);
|
|
|
+ } else {
|
|
|
+ if (that.pageNum == 1) {
|
|
|
+ //当是第一次进来时,需要调用question 获取第一次问答信息,但是传输的是type为5
|
|
|
+ if (res.data.intelligentDialogueEntities.content.length == 0) {
|
|
|
+ //将当前的设置为5
|
|
|
+ that.interveneId = 5;
|
|
|
+ that.getQuestion("", false);
|
|
|
+ } else {
|
|
|
+ let id =
|
|
|
+ res.data.intelligentDialogueEntities.content[0].questionNo;
|
|
|
+ that.getQuestion(id, false);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ //当是第一页
|
|
|
+ //且总条数为0时
|
|
|
+ // if (that.pageNum == 1) {
|
|
|
+ // //当是第一次进来时,需要调用question 获取第一次问答信息,但是传输的是type为5
|
|
|
+ // if (res.data.intelligentDialogueEntities.content.length == 0) {
|
|
|
+ // //将当前的设置为5
|
|
|
+ // that.interveneId = 5;
|
|
|
+ // that.getQuestion("", false);
|
|
|
+ // } else {
|
|
|
+ // let id =
|
|
|
+ // res.data.intelligentDialogueEntities.content[0].questionNo;
|
|
|
+ // that.getQuestion(id, false);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
} else {
|
|
|
}
|
|
|
}
|
|
@@ -521,7 +574,7 @@ export default {
|
|
|
}
|
|
|
);
|
|
|
},
|
|
|
- init(val) {
|
|
|
+ init() {
|
|
|
this.getQuestion(1, true);
|
|
|
let contant1 = document.getElementById("contant1");
|
|
|
this.sleep(101).then(() => {
|
|
@@ -599,6 +652,7 @@ export default {
|
|
|
|
|
|
//第二个参数判断是否是需要回显的,如果是数据已返回就不回显了
|
|
|
//或保存,当第二个参数为true时需要保存,当第二个参数为false时不需要保存
|
|
|
+ //第三个参数判断是否出现
|
|
|
|
|
|
getQuestion(id, flag) {
|
|
|
let that = this;
|
|
@@ -642,13 +696,13 @@ export default {
|
|
|
//头像
|
|
|
from1: HeadImg,
|
|
|
});
|
|
|
- this.pFun(result.question, true, result, flag);
|
|
|
+ this.pFun(result.question, true, result, flag, false);
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
},
|
|
|
//修改文本打印效果
|
|
|
- pFun(val, flag, result, saveFlag) {
|
|
|
+ pFun(val, flag, result, saveFlag, isShow) {
|
|
|
let that = this;
|
|
|
//3个循环播放
|
|
|
this.chatContents[this.chatContents.length - 1].question = "";
|
|
@@ -656,6 +710,17 @@ export default {
|
|
|
// let a = val;
|
|
|
let a = "......";
|
|
|
|
|
|
+ if (this.interveneId != 5) {
|
|
|
+ let paramsSave = {
|
|
|
+ label: 0,
|
|
|
+ content: result ? result.question : "",
|
|
|
+ questionNo: result.id,
|
|
|
+ };
|
|
|
+ if (saveFlag) {
|
|
|
+ this.saveRecord(paramsSave);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
clearInterval(this.flagTime);
|
|
|
this.flagTime = setInterval(
|
|
|
() => {
|
|
@@ -698,13 +763,50 @@ export default {
|
|
|
// this.saveRecord(ob);
|
|
|
//在这判断负面情绪是否足够5个
|
|
|
if (this.interveneId != 5) {
|
|
|
- let paramsSave = {
|
|
|
- label: 0,
|
|
|
- content: result ? result.question : "",
|
|
|
- questionNo: result.id,
|
|
|
- };
|
|
|
- if (saveFlag) {
|
|
|
- this.saveRecord(paramsSave);
|
|
|
+ // let paramsSave = {
|
|
|
+ // label: 0,
|
|
|
+ // content: result ? result.question : "",
|
|
|
+ // questionNo: result.id,
|
|
|
+ // };
|
|
|
+ // if (saveFlag) {
|
|
|
+ // this.saveRecord(paramsSave);
|
|
|
+ // }
|
|
|
+ if (isShow) {
|
|
|
+ this.chatContents.push({
|
|
|
+ id: 123456789,
|
|
|
+ from: 2,
|
|
|
+ isScale: false,
|
|
|
+ //是单选还是文字 0单选 1填空 -1描述
|
|
|
+ isType: 0,
|
|
|
+ disabled: false,
|
|
|
+ question: [
|
|
|
+ {
|
|
|
+ id: "123456789",
|
|
|
+ createTime: null,
|
|
|
+ updateTime: null,
|
|
|
+ questionNo: "-200",
|
|
|
+ nextQuestionNo: "-200",
|
|
|
+ questionType: "0",
|
|
|
+ answer: "继续上次",
|
|
|
+ label: "2",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: "1234567890",
|
|
|
+ createTime: null,
|
|
|
+ updateTime: null,
|
|
|
+ questionNo: "-201",
|
|
|
+ nextQuestionNo: "-201",
|
|
|
+ questionType: "0",
|
|
|
+ answer: "重新开始",
|
|
|
+ label: "2",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ from1: HeadImg,
|
|
|
+ radio: false,
|
|
|
+ text: "",
|
|
|
+ });
|
|
|
+
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -829,7 +931,7 @@ export default {
|
|
|
});
|
|
|
} else if (data[0].questionType == 5) {
|
|
|
let dataTmp = JSON.parse(data[0].questionParam);
|
|
|
- // for (let i = 0; i < dataTmp.length; i++) {
|
|
|
+ // for (let i = 0; i < dataTmp.length; i++) {radi
|
|
|
// if (dataTmp.length - 1 == i) {
|
|
|
// checkIt += dataTmp[i].name;
|
|
|
// } else {
|
|
@@ -852,6 +954,17 @@ export default {
|
|
|
// 选择答案
|
|
|
chooseAnswer(val) {
|
|
|
let id = val.radio;
|
|
|
+
|
|
|
+ if (id == "-200") {
|
|
|
+ //上一次的id
|
|
|
+ this.getQuestion(this.preQuestion, false);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (id == "-201") {
|
|
|
+ this.getQuestion(1, false);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
console.log("下一题编号");
|
|
|
console.log(id);
|
|
|
//循环这个数组得到选择的答案
|
|
@@ -896,10 +1009,6 @@ export default {
|
|
|
} else {
|
|
|
this.getQuestion(id, true);
|
|
|
}
|
|
|
- //如果判断id为空
|
|
|
- // if(){
|
|
|
-
|
|
|
- // }
|
|
|
},
|
|
|
|
|
|
// 量表选中切换下一题
|