From b576ba3501304bdbd56771dc7299e0c40e047aa4 Mon Sep 17 00:00:00 2001
From: YM <479443481@qq.com>
Date: 星期六, 11 五月 2024 19:40:04 +0800
Subject: [PATCH] 1

---
 src/pages/inherit/list.vue |  105 ++++++++++++++++++++++++++++++++--------------------
 1 files changed, 65 insertions(+), 40 deletions(-)

diff --git a/src/pages/inherit/list.vue b/src/pages/inherit/list.vue
index 45f0b2d..3d759f3 100644
--- a/src/pages/inherit/list.vue
+++ b/src/pages/inherit/list.vue
@@ -1,5 +1,5 @@
 <template>
-  <view class="">
+  <view>
     <headNav
       idIndex="2"
       :searchBg="false"
@@ -34,7 +34,7 @@
           涓栧尰鏂囧寲
         </li>
       </ul>
-      <view class="" style="width: 1rem"></view>
+      <view style="width: 1rem"></view>
     </view>
     <view v-if="showType == 1" class="legendBox">
       <view class="socialMappingBox" @click="showSocialMapping">
@@ -87,7 +87,6 @@
 <script>
 import * as echarts from "echarts";
 import {
-  inheritMedicalSataStatistics,
   inheritMedicalCultureList,
   inheritMedicalRelationList
 } from "@/api/index.js";
@@ -108,9 +107,12 @@
   onLoad(options) {
     this.idIndex = options.id;
     this.mainName = decodeURIComponent(options.name);
-    console.log("optionsoptionsoptions", options.id);
+    this.type = options.type;
   },
   mounted() {
+    if (this.type) {
+      this.changeType(this.type);
+    }
     this.getData();
   },
   methods: {
@@ -126,22 +128,48 @@
         for (let i = 0; i < data.edgeList.length; i++) {
           const linkItem = data.edgeList[i];
           const index = data.nodeList.findIndex(
-              (item) => item.identifier == linkItem.endId
-            );
+            (item) =>
+              item.identifier ==
+              (linkItem.endId == this.idIndex
+                ? linkItem.startId
+                : linkItem.endId)
+          );
           if (linkItem.relationType == "浜插睘鍏崇郴") {
             data.nodeList[index].linkType = 1;
-            data.nodeList[index].color = "#DCE7EB";
-            data.nodeList[index].borderColor = "#5F81A4";
+            data.nodeList[index].color = "#F8E2D7";
+            data.nodeList[index].borderColor = "#F3AA78";
           }
           if (linkItem.relationType == "绀句細鍏崇郴") {
             data.nodeList[index].linkType = 2;
-            data.nodeList[index].color = "#E1E1E1";
-            data.nodeList[index].borderColor = "#888888";
+            data.nodeList[index].color = "#ecf4fe";
+            data.nodeList[index].borderColor = "#597aa5";
           }
           this.links.push({
-            source: this.mainName,
-            target: data.nodeList[index].name,
-            relationName: linkItem.relation
+            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 = [];
@@ -150,13 +178,22 @@
             ...item,
             itemStyle: {
               color: item.identifier == this.idIndex ? "#F8E2D7" : item.color,
-              borderColor: item.identifier == this.idIndex ? "#F3AA78" : item.borderColor,
+              borderColor:
+                item.identifier == this.idIndex ? "#F3AA78" : item.borderColor,
               borderWidth: "3"
             }
           };
         });
-        console.log(this.dataList,this.links);
-        this.initBarChart();
+        console.log(this.dataList);
+        console.log(this.links);
+        this.initBarChart(this.dataList, this.links);
+      });
+
+      // 涓栧尰鏂囧寲
+      inheritMedicalCultureList({
+        identifier: this.idIndex
+      }).then((res) => {
+        console.log(res, "res");
       });
     },
     showSocialMapping() {
@@ -167,9 +204,7 @@
         newDataList = [...this.dataList];
         newLinks = [...this.links];
       } else {
-        newDataList = this.dataList.filter(
-          (item) => item.itemStyle.borderColor == "#F3AA78"
-        );
+        newDataList = this.dataList.filter((item) => item.color !== "#ecf4fe");
         newLinks = [...this.links];
       }
       this.initBarChart(newDataList, newLinks);
@@ -183,7 +218,7 @@
         }, 50);
       }
     },
-    initBarChart() {
+    initBarChart(dataList, links) {
       // WMBg
       //閫氳繃 $ref 杩涜鎸傝浇
       var barChart = document.getElementById("barChart");
@@ -233,30 +268,20 @@
               color: "black", // 璁剧疆鑺傜偣鏂囧瓧棰滆壊涓洪粦鑹�
               fontSize: FontSize // 璁剧疆鏂囧瓧澶у皬
             },
-            edgeSymbol: ["circle"],
+            edgeSymbol: ["circle", "arrow"],
             edgeSymbolSize: [4, 10],
-
-            edgeLabel: {
-              show: true,
-              fontSize: FontSize, //鏇存敼涓よ�呭叧绯荤殑瀛椾綋
-              position: "middle",
-              //杩欓噷璁剧疆鍏崇郴鏂囧瓧鏄惁鍜岀嚎娈甸噸鍙�
-              //   padding: [0, 0], // 璋冩暣鍐呰竟璺濅互纭繚鏍囩涓庣嚎娈电揣瀵嗚创鍚�
-              // verticalAlign: 'middle', // 璁剧疆鏂囨湰鐨勫瀭鐩村榻愭柟寮忎负灞呬腑
-              formatter: function (params) {
-                // params.data 鏄竟鐨勬暟鎹璞★紝浣犲彲浠ュ湪杩欓噷瀹氫箟鍏崇郴鍚�
-                // 渚嬪锛屼綘鍙互鏍规嵁 source 鍜� target 鐨勫悕绉版潵瀹氫箟鍏崇郴鍚�
-                return params.data.relationName || "鐖跺瓙"; // 濡傛灉瀹氫箟浜� relationName 鍒欐樉绀哄畠锛屽惁鍒欐樉绀衡�滅埗瀛愨��
-              }
-            },
-            //鍚勪釜鑺傜偣
-            data: this.dataList, //鍏崇郴杩炴帴
-            links: this.links,
+            data: dataList,
+            links: links,
             lineStyle: {
-              color: "#000000",
               opacity: 0.9,
               width: 2,
-              curveness: 0
+              curveness: 0.3
+            },
+            emphasis: {
+              focus: "adjacency",
+              lineStyle: {
+                width: 10
+              }
             },
             force: {
               initLayout: null,

--
Gitblit v1.9.1