1
YM
2024-06-17 a10960e9cee3776ffd3871e5949f6b474127c428
1
2个文件已修改
91 ■■■■ 已修改文件
src/api/index.js 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/academicGenres/chart.vue 82 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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",
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;"
        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 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,22 +238,28 @@
          },
          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];
              if (
                citem.relationType != "代表人物" &&
                citem.relationType != "人物关系"
              ) {
              // 节点
                if (citem.name1) {
              this.nodeData.push({
                name: citem.name2,
                    name: citem.name1,
                x: Math.random() * 1000,
                y: Math.random() * 600,
                itemStyle: {
                  color: citem.relationType == "人物著作" ? "#eee" : "#FDEFE4",
                      color:
                        citem.relationType == "关系文献" ? "#eee" : "#FDEFE4",
                  borderWidth: 4,
                  borderColor:
                    citem.relationType == "人物著作" ? "#9e9e9e" : "#DA7A2B",
                        citem.relationType == "关系文献"
                          ? "#9e9e9e"
                          : "#DA7A2B",
                  borderRadius: 30
                },
                symbolSize: 100
@@ -252,11 +267,28 @@
              // 关系
              this.links.push({
                source: item,
                target: citem.name2,
                    target: citem.name1,
                label: {
                  show: false
                      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, // 设置标签的z轴高度,使其比连接线更高
                      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
            }
          }
        ]