YM
2024-04-30 f4c14c24cb6cf1ed1c09cab760f6b9c8381df557
src/pages/inherit/list.vue
@@ -1,7 +1,7 @@
<template>
  <view class="">
    <headNav
      :idIndex="idIndex"
      idIndex="2"
      :searchBg="false"
      text="中医世医传承数据库"
      bg="/static/image/topBg1.png"
@@ -17,7 +17,7 @@
          >返回</el-button
        >
        <h3 style="margin-left: 0.22rem; font-size: 0.28erm; font-weight: 500">
          邵登瀛
          {{ mainName }}
        </h3>
      </view>
      <ul class="flex tabBox">
@@ -86,515 +86,79 @@
</template>
<script>
import * as echarts from "echarts";
import {
  inheritMedicalSataStatistics,
  inheritMedicalCultureList,
  inheritMedicalRelationList
} from "@/api/index.js";
export default {
  data() {
    return {
      // 标题顶部栏需要的东西
      idIndex: 0,
      mainName: "",
      activeIndex: 1,
      dataList: [
        {
          name: "薛雪",
          x: 300,
          y: 300,
          itemStyle: {
            color: "#F8E2D7",
            borderColor: "#F3AA78",
            borderWidth: "3"
          }
        },
        {
          name: "邵登瀛",
          x: 400,
          y: 300,
          itemStyle: {
            color: "#F8E2D7",
            borderColor: "#F3AA78",
            borderWidth: "3"
          }
        },
        {
          name: "邵鲁瞻",
          x: 500,
          y: 300,
          itemStyle: {
            color: "#F8E2D7",
            borderColor: "#F3AA78",
            borderWidth: "3"
          }
        },
        {
          name: "邵春泉",
          x: 600,
          y: 300,
          itemStyle: {
            color: "#F8E2D7",
            borderColor: "#F3AA78",
            borderWidth: "3"
          }
        },
        {
          name: "徐锦",
          x: 650,
          y: 400,
          itemStyle: {
            color: "#DCE7EB",
            borderColor: "#5F81A4",
            borderWidth: "3"
          }
        },
        {
          name: "邵丙扬",
          x: 700,
          y: 300,
          itemStyle: {
            color: "#F8E2D7",
            borderColor: "#F3AA78",
            borderWidth: "3"
          }
        },
        {
          name: "冯桂芬",
          x: 720,
          y: 400,
          itemStyle: {
            color: "#DCE7EB",
            borderColor: "#5F81A4",
            borderWidth: "3"
          }
        },
        {
          name: "李鸿章",
          x: 740,
          y: 500,
          itemStyle: {
            color: "#E1E1E1",
            borderColor: "#888888",
            borderWidth: "3"
          }
        },
        {
          name: "邵景尧",
          x: 800,
          y: 200,
          itemStyle: {
            color: "#F8E2D7",
            borderColor: "#F3AA78",
            borderWidth: "3"
          }
        },
        {
          name: "邵景康",
          x: 800,
          y: 400,
          itemStyle: {
            color: "#F8E2D7",
            borderColor: "#F3AA78",
            borderWidth: "3"
          }
        },
        {
          name: "鲍昇",
          x: 750,
          y: 100,
          itemStyle: {
            color: "#DCE7EB",
            borderColor: "#5F81A4",
            borderWidth: "3"
          }
        },
        {
          name: "文龙",
          x: 850,
          y: 100,
          itemStyle: {
            color: "#DCE7EB",
            borderColor: "#5F81A4",
            borderWidth: "3"
          }
        },
        {
          name: "傅庆贻",
          x: 950,
          y: 50,
          itemStyle: {
            color: "#DCE7EB",
            borderColor: "#5F81A4",
            borderWidth: "3"
          }
        },
        {
          name: "成允",
          x: 950,
          y: 100,
          itemStyle: {
            color: "#DCE7EB",
            borderColor: "#5F81A4",
            borderWidth: "3"
          }
        },
        {
          name: "胡玉坦",
          x: 950,
          y: 150,
          itemStyle: {
            color: "#DCE7EB",
            borderColor: "#5F81A4",
            borderWidth: "3"
          }
        },
        {
          name: "裕禄",
          x: 950,
          y: 200,
          itemStyle: {
            color: "#DCE7EB",
            borderColor: "#5F81A4",
            borderWidth: "3"
          }
        },
        {
          name: "陆乃昔",
          x: 950,
          y: 250,
          itemStyle: {
            color: "#DCE7EB",
            borderColor: "#5F81A4",
            borderWidth: "3"
          }
        },
        {
          name: "刘传祺",
          x: 950,
          y: 300,
          itemStyle: {
            color: "#DCE7EB",
            borderColor: "#5F81A4",
            borderWidth: "3"
          }
        },
        {
          name: "邵诚",
          x: 950,
          y: 350,
          itemStyle: {
            color: "#DCE7EB",
            borderColor: "#5F81A4",
            borderWidth: "3"
          }
        },
        {
          name: "曾国藩",
          x: 1050,
          y: 200,
          itemStyle: {
            color: "#E1E1E1",
            borderColor: "#888888",
            borderWidth: "3"
          }
        },
        {
          name: "曾国藩01",
          x: 1050,
          y: 50,
          itemStyle: {
            color: "#E1E1E1",
            borderColor: "#888888",
            borderWidth: "3"
          }
        },
        {
          name: "曾国藩02",
          x: 1050,
          y: 350,
          itemStyle: {
            color: "#E1E1E1",
            borderColor: "#888888",
            borderWidth: "3"
          }
        }
      ],
      links: [
        {
          source: "薛雪",
          target: "邵登瀛",
          relationName: "师徒",
          hasArrow: "true"
        },
        {
          source: "邵登瀛",
          target: "邵鲁瞻",
          relationName: "父子"
        },
        {
          source: "邵鲁瞻",
          target: "邵春泉",
          relationName: "父子"
        },
        {
          source: "邵春泉",
          target: "邵丙扬",
          relationName: "叔侄"
        },
        //曲线
        {
          source: "邵春泉",
          target: "徐锦",
          relationName: "朋友",
          //这里设置为不带箭头
          symbol: ["none", "none"],
          lineStyle: {
            color: "#6584B1",
            curveness: -0.2
          }
        },
        {
          source: "邵丙扬",
          target: "邵景尧",
          relationName: "父子"
        },
        {
          source: "邵丙扬",
          target: "邵景康",
          relationName: "父子"
        },
        //曲线
        {
          source: "邵丙扬",
          target: "冯桂芬",
          relationName: "朋友",
          symbol: ["none", "none"],
          lineStyle: {
            color: "#6584B1",
            curveness: -0.2
          }
        },
        //曲线
        {
          source: "邵丙扬",
          target: "鲍昇",
          relationName: "师徒",
          symbol: ["none", "none"],
          lineStyle: {
            color: "#6584B1",
            curveness: 0.2
          }
        },
        //曲线
        {
          source: "冯桂芬",
          target: "李鸿章",
          relationName: "同僚",
          symbol: ["none", "none"],
          lineStyle: {
            color: "#6584B1",
            curveness: -0.2
          }
        },
        {
          source: "邵景尧",
          target: "邵景康",
          relationName: "兄弟"
        },
        {
          source: "邵景康",
          target: "邵景尧",
          relationName: "兄弟"
        },
        {
          source: "邵景尧",
          target: "鲍昇",
          relationName: "姻亲",
          symbol: ["none", "none"],
          lineStyle: {
            color: "#6584B1",
            curveness: -0.2
          }
        },
        {
          source: "邵景尧",
          target: "文龙",
          relationName: "朋友",
          symbol: ["none", "none"],
          lineStyle: {
            color: "#6584B1",
            curveness: 0.2
          }
        },
        {
          source: "邵景尧",
          target: "傅庆贻",
          relationName: "同僚",
          symbol: ["none", "none"],
          lineStyle: {
            color: "#6584B1",
            curveness: -0.1
          }
        },
        {
          source: "邵景尧",
          target: "成允",
          relationName: "同僚",
          symbol: ["none", "none"],
          lineStyle: {
            color: "#6584B1",
            curveness: -0.2
          }
        },
        {
          source: "邵景尧",
          target: "胡玉坦",
          relationName: "同僚",
          symbol: ["none", "none"],
          lineStyle: {
            color: "#6584B1",
            curveness: -0.2
          }
        },
        {
          source: "邵景尧",
          target: "裕禄",
          relationName: "同僚",
          symbol: ["none", "none"],
          lineStyle: {
            color: "#6584B1",
            curveness: -0.2
          }
        },
        {
          source: "邵景尧",
          target: "陆乃昔",
          relationName: "同僚",
          symbol: ["none", "none"],
          lineStyle: {
            color: "#6584B1",
            curveness: -0.2
          }
        },
        {
          source: "邵景尧",
          target: "刘传祺",
          relationName: "同僚",
          symbol: ["none", "none"],
          lineStyle: {
            color: "#6584B1",
            curveness: -0.2
          }
        },
        {
          source: "邵景尧",
          target: "邵诚",
          relationName: "同僚",
          symbol: ["none", "none"],
          lineStyle: {
            color: "#6584B1",
            curveness: -0.2
          }
        },
        {
          source: "成允",
          target: "曾国藩",
          relationName: "同僚",
          symbol: ["none", "none"],
          lineStyle: {
            color: "#6584B1"
          }
        },
        {
          source: "胡玉坦",
          target: "曾国藩",
          relationName: "同僚",
          symbol: ["none", "none"],
          lineStyle: {
            color: "#6584B1"
          }
        },
        {
          source: "裕禄",
          target: "曾国藩",
          relationName: "同僚",
          symbol: ["none", "none"],
          lineStyle: {
            color: "#6584B1"
          }
        },
        {
          source: "陆乃昔",
          target: "曾国藩",
          relationName: "同僚",
          symbol: ["none", "none"],
          lineStyle: {
            color: "#6584B1"
          }
        },
        {
          source: "刘传祺",
          target: "曾国藩",
          relationName: "同僚",
          symbol: ["none", "none"],
          lineStyle: {
            color: "#6584B1"
          }
        },
        {
          source: "成允",
          target: "曾国藩",
          relationName: "同僚",
          symbol: ["none", "none"],
          lineStyle: {
            color: "#6584B1"
          }
        },
        {
          source: "成允",
          target: "曾国藩",
          relationName: "同僚",
          symbol: ["none", "none"],
          lineStyle: {
            color: "#6584B1"
          }
        },
        {
          source: "成允",
          target: "曾国藩",
          relationName: "同僚",
          symbol: ["none", "none"],
          lineStyle: {
            color: "#6584B1"
          }
        },
        {
          source: "傅庆贻",
          target: "曾国藩01",
          relationName: "同僚",
          symbol: ["none", "none"],
          lineStyle: {
            color: "#6584B1"
          }
        },
        {
          source: "邵诚",
          target: "曾国藩02",
          relationName: "同僚",
          symbol: ["none", "none"],
          lineStyle: {
            color: "#6584B1"
          }
        }
      ],
      dataList: [],
      links: [],
      socialMapping: true,
      showType: "1"
    };
  },
  onLoad(options) {
    this.idIndex = options.id;
    this.mainName = decodeURIComponent(options.name);
    console.log("optionsoptionsoptions", options.id);
  },
  mounted() {
    // 初始化 echarts
    this.initBarChart(this.dataList, this.links);
    this.getData();
  },
  methods: {
    getData() {
      inheritMedicalRelationList({
        identifier: this.idIndex,
        socialFlag: true
      }).then((res) => {
        console.log(res);
        let data = 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
            );
          if (linkItem.relationType == "亲属关系") {
            data.nodeList[index].linkType = 1;
            data.nodeList[index].color = "#DCE7EB";
            data.nodeList[index].borderColor = "#5F81A4";
          }
          if (linkItem.relationType == "社会关系") {
            data.nodeList[index].linkType = 2;
            data.nodeList[index].color = "#E1E1E1";
            data.nodeList[index].borderColor = "#888888";
          }
          this.links.push({
            source: this.mainName,
            target: data.nodeList[index].name,
            relationName: linkItem.relation
          });
        }
        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"
            }
          };
        });
        console.log(this.dataList,this.links);
        this.initBarChart();
      });
    },
    showSocialMapping() {
      this.socialMapping = !this.socialMapping;
      let newDataList = [];
@@ -619,7 +183,7 @@
        }, 50);
      }
    },
    initBarChart(dataList, links) {
    initBarChart() {
      // WMBg
      //通过 $ref 进行挂载
      var barChart = document.getElementById("barChart");
@@ -648,9 +212,6 @@
      }
      let option = {
        title: {
          text: [""]
        },
        backgroundColor: {
          type: "image",
          image: "./static/image/WMBg.png",
@@ -663,16 +224,16 @@
        series: [
          {
            type: "graph",
            layout: "none",
            layout: "force",
            symbolSize: SymbolSize + 20,
            //是否允许用户拖动图片
            roam: false,
            roam: true,
            label: {
              show: true,
              color: "black", // 设置节点文字颜色为黑色
              fontSize: FontSize // 设置文字大小
            },
            edgeSymbol: ["circle", "arrow"],
            edgeSymbol: ["circle"],
            edgeSymbolSize: [4, 10],
            edgeLabel: {
@@ -689,13 +250,19 @@
              }
            },
            //各个节点
            data: dataList, //关系连接
            links: links,
            data: this.dataList, //关系连接
            links: this.links,
            lineStyle: {
              color: "#000000",
              opacity: 0.9,
              width: 2,
              curveness: 0
            },
            force: {
              initLayout: null,
              // gravity: 0
              repulsion: 600,
              edgeLength: 400
            }
          }
        ]