浏览代码

修改认知干预下载及睡眠模块

[plg137200.] 1 年之前
父节点
当前提交
34c7de64be

+ 4 - 4
src/main/index.js

@@ -55,11 +55,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

+ 4 - 2
src/renderer/components/LoginPage.vue

@@ -115,7 +115,7 @@
       </el-col>
 
       <!-- <el-footer class="buttLlo">Copyright© 北京决明科技有限公司</el-footer> -->
-       <el-footer class="buttLlo">Copyright© 2023</el-footer>
+      <el-footer class="buttLlo">Copyright© 2023</el-footer>
     </el-row>
     <div class="registerTop" v-show="!registerFlag">
       <div class="registerDes">
@@ -702,7 +702,7 @@ IF NOT EXISTS t_user_table (
                 that.userRegisterLoginV2(
                   that.ruleForm.num,
                   that.ruleForm.userPassword,
-                  that.userType 
+                  that.userType
                 );
                 //注册成功后需要调用登录接口
                 that.resetForm("ruleForm");
@@ -778,6 +778,7 @@ IF NOT EXISTS t_user_table (
           if (res.data.code == 200) {
             sessionStorage.setItem("token", res.data.data.token);
             if (that.userType == "1") {
+              sessionStorage.setItem("name", res.data.data.userEntry.userName);
               sessionStorage.setItem("num", that.account);
               sessionStorage.setItem("pass", that.$md5(that.password));
               sessionStorage.setItem("userType", "1");
@@ -793,6 +794,7 @@ IF NOT EXISTS t_user_table (
 
             if (that.userType == "2") {
               // sessionStorage.setItem("num", that.account);
+              sessionStorage.setItem("name", res.data.data.userEntry.userName);
               sessionStorage.setItem("num", that.account);
               sessionStorage.setItem("pass", that.$md5(that.password));
               sessionStorage.setItem("userType", "2");

+ 299 - 55
src/renderer/components/ManagePluse.vue

@@ -5,19 +5,37 @@
       <el-row>
         <el-col :span="1">&nbsp;</el-col>
         <el-col :span="22">
-          <span class="musicTitle">脉搏测试记录</span>
+          <div style="display: flex">
+            <i
+              class="el-icon-arrow-left"
+              style="cursor: pointer; line-height: 1.5"
+              @click="goBack()"
+            ></i>
+            <span class="musicTitle">量表测试记录</span>
+          </div>
           <el-divider></el-divider>
         </el-col>
+
         <el-col :span="1">&nbsp;</el-col>
       </el-row>
     </div> -->
     <div>
       <el-row>
         <el-col :span="1">&nbsp;</el-col>
-        <el-col :span="6">
-          <div style="margin-top: 15px; margin-bottom: 15px" class="xl_input">
+        <el-col :span="20" style="margin-top: 15px">
+          <div style="display: flex" class="xl_input">
+            <el-date-picker
+              v-model="value1"
+              type="daterange"
+              range-separator="至"
+              start-placeholder="开始日期"
+              end-placeholder="结束日期"
+              @change="timeChange"
+            >
+            </el-date-picker>
+            &nbsp;&nbsp;&nbsp;&nbsp;
             <el-input
-              placeholder="请输入搜索内容"
+              placeholder="请输入用户姓名"
               v-model="nameSearch"
               @input="searchEle"
               prefix-icon="el-icon-search"
@@ -30,44 +48,85 @@
             </el-input>
           </div>
         </el-col>
-        <!-- <el-col
-          :span="16"
-          style="text-align: right; margin-top: 20px; margin-bottom: 10px"
-        >
-          <el-button size="small" @click="downloadALL" class="xl_d_button">
+        <!-- <el-col :span="6">
+          
+        </el-col> -->
+        <!-- <el-col :span="8">&nbsp;</el-col> -->
+      </el-row>
+      <el-row style="margin-top: 15px">
+        <el-col :span="1">&nbsp;</el-col>
+        <el-col :span="22" style="text-align: left">
+          <!-- <el-button
+            size="small"
+            @click="download(1, 1)"
+            class="xl_down_button"
+            :disabled="multipleSelection.length === 0 && disableFlag"
+          >
+            批量下载(原始数据)</el-button
+          >
+          <el-button
+            size="small"
+            :disabled="tableData.length === 0 && disableFlag"
+            @click="download(1, 2)"
+            class="xl_down_button"
+          >
+            全部下载(原始数据)</el-button
+          > -->
+          <el-button
+            size="small"
+            @click="download(2, 1)"
+            class="xl_down_button"
+            :disabled="multipleSelection.length === 0 && disableFlag"
+          >
+            批量下载</el-button
+          >
+          <el-button
+            size="small"
+            :disabled="tableData.length === 0 && disableFlag"
+            class="xl_down_button"
+            @click="batchDownloadOriginalAll()"
+          >
             全部下载</el-button
           >
-        </el-col> -->
+        </el-col>
+        <el-col :span="1">&nbsp;</el-col>
       </el-row>
     </div>
-    <div>
+    <div style="margin-top: 16px">
       <el-row>
         <el-col :span="1"> &nbsp;</el-col>
         <el-col :span="22">
           <el-table
             :data="tableData"
+            style="width: 100%"
+            @selection-change="handleSelectionChange"
             :header-cell-style="{
               background: '#66B497',
               color: '#FFFFFF',
               'letter-spacing': '4px',
             }"
             :row-class-name="tableRowClassName"
-            style="width: 100%"
           >
+            <el-table-column type="selection" align="center" width="55">
+            </el-table-column>
             <el-table-column prop="userName" align="center" label="姓名">
             </el-table-column>
+            <el-table-column prop="identifier" align="center" label="编号">
+            </el-table-column>
             <el-table-column
-              prop="identifier"
+              prop="createTime"
               align="center"
-              label="编号"
+              label="测试时间"
+              :formatter="dateForMa"
             ></el-table-column>
-            <el-table-column label="操作" align="center">
+            <!-- <el-table-column prop="profession" label="职业"></el-table-column> -->
+            <el-table-column label="查看测试记录" align="center">
               <template slot-scope="scope">
                 <el-button
-                  size="mini"
                   class="xl_d_button"
-                  @click="handleEdit(scope.$index, scope.row)"
-                  >查看记录</el-button
+                  size="mini"
+                  @click="singleDownload(scope.$index, scope.row)"
+                  >下载</el-button
                 >
               </template>
             </el-table-column>
@@ -82,7 +141,8 @@
         @current-change="handleCurrentChange"
         :current-page="pageNum"
         :page-size="pageSize"
-        layout="total,  prev, pager, next, jumper"
+        :page-sizes="[10, , 50, 100, 200, 300, 400]"
+        layout="total, sizes, prev, pager, next, jumper"
         :total="totolSize"
       >
       </el-pagination>
@@ -96,38 +156,111 @@ export default {
   data() {
     return {
       head_style: "#f5f7fa",
+      value1: "",
+      startDate: "",
+      endDate: "",
+      identifier: "",
       pageNum: 1,
       pageSize: 10,
       totolSize: 10,
       nameSearch: "",
       tableData: [],
+      multipleSelection: [],
+      flag: "",
+      disableFlag: true,
     };
   },
   mounted() {
+    this.flag = this.$route.query.flag;
     this.queryEle();
   },
   methods: {
-    tableRowClassName({ rowIndex }) {
-      if (rowIndex % 2 === 0) {
-        return "warning-row";
-      } else if (rowIndex % 2 === 1) {
-        return "success-row";
+    dateForMa(row) {
+      let date = new Date(row.createTime);
+      let formattedDate = `${date.getFullYear()}-${(
+        "0" +
+        (date.getMonth() + 1)
+      ).slice(-2)}-${("0" + date.getDate()).slice(-2)} ${(
+        "0" + date.getHours()
+      ).slice(-2)}:${("0" + date.getMinutes()).slice(-2)}:${(
+        "0" + date.getSeconds()
+      ).slice(-2)}`;
+      return formattedDate;
+    },
+    //返回上一页
+    goBack() {
+      this.$router.go(-1);
+    },
+    //批量下载
+    download(val, value) {
+      //获取数组集合
+      let idArr = [];
+      for (let i = 0; i < this.multipleSelection.length; i++) {
+        idArr.push(this.multipleSelection[i].id);
       }
-      return "success-row";
+      this.batchDownloadOriginal(val, value, idArr);
     },
-    downloadALL() {
+     //全部下载(原始数据)
+    batchDownloadOriginalAll() {
+      let that = this;
+      let arr = [];
+      //原始数据批量下载路径
+      let path = `chat/chatRecord/AllDownload?identifier=${that.nameSearch}&beginDate=${that.startDate}&endDate=${that.endDate}`;
+      // let path = `record/download`;
       let baseUrl = sessionStorage.getItem("baseUrl");
+      //window.location.href = `${baseUrl}${path}?ids=${arr}`;
+      let a =arr.join();
       axios({
-        method: "post",
-        url: `${baseUrl}v1/recordPhy/export/all/pulse/target`,
+        method: "get",
+        url: `${baseUrl}${path}`,
         timeout: 600000, // 请求超时时间,数据量多后台响应慢的情况可以调大点,没生效的话可能是vue.config.js里的配置影响了
         responseType: "blob", // 返回类型为数据流
         data: {
           // ids: arr,
-          // flag: 1,
+          // flag: that.flag,
+          // startDate: that.startDate,
+          // endDate: that.endDate,
+          // userName: that.nameSearch,
+        }, // 需要传参的话,在这传
+      }).then((res) => {
+        if (res && res.data) {
+          // console.log(decodeURIComponent(res.headers["filename"]))
+          // 调用js-file-download下载文件,第一个参数是数据流,第二个参数是文件名,我这后端返回时把文件名放到响应的header的filename字段中,所以用这种方式取出
+          jsFileDownload(res.data, decodeURIComponent(res.headers["filename"]));
+        }
+      });
+    },
+    //批量下载(原始数据)
+    batchDownloadOriginal(val, value, idArr) {
+      let that = this;
+      let arr = [];
+      //原始数据批量下载路径
+      let path = `v1/record/download/source`;
+      if (val === 2) {
+        path = `chat/chatRecord/batchDownload`;
+      }
+      if ((val === 1 && value === 1) || (val === 2 && value === 1)) {
+        arr = idArr;
+      } else {
+        arr = [];
+      }
+      // let path = `record/download`;
+      let baseUrl = sessionStorage.getItem("baseUrl");
+      //window.location.href = `${baseUrl}${path}?ids=${arr}`;
+      let a =arr.join();
+      axios({
+        method: "get",
+        url: `${baseUrl}${path}?ids=${a}`,
+        timeout: 600000, // 请求超时时间,数据量多后台响应慢的情况可以调大点,没生效的话可能是vue.config.js里的配置影响了
+        responseType: "blob", // 返回类型为数据流
+        data: {
+          ids: arr,
+          flag: that.flag,
+          startDate: that.startDate,
+          endDate: that.endDate,
+          userName: that.nameSearch,
         }, // 需要传参的话,在这传
       }).then((res) => {
-        // that.disableFlag = true;
         if (res && res.data) {
           // console.log(decodeURIComponent(res.headers["filename"]))
           // 调用js-file-download下载文件,第一个参数是数据流,第二个参数是文件名,我这后端返回时把文件名放到响应的header的filename字段中,所以用这种方式取出
@@ -135,27 +268,55 @@ export default {
         }
       });
     },
+    handleSelectionChange(val) {
+      this.multipleSelection = val;
+    },
+    timeChange(val) {
+      if (val === null) {
+        this.startDate = "";
+        this.endDate = "";
+      } else {
+        this.startDate = this.fomatterDate(this.value1[0]);
+        this.endDate = this.fomatterDate(this.value1[1]);
+      }
+      this.pageNum = 1;
+      this.queryEle();
+    },
+    //格式化时间格式
+    fomatterDate(val) {
+      var date = new Date(val);
+      let year = date.getFullYear();
+      let month = this.fomatterM(date.getMonth() + 1);
+      let currentDay = this.fomatterM(date.getDate());
+      return year + "-" + month + "-" + currentDay;
+    },
+    fomatterM(val) {
+      if (val < 10) {
+        return "0" + val;
+      } else {
+        return val + "";
+      }
+    },
     searchEle() {
       this.pageNum = 1;
       this.queryEle();
     },
     queryEle() {
       let that = this;
-      that.$http.post(
-        `v1/recordPhy/user`,
+      that.$http.get(
+        `/chat/chat/list?identifier=${that.nameSearch}&beginDate=${that.startDate}&endDate=${that.endDate}&pageNum=${that.pageNum}&pageSize=${that.pageSize}`,
         {
-          pageNum: that.pageNum,
-          pageSize: that.pageSize,
-          startDate: "",
-          endDate: "",
-          type: 1,
-          filaName: "",
-          userName: that.nameSearch,
+          // pageNum: that.pageNum,
+          // pageSize: that.pageSize,
+          // flag: that.flag,
+          // startDate: that.startDate,
+          // endDate: that.endDate,
+          // userName: that.nameSearch,
         },
         (res) => {
-          if (res.data.code == 200) {
-            that.tableData = res.data.data.data;
-            that.totolSize = res.data.data.allNum;
+          if (res.code == 200) {
+            that.tableData = res.data.content;
+            that.totolSize = res.data.totalElements;
           } else {
             this.$message.error("访问服务器失败!");
           }
@@ -163,6 +324,7 @@ export default {
       );
     },
     handleSizeChange(val) {
+      this.pageSize = val;
       this.queryEle();
     },
     handleCurrentChange(val) {
@@ -171,13 +333,97 @@ export default {
       // this.pageNum = val;
       // this.queryList();
     },
-    handleEdit(index, row) {
-      this.$router.push({
-        path: "/menu/managePluseRecord",
-        query: { identifier: row.identifier },
+    singleDownload(index, row) {
+      let baseUrl = sessionStorage.getItem("baseUrl");
+      let path = `/chat/chatRecord/download?id=${row.id}`;
+      // let arr = [row.id];
+      axios({
+        method: "get",
+        url: `${baseUrl}${path}`,
+        timeout: 600000, // 请求超时时间,数据量多后台响应慢的情况可以调大点,没生效的话可能是vue.config.js里的配置影响了
+        responseType: "blob", // 返回类型为数据流
+        data: {
+          // ids: arr,
+        }, // 需要传参的话,在这传
+      }).then((res) => {
+        if (res && res.data) {
+          console.log(res.headers["filename"]);
+          // console.log(decodeURIComponent(res.headers["filename"]))
+          // 调用js-file-download下载文件,第一个参数是数据流,第二个参数是文件名,我这后端返回时把文件名放到响应的header的filename字段中,所以用这种方式取出
+          jsFileDownload(res.data, decodeURIComponent(res.headers["filename"]));
+        }
+      });
+    },
+    getAnswerQuestionPaymentSuccess(id) {
+      sessionStorage.setItem("back_page", "3");
+      let _this = this;
+
+      _this.$http.post(`v1/record/find/${id}`, {}, (res) => {
+        if (res.data.code == 200 && res.data.data) {
+          _this.resultJsonParams = res.data.data;
+          // let sleep = JSON.parse(
+          //   _this.resultJsonParams.userRecordEntity.testResult
+          // );
+          // sleep = sleep[0].newTableContext.result[0].improvementSuggestions;
+          // if (_this.scale_flag === "20210910163158") {
+          //   _this.askEnd(sleep);
+          //   this.inputFlag = 0;
+          // }
+          // if (_this.scale_flag === "20220805135201") {
+          //   _this.askEnd(sleep);
+          //   this.inputFlag = 0;
+          // }
+
+          // let testResult = JSON.parse(res.data.userRecordEntity.testResult)[0]
+          //   .version;
+          let testResult = JSON.parse(
+            res.data.data.userRecordEntity.testResult
+          )[0].version;
+
+          if (testResult == 2) {
+            _this.$router.push({
+              name: "scaleResultSCl",
+              params: { tableData: _this.resultJsonParams },
+            });
+          } else {
+            _this.$router.push({
+              name: "scaleResult",
+              params: { tableData: _this.resultJsonParams },
+            });
+          }
+        }
       });
+      // _this.$http.get(`/getRecordById?id=${id}`, {}, (res) => {
+      //   if (res.code == 200) {
+      //     _this.resultJsonParams = res.data;
+      //     let testResult = JSON.parse(res.data?.userRecordEntity?.testResult)[0]
+      //       .version;
+
+      //     if (testResult == 2) {
+      //       _this.$router.push({
+      //         name: "scaleResultSCl",
+      //         query: _this.resultJsonParams,
+      //       });
+      //     } else {
+      //       _this.$router.push({
+      //         name: "ScaleResult",
+      //         query: JSON.stringify(_this.resultJsonParams),
+      //       });
+      //     }
+      //   }
+
+      //   console.log("请求数据的list", res);
+      // });
     },
     handleDelete(index, row) {},
+    tableRowClassName({ rowIndex }) {
+      if (rowIndex % 2 === 0) {
+        return "warning-row";
+      } else if (rowIndex % 2 === 1) {
+        return "success-row";
+      }
+      return "success-row";
+    },
   },
 };
 </script>
@@ -188,13 +434,11 @@ export default {
   overflow-y: auto !important;
   background: #ffffff;
 }
-/* .xl_d_button,
-.xl_d_button:hover,
-.xl_d_button:focus {
-  background: rgb(87, 172, 187);
-  opacity: 1;
-  font-family: PingFang SC;
-  font-weight: 400;
-  color: #ffffff;
-} */
+.el-input-group {
+  line-height: normal;
+  display: inline-table;
+  width: 200px !important;
+  border-collapse: separate;
+  border-spacing: 0;
+}
 </style>

+ 1 - 1
src/renderer/components/ManageScaleUserRecord.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="main_right_height">
-     <TopDes :flag="false" topDesFont="认知行为干预记录"></TopDes>
+     <TopDes :flag="false" topDesFont="用户测评记录"></TopDes>
     <!-- <div>
       <el-row>
         <el-col :span="1">&nbsp;</el-col>

+ 1 - 1
src/renderer/components/Menu.vue

@@ -72,7 +72,7 @@
             <span slot="title" class="menu_text_cla">主页</span>
           </el-menu-item>
           <el-menu-item
-            index="/menu/smart"
+            index="/menu/smart1"
             v-show="userType === 1"
             @click="menuClick('rjdh')"
           >

+ 70 - 0
src/renderer/components/Smart.vue

@@ -425,6 +425,76 @@ export default {
             question: "接下来让我们聊一聊吧",
             from1: HeadImg,
           },
+            {
+            from: 2,
+            answer: "心情不好,你能帮我吗?",
+            from1: HeadImg,
+          },
+            {
+            from: 1,
+            question: "当然可以,你可以和我分享你的感受。",
+            from1: HeadImg,
+          },
+           {
+            from: 2,
+            answer: "工作压力有点大",
+            from1: HeadImg,
+          },
+           {
+            from: 1,
+            question: "我理解你的感受,工作压力确实很大。你有没有尝试过放松一下?",
+            from1: HeadImg,
+          },
+           {
+            from: 2,
+            answer: "有啥好的放松方法吗?",
+            from1: HeadImg,
+          },
+           {
+            from: 1,
+            question: "你可以试试冥想或者瑜伽,这些可以帮助你放松身心。",
+            from1: HeadImg,
+          },
+           {
+            from: 2,
+            answer: "好吧",
+            from1: HeadImg,
+          },
+            {
+            from: 1,
+            question: "同时,你也可以找一些喜欢的事情来做,比如看书、听音乐、旅行等等。这些可以让你心情愉悦。",
+            from1: HeadImg,
+          },
+              {
+            from: 2,
+            answer: "怎么能知道我有没有抑郁",
+            from1: HeadImg,
+          },
+             {
+            from: 1,
+            question: "如果你感到心情低落、失去兴趣、睡眠不好等,可以考虑寻求专业帮助。你可以去医院或者心理咨询机构咨询。",
+            from1: HeadImg,
+          },
+            {
+            from: 2,
+            answer: "你会说笑话吗",
+            from1: HeadImg,
+          },
+           {
+            from: 1,
+            question: "当然会,我可以给你讲一些搞笑的故事或者笑话,让你开心一下.",
+            from1: HeadImg,
+          },
+           {
+            from: 2,
+            answer: "讲一个吧.",
+            from1: HeadImg,
+          },
+           {
+            from: 1,
+            question: "有一天,一只羊走进了酒吧,然后就再也没出来过。因为酒吧的招牌上写着“羊群不进”.",
+            from1: HeadImg,
+          },
         ];
       } else {
         this.chatContents.push({

+ 531 - 0
src/renderer/components/Smart1.vue

@@ -0,0 +1,531 @@
+<template>
+  <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">
+            <div
+              class="chat-msg-content"
+              id="rongqi"
+              v-for="content in chatContents"
+              :key="content.index"
+            >
+              <div
+                v-if="content.from == 1"
+                :key="content.id"
+                class="main_answer_right"
+                style="margin-top: 10px"
+              >
+                <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>
+                </div>
+              </div>
+              <el-row v-else style="margin-top: 10px">
+                <el-col :span="10"> &nbsp; </el-col>
+                <el-col :span="14">
+                  <div class="main_answer_left" style="float: right">
+                    <div class="message-wrapper message-wrapper-right">
+                      <div class="message">{{ content.answer }}</div>
+                    </div>
+                    <div class="img-wrapper">
+                      <img
+                        width="60px"
+                        heigth="60px"
+                        class="img"
+                        :src="from2"
+                      />
+                    </div>
+                  </div>
+                </el-col>
+              </el-row>
+            </div>
+          </div>
+        </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">
+        <!-- <el-col :span="1"> &nbsp; </el-col> -->
+        <el-col :span="22">
+          <el-input
+            class="xl_input"
+            type="textarea"
+            resize="none"
+            placeholder="请输入内容"
+            v-model="desc"
+            show-word-limit
+            @keyup.enter.native="sendMsg"
+            clearable
+          >
+          </el-input>
+        </el-col>
+        <el-col :span="2" style="">
+          &nbsp;&nbsp;
+          <!-- {{sendMsgFlag}}
+            {{desc.length>0}}
+            !((!sendMsgFlag)||(desc.length>0)) -->
+          <el-button
+            :disabled="desc.length == 0"
+            class="xl_d_send"
+            @click="sendMsg"
+            >发送</el-button
+          >
+        </el-col>
+      </el-row>
+      <el-row v-show="inputFlag === 2" class="footSendSelect">
+        <el-col :span="1"> &nbsp; </el-col>
+        <el-col :span="22" style="margin-top: 20px; margin-bottom: 20px">
+          <div>
+            <el-radio
+              style="margin-top: 10px"
+              v-for="(item, index) in scale_checkItems"
+              :key="index"
+              v-model="radio"
+              :label="item"
+              fill="#57ACBB"
+              @change="selectRadio(item)"
+              >{{ item }}</el-radio
+            >
+          </div></el-col
+        >
+        <el-col :span="1"> &nbsp; </el-col>
+      </el-row>
+      <el-row v-show="inputFlag === 3" class="footSendSelect">
+        <el-col :span="1"> &nbsp; </el-col>
+        <el-col :span="22" style="margin-top: 20px; margin-bottom: 20px">
+          <div>
+            <el-radio
+              :disabled="!scaleSelectFlag"
+              style="margin-top: 10px"
+              v-for="(item, index) in scale_checkItems"
+              :key="index"
+              v-model="radio"
+              :label="item"
+              fill="#57ACBB"
+              @change="choiceTriger(item)"
+              >{{ item }}</el-radio
+            >
+          </div></el-col
+        >
+        <el-col :span="1"> &nbsp; </el-col>
+      </el-row>
+    </div>
+  </div>
+</template>
+<script>
+import HeadImg from "@/assets/lion.png";
+import HeadImg1 from "@/assets/persion.png";
+import axios from "axios";
+export default {
+  data() {
+    return {
+      pageNum: 1,
+      pageSize: 10,
+      tmpRadio: "",
+      radio: "",
+      inputFlag: 1,
+      desc: "",
+      from1: HeadImg,
+      from2: HeadImg1,
+      chatContents: [],
+      //前三个问题
+      preList: [],
+      questionList: [
+        { index: 1, des: "能描述一下您最近训练的内容吗?", type: "1-2" },
+      ],
+      //随机的4个数集合
+      radomNumList: [],
+      questionNum: 0,
+
+      //随机4个问题的集合
+      randomQuestion: [],
+      //随机4个答案的集合
+      randomAnswer: [],
+      //全部题目
+      scale_infos: [{ answer: "" }],
+      //题目总数
+      scale_all: 0,
+      scale_checkItems: [],
+      //进度参数
+      scale_percent: [],
+      //
+      scale_index: 0,
+      // 答案数据
+      scale_result: [],
+
+      //检测情绪前的发送数据条数
+      threeAnswers: [],
+
+      //负面情绪标志
+      moonNegative: 0,
+      scale_flag: "",
+      pressure_flag: "",
+      sendMsgFlag: true,
+      scaleSelectFlag: true,
+    };
+  },
+  created() {},
+  mounted() {
+    this.init();
+    // this.selectScale("20220805135201");
+  },
+  methods: {
+    init() {
+      //进入页面后先执行查询前50条数据的接口
+      this.selectPage();
+    },
+    //查询记录的方法
+    selectPage() {
+      this.$http.post(
+        `///`,
+        {
+          pageNum: this.pageNum,
+          pageSize: this.pageSize,
+        },
+        (res) => {
+          if (res.data.code == 200) {
+          } 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));
+    },
+
+    sendMsg() {
+      this.sendMsgFlag = false;
+      let contant1 = document.getElementById("contant1");
+      let tmp = {
+        from: 2,
+        answer: this.desc,
+        from1: HeadImg,
+      };
+      this.chatContents.push(tmp);
+      this.getQuestion("11111");
+      // 让滚动条始终在最底部
+      this.sleep(101).then(() => {
+        contant1.scrollTop = contant1.scrollHeight;
+      });
+      this.desc = "";
+      //立马调用
+      //进行提问的接口
+      //第一个问题出来后先对答案进行解析
+    },
+    //获取问题的接口//需要传输上下文关系,应该是需要上一个问题回答的是啥
+    getQuestion(val) {
+      this.$http.post(
+        `///`,
+        {
+          data: val,
+        },
+        (res) => {
+          if (res.data.code == 200) {
+          } else {
+          }
+        }
+      );
+      this.chatContents.push({
+        from: 1,
+        question: val,
+        from1: HeadImg,
+      });
+      this.saveRecord(val)
+    },
+    //保存记录的接口
+    saveRecord(val) {
+      this.$http.post(
+        `///`,
+        {
+          data: val,
+        },
+        (res) => {
+          if (res.data.code == 200) {
+          } else {
+          }
+        }
+      );
+    },
+    //调用接口查询情绪
+    selectMood(val) {
+      // this.sendMsgFlag=true;
+      let that = this;
+      axios
+        .post(`http://127.0.0.1:9999/sentiment`, { text: val })
+        .then((res) => {
+          that.sendMsgFlag = true;
+          that.threeAnswers.push(res.data.sentiment);
+          //是否问问题的标志
+          //当答案小于3时需要接着提问
+          if (that.threeAnswers.length < 3) {
+            that.askQuestions();
+          } else if (that.threeAnswers.length === 3) {
+            //当等于3时需要判断是否接着提问
+            //当负面情绪小于2时则终止询问
+            //当负面情绪大于等于2时需要再次提问
+            that.judgeMood(2);
+          } else if (that.threeAnswers.length === 4) {
+            //当问题等于4时再次询问
+            that.askQuestions();
+          } else if (that.threeAnswers.length === 5) {
+            //调用判断结果负面情绪是否大于等于3
+            that.judgeMood(3);
+          }
+
+          //当回答的答案大于等于3时判断是否结束,当负面情绪大于等于2时
+          // that.judgeMood();
+        });
+    },
+    askEnd(val) {
+      this.chatContents.push({
+        from: 1,
+        question: val,
+        from1: HeadImg,
+      });
+      let contant1 = document.getElementById("contant1");
+      this.sleep(101).then(() => {
+        contant1.scrollTop = contant1.scrollHeight;
+      });
+    },
+    answerSelect(val) {
+      this.chatContents.push({
+        from: 2,
+        answer: val,
+        from1: HeadImg,
+      });
+    },
+    askQuestions() {
+      this.chatContents.push({
+        from: 1,
+        question: this.preList[this.threeAnswers.length].des,
+        from1: HeadImg,
+      });
+      this.questionNum++;
+    },
+    goBack() {
+      this.$router.go(-1);
+    },
+  },
+};
+</script>
+<style scoped>
+.mainTable-top {
+  margin-top: 5%;
+}
+.mainTable-top-two {
+  margin-top: 10%;
+}
+.mainTable-tab {
+  cursor: pointer;
+  margin-left: 100px;
+  margin-right: 100px;
+  border-radius: 5px;
+  border: 1px solid #000000;
+  text-align: center;
+  height: 150px;
+  margin-bottom: 100px;
+}
+.mainTable-tab-p {
+  padding-top: 40px;
+}
+.musicTitle {
+  display: block;
+  font-size: 18px;
+  color: #57acbb;
+  margin-bottom: 5px;
+}
+.main_answer_left {
+  display: flex;
+  /* text-align: left; */
+}
+.main_answer_right {
+  display: flex;
+  /* text-align: right; */
+}
+.message-wrapper {
+  background-color: #ffffff;
+}
+.message-wrapper-left {
+  margin-left: 10px;
+  /* border-radius: 0 1rem 1rem 1rem; */
+  border-radius: 4px 4px 4px 4px;
+  max-width: 20.86667rem;
+  display: inline-table;
+}
+.message-wrapper-right {
+  margin-right: 10px;
+  border-radius: 4px 4px 4px 4px;
+  max-width: 20.86667rem;
+  display: inline-table;
+  background-color: #1fd18e;
+  color: #ffffff;
+  /* margin-top: 25px; */
+}
+.message {
+  word-break: break-all;
+  padding: 18px;
+  /* font-size: 20px; */
+}
+
+.xl_d_button {
+  background: rgb(87, 172, 187);
+  opacity: 1;
+  border-radius: 50%;
+  font-size: 20px;
+  font-family: PingFang SC;
+  font-weight: 400;
+  color: #ffffff;
+  width: 40px;
+  line-height: 40px;
+  text-align: center;
+}
+.xl_d_button:hover {
+  background: rgb(87, 172, 187);
+  opacity: 1;
+  /* border-radius: 18px; */
+  font-size: 14px;
+  font-family: PingFang SC;
+  font-weight: 400;
+  color: #ffffff;
+}
+.xl_d_button:focus {
+  background: rgb(87, 172, 187);
+  opacity: 1;
+  /* border-radius: 18px; */
+  font-size: 14px;
+  font-family: PingFang SC;
+  font-weight: 400;
+  color: #ffffff;
+}
+.refrshSmart {
+  float: right;
+  cursor: pointer;
+}
+.xl_input >>> .el-input__inner {
+  border: 0;
+  border-radius: 4px;
+  background-color: #f4f4f4;
+}
+.footSend {
+  background: #ffffff;
+  position: absolute;
+  height: 80px;
+  margin-left: 2%;
+  width: 90%;
+  border-radius: 14px;
+  bottom: 50px;
+}
+.smart_line_class {
+  /* background: #BBC5D4; */
+  position: absolute;
+  height: 1px;
+  margin-left: 2%;
+  width: 90%;
+  border-radius: 14px;
+  bottom: 150px;
+  border-bottom: 1px solid #bbc5d4;
+}
+.footSend >>> .el-textarea__inner {
+  border: 0px solid #ffffff !important;
+  border-radius: 14px !important;
+}
+.footSendSelect {
+  background: #ffffff;
+  /* padding-bottom: 40px; */
+  position: absolute;
+  margin-left: 2%;
+  width: 90%;
+  bottom: 40px;
+}
+.xl_d_send {
+  margin-top: 18px;
+  color: #087b50;
+  background: #c6f0ed !important;
+  opacity: 1;
+  font-size: 14px;
+  font-family: PingFang SC;
+  font-weight: 400;
+  text-align: center;
+  border: 0px;
+  border-radius: 10px;
+}
+.xl_d_send:hover {
+  margin-top: 18px;
+  color: #087b50;
+  background: #c6f0ed !important;
+  opacity: 1;
+  font-size: 14px;
+  font-family: PingFang SC;
+  font-weight: 400;
+  text-align: center;
+  border-radius: 10px;
+}
+.xl_d_send:focus {
+  margin-top: 18px;
+  color: #087b50;
+  background: #c6f0ed !important;
+  opacity: 1;
+  font-size: 14px;
+  font-family: PingFang SC;
+  font-weight: 400;
+  text-align: center;
+  border-radius: 10px;
+}
+.xl_d_send.is-disabled,
+.xl_d_send.is-disabled:hover,
+.xl_d_send.is-disabled:focus {
+  margin-top: 18px;
+  color: #087b50;
+  background: #c6f0ed !important;
+  opacity: 1;
+  font-size: 14px;
+  font-family: PingFang SC;
+  font-weight: 400;
+  text-align: center;
+  border-radius: 10px;
+}
+
+.main_right_height {
+  /* padding:40px; */
+  height: 100vh !important;
+  display: block !important;
+  overflow-y: auto !important;
+  background-color: #ffffff;
+}
+
+.smart_content {
+  height: 88%;
+  margin-top: 5%;
+  width: 94%;
+  margin-left: 3%;
+  border-radius: 40px;
+  background: #f6f6f6;
+}
+.chat-window {
+  height: 70vh;
+  overflow: auto;
+  /* overflow-y:hidden; */
+}
+
+/* .contant1{
+ height:70vh;
+  overflow:auto;
+} */
+</style>

+ 17 - 961
src/renderer/components/intervene.vue

@@ -2,7 +2,12 @@
   <div class="main_right_height">
     <TopDes :flag="false" topDesFont="认知行为干预"></TopDes>
     <div class="intervene_content">
-      <div class="intervene_item" v-for="item in interveneList" :key="item.id" @click="goDetail(item)">
+      <div
+        class="intervene_item"
+        v-for="item in interveneList"
+        :key="item.id"
+        @click="goDetail(item)"
+      >
         <img :src="item.imgUrl" alt="" />
         <h2>{{ item.name }}</h2>
         <p style="font-size: 1vw">{{ item.title }}</p>
@@ -12,118 +17,35 @@
   </div>
 </template>
 <script>
-import * as echarts from "echarts";
-const { ipcRenderer } = require("electron");
-var chartDom;
-const fs = require("fs");
-var os = require("os");
-var userInfo = os.userInfo();
-import Utils from "./util.js";
+
 export default {
   data() {
     return {
-      isEcg: "未连接",
-      numPluseDom: "",
-      numPluseTmp: "",
-      //存储文件的路径
-      filePath: "",
-      currentPulseFlag: false,
-      //脉搏原始信号
-      pulseList: [],
-      //脉搏x轴数据
-      pulseListX: [],
-      //脉搏全量数据
-      pulseListAll: [],
-      //脉搏过滤后的数据
-      filterPluse: [],
-      //脉搏滤波后最大值和最小值
-      filterPluseMin: 0,
-      filterPluseMax: 100,
-      testFlag: "开始测试",
-      aa: {
-        sdnn: "-",
-        sdsd: "-",
-        rmssd: "-",
-        sd1: "-",
-        sd2: "-",
-        pnn20: "-",
-        pnn50: "-",
-        p_total: "-",
-        vlf: "-",
-        lf: "-",
-        hf: "-",
-        "lf/hf": "-",
-        lf_nu: "-",
-        hf_nu: "-",
-        "0.1Hz": "-",
-      },
-      bb: {
-        sdnn: "-",
-        sdsd: "-",
-        rmssd: "-",
-        sd1: "-",
-        sd2: "-",
-        pnn20: "-",
-        pnn50: "-",
-        p_total: "-",
-        vlf: "-",
-        lf: "-",
-        hf: "-",
-        "lf/hf": "-",
-        lf_nu: "-",
-        hf_nu: "-",
-        "0.1Hz": "-",
-      },
-      cc: {
-        sdnn: "-",
-        sdsd: "-",
-        rmssd: "-",
-        sd1: "-",
-        sd2: "-",
-        pnn20: "-",
-        pnn50: "-",
-        p_total: "-",
-        vlf: "-",
-        lf: "-",
-        hf: "-",
-        "lf/hf": "-",
-        lf_nu: "-",
-        hf_nu: "-",
-        "0.1Hz": "-",
-      },
-      //游戏脉搏开始标志
-      animationPulseFlag: false,
-      //游戏期间的脉搏数据
-      pulseAnimationList: [],
-      //游戏期间脉搏指标数组
-      pulseAnimationTarget: [],
-      //测试脉搏期间的指标数组
-      pulseTarget: [],
       interveneList: [
         {
-          id: 0,
+          id: 1,
           imgUrl: require("../assets/newImage/rzgy1.png"),
           name: "战胜焦虑",
           title: "每天放松好心情",
           desc: "焦虑是个人对可能会出现的危险或威胁所产生的紧张、不安、忧虑、烦恼等不愉快的复杂情绪状态,CBT通过认知重构,暴露疗法,行为改变,放松训练等方法可以有效治疗焦虑。",
         },
         {
-          id: 1,
+          id: 2,
           imgUrl: require("../assets/newImage/rzgy2.png"),
           name: "走出抑郁",
           title: "重新点燃生活的希望",
           desc: "抑郁症是一种以连续且长期的心情低落为主要特征的心理疾病,通过CBT的阶段治疗,配合认知重建,行为改变等治疗手段可有效缓解抑郁情绪。",
-          url: '/treatDepression'
+          url: "/treatDepression",
         },
         {
-          id: 2,
+          id: 3,
           imgUrl: require("../assets/newImage/rzgy3.png"),
           name: "远离失眠",
           title: "甜蜜梦乡不是奢望",
           desc: "失眠和睡眠节律紊乱等睡眠障碍会对您的生活质量和身体健康产生严重影响,CBT治疗通过放松训练,睡眠限制治疗,刺激控制技术,睡眠健康教育等方法来改善睡眠障碍。",
         },
         {
-          id: 3,
+          id: 4,
           imgUrl: require("../assets/newImage/rzgy4.png"),
           name: "克服应激",
           title: "与自己的身心和解",
@@ -132,884 +54,18 @@ export default {
       ],
     };
   },
-  activated() {
-    let that = this;
-    this.currentPulseFlag = true;
-    chartDom.resize();
-    let url = userInfo.homedir;
-
-    let downloadsUrl = url.replace(/\\/g, "/");
-
-    this.filePath = downloadsUrl + "/KJB";
-    fs.exists(that.filePath, function (exists) {
-      // var that = this;
-
-      if (!exists) {
-        fs.mkdirSync(that.filePath);
-      }
-    });
-  },
-  deactivated() {
-    this.currentPulseFlag = false;
-  },
+  activated() {},
+  deactivated() {},
   mounted() {
     console.log(
       "-----------------------------------------------------------------"
     );
-
-    console.log(Utils);
-    let that = this;
-    chartDom = echarts.init(document.getElementById("pluse"));
-
-    var flag = true;
-    window.addEventListener("resize", function () {
-      if (flag) {
-        setTimeout(() => {
-          chartDom.resize();
-          flag = true;
-        }, 1000);
-      }
-      flag = false;
-    });
-    this.pulseListX = this.initPluseX();
-
-    this.refreshPluse();
-
-    ipcRenderer.on("asynchronous-message", (event, arg) => {
-      let a = JSON.parse(arg);
-      let pluseArrTmp = [];
-      if (a.flag === "KJB") {
-        pluseArrTmp = JSON.parse(a.data);
-      } else if (a.flag === "KJB-PULSE-STATE") {
-        if (a.data === "PULSE-STOP") {
-          console.log(a.data);
-          this.startTest(2);
-        }
-      }
-
-      for (let i = 0; i < pluseArrTmp.length; i++) {
-        if (this.pulseList.length == 500) {
-          // e.log(this.listMachining);
-          this.pulseList.shift();
-          this.pulseListX.shift();
-        }
-        if (!isNaN(pluseArrTmp[i])) {
-          //如果有些界面点击开始则开始储存游戏开始的数据
-
-          this.pulseList.push(pluseArrTmp[i]);
-          this.pulseListAll.push(pluseArrTmp[i]);
-
-          if (this.animationPulseFlag) {
-            this.pulseAnimationList.push(pluseArrTmp[i]);
-          }
-
-          if (this.pulseListAll.length > 500) {
-            this.pulseListX.push(this.pulseListAll.length);
-          }
-          this.numPluseDom = this.pulseListAll.length.toString();
-        }
-      }
-    });
-    Utils.$on("animation-pulse", (msg) => {
-      if (msg.command == "开始") {
-        that.pulseAnimationList = [];
-        that.pulseAnimationTarget = [];
-        that.animationPulseFlag = true;
-      } else {
-        that.animationPulseFlag = false;
-        let saveTime = that.getCurrentTime();
-        //调用保存接口
-        //将数据
-        //将脉搏数据存储进文件
-
-        //调用接口将脉搏数据入库
-        let timeStamp = that.formateDate();
-        let acount = sessionStorage.getItem("num");
-        let fileName = acount + "-" + timeStamp + "脉搏训练";
-        let test_result_tmp = that.pulseAnimationList;
-        fs.writeFile(
-          `${that.filePath}/${fileName}.txt`,
-          test_result_tmp,
-          "binary",
-          function (err) {
-            if (err) {
-              that.$message.error("导出失败");
-            } else {
-            }
-          }
-        );
-
-        let params = {
-          num: sessionStorage.getItem("num"), //个人编号
-          gameScene: that.formatterGame(msg.gameScene), //游戏场景
-          equipmentType: "脉搏", //设备类型
-          gameDifficulty: that.formatterGameDiff(msg.gameDifficulty), //游戏难度
-          gameTime: that.formatterGameTime(msg.gameTime), //游戏时间
-          animationSourceList: "-", //原始数据
-          fileName: fileName,
-          animationTarget: JSON.stringify(that.pulseAnimationTarget), //指标数据
-          saveTime: saveTime, //保存指标数据
-        };
-        that.savePulseAnimation(params);
-      }
-    });
-    ipcRenderer.on("send-message-to-render-pluse", (event, arg) => {
-      // that.filterPluse = arg;
-      let filterPluseList = arg;
-      for (let i = 0; i < filterPluseList.length; i++) {
-        that.filterPluse[i] = filterPluseList[i].toFixed();
-      }
-      that.filterPluseMin = Math.min.apply(null, that.filterPluse);
-      that.filterPluseMax = Math.max.apply(null, that.filterPluse);
-    });
-
-    ipcRenderer.on("send-message-to-render-hrv", (event, arg) => {
-      console.log("22222222222222222222");
-      that.aa = arg;
-      if (typeof that.aa === "undefined") {
-        that.aa = "";
-      }
-      if (that.aa == "") {
-        that.aa = {
-          sdnn: "-",
-          sdsd: "-",
-          rmssd: "-",
-          sd1: "-",
-          sd2: "-",
-          pnn20: "-",
-          pnn50: "-",
-          p_total: "-",
-          vlf: "-",
-          lf: "-",
-          hf: "-",
-          "lf/hf": "-",
-          lf_nu: "-",
-          hf_nu: "-",
-          "0.1Hz": "-",
-        };
-      } else {
-        if (that.aa.sdnn != "" || that.aa.sdnn != null) {
-          that.aa.sdnn = parseFloat(that.aa.sdnn).toFixed(4);
-        } else {
-          that.aa.sdnn = "-";
-        }
-
-        if (that.aa.sdsd != "" || that.aa.sdsd != null) {
-          that.aa.sdsd = parseFloat(that.aa.sdsd).toFixed(4);
-        } else {
-          that.aa.sdsd = "-";
-        }
-
-        if (that.aa.rmssd != "" || that.aa.rmssd != null) {
-          that.aa.rmssd = parseFloat(that.aa.rmssd).toFixed(4);
-        } else {
-          that.aa.rmssd = "-";
-        }
-
-        if (that.aa.sd1 != "" || that.aa.sd1 != null) {
-          that.aa.sd1 = parseFloat(that.aa.sd1).toFixed(4);
-        } else {
-          that.aa.sd1 = "-";
-        }
-
-        if (that.aa.sd2 != "" || that.aa.sd2 != null) {
-          that.aa.sd2 = parseFloat(that.aa.sd2).toFixed(4);
-        } else {
-          that.aa.sd2 = "-";
-        }
-
-        if (that.aa.pnn20 != "" || that.aa.pnn20 != null) {
-          that.aa.pnn20 = parseFloat(that.aa.pnn20).toFixed(4);
-        } else {
-          that.aa.pnn20 = "-";
-        }
-        if (that.aa.pnn50 != "" || that.aa.pnn50 != null) {
-          that.aa.pnn50 = parseFloat(that.aa.pnn50).toFixed(4);
-        } else {
-          that.aa.pnn50 = "-";
-        }
-
-        if (that.aa.p_total != "" || that.aa.p_total != null) {
-          that.aa.p_total = parseFloat(that.aa.p_total).toFixed(4);
-        } else {
-          that.aa.p_total = "-";
-        }
-        if (that.aa.vlf != "" || that.aa.vlf != null) {
-          that.aa.vlf = parseFloat(that.aa.vlf).toFixed(4);
-        } else {
-          that.aa.vlf = "-";
-        }
-
-        if (that.aa.lf != "" || that.aa.lf != null) {
-          that.aa.lf = parseFloat(that.aa.lf).toFixed(4);
-        } else {
-          that.aa.lf = "-";
-        }
-
-        if (that.aa.hf != "" || that.aa.hf != null) {
-          that.aa.hf = parseFloat(that.aa.hf).toFixed(4);
-        } else {
-          this.aa.hf = "-";
-        }
-        if (that.aa["lf/hf"] != "" || that.aa["lf/hf"] != null) {
-          that.aa["lf/hf"] = parseFloat(that.aa["lf/hf"]).toFixed(4);
-        } else {
-          that.aa["lf/hf"] = "-";
-        }
-
-        if (that.aa.lf_nu != "" || that.aa.lf_nu != null) {
-          that.aa.lf_nu = parseFloat(that.aa.lf_nu).toFixed(4);
-        } else {
-          that.aa.lf_nu = "-";
-        }
-        if (that.aa.hf_nu != "" || that.aa.hf_nu != null) {
-          that.aa.hf_nu = parseFloat(that.aa.hf_nu).toFixed(4);
-        } else {
-          that.aa.hf_nu = "-";
-        }
-
-        if (that.aa["0.1Hz"] != "" || that.aa["0.1Hz"] != null) {
-          that.aa["0.1Hz"] = parseFloat(that.aa["0.1Hz"]).toFixed(4);
-        } else {
-          that.aa["0.1Hz"] = "-";
-        }
-      }
-      //调用接口将脉搏数据入库
-      let timeStamp = that.formateDate();
-      let acount = sessionStorage.getItem("num");
-      let fileName = acount + "-" + timeStamp + "脉搏";
-      let test_result_tmp = that.pulseListAll;
-      fs.writeFile(
-        `${that.filePath}/${fileName}.txt`,
-        test_result_tmp,
-        "binary",
-        function (err) {
-          if (err) {
-            that.$message.error("导出失败");
-          } else {
-          }
-        }
-      );
-      that.$http.post(
-        `v1/recordPhy/save`,
-        {
-          testDate: timeStamp,
-          testResult: that.aa,
-          sourceData: "",
-          hrv: that.aa,
-          type: 1,
-          identifier: sessionStorage.getItem("num"),
-          fileName: fileName,
-          target: that.pulseTarget,
-        },
-        (res) => {
-          if (res.data.code == 200) {
-            this.$message.success("保存成功");
-          } else {
-            this.$message.error("访问服务器失败!");
-          }
-        }
-      );
-    });
-
-    ipcRenderer.on("send-message-to-render-hrv-pluseAll", (event, arg) => {
-      that.bb = arg;
-      if (typeof that.bb === "undefined") {
-        that.bb = "";
-      }
-      if (that.bb == "") {
-        that.bb = {
-          sdnn: "-",
-          sdsd: "-",
-          rmssd: "-",
-          sd1: "-",
-          sd2: "-",
-          pnn20: "-",
-          pnn50: "-",
-          p_total: "-",
-          vlf: "-",
-          lf: "-",
-          hf: "-",
-          "lf/hf": "-",
-          lf_nu: "-",
-          hf_nu: "-",
-          "0.1Hz": "-",
-        };
-      } else {
-        if (that.bb.sdnn != "" || that.bb.sdnn != null) {
-          that.bb.sdnn = parseFloat(that.bb.sdnn).toFixed(4);
-        } else {
-          that.bb.sdnn = "-";
-        }
-
-        if (that.bb.sdsd != "" || that.bb.sdsd != null) {
-          that.bb.sdsd = parseFloat(that.bb.sdsd).toFixed(4);
-        } else {
-          that.bb.sdsd = "-";
-        }
-
-        if (that.bb.rmssd != "" || that.bb.rmssd != null) {
-          that.bb.rmssd = parseFloat(that.bb.rmssd).toFixed(4);
-        } else {
-          that.bb.rmssd = "-";
-        }
-
-        if (that.bb.sd1 != "" || that.bb.sd1 != null) {
-          that.bb.sd1 = parseFloat(that.bb.sd1).toFixed(4);
-        } else {
-          that.bb.sd1 = "-";
-        }
-
-        if (that.bb.sd2 != "" || that.bb.sd2 != null) {
-          that.bb.sd2 = parseFloat(that.bb.sd2).toFixed(4);
-        } else {
-          that.bb.sd2 = "-";
-        }
-
-        if (that.bb.pnn20 != "" || that.bb.pnn20 != null) {
-          that.bb.pnn20 = parseFloat(that.bb.pnn20).toFixed(4);
-        } else {
-          that.bb.pnn20 = "-";
-        }
-        if (that.bb.pnn50 != "" || that.bb.pnn50 != null) {
-          that.bb.pnn50 = parseFloat(that.bb.pnn50).toFixed(4);
-        } else {
-          that.bb.pnn50 = "-";
-        }
-
-        if (that.bb.p_total != "" || that.bb.p_total != null) {
-          that.bb.p_total = parseFloat(that.bb.p_total).toFixed(4);
-        } else {
-          that.bb.p_total = "-";
-        }
-        if (that.bb.vlf != "" || that.bb.vlf != null) {
-          that.bb.vlf = parseFloat(that.bb.vlf).toFixed(4);
-        } else {
-          that.bb.vlf = "-";
-        }
-
-        if (that.bb.lf != "" || that.bb.lf != null) {
-          that.bb.lf = parseFloat(that.bb.lf).toFixed(4);
-        } else {
-          that.bb.lf = "-";
-        }
-
-        if (that.bb.hf != "" || that.bb.hf != null) {
-          that.bb.hf = parseFloat(that.bb.hf).toFixed(4);
-        } else {
-          this.bb.hf = "-";
-        }
-        if (that.bb["lf/hf"] != "" || that.bb["lf/hf"] != null) {
-          that.bb["lf/hf"] = parseFloat(that.bb["lf/hf"]).toFixed(4);
-        } else {
-          that.bb["lf/hf"] = "-";
-        }
-
-        if (that.bb.lf_nu != "" || that.bb.lf_nu != null) {
-          that.bb.lf_nu = parseFloat(that.bb.lf_nu).toFixed(4);
-        } else {
-          that.bb.lf_nu = "-";
-        }
-        if (that.bb.hf_nu != "" || that.bb.hf_nu != null) {
-          that.bb.hf_nu = parseFloat(that.bb.hf_nu).toFixed(4);
-        } else {
-          that.bb.hf_nu = "-";
-        }
-
-        if (that.bb["0.1Hz"] != "" || that.bb["0.1Hz"] != null) {
-          that.bb["0.1Hz"] = parseFloat(that.bb["0.1Hz"]).toFixed(4);
-        } else {
-          that.bb["0.1Hz"] = "-";
-        }
-      }
-      if (that.bb.lf == "-" || that.bb.hf == "-") {
-        Utils.$emit("pulse", {
-          status: that.isEcg,
-          waitTime: 0,
-          value: 0,
-          pulseGame: 0,
-          bbGame: "",
-        });
-        //当游戏点击开始后
-        //进行保存指标数据进数据库
-        // that.pulseAnimationList = [];
-        // that.pulseAnimationTarget = [];
-        // that.animationPulseFlag = ture;
-        //当脉搏连接上且按钮为结束测试时
-        // if ((that.isEcg = "已连接" && that.testFlag == "结束测试")) {
-        //   that.pulseTarget.push({ lf: "-", hf: "-", "lf/hf": 0 });
-        // }
-        if (that.animationPulseFlag) {
-          // let linTarget={}
-          that.pulseAnimationTarget.push({ lf: "-", hf: "-", "lf/hf": 0 });
-        }
-      } else {
-        let lf = parseInt(that.bb.lf);
-        let hf = parseInt(that.bb.hf);
-        let pulseGame = parseInt(that.bb.hf_nu);
-        Utils.$emit("pulse", {
-          status: that.isEcg,
-          waitTime: 0,
-          value: lf / hf,
-          pulseGame: pulseGame,
-          bbGame: that.bb,
-        });
-        // if ((that.isEcg = "已连接" && that.testFlag == "结束测试")) {
-        //   that.pulseTarget.push({ lf: lf, hf: hf, "lf/hf": lf / hf });
-        // }
-        if (that.animationPulseFlag) {
-          // let linTarget={}
-          that.pulseAnimationTarget.push({ lf: lf, hf: hf, "lf/hf": lf / hf });
-        }
-      }
-      //判断那两个指标是否存在
-    });
-
-    ipcRenderer.on("send-message-to-render-hrv-realtime", (event, arg) => {
-      that.cc = arg;
-      if (typeof that.cc === "undefined") {
-        that.cc = "";
-      }
-      if (that.cc == "") {
-        that.cc = {
-          sdnn: "-",
-          sdsd: "-",
-          rmssd: "-",
-          sd1: "-",
-          sd2: "-",
-          pnn20: "-",
-          pnn50: "-",
-          p_total: "-",
-          vlf: "-",
-          lf: "-",
-          hf: "-",
-          "lf/hf": "-",
-          lf_nu: "-",
-          hf_nu: "-",
-          "0.1Hz": "-",
-        };
-      } else {
-        if (that.cc.sdnn != "" || that.cc.sdnn != null) {
-          that.cc.sdnn = parseFloat(that.cc.sdnn).toFixed(4);
-        } else {
-          that.cc.sdnn = "-";
-        }
-
-        if (that.cc.sdsd != "" || that.cc.sdsd != null) {
-          that.cc.sdsd = parseFloat(that.cc.sdsd).toFixed(4);
-        } else {
-          that.cc.sdsd = "-";
-        }
-
-        if (that.cc.rmssd != "" || that.cc.rmssd != null) {
-          that.cc.rmssd = parseFloat(that.cc.rmssd).toFixed(4);
-        } else {
-          that.cc.rmssd = "-";
-        }
-
-        if (that.cc.sd1 != "" || that.cc.sd1 != null) {
-          that.cc.sd1 = parseFloat(that.cc.sd1).toFixed(4);
-        } else {
-          that.cc.sd1 = "-";
-        }
-
-        if (that.cc.sd2 != "" || that.cc.sd2 != null) {
-          that.cc.sd2 = parseFloat(that.cc.sd2).toFixed(4);
-        } else {
-          that.cc.sd2 = "-";
-        }
-
-        if (that.cc.pnn20 != "" || that.cc.pnn20 != null) {
-          that.cc.pnn20 = parseFloat(that.cc.pnn20).toFixed(4);
-        } else {
-          that.cc.pnn20 = "-";
-        }
-        if (that.cc.pnn50 != "" || that.cc.pnn50 != null) {
-          that.cc.pnn50 = parseFloat(that.cc.pnn50).toFixed(4);
-        } else {
-          that.cc.pnn50 = "-";
-        }
-
-        if (that.cc.p_total != "" || that.cc.p_total != null) {
-          that.cc.p_total = parseFloat(that.cc.p_total).toFixed(4);
-        } else {
-          that.cc.p_total = "-";
-        }
-        if (that.cc.vlf != "" || that.cc.vlf != null) {
-          that.cc.vlf = parseFloat(that.cc.vlf).toFixed(4);
-        } else {
-          that.cc.vlf = "-";
-        }
-
-        if (that.cc.lf != "" || that.cc.lf != null) {
-          that.cc.lf = parseFloat(that.cc.lf).toFixed(4);
-        } else {
-          that.cc.lf = "-";
-        }
-
-        if (that.cc.hf != "" || that.cc.hf != null) {
-          that.cc.hf = parseFloat(that.cc.hf).toFixed(4);
-        } else {
-          this.cc.hf = "-";
-        }
-        if (that.cc["lf/hf"] != "" || that.cc["lf/hf"] != null) {
-          that.cc["lf/hf"] = parseFloat(that.cc["lf/hf"]).toFixed(4);
-        } else {
-          that.cc["lf/hf"] = "-";
-        }
-
-        if (that.cc.lf_nu != "" || that.cc.lf_nu != null) {
-          that.cc.lf_nu = parseFloat(that.cc.lf_nu).toFixed(4);
-        } else {
-          that.cc.lf_nu = "-";
-        }
-        if (that.cc.hf_nu != "" || that.cc.hf_nu != null) {
-          that.cc.hf_nu = parseFloat(that.cc.hf_nu).toFixed(4);
-        } else {
-          that.cc.hf_nu = "-";
-        }
-
-        if (that.cc["0.1Hz"] != "" || that.cc["0.1Hz"] != null) {
-          that.cc["0.1Hz"] = parseFloat(that.cc["0.1Hz"]).toFixed(4);
-        } else {
-          that.cc["0.1Hz"] = "-";
-        }
-      }
-      if (that.cc.lf == "-" || that.cc.hf == "-") {
-        //当游戏点击开始后
-        //进行保存指标数据进数据库
-        // that.pulseAnimationList = [];
-        // that.pulseAnimationTarget = [];
-        // that.animationPulseFlag = ture;
-        //当脉搏连接上且按钮为结束测试时
-        if (that.isEcg == "已连接" && that.testFlag == "结束测试") {
-          that.pulseTarget.push({ lf: "-", hf: "-", "lf/hf": 0 });
-        }
-      } else {
-        let lf = parseInt(that.cc.lf);
-        let hf = parseInt(that.cc.hf);
-        if (that.isEcg == "已连接" && that.testFlag == "结束测试") {
-          that.pulseTarget.push({ lf: lf, hf: hf, "lf/hf": lf / hf });
-        }
-      }
-    });
-
-    //实时算法的东西
-
-    setInterval(() => {
-      //向游戏训练传输脉搏的连接状态
-      //如果连接状态时已连接,则判断运行是否超过3分钟,如果未超过3分钟则返回剩余多少分钟
-      //如果剩余是0,则再传输指标值
-
-      //应该是判断属于游戏脉搏数组的长度
-      //用游戏脉搏的数组判断是否大于3分钟。3分钟数据长度后,需要将数据算为指标,指标算出来以后传输给游戏界面
-      if (that.pulseAnimationList.length > 0) {
-        if (that.pulseAnimationList.length >= 18000 && that.isEcg == "已连接") {
-          let rawData = that.pulseAnimationList;
-          if (that.animationPulseFlag) {
-            ipcRenderer.send("asynchronoushrv-message-pluseAll", rawData);
-          }
-        } else {
-          Utils.$emit("pulse", {
-            status: that.isEcg,
-            waitTime: 180 - that.pulseAnimationList.length / 100,
-            value: 0,
-          });
-        }
-      } else {
-        Utils.$emit("pulse", {
-          status: that.isEcg,
-          waitTime: 180 - that.pulseAnimationList.length / 100,
-          value: 0,
-        });
-      }
-
-      //判断全量的数据
-      if (that.pulseListAll.length > 0) {
-        // Utils.$emit("pluse", 1); 100*60*3
-        //需要计算脉搏单独测试的接口。
-        //满足条件 长度大于18000 并且脉搏已连接,并且按钮为已点击开始测试的状态
-        if (
-          that.pulseListAll.length >= 18000 &&
-          that.isEcg == "已连接" &&
-          that.testFlag == "结束测试"
-        ) {
-          let rawData = that.pulseListAll;
-          //脉搏页面自己测试的数据调用算法
-          ipcRenderer.send("asynchronoushrv-message-pluse-realtime", rawData);
-          //向python程序发送消息计算hrv值
-          //计算hrv值后向生物反馈发送指标消息
-        }
-      }
-
-      if (that.pulseList.length > 0) {
-        //连接状态在不在当前页面时也要体现出来
-        if (that.numPluseTmp !== that.numPluseDom) {
-          //假如不相等就是已连接
-          that.numPluseTmp = that.numPluseDom;
-          that.isEcg = "已连接";
-        } else {
-          that.isEcg = "未连接";
-          // this.isEle = "未连接";
-          //已断开
-        }
-        if (that.currentPulseFlag) {
-          that.refreshPluse();
-        }
-      }
-    }, 1000);
   },
   methods: {
-    //保存游戏数据接口
-
-    savePulseAnimation(params) {
-      let that = this;
-      that.$http.post(
-        `v1/game/record/save`,
-        {
-          identifier: params.num,
-          gameScene: params.gameScene,
-          equipmentType: params.equipmentType,
-          gameDifficulty: params.gameDifficulty,
-          gameTime: params.gameTime,
-          animationSourceList: params.animationSourceList,
-          fileName: params.fileName,
-          animationTarget: params.animationTarget,
-          saveTime: params.saveTime,
-        },
-        (res) => {
-          if (res.data.code == 200) {
-            // this.$message.success("保存成功");
-            this.$message({
-              message: "保存成功",
-              type: "success",
-              duration: 800,
-            });
-          } else {
-            this.$message.error("访问服务器失败!");
-          }
-        }
-      );
-    },
-    formatterGameTime(val) {
-      if (val == "1") {
-        return "3分钟";
-      }
-      if (val == "2") {
-        return "5分钟";
-      }
-      if (val == "3") {
-        return "10分钟";
-      }
-      return "";
-    },
-    formatterGameDiff(val) {
-      if (val == "1") {
-        return "简单";
-      }
-      if (val == "2") {
-        return "普通";
-      }
-      if (val == "3") {
-        return "困难";
-      }
-      return "";
-    },
-    //格式化游戏场景
-    formatterGame(val) {
-      if (val == "1") {
-        return "心灵之火";
-      }
-      if (val == "2") {
-        return "心之花";
-      }
-      if (val == "3") {
-        return "急速赛车";
-      }
-      if (val == "4") {
-        return "爆爆桶";
-      }
-      if (val == "5") {
-        return "炸弹";
-      }
-      if (val == "6") {
-        return "漂浮球";
-      }
-      return "";
-    },
-    getCurrentTime() {
-      let date = new Date();
-      let year = date.getFullYear();
-      let month = this.formatterMonth(date.getMonth() + 1);
-      let day = this.formatterMonth(date.getDate());
-      let hour = this.formatterMonth(date.getHours());
-      let min = this.formatterMonth(date.getMinutes());
-      let ss = this.formatterMonth(date.getSeconds());
-      let ms = date.getMilliseconds();
-      return (
-        year.toString() +
-        "年" +
-        month.toString() +
-        "月" +
-        day.toString() +
-        "日" +
-        hour.toString() +
-        "时" +
-        min.toString() +
-        "分" +
-        ss.toString() +
-        "秒" +
-        ms
-      );
-    },
-    formatterMonth(val) {
-      let a = 0;
-      if (val < 10) {
-        a = "0" + val;
-        return a;
-      } else {
-        a = val;
-        return a;
-      }
-    },
-    formateDate() {
-      let current = new Date();
-      let year = current.getFullYear();
-      let month = current.getMonth();
-      let day = current.getDate();
-      let hour = current.getHours();
-      let min = current.getMinutes();
-      let ss = current.getSeconds();
-      let mm = current.getMilliseconds();
-      return (
-        year +
-        "年" +
-        (month + 1) +
-        "月" +
-        day +
-        "日" +
-        hour +
-        "时" +
-        min +
-        "分" +
-        ss +
-        "秒" +
-        mm
-      );
-    },
-    startTest(val) {
-      console.log("val == 1");
-      console.log(val == "1");
-      let that = this;
-      if (val == "1") {
-        if (this.testFlag == "开始测试") {
-          this.pulseTarget = [];
-          this.testFlag = "结束测试";
-          this.pulseList = [];
-          //脉搏x轴数据
-          this.pulseListX = this.initPluseX();
-          //脉搏全量数据
-          this.pulseListAll = [];
-          //脉搏过滤后的数据
-          this.filterPluse = [];
-          //脉搏滤波后最大值和最小值
-          this.filterPluseMin = 0;
-          this.filterPluseMax = 100;
-        } else {
-          this.testFlag = "开始测试";
-          let rawData = this.pulseListAll;
-          //调用算法将值算出来
-          ipcRenderer.send("asynchronoushrv-message", rawData);
-          ipcRenderer.send("pulse-message-stop", "1");
-        }
-      } else {
-        if (this.testFlag == "结束测试") {
-          this.testFlag = "开始测试";
-          let rawData = this.pulseListAll;
-          //调用算法将值算出来
-          ipcRenderer.send("asynchronoushrv-message", rawData);
-        }
-      }
-    },
-    initPluseX() {
-      let tempArr = [];
-      for (let i = 0; i <= 500; i++) {
-        tempArr.push(i);
-      }
-      return tempArr;
-    },
-    goBack() {
-      this.$router.go(-1);
-    },
-    refreshPluse() {
-      // if (this.numPluseTmp !== this.numPluseDom) {
-      //   //假如不相等就是已连接
-      //   this.numPluseTmp = this.numPluseDom;
-      //   this.isEcg = "已连接";
-      // } else {
-      //   this.isEcg = "未连接";
-      //   // this.isEle = "未连接";
-      //   //已断开
-      // }
-
-      let arrPluse = [];
-      for (let i = 0; i < this.pulseList.length; i++) {
-        arrPluse.push(this.pulseList[i] * -1);
-      }
-      if (arrPluse.length > 0) {
-        ipcRenderer.send("asynchronoushrv-filter_signal", arrPluse);
-      }
-
-      let option;
-      option = {
-        animation: false,
-        title: {
-          text: "脉搏",
-          subtext: "",
-          left: "center",
-          align: "right",
-          x: "center",
-          y: "bottom",
-        },
-        xAxis: {
-          name: "",
-          boundaryGap: false,
-          splitLine: { show: true },
-          type: "category",
-          data: this.pulseListX,
-          axisLabel: {
-            interval: 99,
-            formatter: function (value, index) {
-              let i = parseInt(value);
-              // 采样大于100 情况下
-              let b = Math.round(i / 100);
-              if (i % 100 > 50) {
-                b = b + 1;
-              }
-              // 向下取整
-              return b;
-            },
-          },
-        },
-        yAxis: {
-          type: "value",
-          min: this.filterPluseMin,
-          max: this.filterPluseMax,
-        },
-        series: [
-          {
-            data: this.filterPluse,
-            type: "line",
-            smooth: true,
-            showSymbol: false,
-          },
-        ],
-      };
-      chartDom.setOption(option);
-    },
     goDetail(item) {
-      this.$router.push('/menu/treatDepression')
-    }
+      // this.$router.push("/menu/treatDepression");
+      this.$router.push({path:'/menu/treatDepression',query:{id:item.id}});
+    },
   },
 };
 </script>

+ 379 - 44
src/renderer/components/treatDepression.vue

@@ -8,24 +8,37 @@
             <div
               class="chat-msg-content"
               id="rongqi"
-              v-for="content in chatContents"
-              :key="content.index"
+              v-for="(content, index) in chatContents"
+              :key="index"
             >
               <div
-                v-if="content.from == 1"
-                :key="content.id"
+                v-if="content.from == 1 && content.question !== ''"
                 class="main_answer_right"
                 style="margin-top: 10px"
               >
-                <div class="img-wrapper">
+                <!-- &&!(chatContents.length - 1 == index) -->
+                <div
+                  class="img-wrapper"
+                  v-if="
+                    (content.isType == 0 && chatContents.length - 1 == index) ||
+                    content.isType == -1 ||
+                    (content.isType == 5 && chatContents.length - 1 == index)
+                  "
+                >
                   <img width="60px" heigth="60px" class="img" :src="from1" />
                 </div>
-                <div class="message-wrapper message-wrapper-left">
-                  <div class="message" v-if="content.isScale">
+                <div
+                  class="message-wrapper message-wrapper-left"
+                  v-if="
+                    (content.isType == 0 && chatContents.length - 1 == index) ||
+                    content.isType == -1 ||
+                    (content.isType == 5 && chatContents.length - 1 == index)
+                  "
+                >
+                  <div class="message" v-if="content.isType == 0">
                     <el-radio-group
                       v-model="answerList[content.index].checkItems"
                       @input="nextHandle(content.index)"
-                      :disabled="content.disabled"
                     >
                       <el-radio
                         v-for="(item, index) in content.question"
@@ -37,17 +50,35 @@
                       >
                     </el-radio-group>
                   </div>
-                  <div class="message" v-else>{{ content.question }}</div>
+                  <div class="message" v-if="content.isType == 5">
+                    <el-radio-group
+                      v-model="answerList[content.index].checkItems"
+                      @input="nextHandle(content.index)"
+                    >
+                      <el-radio
+                        v-for="(item, index) in content.question"
+                        :key="index"
+                        size="small"
+                        :label="item.label"
+                        border
+                        >{{ item.name }}</el-radio
+                      >
+                    </el-radio-group>
+                  </div>
+                  <div class="message" v-if="content.isType == -1">
+                    {{ content.question }}
+                  </div>
                 </div>
               </div>
-              <el-row v-else style="margin-top: 10px">
+              <el-row v-if="content.from == 2" style="margin-top: 10px">
                 <el-col :span="10"> &nbsp; </el-col>
                 <el-col :span="14">
                   <div class="main_answer_left" style="float: right">
                     <div class="message-wrapper message-wrapper-right">
                       <el-radio-group
+                        v-if="content.isType == 0"
                         v-model="content.radio"
-                        :disabled="content.disabled"
+                        :disabled="!(chatContents.length - 1 == index)"
                         @input="chooseAnswer"
                       >
                         <el-radio
@@ -59,6 +90,39 @@
                           >{{ item.answer }}</el-radio
                         >
                       </el-radio-group>
+                      <div class="send_class" v-if="content.isType == 1">
+                        <el-input
+                          :disabled="!(chatContents.length - 1 == index)"
+                          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.nextQuestionNo)"
+                          class="el-icon-s-promotion"
+                        ></i>
+                      </div>
+                      <div
+                        class=""
+                        style="color: #000000"
+                        v-if="content.isType == -1"
+                      >
+                        {{ 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
@@ -167,38 +231,161 @@ export default {
       flag: "",
       questionList: [],
       answerList: [],
+      interveneId: "",
     };
   },
   created() {},
   mounted() {
+    this.interveneId = this.$route.query.id;
     this.init("start");
     // this.selectScale("20220805135201");
   },
   methods: {
+    //保存测试记录
+    saveChat() {
+      let list = [];
+      for (let i = 0; i < this.chatContents.length; i++) {
+        //先判断当前类型是form是左侧还是右侧
+        //当是对话左侧的时候
+        if (this.chatContents[i].from == 1) {
+          if (this.chatContents[i].question !== "") {
+            if (this.chatContents[i].isType == -1) {
+              //存储进去
+              let ob = {
+                from: this.chatContents[i].from,
+                question: this.chatContents[i].question,
+              };
+              list.push(ob);
+            } else if (this.chatContents[i].isType == 0) {
+              //如果是选择题选择题且必定是量表
+              let ob = {
+                from: 2,
+                question:
+                  this.answerList[this.chatContents[i].index].checkItems,
+              };
+              list.push(ob);
+            }else if(this.chatContents[i].isType == 5){
+               let ob = {
+                from: 2,
+                question:
+                  this.answerList[this.chatContents[i].index].checkItems,
+              };
+              list.push(ob);
+            }
+          }
+          //判断是不是量表
+          //如果是
+          //则判断是选择题还是描述
+          //如果是描述
+        } else if (this.chatContents[i].from == 2) {
+          //如果是选择题的话
+          if (this.chatContents[i].isType == 0) {
+            for (let j = 0; j < this.chatContents[i].question.length; j++) {
+              if (
+                this.chatContents[i].question[j].nextQuestionNo ==
+                this.chatContents[i].radio
+              ) {
+                let ob = {
+                  from: 2,
+                  question: this.chatContents[i].question[j].answer,
+                };
+                list.push(ob);
+              }
+            }
+          } else if (this.chatContents[i].isType == 1) {
+            //如果是填空题
+            let ob = {
+              from: 2,
+              question: this.chatContents[i].text,
+            };
+            list.push(ob);
+          }
+          //先看
+        }
+      }
+      // console.log(JSON.stringify(list));
+      //调用保存接口
+      this.saveRealFun(list);
+    },
+    saveRealFun(list) {
+      this.$http.post(
+        `/chat/complete/chat`,
+        {
+          content: list,
+          userName: sessionStorage.getItem("name"),
+          label: this.interveneId,
+          identifier: sessionStorage.getItem("num"),
+        },
+        (res) => {
+          if (res.data.code == 200) {
+          } else {
+            that.$message.error("访问服务器失败!");
+          }
+        }
+      );
+    },
     init(val) {
-      this.getQuestion();
+      this.getQuestion(1);
       let contant1 = document.getElementById("contant1");
       this.sleep(101).then(() => {
         contant1.scrollTop = contant1.scrollHeight;
       });
     },
-
+    sendMessageFun(id) {
+      //发送填空题
+      if (!id == "") {
+        this.getQuestion(id);
+      } else {
+        this.chatContents.push({
+          //是问题还是答案
+          from: 1,
+          //是否是量表的信息
+          isScale: false,
+          //是单选还是文字  0单选  1填空  -1描述
+          isType: -1,
+          //可点击可不点击 0单选   1填空
+          disabled: false,
+          //问题
+          question: "对话结束",
+          //头像
+          from1: HeadImg,
+        });
+        this.saveChat();
+        let contant1 = document.getElementById("contant1");
+        this.sleep(101).then(() => {
+          contant1.scrollTop = contant1.scrollHeight;
+        });
+      }
+    },
     // 获取问题
     getQuestion(id) {
       this.$http.get(
-        "chat/getQuestion/2",
+        `chat/getQuestion/${this.interveneId}`,
         {
           id: id,
         },
         (res) => {
           if (res.code == "200") {
             let result = res.data;
+            if (result == null) {
+              //将结束对话
+              // console.log(this.chatContents)
+              this.saveChat();
+              return;
+            }
             // 将本次问题加入对话
             this.chatContents.push({
+              //是问题还是答案
               from: 1,
+              //是否是量表的信息
               isScale: false,
+              //是单选还是文字  0单选  1填空  -1描述
+              isType: -1,
+              //可点击可不点击 0单选   1填空
               disabled: false,
-              question: result.question,
+              //问题
+              question: result ? result.question : "",
+              //头像
               from1: HeadImg,
             });
             let contant1 = document.getElementById("contant1");
@@ -223,21 +410,44 @@ export default {
 
     // 获取答案
     getAnswer(id) {
-      this.$http.get(`chat/getAnswer/${id}/2`, {}, (res) => {
-        if (res.code == "200" && res.data.length > 0) {
-          let result = res.data;
-          this.chatContents.push({
-            from: 2,
-            isScale: false,
-            disabled: false,
-            question: result,
-            from1: HeadImg,
-            radio: "",
-          });
-          let contant1 = document.getElementById("contant1");
-          this.sleep(101).then(() => {
-            contant1.scrollTop = contant1.scrollHeight;
-          });
+      this.$http.get(`chat/getAnswer/${id}/${this.interveneId}`, {}, (res) => {
+        if (res.code == "200") {
+          if (res.data.length > 0) {
+            let result = res.data;
+            if (parseInt(result[0].questionType) == 1) {
+              this.chatContents.push({
+                id: result[0].id,
+                from: 2,
+                isScale: false,
+                //是单选还是文字  0单选  1填空  -1描述
+                isType: parseInt(result[0].questionType),
+                disabled: false,
+                question: result,
+                from1: HeadImg,
+                radio: false,
+                text: "",
+              });
+            } else {
+              this.chatContents.push({
+                from: 2,
+                isScale: false,
+                //是单选还是文字  0单选  1填空  -1描述
+                isType: parseInt(result[0].questionType),
+                disabled: false,
+                question: result,
+                from1: HeadImg,
+                radio: false,
+                text: "",
+              });
+            }
+
+            let contant1 = document.getElementById("contant1");
+            this.sleep(101).then(() => {
+              contant1.scrollTop = contant1.scrollHeight;
+            });
+          } else {
+            this.saveChat();
+          }
         }
       });
     },
@@ -259,46 +469,131 @@ export default {
             scoreDirection: data[i].scoreDirection,
             serialNo: data[i].serialNo,
             weight: data[i].weight,
+            questionParam: data[i].questionParam,
           });
         }
         this.questionList = res.data;
         this.answerList = anwserListx;
         this.scaleTestStart = true;
         let checkItems = data[0].checkItems;
+
+        //先判断时哪个类型
+        //正常时是发布的类型是  描述和单选   --但是现在多一个特别的单选
+        //
+
         this.chatContents.push({
-          index: 0,
           from: 1,
-          disabled: false,
           isScale: true,
-          question: checkItems.split(";"),
+          disabled: false,
+          isType: -1,
+          question: data[0].answer,
           from1: HeadImg,
         });
+        //当  questionType==0时    当questionType==5时
+        if (data[0].questionType == 0) {
+          this.chatContents.push({
+            index: 0,
+            from: 1,
+            disabled: false,
+            isScale: true,
+            isType: 0,
+            question: checkItems.split(";"),
+            from1: HeadImg,
+          });
+        } else if (data[0].questionType == 5) {
+          let dataTmp = JSON.parse(data[0].questionParam);
+          // for (let i = 0; i < dataTmp.length; i++) {
+          //   if (dataTmp.length - 1 == i) {
+          //     checkIt += dataTmp[i].name;
+          //   } else {
+          //     checkIt += dataTmp[i].name + ";";
+          //   }
+          // }
+          this.chatContents.push({
+            index: 0,
+            from: 1,
+            disabled: false,
+            isScale: true,
+            isType: 5,
+            question: dataTmp,
+            from1: HeadImg,
+          });
+        }
       });
     },
 
     // 选择答案
     chooseAnswer(id) {
+      console.log("下一题编号");
+      console.log(id);
       this.getQuestion(id);
     },
 
     // 量表选中切换下一题
     nextHandle(i) {
       this.chatContents[i].disabled = true;
+
       if (i < this.questionList.length - 1) {
+        let ttmp = this.answerList[i].checkItems;
+        this.chatContents.push({
+          from: 2,
+          isScale: false,
+          isType: -1,
+          question: ttmp,
+          from1: HeadImg,
+        });
+
         i = i + 1;
         let checkItems = this.questionList[i].checkItems;
         this.chatContents.push({
           index: i,
           from: 1,
           isScale: true,
-          question: checkItems.split(";"),
+          isType: -1,
+          question: this.questionList[i].answer,
           from1: HeadImg,
         });
+        if (this.questionList[i].questionType == 0) {
+          this.chatContents.push({
+            index: i,
+            from: 1,
+            isScale: true,
+            isType: 0,
+            question: checkItems.split(";"),
+            from1: HeadImg,
+          });
+        } else if (this.questionList[i].questionType == 5) {
+          let dataTmp = JSON.parse(this.questionList[i].questionParam);
+          // for (let j = 0; j < dataTmp.length; j++) {
+          //   if (dataTmp.length - 1 == i) {
+          //     checkIt += dataTmp[j].name;
+          //   } else {
+          //     checkIt += dataTmp[j].name + ";";
+          //   }
+          // }
+          this.chatContents.push({
+            index: i,
+            from: 1,
+            isScale: true,
+            isType: 5,
+            question: dataTmp,
+            from1: HeadImg,
+          });
+        }
+
         let contant1 = document.getElementById("contant1");
         this.sleep(101).then(() => {
           contant1.scrollTop = contant1.scrollHeight;
         });
       } else {
+        let ttmp = this.answerList[i].checkItems;
+        this.chatContents.push({
+          from: 2,
+          isScale: false,
+          isType: -1,
+          question: ttmp,
+          from1: HeadImg,
+        });
         this.getScaleResult(this.flag);
       }
     },
@@ -329,19 +624,55 @@ export default {
           let testResult = JSON.parse(
             res.data.data.userRecordEntity.testResult
           );
-          let score = Number(testResult[0].newTableContext.result[0].score);
-          if (score < 10) {
+          // console.log(res.data.data.userRecordEntity.testResults);
+          // console.log(testResult);
+          if (this.interveneId == 1) {
+            let score = Number(testResult[0].newTableContext.result[0].score);
+            if (score < 50) {
+              this.chatContents.push({
+                from: 1,
+                isScale: false,
+                isType: -1,
+                question: "根据测试,你很健康,无焦虑表现",
+                from1: HeadImg,
+              });
+              let contant1 = document.getElementById("contant1");
+              this.sleep(101).then(() => {
+                contant1.scrollTop = contant1.scrollHeight;
+              });
+            } else if (score < 70) {
+              this.getNext("轻度焦虑或中度焦虑");
+            } else {
+              this.getNext("重度焦虑");
+            }
+          } else if (this.interveneId == 2) {
+            let score = Number(testResult[0].newTableContext.result[0].score);
+            if (score < 10) {
+              this.chatContents.push({
+                from: 1,
+                isScale: false,
+                isType: -1,
+                question: "根据测试,你很健康,无抑郁表现",
+                from1: HeadImg,
+              });
+              let contant1 = document.getElementById("contant1");
+              this.sleep(101).then(() => {
+                contant1.scrollTop = contant1.scrollHeight;
+              });
+            } else if (score < 19) {
+              this.getNext("轻度抑郁或有抑郁症状");
+            } else {
+              this.getNext("重度抑郁");
+            }
+          } else if (this.interveneId == 3) {
             this.chatContents.push({
-              index: 0,
               from: 1,
               isScale: false,
-              question: "根据测试,你很健康,无抑郁表现",
+              isType: -1,
+              question: res.data.data.userRecordEntity.testResults,
               from1: HeadImg,
             });
-          } else if (score < 19) {
-            this.getNext("轻度抑郁或有抑郁症状");
-          } else {
-            this.getNext("重度抑郁");
+            this.getQuestion(44);
           }
         }
       });
@@ -349,7 +680,7 @@ export default {
 
     getNext(result) {
       this.$http.get(
-        `chat/getNextQuestionByScaleResult?label=2&result=${result}`,
+        `chat/getNextQuestionByScaleResult?label=${this.interveneId}&result=${result}`,
         {},
         (res) => {
           if (res.code == 200) {
@@ -447,7 +778,6 @@ export default {
 
           this.askQuestions();
         } else {
-          console.log("需要进行选择提");
           this.inputFlag = 2;
           //进行提问
           this.chatContents.push({
@@ -1189,4 +1519,9 @@ export default {
   display: block;
   margin: 10px 0 0 0;
 }
+.send_class {
+  display: flex;
+  flex-direction: row;
+  align-items: center;
+}
 </style>

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

@@ -4,6 +4,7 @@ import SoftKey from '../../main/SoftKey.js'
 import MainTable from '@/components/MainTable'
 import Relax from '@/components/Relax'
 import Smart from '@/components/Smart'
+import Smart1 from '@/components/Smart1'
 import Evaluation from '@/components/Evaluation'
 import Electrical from '@/components/Electrical'
 import Pulse from '@/components/Pulse'
@@ -94,6 +95,11 @@ if (result != '0') {
           name: 'smart',
           component: Smart
         },
+        {
+          path: 'smart1',
+          name: 'smart1',
+          component: Smart1
+        },
         {
           path: 'electrical',
           name: 'electrical',

+ 2 - 2
src/utils/http.js

@@ -4,9 +4,9 @@ import { Decrypt, Encrypt, ContentType } from "./utils";
 import router from "@/router";
 import global from '../../exe/global.js'
 sessionStorage.setItem("baseUrl", global.dev)
-// sessionStorage.setItem("baseUrl", 'http://10.113.248.3:8086/')
+// sessionStorage.setItem("baseUrl", 'http://10.113.248.5:8088/')
 axios.defaults.baseURL = global.dev;
-// axios.defaults.baseURL = 'http://10.113.248.3:8086/';
+// axios.defaults.baseURL = 'http://10.113.248.5:8088/';
 // axios.defaults.baseURL = "/api";
 
 axios.defaults.timeout = 30000; // 超时时间

+ 5 - 4
src/utils/public.css

@@ -170,12 +170,13 @@
 .xl_input .el-input__inner {
     width: 35.4vw;
     line-height: 64px;
-    background: #eaeaea;
-    border-radius: 30px 30px 30px 30px !important;
+    background: #F5F5F5;
+    border-radius: 15px 15px 15px 15px !important;
     opacity: 1;
     box-sizing: border-box;
     font-weight: 400;
-    color: #929292;
+    border:none;
+    /* color: #929292; */
 }
 
 .el-checkbox__input.is-checked .el-checkbox__inner,
@@ -186,7 +187,7 @@
 
 .xl_input .el-range-editor .el-range-input {
     line-height: 1;
-    background-color: #eaeaea;
+    background-color: #F5F5F5;
 }
 
 .select_class_animation /deep/ .el-input__inner {