[plg137200.] 1 жил өмнө
parent
commit
c91f167f62

+ 4 - 4
src/main/index.js

@@ -58,11 +58,11 @@ let loadingWindow
 //设置访问路径
 //打包访问的路径
 
-let serveUrl = "./resources/exe"
-let serveUrlJar = '\\resources\\exe'
+// let serveUrl = "./resources/exe"
+// let serveUrlJar = '\\resources\\exe'
 //本地访问的路径
-// let serveUrl = "./exe"
-// let serveUrlJar = '\\exe'
+let serveUrl = "./exe"
+let serveUrlJar = '\\exe'
 /**
  * Set `__static` path to static files in production
  * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html

+ 16 - 5
src/renderer/components/Menu.vue

@@ -34,14 +34,15 @@
             </div>
           </div>
         </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"
           background-color="transparent"
           text-color="#d9dbdc"
-          active-text-color="#ffffff"
+          active-text-color=""
           :popper-append-to-body="false"
           :router="true"
         >
@@ -73,9 +74,11 @@
             <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' }]" -->
           <el-menu-item
             index="/menu/smart1"
             v-show="userType === 1"
+         
             @click="menuClick('rjdh')"
           >
             <!-- @mouseover="menuClick('rjdh')" -->
@@ -87,7 +90,7 @@
             <span
               slot="title"
               class="menu_text_span"
-              :style="{ color: rjdh ? '#ffffff' : '#0FB577' }"
+              :style="[{ color: rjdh ? '#ffffff' : '#0FB577' }]"
               >智能对话</span
             >
           </el-menu-item>
@@ -99,7 +102,7 @@
             <img
               class="menu_icon_cla"
               :src="require('@/assets/menuIcon/' + xlcpUrl)"
-            />
+            />  
             <span
               slot="title"
               class=""
@@ -123,8 +126,10 @@
               >心理放松</span
             >
           </el-menu-item>
+             <!-- :style="[{background:rzgy?'':'#ffffff'}]" -->
           <el-menu-item
             index="/menu/intervene"
+          
             v-show="userType === 1"
             @click="menuClick('rzgy')"
           >
@@ -134,7 +139,8 @@
             />
             <span
               slot="title"
-              :style="{ color: rzgy ? '#ffffff' : '#0FB577' }"
+              
+               :style="[{ color: rzgy ? '#ffffff' : '#0FB577' }]"
               class="menu_text_cla"
               >认知行为干预</span
             >
@@ -143,9 +149,11 @@
             <i class="el-icon-menu"></i>
             <span slot="title">脉搏采集</span>
           </el-menu-item> -->
+           <!-- :style="{ background: swfk ? '' : '#ffffff' }" -->
           <el-menu-item
             index="/menu/animation"
             v-show="userType === 1"
+           
             @click="menuClick('swfk')"
           >
             <img
@@ -280,6 +288,7 @@
       >
         <div class="menu_left_new">
           <router-view
+            @updateProjectId="menuClick"
             v-if="!$route.meta.keepAlive"
             class="menu_left_keep"
           ></router-view>
@@ -763,6 +772,7 @@ export default {
         this.swfk = true;
       }
       if (val == "rzgy") {
+        this.defaultUrl='/menu/intervene'
         this.rzgyUrl = "rzgy1.png";
         this.rzgy = false;
         this.xlfsUrl = "xlfs.png";
@@ -775,6 +785,7 @@ export default {
         this.swfk = true;
       }
       if (val == "swfk") {
+        this.defaultUrl='/menu/animation'
         this.swfkUrl = "swfk1.png";
         this.swfk = false;
         this.rzgyUrl = "rzgy.png";

+ 138 - 35
src/renderer/components/Smart1.vue

@@ -2,9 +2,17 @@
   <div class="main_right_height">
     <div class="smart_content">
       <el-row>
-        <el-col :span="1">&nbsp;</el-col>
-        <el-col :span="22">
-          <div class="chat-window" id="contant1">
+        <!-- <el-col :span="1">&nbsp;</el-col> -->
+        <el-col :span="24">
+          <div
+            class="chat-window"
+            id="contant1"
+            ref="scrollview"
+            style="margin-top: 20px"
+          >
+            <div v-if="echoFlag" style="text-align: center">
+              <i class="el-icon-loading"></i>
+            </div>
             <div
               class="chat-msg-content"
               id="rongqi"
@@ -15,16 +23,17 @@
                 v-if="content.from == 1"
                 :key="content.id"
                 class="main_answer_right"
-                style="margin-top: 10px"
+                style="margin-top: 10px; padding-left: 20px"
               >
                 <div class="img-wrapper">
                   <img width="60px" heigth="60px" class="img" :src="from1" />
                 </div>
                 <div class="message-wrapper message-wrapper-left">
-                  <div class="message">{{ content.question }}</div>
+                  <!-- {{ content.question }} -->
+                  <div class="message" v-html="content.question"></div>
                 </div>
               </div>
-              <el-row v-else style="margin-top: 10px">
+              <el-row v-else style="margin-top: 10px; padding-right: 20px">
                 <el-col :span="10"> &nbsp; </el-col>
                 <el-col :span="14">
                   <div class="main_answer_left" style="float: right">
@@ -45,7 +54,7 @@
             </div>
           </div>
         </el-col>
-        <el-col :span="1">&nbsp;</el-col>
+        <!-- <el-col :span="1">&nbsp;</el-col> -->
       </el-row>
       <div class="smart_line_class"></div>
       <el-row v-show="inputFlag === 1" class="footSend">
@@ -215,18 +224,51 @@ export default {
 
       flagTime: null,
       printIndex: 0,
+      //当回显接口正在调用时为true
+      echoFlag: false,
+      //当前返回历史记录
+      currenRecordTotol: 0,
     };
   },
   created() {},
 
   mounted() {
+    window.jumpPage = this.jumpPage;
+    const scrollview = this.$refs["scrollview"];
     this.init();
     //获取编号
     this.identifier = sessionStorage.getItem("num");
     this.userName = sessionStorage.getItem("name");
     // this.selectScale("20220805135201");
+    scrollview.addEventListener("scroll", this.handleScroll, true);
+    this.askEndMul(
+      '	轻度:建议您使用系统中的虚拟现实、生物反馈训练<span onclick="jumpPage(1)" style="color:blue;cursor:pointer">(点击跳转)</span>、认知行为干预<span  onclick="jumpPage(2)" style="color:blue;cursor:pointer">(点击跳转--走出抑郁)</span>功能进行心理状态调'
+    );
+  },
+  destroyed() {
+    let that = this;
+    const scrollview = this.$refs["scrollview"];
+    scrollview.removeEventListener("scroll", that.handleScroll, true);
   },
   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");
+      //滚动监听事件
+    },
     //上来就监听数据变化 如果有变化就保存最后一条数据
     //如果保存保存后
 
@@ -318,7 +360,7 @@ export default {
         _this.scaleSelectFlag = true;
         if (res.data.code == 200 && res.data.data) {
           _this.resultJsonParams = res.data.data;
-
+          debugger;
           let testResult = JSON.parse(
             res.data.data.userRecordEntity.testResult
           )[0].version;
@@ -369,6 +411,17 @@ 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) {
+                  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);
@@ -402,6 +455,24 @@ export default {
         }
       });
     },
+    jumpPage(val) {
+      console.log(val);
+      if (val == 1) {
+        
+        //跳转到生物反馈
+        // this.$router.push(c)
+        this.$router.push({ path: "/menu/animation" });
+        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/animation" });
+        this.$emit('updateProjectId','rzgy')
+        //跳转到//认知干预
+      }
+    },
     askEndMul(val) {
       this.chatContents.push({
         from: 1,
@@ -579,35 +650,62 @@ export default {
     },
     init() {
       //进入页面后先执行查询前50条数据的接口
-      // this.selectPage();
+
+      //查询前5条数据
+      this.selectPage();
+      let contant1 = document.getElementById("contant1");
+      this.sleep(300).then(() => {
+        contant1.scrollTop = contant1.scrollHeight;
+      });
     },
     //查询记录的方法
     selectPage() {
-      this.$http.post(
-        `///`,
-        {
-          pageNum: this.pageNum,
-          pageSize: this.pageSize,
-        },
+      let that = this;
+      that.echoFlag = true;
+      this.$http.get(
+        `/intelligent/dialogueRecords?identifier=${sessionStorage.getItem(
+          "num"
+        )}&pageNum=${that.pageNum}&pageSize=${that.pageSize}&type=0`,
+        {},
         (res) => {
-          if (res.data.code == 200) {
+          if (res.code == 200) {
+            that.echoFlag = false;
+            //  res.data.
+
+            if (res.data.intelligentDialogueEntities.content.length > 0) {
+              that.currenRecordTotol =
+                res.data.intelligentDialogueEntities.content.length;
+              //判断当前是第几页
+              //如果是第一个
+              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.intelligentDialogueEntities.content[i].content,
+                    from1: HeadImg,
+                  });
+                } else {
+                  this.chatContents.unshift({
+                    from: 2,
+                    answer:
+                      res.data.intelligentDialogueEntities.content[i].content,
+                    from1: HeadImg,
+                  });
+                }
+              }
+              // console.log(this.chatContents);
+            }
           } else {
           }
         }
       );
-      for (let i = 0; i < 5; i++) {
-        this.chatContents.push({
-          from: 1,
-          question: "对话内容" + i,
-          from1: HeadImg,
-        });
-        this.chatContents.push({
-          from: 2,
-          answer: "对话内容" + i,
-          from1: HeadImg,
-        });
-      }
-      //手动加10条
     },
     sleep(time) {
       return new Promise((resolve) => setTimeout(resolve, time));
@@ -648,7 +746,7 @@ export default {
       // http://127.0.0.1:9999/sentiment
       let that = this;
       axios
-        .post(`http://127.0.0.1:9999/sentiment`, { text: val })
+        .post(`http://192.168.245.88:9999/sentiment`, { text: val })
         .then((res) => {
           console.log(res.data.sentiment);
           if (
@@ -696,7 +794,7 @@ export default {
       //`http://127.0.0.1:9998/chat`
       HTTP_AXIOS({
         method: "post",
-        url: `http://127.0.0.1:9998/chat`,
+        url: `http://192.168.245.88:9998/chat`,
         data: { text: list },
         timeout: 300000,
       })
@@ -761,10 +859,12 @@ export default {
             this.chatContents[this.chatContents.length - 1].question +=
               a.charAt(this.printIndex);
             this.printIndex++;
-            let contant1 = document.getElementById("contant1");
-            this.sleep(101).then(() => {
-              contant1.scrollTop = contant1.scrollHeight;
-            });
+            if (flag) {
+              let contant1 = document.getElementById("contant1");
+              this.sleep(101).then(() => {
+                contant1.scrollTop = contant1.scrollHeight;
+              });
+            }
           } else {
             if (flag) {
               that.buttonFlag = false;
@@ -802,6 +902,8 @@ export default {
         label: val.label,
         content: val.content,
         userName: this.userName,
+        questionNo: "",
+        type: "0",
       };
       console.log(data);
       // this.$message.success("保存成功");
@@ -1082,6 +1184,7 @@ export default {
   background: #f6f6f6;
 }
 .chat-window {
+  /* overflow-y: scroll; */
   height: 70vh;
   overflow: auto;
   /* overflow-y:hidden; */

