Browse Source

提交,认知干预代码

[plg137200.] 1 năm trước cách đây
mục cha
commit
5efac77acf

+ 22 - 35
src/renderer/components/Menu.vue

@@ -36,7 +36,7 @@
         </div>
         <!-- :default-active="defaultUrl"           :default-active="$route.path"-->
         <el-menu
-         :default-active="defaultUrl"  
+          :default-active="defaultUrl"
           class="el-menu-vertical-demo"
           @open="handleOpen"
           @close="handleClose"
@@ -74,15 +74,12 @@
             <img class="menu_icon_cla" src="../assets/menuIcon/main.png" />
             <span slot="title" class="menu_text_cla">主页</span>
           </el-menu-item>
-             <!-- :style="[{ background: rjdh ? '' : '#ffffff' }]" -->
+          <!-- :style="[{ background: rjdh ? '' : '#ffffff' }]" -->
           <el-menu-item
             index="/menu/smart1"
             v-show="userType === 1"
-         
             @click="menuClick('rjdh')"
           >
-            <!-- @mouseover="menuClick('rjdh')" -->
-            <!-- @click="menuClick('rjdh')" -->
             <img
               class="menu_icon_cla"
               :src="require('@/assets/menuIcon/' + rjdhUrl)"
@@ -102,7 +99,7 @@
             <img
               class="menu_icon_cla"
               :src="require('@/assets/menuIcon/' + xlcpUrl)"
-            />  
+            />
             <span
               slot="title"
               class=""
@@ -126,10 +123,9 @@
               >心理放松</span
             >
           </el-menu-item>
-             <!-- :style="[{background:rzgy?'':'#ffffff'}]" -->
+          <!-- :style="[{background:rzgy?'':'#ffffff'}]" -->
           <el-menu-item
             index="/menu/intervene"
-          
             v-show="userType === 1"
             @click="menuClick('rzgy')"
           >
@@ -139,8 +135,7 @@
             />
             <span
               slot="title"
-              
-               :style="[{ color: rzgy ? '#ffffff' : '#0FB577' }]"
+              :style="[{ color: rzgy ? '#ffffff' : '#0FB577' }]"
               class="menu_text_cla"
               >认知行为干预</span
             >
@@ -149,11 +144,10 @@
             <i class="el-icon-menu"></i>
             <span slot="title">脉搏采集</span>
           </el-menu-item> -->
-           <!-- :style="{ background: swfk ? '' : '#ffffff' }" -->
+          <!-- :style="{ background: swfk ? '' : '#ffffff' }" -->
           <el-menu-item
             index="/menu/animation"
             v-show="userType === 1"
-           
             @click="menuClick('swfk')"
           >
             <img
@@ -590,6 +584,11 @@ export default {
       },
     };
   },
