Ver código fonte

智慧选址

maxiaoxiao 11 meses atrás
pai
commit
a0d9c84746
2 arquivos alterados com 78 adições e 44 exclusões
  1. 67 37
      src/views/aiModel/index.vue
  2. 11 7
      src/views/siteselection/index.vue

+ 67 - 37
src/views/aiModel/index.vue

@@ -17,6 +17,12 @@
       <div v-for="(item, index) in questionList" :key="index">
         <!--右侧-->
         <div class="counsel-right flex" v-if="item.type == 0">
+          <i class="el-icon-loading" v-if="item.status == 0"></i>
+          <i
+            class="el-icon-warning cursor"
+            v-else-if="item.status == 1"
+            @click="sendToBackend(item.content, index)"
+          ></i>
           <div class="content">
             <span>{{ item.content }}</span>
           </div>
@@ -44,7 +50,12 @@
       <div class="noise"></div>
     </div>
     <div class="searchBtom">
-      <i class="el-icon-microphone icon" title="按住说话" @click="voice"></i>
+      <div
+        class="el-icon-microphone icon"
+        title="按住说话"
+        :disabled="spdisabled"
+        @click="voice"
+      ></div>
       <el-input
         clearable
         v-model="sendContent"
@@ -68,7 +79,7 @@ export default {
   props: {},
   data() {
     return {
-      questionList: [],
+      questionList: [{ type: 0, content: "aaa" }],
       defaultMsg:
         "我要进行选址,选择居住用地,距离幼儿园200米,距离医院300米,远离火葬场5000米",
       sendContent: "",
@@ -98,7 +109,7 @@ export default {
         };
         recognition.onresult = (event) => {
           this.sendContent = event.results[0][0].transcript;
-          this.sendToBackend(); // 将识别结果发送到后台
+          this.send(); // 将识别结果发送到后台
         };
         recognition.onerror = (event) => {
           this.$message.warning("语音识别出错: " + event.error);
@@ -117,18 +128,24 @@ export default {
     send() {
       // 咨询问题
       if (this.sendContent) {
-        this.questionList.push({ type: 0, content: this.sendContent });
-        this.sendToBackend(this.sendContent);
+        this.questionList.push({
+          type: 0,
+          content: this.sendContent,
+          status: 0,
+        });
+        this.sendToBackend(this.sendContent, this.questionList.length - 1);
         this.sendContent = "";
       }
     },
     voice() {
+      console.log("---this.spdisabled-", this.spdisabled);
       if (!this.spdisabled) {
         if (!recognition) this.initSpeech();
         recognition.start(); // 开始语音识别
       }
     },
-    sendToBackend(msg) {
+    sendToBackend(msg, mindex) {
+      this.questionList[mindex].status = 0;
       axios({
         method: "POST",
         url: `${window.aiURI}/msg`,
@@ -136,38 +153,45 @@ export default {
         headers: {
           "Content-Type": "application/json",
         },
-      }).then((mres) => {
-        if (mres.status == 200) {
-          if (mres.data.type == "selectLand") {
-            this.questionList.push({ content: "分析中...请稍等" });
-            const loading = this.$loading({
-              lock: true,
-              text: "分析中",
-              spinner: "el-icon-loading",
-              background: "rgba(0, 0, 0, 0.7)",
-            });
-            AddFzxz(mres.data.data)
-              .then((res) => {
-                loading.close();
-                this.questionList.push({
-                  type: mres.data.type,
-                  content: "查看智能选址结果",
-                  data: res.data,
-                });
-                this.$message({
-                  message: res.message,
-                  type: res.success ? "success" : "warning",
-                });
-              })
-              .catch((error) => {
-                loading.close();
-                this.$message.error(error);
+      })
+        .then((mres) => {
+          if (mres.status == 200) {
+            this.questionList[mindex].status = 2;
+            if (mres.data.type == "selectLand") {
+              this.questionList.push({ content: "分析中...请稍等" });
+              const loading = this.$loading({
+                lock: true,
+                text: "分析中",
+                spinner: "el-icon-loading",
+                background: "rgba(0, 0, 0, 0.7)",
               });
+              AddFzxz(mres.data.data)
+                .then((res) => {
+                  loading.close();
+                  this.questionList.push({
+                    type: mres.data.type,
+                    content: "查看智能选址结果",
+                    data: res.data,
+                  });
+                  this.$message({
+                    message: res.message,
+                    type: res.success ? "success" : "warning",
+                  });
+                })
+                .catch((error) => {
+                  loading.close();
+                  this.$message.error(error);
+                });
+            }
+          } else {
+            this.questionList[mindex].status = 1;
+            // this.$message.error("发送到后台时发生错误:");
           }
-        } else {
-          this.$message.error("发送到后台时发生错误:");
-        }
-      });
+        })
+        .catch(() => {
+          this.questionList[mindex].status = 1;
+          // this.$message.error("发送到后台时发生错误:");
+        });
     },
     onClick(item) {
       if (item.type == "selectLand") {
@@ -235,9 +259,12 @@ export default {
       cursor: pointer;
       display: block;
     }
+    .cursor {
+      cursor: pointer;
+    }
     .content {
       // flex: 1;
-      margin-left: 20px;
+      margin-left: 10px;
       max-width: calc(100% - 100px);
       padding: 5px 20px;
       border-radius: 8px;
@@ -266,6 +293,9 @@ export default {
       justify-content: flex-end;
       align-items: flex-start;
       width: 100%;
+      i {
+        font-size: 20px;
+      }
     }
   }
 }

+ 11 - 7
src/views/siteselection/index.vue

@@ -78,14 +78,12 @@ export default {
     };
   },
   created() {},
-  mounted() {
-    console.log("-----",this.$route.query)
-    // http://192.168.60.66:8080/siteselection?finalTable=temporary_1724917081014_f2d0835a22134486afbf96f29a9f49bb&rwbsm=0914edc2818a4661856a59c7c53555a2
-    if (this.$route.query) {
-      this.rwBsm = this.$route.query.rwbsm;
-      this.activeTabs = "xzjg";
-    }
+  computed: {
+    query() {
+      return this.$route.query.rwbsm;
+    },
   },
+  mounted() {},
   methods: {
     changeData(name, updata) {
       this[name] = updata;
@@ -104,6 +102,12 @@ export default {
         this.$refs.lsju.changeForm();
       }
     },
+    query(newVal, oldVal) {
+      if (newVal) {
+        this.rwBsm = newVal;
+        this.activeTabs = "xzjg";
+      }
+    },
   },
 };
 </script>