+ 53 - 2
src/renderer/components/treatDepression.vue

@@ -3,8 +3,12 @@
     <div class="smart_content">
       <el-row>
         <!-- <el-col :span="1">&nbsp;</el-col> -->
-        <el-col :span="24" >
-          <div class="chat-window" style='padding-left:20px;padding-right:20px;margin-top:20px' id="contant1">
+        <el-col :span="24">
+          <div
+            class="chat-window"
+            style="padding-left: 20px; padding-right: 20px; margin-top: 20px"
+            id="contant1"
+          >
             <div
               class="chat-msg-content"
               id="rongqi"
@@ -263,6 +267,11 @@ export default {
       questionList: [],
       answerList: [],
       interveneId: "",
+
+      //当回显接口正在调用时为true
+      echoFlag: false,
+      //当前返回历史记录
+      currenRecordTotol: 0,
     };
   },
   created() {},
@@ -270,8 +279,50 @@ export default {
     this.interveneId = this.$route.query.id;
     this.init("start");
     // this.selectScale("20220805135201");
+    //上来就查询之前的聊天记录
+    this.selectPage();
   },
   methods: {
+    //查询聊天记录
+    selectPage() {
+      let that = this;
+      that.echoFlag = true;
+      this.$http.get(
+        `/intelligent/dialogueRecords?identifier=${sessionStorage.getItem(
+          "num"
+        )}&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;
+              //判断当前是第几页
+              //如果是第一个
+              for (let i = 0; i < res.data.content.length; i++) {
+                if (res.data.content[i].label == "0") {
+                  this.chatContents.unshift({
+                    from: 1,
+                    question: res.data.content[i].content,
+                    from1: HeadImg,
+                  });
+                } else {
+                  this.chatContents.unshift({
+                    from: 2,
+                    answer: res.data.content[i].content,
+                    from1: HeadImg,
+                  });
+                }
+              }
+              console.log(this.chatContents);
+            }
+          } else {
+          }
+        }
+      );
+    },
     //保存测试记录
     saveChat() {
       let list = [];

+ 7 - 5
src/renderer/router/index.js

@@ -123,10 +123,16 @@ if (result != '0') {
           path: 'intervene',
           name: 'Intervene',
           component: Intervene,
+ 
           meta: {
             keepAlive: true, // 需要被缓存
           }
         },
+        {
+          path: 'treatDepression',
+          name: 'TreatDepression',
+          component: () => import('@/components/treatDepression.vue')
+        },
         {
           path: 'animation',
           name: 'animation',
@@ -276,11 +282,7 @@ if (result != '0') {
           name: 'healthDetail',
           component: () => import('@/components/healthDetail.vue')
         },
-        {
-          path: 'treatDepression',
-          name: 'TreatDepression',
-          component: () => import('@/components/treatDepression.vue')
-        }
+       
       ]
     },
     {