+  watch:{
+    $route(){
+      this.setCurrentRoute();
+    }
+  },
   mounted() {
     this.acount = sessionStorage.getItem("num");
     this.defaultUrl = sessionStorage.getItem("defaultUrl");
@@ -605,27 +604,15 @@ export default {
     //根据用户编号查询用户信息
   },
   methods: {
-    //根据用户编号查询用户信息
-    // queryUserMessage(){
-    //   let that=this;
-    //   that.$http.get(
-    //         `v1/user/getUser/${that.acount}`,
-    //         {
-    //           identifier: that.acount,
-
-    //         },
-    //         (res) => {
-    //           if (res.data.code == 200) {
-    //             that.centerDialogPass = false;
-    //             that.$message.success("修改成功");
-    //             that.$router.push("/");
-    //           } else {
-    //             this.$message.error("访问服务器失败!");
-    //           }
-    //         }
-    //       );
-    // },
-
+    setCurrentRoute(){
+      // console.log(this.$route.path)
+      this.defaultUrl=this.$route.path;
+      // /menu/treatDepression
+      if(this.$route.path=='/menu/treatDepression'){
+        console.log('1234567')
+        this.defaultUrl= '/menu/intervene'
+      }
+    },
     menuManageClick(val) {
       if (val == "yhgl") {
         this.yhglUrl = "yhgl1.png";
@@ -772,7 +759,6 @@ export default {
         this.swfk = true;
       }
       if (val == "rzgy") {
-        this.defaultUrl='/menu/intervene'
         this.rzgyUrl = "rzgy1.png";
         this.rzgy = false;
         this.xlfsUrl = "xlfs.png";
@@ -783,9 +769,10 @@ export default {
         this.rjdh = true;
         this.swfkUrl = "swfk.png";
         this.swfk = true;
+        // this.defaultUrl = "/menu/intervene";
       }
       if (val == "swfk") {
-        this.defaultUrl='/menu/animation'
+        this.defaultUrl = "/menu/animation";
         this.swfkUrl = "swfk1.png";
         this.swfk = false;
         this.rzgyUrl = "rzgy.png";

+ 15 - 13
src/renderer/components/Smart1.vue

@@ -241,14 +241,15 @@ export default {
     this.userName = sessionStorage.getItem("name");
     // this.selectScale("20220805135201");
     scrollview.addEventListener("scroll", this.handleScroll, true);
+    // /menu/evaluation
     this.askEndMul(
       '	轻度:建议您使用系统中的虚拟现实、生物反馈训练<span onclick="jumpPage(1)" style="color:blue;cursor:pointer">(点击跳转)</span>、认知行为干预<span  onclick="jumpPage(2)" style="color:blue;cursor:pointer">(点击跳转--走出抑郁)</span>功能进行心理状态调'
     );
   },
-  destroyed() {
+  beforeDestroy() {
     let that = this;
     const scrollview = this.$refs["scrollview"];
-    scrollview.removeEventListener("scroll", that.handleScroll, true);
+    scrollview.removeEventListener("scroll", that.handleScroll);
   },
   methods: {
     handleScroll() {
@@ -263,7 +264,6 @@ export default {
             this.selectPage();
           }
         }
-
         //当等于0时需要调用加载上一页
       }
       // console.log("qlkhdeqj1");
@@ -411,17 +411,14 @@ export default {
                   this.askEndMul("抑郁建议:" + sleep[i].value[0] + " ");
                 }
               }
-
               if (sleep[i].name === "总分") {
                 let score = JSON.parseInt(sleep[i].value[0]);
-                if (score >= 0 || score <= 20) {
+                if (score >= 0 && score <= 20) {
                   this.askEndMul(
                     '	轻度:建议您使用系统中的虚拟现实、生物反馈训练<span onclick="jumpPage(1)" style="color:blue;cursor:pointer">(点击跳转)</span>、认知行为干预<span  onclick="jumpPage(2)" style="color:blue;cursor:pointer">(点击跳转--走出抑郁)</span>功能进行心理状态调'
                   );
                 }
-                //str = "抑郁建议:" + sleep[i].value[0] + " ";
               }
-
               //}
             }
             console.log(sleep);
@@ -456,20 +453,25 @@ export default {
       });
     },
     jumpPage(val) {
+      let that = this;
       console.log(val);
       if (val == 1) {
-        
         //跳转到生物反馈
         // this.$router.push(c)
         this.$router.push({ path: "/menu/animation" });
-        this.$emit('updateProjectId','swfk')
+        this.$emit("updateProjectId", "swfk");
       }
       if (val == 2) {
         // this.$router.push({ path: "/menu/intervene/treatDepression", query: { id: 2 } });
         //  this.$router.push({ path: "/menu/intervene", query: { id: 2 } });
-           this.$router.push({ path: "/menu/treatDepression", query: { id: 2 } });
+        // this.$router.push({ path: "/menu/intervene" });
+        // this.$router.push({ path: "/menu/evaluation", query: { id: 2 } });
+        this.$router.push({ path: "/menu/treatDepression", query: { id: 2 } });
+        this.$emit("updateProjectId", "rzgy");
+        //  that.$router.push({ path: "/menu/treatDepression", query: { id: 2 } });
+
         //  this.$router.push({ path: "/menu/animation" });
-        this.$emit('updateProjectId','rzgy')
+
         //跳转到//认知干预
       }
     },
@@ -746,7 +748,7 @@ export default {
       // http://127.0.0.1:9999/sentiment
       let that = this;
       axios
-        .post(`http://192.168.245.88:9999/sentiment`, { text: val })
+        .post(`http://127.0.0.1:9999/sentiment`, { text: val })
         .then((res) => {
           console.log(res.data.sentiment);
           if (
@@ -794,7 +796,7 @@ export default {
       //`http://127.0.0.1:9998/chat`
       HTTP_AXIOS({
         method: "post",
-        url: `http://192.168.245.88:9998/chat`,
+        url: `http://127.0.0.1:9998/chat`,
         data: { text: list },
         timeout: 300000,
       })

+ 11 - 11
src/renderer/components/TopPage.vue

@@ -195,17 +195,17 @@ export default {
       // console.log("我得到数据了拉阿拉啦啦啦啦啦");
       //  console.log(arg);
     });
-    const links = document.getElementById("topPageHelp");
-    links.addEventListener("click", (e) => {
-      const url = links.getAttribute("href");
-      e.preventDefault();
-      //\\resources\\exe\\HelpCenter\\help.html
-      shell.openExternal(
-        this.serveBaseUrl + "\\resources\\exe\\HelpCenter\\help.html"
-      );
-      //shell.openExternal(this.serveBaseUrl + "\\resources\\exe\\HelpCenter\\help.html");
-      //shell.openExternal(this.serveBaseUrl + "\\exe\\HelpCenter\\zb使用说明书.pdf");
-    });
+    // const links = document.getElementById("topPageHelp");
+    // links.addEventListener("click", (e) => {
+    //   const url = links.getAttribute("href");
+    //   e.preventDefault();
+    //   //\\resources\\exe\\HelpCenter\\help.html
+    //   shell.openExternal(
+    //     this.serveBaseUrl + "\\resources\\exe\\HelpCenter\\help.html"
+    //   );
+    //   //shell.openExternal(this.serveBaseUrl + "\\resources\\exe\\HelpCenter\\help.html");
+    //   //shell.openExternal(this.serveBaseUrl + "\\exe\\HelpCenter\\zb使用说明书.pdf");
+    // });
 
   },
   methods: {

+ 1 - 3
src/renderer/components/intervene.vue

@@ -57,9 +57,7 @@ export default {
   activated() {},
   deactivated() {},
   mounted() {
-    console.log(
-      "-----------------------------------------------------------------"
-    );
+   
   },
   methods: {
     goDetail(item) {

+ 249 - 54
src/renderer/components/treatDepression.vue

@@ -8,7 +8,11 @@
             class="chat-window"
             style="padding-left: 20px; padding-right: 20px; margin-top: 20px"
             id="contant1"
+            ref="scrollview"
           >
+            <div v-if="echoFlag" style="text-align: center">
+              <i class="el-icon-loading"></i>
+            </div>
             <div
               class="chat-msg-content"
               id="rongqi"
@@ -84,7 +88,7 @@
                         v-if="content.isType == 0"
                         v-model="content.radio"
                         :disabled="!(chatContents.length - 1 == index)"
-                        @input="chooseAnswer"
+                        @input="chooseAnswer(content)"
                       >
                         <el-radio
                           style="width: 100%"
@@ -102,11 +106,15 @@
                           v-if="content.isType == 1"
                           v-model="content.text"
                         /><i
-                          style="width: 20px; height: 20px; color: #57c02c"
-                          v-if="content.isType == 1"
-                          @click="
-                            sendMessageFun(content.question[0].nextQuestionNo)
+                          v-show="chatContents.length - 1 == index"
+                          style="
+                            width: 20px;
+                            height: 20px;
+                            color: #57c02c;
+                            margin-left: 10px;
                           "
+                          v-if="content.isType == 1"
+                          @click="sendMessageFun(content)"
                           class="el-icon-s-promotion"
                         ></i>
 
@@ -119,20 +127,6 @@
                       >
                         {{ content.question }}
                       </div>
-                      <!-- <el-radio-group v-if="content.isType==-1"
-                        v-model="content.radio"
-                        :disabled="content.disabled"
-                        @input="chooseAnswer"
-                      >
-                        <el-radio
-                          v-for="item in content.question"
-                          :key="item.id"
-                          size="small"
-                          :label="item.nextQuestionNo"
-                          border
-                          >{{ item.answer }}</el-radio
-                        >
-                      </el-radio-group> -->
                     </div>
                     <div class="img-wrapper">
                       <img
@@ -267,22 +261,73 @@ export default {
       questionList: [],
       answerList: [],
       interveneId: "",
-
       //当回显接口正在调用时为true
       echoFlag: false,
       //当前返回历史记录
       currenRecordTotol: 0,
+      //当前页
+      pageNum: 1,
+      //一页多少条
+      pageSize: 10,
+      printIndex: 0,
+      flagTime: null,
     };
   },
   created() {},
   mounted() {
+    var scrollview = this.$refs["scrollview"];
     this.interveneId = this.$route.query.id;
-    this.init("start");
+    //
+    // this.init("start");
     // this.selectScale("20220805135201");
     //上来就查询之前的聊天记录
+    scrollview.addEventListener("scroll", this.handleScroll, true);
     this.selectPage();
+    //判断是否是第一次进来,如果查询记录为空,则是第一次进来--则需要调用出初始化语句
+    //如果不是第一次进来--则接着上次的记录说
   },
+  beforeDestroy() {
+    let that = this;
+    var scrollview = this.$refs["scrollview"];
+    scrollview.removeEventListener("scroll", that.handleScroll);
+  },
+
   methods: {
+    handleScroll() {
+      let scrollview = this.$refs["scrollview"];
+      if (scrollview.scrollTop == 0) {
+        //当前没有调接口的时候
+        if (!this.echoFlag) {
+          //判断上一次的页面是否足够10条如果不够就不查询了
+          //页面页数加1
+          if (this.currenRecordTotol == this.pageSize) {
+            this.pageNum++;
+            this.selectPage();
+          }
+        }
+        //当等于0时需要调用加载上一页
+      }
+      // console.log("qlkhdeqj1");
+      //滚动监听事件
+    },
+    //保存聊天记录--单条
+    saveRecord(val) {
+      let data = {
+        identifier: sessionStorage.getItem("num"),
+        label: val.label,
+        content: val.content,
+        userName: sessionStorage.getItem("name"),
+        questionNo: val.questionNo,
+        type: this.interveneId,
+      };
+      console.log(data);
+      // this.$message.success("保存成功");
+      this.$http.post(`/intelligent/save`, data, (res) => {
+        if (res.data.code == 200) {
+        } else {
+        }
+      });
+    },
     //查询聊天记录
     selectPage() {
       let that = this;
@@ -290,34 +335,72 @@ export default {
       this.$http.get(
         `/intelligent/dialogueRecords?identifier=${sessionStorage.getItem(
           "num"
-        )}&pageNum=${that.pageNum}&pageSize=${that.pageSize}&type=${that.interveneId}`,
+        )}&pageNum=${that.pageNum}&pageSize=${that.pageSize}&type=${
+          that.interveneId
+        }`,
         {},
         (res) => {
-          debugger;
           if (res.code == 200) {
             that.echoFlag = false;
             //  res.data.
-            if (res.data.content.length > 0) {
-              that.currenRecordTotol = res.data.content.length;
+            if (res.data.intelligentDialogueEntities.content.length > 0) {
+              that.currenRecordTotol =
+                res.data.intelligentDialogueEntities.content.length;
               //判断当前是第几页
               //如果是第一个
-              for (let i = 0; i < res.data.content.length; i++) {
-                if (res.data.content[i].label == "0") {
+              for (
+                let i = 0;
+                i < res.data.intelligentDialogueEntities.content.length;
+                i++
+              ) {
+                if (
+                  res.data.intelligentDialogueEntities.content[i].label == "0"
+                ) {
                   this.chatContents.unshift({
                     from: 1,
-                    question: res.data.content[i].content,
+                    //是否是量表的信息
+                    isScale: false,
+                    //是单选还是文字  0单选  1填空  -1描述
+                    isType: -1,
+                    //可点击可不点击 0单选   1填空
+                    disabled: false,
+                    //问题
+                    question:
+                      res.data.intelligentDialogueEntities.content[i].content,
+                    //头像
                     from1: HeadImg,
                   });
                 } else {
                   this.chatContents.unshift({
                     from: 2,
-                    answer: res.data.content[i].content,
+                    //是否是量表的信息
+                    isScale: false,
+                    //是单选还是文字  0单选  1填空  -1描述
+                    isType: -1,
+                    //可点击可不点击 0单选   1填空
+                    disabled: false,
+                    //问题
+                    question:
+                      res.data.intelligentDialogueEntities.content[i].content,
+                    //头像
                     from1: HeadImg,
                   });
                 }
               }
               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('');
+              } else {
+              }
+            }
           } else {
           }
         }
@@ -413,9 +496,22 @@ export default {
         contant1.scrollTop = contant1.scrollHeight;
       });
     },
-    sendMessageFun(id) {
+    sendMessageFun(val) {
+      let id = val.question[0].nextQuestionNo;
+      let questionNo = val.question[0].questionNo;
       //发送填空题
+
       if (!id == "") {
+        let paramsSave = {
+          label: 1,
+          content: val.text,
+          questionNo: questionNo,
+        };
+        //当标志是5时,则不需要保存
+        if (this.interveneId != 5) {
+          this.saveRecord(paramsSave);
+        }
+
         this.getQuestion(id);
       } else {
         this.chatContents.push({
@@ -432,7 +528,13 @@ export default {
           //头像
           from1: HeadImg,
         });
-        this.saveChat();
+        // let paramsSave = {
+        //   label: 1,
+        //   content: val.text,
+        //   questionNo: questionNo,
+        // };
+        // this.saveRecord(paramsSave);
+        // this.saveChat();
         let contant1 = document.getElementById("contant1");
         this.sleep(101).then(() => {
           contant1.scrollTop = contant1.scrollHeight;
@@ -441,10 +543,11 @@ export default {
     },
     // 获取问题
     getQuestion(id) {
-      if (id == "109" || id == "117" || id == "119") {
-        this.centerDialogVisible = true;
+      if (this.interveneId == 4) {
+        if (id == "109" || id == "117" || id == "119") {
+          this.centerDialogVisible = true;
+        }
       }
-
       this.$http.get(
         `chat/getQuestion/${this.interveneId}`,
         {
@@ -456,7 +559,7 @@ export default {
             if (result == null) {
               //将结束对话
               // console.log(this.chatContents)
-              this.saveChat();
+              // this.saveChat();
               return;
             }
             // 将本次问题加入对话
@@ -470,27 +573,100 @@ export default {
               //可点击可不点击 0单选   1填空
               disabled: false,
               //问题
-              question: result ? result.question : "",
+              question: "",
               //头像
               from1: HeadImg,
             });
-            let contant1 = document.getElementById("contant1");
-            this.sleep(101).then(() => {
-              contant1.scrollTop = contant1.scrollHeight;
-            });
-            if (!result.nextQuestionNo) {
-              // 无下一题,查询答案
-              this.getAnswer(result.id);
-            } else if (/flag/g.test(result.nextQuestionNo)) {
-              // 下一题为量表,查询量表内容
-              this.flag = result.nextQuestionNo.split("-")[1];
-              this.getScaleInfo(this.flag);
+            this.pFun(result.question, true, result);
+          }
+        }
+      );
+    },
+    //修改文本打印效果
+    pFun(val, flag, result) {
+      let that = this;
+      //3个循环播放
+      this.chatContents[this.chatContents.length - 1].question = "";
+      this.printIndex = 0;
+      // let a = val;
+      let a = "......";
+
+      clearInterval(this.flagTime);
+      this.flagTime = setInterval(
+        () => {
+          if (this.printIndex < a.length) {
+            this.chatContents[this.chatContents.length - 1].question +=
+              a.charAt(this.printIndex);
+            this.printIndex++;
+
+            if (a == "......") {
+              if (this.printIndex == 4) {
+                this.chatContents[this.chatContents.length - 1].question = "";
+                this.printIndex = 0;
+                a = val;
+              }
+            }
+
+            if (flag) {
+              if (a != "......") {
+                let contant1 = document.getElementById("contant1");
+                this.sleep(101).then(() => {
+                  contant1.scrollTop = contant1.scrollHeight;
+                });
+              }
+            }
+          } else {
+            if (flag) {
+              that.buttonFlag = false;
+              //清除定时器
+              let contant1 = document.getElementById("contant1");
+              this.sleep(101).then(() => {
+                contant1.scrollTop = contant1.scrollHeight;
+              });
+              // this.saveRecord(this.chatContents[this.chatContents.length - 1].question)
+              clearInterval(this.flagTime);
+              // let ob = {
+              //   label: 0,
+              //   content:
+              //     this.chatContents[this.chatContents.length - 1].question,
+              // };
+              // this.saveRecord(ob);
+              //在这判断负面情绪是否足够5个
+              if (this.interveneId != 5) {
+                let paramsSave = {
+                  label: 0,
+                  content: result ? result.question : "",
+                  questionNo: result.id,
+                };
+                this.saveRecord(paramsSave);
+              }
+
+              //         identifier: sessionStorage.getItem("num"),
+              // label: val.label,
+              // content: val.content,
+              // userName:sessionStorage.getItem("name"),
+              // questionNo: val.questionNo,
+              // type: this.interveneId,
+              if (!result.nextQuestionNo) {
+                // 无下一题,查询答案
+                this.getAnswer(result.id);
+
+                //保存所选问题的答案
+              } else if (/flag/g.test(result.nextQuestionNo)) {
+                // 下一题为量表,查询量表内容
+                this.flag = result.nextQuestionNo.split("-")[1];
+                this.getScaleInfo(this.flag);
+              } else {
+                // 下一题非量表,继续查询下一题
+                this.getQuestion(result.nextQuestionNo);
+              }
             } else {
-              // 下一题非量表,继续查询下一题
-              this.getQuestion(result.nextQuestionNo);
+              this.printIndex = 0;
+              this.chatContents[this.chatContents.length - 1].question = ".";
             }
           }
-        }
+        },
+        flag ? 60 : 300
       );
     },
     // 获取答案
@@ -525,13 +701,12 @@ export default {
                 text: "",
               });
             }
-
             let contant1 = document.getElementById("contant1");
             this.sleep(101).then(() => {
               contant1.scrollTop = contant1.scrollHeight;
             });
           } else {
-            this.saveChat();
+            // this.saveChat();
           }
         }
       });
@@ -608,9 +783,29 @@ export default {
     },
 
     // 选择答案
-    chooseAnswer(id) {
+    chooseAnswer(val) {
+      let id = val.radio;
       console.log("下一题编号");
       console.log(id);
+      //循环这个数组得到选择的答案
+      let questionRadio = val.question;
+      let contentRadio = "";
+      let questionNo = "";
+      for (let i = 0; i < questionRadio.length; i++) {
+        if (questionRadio[i].nextQuestionNo == id) {
+          contentRadio = questionRadio[i].answer;
+          questionNo = questionRadio[i].questionNo;
+        }
+      }
+      let paramsSave = {
+        label: 1,
+        content: contentRadio,
+        questionNo: questionNo,
+      };
+      //当编号是5时不需要保存
+      if (this.interveneId != 5) {
+        this.saveRecord(paramsSave);
+      }
       if (id == "") {
         this.chatContents.push({
           //是问题还是答案
@@ -626,7 +821,7 @@ export default {
           //头像
           from1: HeadImg,
         });
-        this.saveChat();
+        // this.saveChat();
         let contant1 = document.getElementById("contant1");
         this.sleep(101).then(() => {
           contant1.scrollTop = contant1.scrollHeight;

+ 0 - 4
src/renderer/router/index.js

@@ -123,10 +123,6 @@ if (result != '0') {
           path: 'intervene',
           name: 'Intervene',
           component: Intervene,
- 
-          meta: {
-            keepAlive: true, // 需要被缓存
-          }
         },
         {
           path: 'treatDepression',