From f41e347a34d2859c149c59691bda6d179b209d44 Mon Sep 17 00:00:00 2001
From: yxl <584911253@qq.com>
Date: 星期三, 22 一月 2025 17:42:53 +0800
Subject: [PATCH] 最新修改

---
 src/views/chartView/index.vue |  131 ++++++++++++++++++++++++++++++++++++-------
 1 files changed, 109 insertions(+), 22 deletions(-)

diff --git a/src/views/chartView/index.vue b/src/views/chartView/index.vue
index 95beaf3..5d12549 100644
--- a/src/views/chartView/index.vue
+++ b/src/views/chartView/index.vue
@@ -131,7 +131,10 @@
         // console.log('Received message:', event.data);
         console.log(event);
 
-        if (event.data != "杩炴帴鎴愬姛" || event.data != "鏀跺埌娑堟伅锛屾秷鎭唴瀹癸細蹇冭烦鍖呮娴�") {
+        if (
+          event.data != "杩炴帴鎴愬姛" ||
+          event.data.indexOf("鏀跺埌娑堟伅锛屾秷鎭唴瀹癸細蹇冭烦鍖呮娴�") <= 0
+        ) {
           console.log(event.data);
           const val = JSON.parse(event.data);
           if (val.session_id == this.uuid) {
@@ -240,14 +243,12 @@
           0.001313831409284339,
           2
         );
-      } else {
-        //鍏抽棴鍦板浘
-        // this.$store.state.setScreenFlag = false;
       }
       mapImg.removeInit();
       mapSetFunc.removeAll();
       this.$store.state.setListColor = [];
       this.$store.state.showLenged = false;
+      this.$store.state.showRelationBox = false;
 
       // const formData = new FormData();
       // formData.append("message", res);
@@ -296,7 +297,7 @@
 
           const type = response.type;
           //鏅�氬璇濅俊鎭煡璇�
-          if (type == "message") {
+          if (type == "message" || type == "Rag") {
             //鍏抽棴鍦板浘
             if (!this.closeMap) {
               this.$store.state.setScreenFlag = false;
@@ -304,7 +305,7 @@
             var rolMsg = [
               {
                 type: "text",
-                val: response.msg,
+                val: type == "Rag" ? response.content : response.msg,
               },
             ];
             this.refashMsg(rolMsg);
@@ -315,13 +316,6 @@
             this.$store.state.setScreenFlag = true;
             this.setMapfunc(response.content, obj);
           }
-          // if (type == "Map") {
-          //   this.setMapfunc(response.content, obj);
-          // } else if (type == "Rag") {
-          //   this.setMapRag(response, obj);
-          // } else {
-          //   // this.setMapfunc(response.content, obj);
-          // }
         })
         .catch((error) => {
           var rolMsg = [
@@ -346,7 +340,6 @@
           } else {
             roleMsg = msgData.getAffairsData([{ type: "text", val: res.msg }]);
           }
-
           this.refashMsg(roleMsg.list);
           break;
         case "queryMeta":
@@ -389,7 +382,6 @@
           var roleMsg = msgData.getAffairsData([
             { type: "text", val: "鍦板浘宸叉樉绀�" },
           ]);
-          console.log("roleMsg----", roleMsg);
           this.refashMsg(roleMsg.list);
           break;
         case "aroundPoi":
@@ -504,13 +496,38 @@
           this.setUpdateHistoryInFor(obj, res.msg);
           this.refashMsg(roleMsg.list);
           break;
-        // default:
-        //   this.setUpdateHistoryInFor(obj, res.msg);
-        //   var roleMsg1 = msgData.getAffairsData([
-        //     { type: "text", val: res.msg },
-        //   ]);
-        //   this.refashMsg(roleMsg1.list);
-        //   break;
+        case "attackentity":
+          mapSetFunc.init(res);
+          this.setUpdateHistoryInFor(obj, res.msg);
+          if (res.data.length === 1) {
+            var roleMsg = msgData.getAffairsData([
+              { type: "text", val: res.data[0].targetinfo },
+            ]);
+            this.refashMsg(roleMsg.list);
+          } else {
+            const markData = res.data
+              .map((item) => `| ${item.name} | ${item.targetinfo} |`)
+              .join("\n");
+            let markAttr = `| 鍚嶇О | 灞炴�т俊鎭� |\n|------|------|\n` + markData;
+            var roleMsg = msgData.getMdData("markdown", markAttr);
+            this.refashMsg(roleMsg.list);
+          }
+          break;
+        case "getRelatedEntity":
+          this.setUpdateHistoryInFor(obj, res.msg);
+          this.handleRelationData(res.data);
+          var roleMsg = msgData.getAffairsData([
+            { type: "text", val: "椤甸潰宸叉樉绀�" },
+          ]);
+          this.refashMsg(roleMsg.list);
+          break;
+        default:
+          this.setUpdateHistoryInFor(obj, res.msg);
+          var roleMsg1 = msgData.getAffairsData([
+            { type: "text", val: res.msg },
+          ]);
+          this.refashMsg(roleMsg1.list);
+          break;
       }
     },
     setUpdateHistoryInFor(obj, message) {
@@ -575,6 +592,76 @@
       this.loading = false;
       this.list[this.list.length - 1].list = res;
     },
+    //鍏崇郴鏁版嵁澶勭悊
+    handleRelationData(data) {
+      // 鍑嗗鑺傜偣鍜岃竟
+      let graphData = [];
+      let links = [];
+      // 澶勭悊涓荤被鍨�(mainType)
+      Object.keys(data.mainType).forEach((main) => {
+        graphData.push({
+          name: main,
+          category: "mainType",
+          symbolSize: 70,
+          itemStyle: {
+            color: "#4169E1",
+          },
+        });
+
+        data.mainType[main].forEach((sec) => {
+          graphData.push({
+            name: sec,
+            category: "secType",
+            symbolSize: 60,
+            itemStyle: {
+              color: "#87CEFA",
+            },
+          });
+
+          // 澶勭悊瀛愮被鍨�(secType)
+          if (data.secType[sec]) {
+            data.secType[sec].forEach((sub) => {
+              graphData.push({
+                name: sub,
+                category: "subType",
+                symbolSize: 50,
+                itemStyle: {
+                  color: "#30ECA6",
+                },
+              });
+
+              // 澶勭悊鍏蜂綋椤�(subtype)
+              if (data.subtype[sub]) {
+                data.subtype[sub].forEach((item) => {
+                  graphData.push({
+                    name: item.name,
+                    category: "subTypeItem",
+                    symbolSize: 50,
+                    itemStyle: {
+                      color: "#00BFFF",
+                    },
+                    uuid: item.uuid,
+                    lontitude: item.lontitude,
+                    lattitude: item.lattitude,
+                  });
+                  links.push({ source: sub, target: item.name });
+                });
+              }
+              // 鐖跺瓙鑺傜偣杩炴帴
+              links.push({ source: sec, target: sub });
+            });
+          }
+          // 鐖跺瓙鑺傜偣杩炴帴
+          links.push({ source: main, target: sec });
+        });
+      });
+      console.log("nodes---", graphData, "links---", links);
+      this.$store.state.showRelationBox = true;
+      this.$store.state.relationData = {
+        nodes: graphData,
+        links: links,
+      };
+    },
   },
 };
 </script>

--
Gitblit v1.9.3