From c56935d7085725e609d926b064c146f3ffc29e6e Mon Sep 17 00:00:00 2001
From: YM <479443481@qq.com>
Date: 星期四, 06 六月 2024 19:33:48 +0800
Subject: [PATCH] 1

---
 src/pages/inherit/list.vue |  143 +++++++++++++++++++++++------------------------
 1 files changed, 69 insertions(+), 74 deletions(-)

diff --git a/src/pages/inherit/list.vue b/src/pages/inherit/list.vue
index 59f24e5..21130a8 100644
--- a/src/pages/inherit/list.vue
+++ b/src/pages/inherit/list.vue
@@ -132,69 +132,71 @@
         identifier: this.idIndex,
         socialFlag: true
       }).then((res) => {
-        let data = res.object;
+        this.dataList = res.object;
         // 澶勭悊鑺傜偣棰滆壊
-        this.links = [];
-        for (let i = 0; i < data.edgeList.length; i++) {
-          const linkItem = data.edgeList[i];
-          const index = data.nodeList.findIndex(
-            (item) =>
-              item.identifier ==
-              (linkItem.endId == this.idIndex
-                ? linkItem.startId
-                : linkItem.endId)
-          );
-          if (linkItem.relationType == "浜插睘鍏崇郴") {
-            data.nodeList[index].linkType = 1;
-            data.nodeList[index].color = "#F8E2D7";
-            data.nodeList[index].borderColor = "#F3AA78";
-          }
-          if (linkItem.relationType == "绀句細鍏崇郴") {
-            data.nodeList[index].linkType = 2;
-            data.nodeList[index].color = "#ecf4fe";
-            data.nodeList[index].borderColor = "#597aa5";
-          }
-          this.links.push({
-            source: data.nodeList.find(
-              (item) => item.identifier == linkItem.startId
-            ).name,
-            target: data.nodeList.find(
-              (item) => item.identifier == linkItem.endId
-            ).name,
-            relationType: linkItem.relationType,
-            label: {
-              show: true,
-              formatter: function (params) {
-                // 浣跨敤鍑芥暟鍔ㄦ�佺敓鎴愭爣绛惧唴瀹�
-                // return relationships.find(rel => rel.source === nodes[params.data
-                // 		.source] && rel.target === nodes[params.data.target])
-                // 	.relation;
-                return linkItem.relation;
-              }, // 璁剧疆鍏崇郴鏍囩鍐呭涓�"Child-Parent"
-              color: "#2C2C2C",
-              fontSize: 16,
-              backgroundColor: "rgba(255, 255, 255, 1)",
-              padding: [3, 8],
-              borderRadius: 30,
-              position: "middle", // 璁剧疆鏍囩鏂囨湰鍦ㄧ嚎鐨勪腑闂翠綅缃笂灞呬腑鏄剧ず
-              // z: -1, // 璁剧疆鏍囩鐨剒杞撮珮搴︼紝浣垮叾姣旇繛鎺ョ嚎鏇撮珮
-              distance: -10 // 灏嗘爣绛炬斁缃湪杩炴帴绾夸笂
-            }
-          });
-        }
-        this.dataList = [];
-        this.dataList = data.nodeList.map((item) => {
-          return {
-            ...item,
-            itemStyle: {
-              color: item.identifier == this.idIndex ? "#F8E2D7" : item.color,
-              borderColor:
-                item.identifier == this.idIndex ? "#F3AA78" : item.borderColor,
-              borderWidth: "3"
-            }
-          };
-        });
-        this.initBarChart(this.dataList, this.links);
+        // this.links = [];
+        // for (let i = 0; i < data.edgeList.length; i++) {
+        //   const linkItem = data.edgeList[i];
+        //   const index = data.nodeList.findIndex(
+        //     (item) =>
+        //       item.identifier ==
+        //       (linkItem.endId == this.idIndex
+        //         ? linkItem.startId
+        //         : linkItem.endId)
+        //   );
+        //   if (linkItem.relationType == "浜插睘鍏崇郴") {
+        //     data.nodeList[index].linkType = 1;
+        //     data.nodeList[index].color = "#F8E2D7";
+        //     data.nodeList[index].borderColor = "#F3AA78";
+        //   }
+        //   if (linkItem.relationType == "绀句細鍏崇郴") {
+        //     data.nodeList[index].linkType = 2;
+        //     data.nodeList[index].color = "#ecf4fe";
+        //     data.nodeList[index].borderColor = "#597aa5";
+        //   }
+        //   this.links.push({
+        //     source: data.nodeList.find(
+        //       (item) => item.identifier == linkItem.startId
+        //     ).name,
+        //     target: data.nodeList.find(
+        //       (item) => item.identifier == linkItem.endId
+        //     ).name,
+        //     relationType: linkItem.relationType,
+        //     label: {
+        //       show: true,
+        //       formatter: function (params) {
+        //         // 浣跨敤鍑芥暟鍔ㄦ�佺敓鎴愭爣绛惧唴瀹�
+        //         // return relationships.find(rel => rel.source === nodes[params.data
+        //         // 		.source] && rel.target === nodes[params.data.target])
+        //         // 	.relation;
+        //         return linkItem.relation;
+        //       }, // 璁剧疆鍏崇郴鏍囩鍐呭涓�"Child-Parent"
+        //       color: "#2C2C2C",
+        //       fontSize: 16,
+        //       backgroundColor: "rgba(255, 255, 255, 1)",
+        //       padding: [3, 8],
+        //       borderRadius: 30,
+        //       position: "middle", // 璁剧疆鏍囩鏂囨湰鍦ㄧ嚎鐨勪腑闂翠綅缃笂灞呬腑鏄剧ず
+        //       // z: -1, // 璁剧疆鏍囩鐨剒杞撮珮搴︼紝浣垮叾姣旇繛鎺ョ嚎鏇撮珮
+        //       distance: -10 // 灏嗘爣绛炬斁缃湪杩炴帴绾夸笂
+        //     }
+        //   });
+        // }
+        // this.dataList = data.nodeList.map((item) => {
+        //   return {
+        //     ...item,
+        //     itemStyle: {
+        //       color: item.identifier == this.idIndex ? "#F8E2D7" : item.color,
+        //       borderColor:
+        //         item.identifier == this.idIndex ? "#F3AA78" : item.borderColor,
+        //       borderWidth: "3"
+        //     }
+        //   };
+        // });
+        setTimeout(() => {
+          this.initBarChart();
+        }, 50);
+        
       });
 
       // 涓栧尰鏂囧寲
@@ -228,7 +230,7 @@
         }, 50);
       }
     },
-    initBarChart(dataList, links) {
+    initBarChart() {
       // WMBg
       //閫氳繃 $ref 杩涜鎸傝浇
       var barChart = document.getElementById("barChart");
@@ -268,8 +270,7 @@
         animationEasingUpdate: "quinticInOut",
         series: [
           {
-            type: "graph",
-            layout: "force",
+            type: "tree",
             symbolSize: SymbolSize + 20,
             //鏄惁鍏佽鐢ㄦ埛鎷栧姩鍥剧墖
             roam: true,
@@ -280,25 +281,19 @@
             },
             edgeSymbol: ["circle", "arrow"],
             edgeSymbolSize: [4, 10],
-            data: dataList,
-            links: links,
+            data: [this.dataList],
             lineStyle: {
               opacity: 0.9,
               width: 2,
               curveness: 0.3
-            },
-            emphasis: {
-              focus: "adjacency",
-              lineStyle: {
-                width: 10
-              }
             },
             force: {
               initLayout: null,
               // gravity: 0
               repulsion: 600,
               edgeLength: 400
-            }
+            },
+            expandAndCollapse: false,
           }
         ]
       };

--
Gitblit v1.9.1