From a10960e9cee3776ffd3871e5949f6b474127c428 Mon Sep 17 00:00:00 2001
From: YM <479443481@qq.com>
Date: 星期一, 17 六月 2024 18:55:58 +0800
Subject: [PATCH] 1

---
 src/pages/academicGenres/chart.vue |  122 +++++++++++++++++++++++++++-------------
 src/api/index.js                   |    9 +++
 2 files changed, 91 insertions(+), 40 deletions(-)

diff --git a/src/api/index.js b/src/api/index.js
index 746dfe9..0aa8942 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -287,6 +287,15 @@
   });
 };
 
+export const schoolAtlas = (id) => {
+  return req1({
+    url: "/person/schoolAtlas?schoolId=" + id,
+    method: "post"
+  });
+};
+
+ 
+
 export const searchSchoolPerson = (data) => {
   return req1({
     url: "/person/searchSchoolPerson",
diff --git a/src/pages/academicGenres/chart.vue b/src/pages/academicGenres/chart.vue
index a617464..429f1ee 100644
--- a/src/pages/academicGenres/chart.vue
+++ b/src/pages/academicGenres/chart.vue
@@ -65,23 +65,32 @@
         </li>
       </ul>
     </view>
-    <view class="contentBox" style="position: relative;">
+    <view class="contentBox" style="position: relative">
       <div
-          v-if="nodeData.length == 0"
-          style="color: #666; text-align: center; font-size: 16px; position: absolute;top: 1rem;left: 0;right: 0;"
-        >
-          鏆傛棤鏁版嵁
-        </div>
-      <view id="main" style="width: 100%; height: 100%">
-        
-      </view>
-
+        v-if="nodeData.length == 0"
+        style="
+          color: #666;
+          text-align: center;
+          font-size: 16px;
+          position: absolute;
+          top: 1rem;
+          left: 0;
+          right: 0;
+        "
+      >
+        鏆傛棤鏁版嵁
+      </div>
+      <view id="main" style="width: 100%; height: 100%"> </view>
     </view>
   </view>
 </template>
 
 <script>
-import { getIntroduction, searchSchoolPerson } from "@/api/index.js";
+import {
+  getIntroduction,
+  searchSchoolPerson,
+  schoolAtlas
+} from "@/api/index.js";
 import * as echarts from "echarts";
 export default {
   data() {
@@ -229,34 +238,57 @@
           },
           symbolSize: 100
         });
-        searchSchoolPerson({
-          keyword: item
-        }).then((res) => {
+        schoolAtlas(Number(this.idIndex)).then((res) => {
           if (res.list) {
             for (let i = 0; i < res.list.length; i++) {
               const citem = res.list[i];
-              // 鑺傜偣
-              this.nodeData.push({
-                name: citem.name2,
-                x: Math.random() * 1000,
-                y: Math.random() * 600,
-                itemStyle: {
-                  color: citem.relationType == "浜虹墿钁椾綔" ? "#eee" : "#FDEFE4",
-                  borderWidth: 4,
-                  borderColor:
-                    citem.relationType == "浜虹墿钁椾綔" ? "#9e9e9e" : "#DA7A2B",
-                  borderRadius: 30
-                },
-                symbolSize: 100
-              });
-              // 鍏崇郴
-              this.links.push({
-                source: item,
-                target: citem.name2,
-                label: {
-                  show: false
+              if (
+                citem.relationType != "浠h〃浜虹墿" &&
+                citem.relationType != "浜虹墿鍏崇郴"
+              ) {
+                // 鑺傜偣
+                if (citem.name1) {
+                  this.nodeData.push({
+                    name: citem.name1,
+                    x: Math.random() * 1000,
+                    y: Math.random() * 600,
+                    itemStyle: {
+                      color:
+                        citem.relationType == "鍏崇郴鏂囩尞" ? "#eee" : "#FDEFE4",
+                      borderWidth: 4,
+                      borderColor:
+                        citem.relationType == "鍏崇郴鏂囩尞"
+                          ? "#9e9e9e"
+                          : "#DA7A2B",
+                      borderRadius: 30
+                    },
+                    symbolSize: 100
+                  });
+                  // 鍏崇郴
+                  this.links.push({
+                    source: item,
+                    target: citem.name1,
+                    label: {
+                      show: true,
+                      formatter: function (params) {
+                        // 浣跨敤鍑芥暟鍔ㄦ�佺敓鎴愭爣绛惧唴瀹�
+                        // return relationships.find(rel => rel.source === nodes[params.data
+                        // 		.source] && rel.target === nodes[params.data.target])
+                        // 	.relation;
+                        return citem.name2;
+                      }, // 璁剧疆鍏崇郴鏍囩鍐呭涓�"Child-Parent"
+                      color: "#2C2C2C",
+                      fontSize: 14,
+                      backgroundColor: "rgba(255, 255, 255, 1)",
+                      padding: [3, 8],
+                      borderRadius: 30,
+                      position: "middle", // 璁剧疆鏍囩鏂囨湰鍦ㄧ嚎鐨勪腑闂翠綅缃笂灞呬腑鏄剧ず
+                      // z: -1, // 璁剧疆鏍囩鐨剒杞撮珮搴︼紝浣垮叾姣旇繛鎺ョ嚎鏇撮珮
+                      distance: -10 // 灏嗘爣绛炬斁缃湪杩炴帴绾夸笂
+                    }
+                  });
                 }
-              });
+              }
             }
           }
           this.init();
@@ -295,7 +327,8 @@
         series: [
           {
             type: "graph",
-            layout: "none",
+            layout: "force",
+            roam: true,
             symbolSize: SymbolSize + 20,
             //鏄惁鍏佽鐢ㄦ埛鎷栧姩鍥剧墖
             roam: true,
@@ -306,7 +339,12 @@
             },
             edgeSymbol: ["circle", "arrow"],
             edgeSymbolSize: [4, 10],
-
+            emphasis: {
+              focus: "adjacency",
+              lineStyle: {
+                width: 10
+              }
+            },
             edgeLabel: {
               show: true,
               fontSize: FontSize, //鏇存敼涓よ�呭叧绯荤殑瀛椾綋
@@ -324,10 +362,14 @@
             data: this.nodeData, //鍏崇郴杩炴帴
             links: this.links,
             lineStyle: {
-              color: "#000000",
               opacity: 0.9,
-              width: 2,
-              curveness: 0
+              width: 2
+            },
+            force: {
+              // layoutAnimation: false,
+              // friction: 1,
+              repulsion: 800,
+              edgeLength: 400
             }
           }
         ]

--
Gitblit v1.9.1