1
YM
2024-07-22 dde861004f66da709a7ba5a03c3b59215813f96d
src/pages/academicSchools/index.vue
@@ -4,7 +4,14 @@
  >
    <headNav :idIndex="'6'" text="学术流派" />
    <!-- 高级搜索 -->
    <view style="margin-left: 0.6rem; margin-top: 0.1rem; display: flex">
    <view
      style="
        margin-left: 0.6rem;
        margin-top: 0.1rem;
        display: flex;
        position: relative;
      "
    >
      <advancedSearch
        @onSearch="onSearch"
        placehold="请输入关键字"
@@ -32,10 +39,37 @@
            v-for="(item, index) in hotKeyList"
            :key="item"
          >
            {{ item }}
            {{ item.name }}
          </li>
        </ul>
      </view>
      <view v-if="isAdvancedSearch">
        <h3>高级搜索</h3>
        <MyForm @submit="onSubmit" :from="searchFrom" />
      </view>
      <div v-if="showPerson" class="personDialog">
        <i class="el-icon-circle-close closeBtn" @click="()=>{showPerson = false}"></i>
        <el-table :data="personList" style="width: 100%">
          <el-table-column prop="name" label="姓名">
            <template slot-scope="scope">
              <span
                style="color: #409eff; cursor: pointer"
                @click="
                  () => {
                    currentId = scope.row.id;
                    getData();
                  }
                "
                >{{ scope.row.name }}</span
              >
            </template>
          </el-table-column>
          <el-table-column prop="age" label="时代"> </el-table-column>
          <el-table-column prop="nativePlace" label="籍贯"> </el-table-column>
          <el-table-column prop="alias" label="别名"> </el-table-column>
          <el-table-column prop="division" label="医学分科"> </el-table-column>
        </el-table>
      </div>
    </view>
    <!-- 关系表地图 -->
@@ -57,6 +91,19 @@
      >
        暂无相关数据
      </div>
      <div
        v-if="loading"
        v-loading="loading"
        style="
          position: absolute;
          top: 30%;
          left: 0;
          right: 0;
          text-align: center;
          font-size: 0.2rem;
          color: #666;
        "
      ></div>
    </div>
    <div id="customDialog" class="customDialog">
      <div class="title">
@@ -79,9 +126,11 @@
import {
  getPersonData,
  getHotSearch,
  getPDataStatistics
  getPDataStatistics,
  academicSearch
} from "@/api/index.js";
import * as echarts from "echarts";
import MyForm from "@/components/form/form.vue";
export default {
  data() {
    return {
@@ -107,7 +156,52 @@
      detailData: {
        name: ""
      },
      isAdvancedSearch: false
      isAdvancedSearch: false,
      searchFrom: [
        {
          type: "input",
          label: "姓名/别名",
          name: "name",
          value: ""
        },
        {
          type: "input",
          label: "活动地",
          name: "address",
          value: ""
        },
        {
          type: "input",
          label: "作品",
          name: "address",
          value: ""
        },
        {
          type: "input",
          label: "人物标签",
          name: "address",
          value: ""
        },
        {
          type: "input",
          label: "社会身份",
          name: "address",
          value: ""
        },
        {
          type: "input",
          label: "时期",
          name: "address",
          value: ""
        }
      ],
      showPerson: false,
      personList: [],
      personPageInfo: {
        totalCount: 0,
        page: 1,
        limit: 10
      }
    };
  },
  mounted() {
@@ -136,8 +230,12 @@
            relationTypeName: ele.relationTypeName,
            parentName: parent?.NAME[0]?.content1 ?? parent.parentName,
            name2: personInfo?.NAME[0]?.content1,
            category: type
            category: type,
            symbolSize: 15
          };
          if (order > 80) {
            order = 80;
          }
          if (str == "literatureList") {
            obj.relationTypeName = ele.literatureName;
          }
@@ -152,7 +250,7 @@
          }
          newArr.push(obj);
          if (ele["kinList"] && ele["kinList"]?.length) {
            order++;
            order += 15;
            this.getPersonInfo(
              ele["kinList"],
              "kinList",
@@ -163,7 +261,7 @@
            );
          }
          if (ele["teacherStudentList"] && ele["teacherStudentList"]?.length) {
            order++;
            order += 15;
            this.getPersonInfo(
              ele["teacherStudentList"],
              "teacherStudentList",
@@ -178,7 +276,7 @@
              ele["literatureList"],
              "literatureList"
            );
            order++;
            order += 15;
            this.getPersonInfo(
              data,
              "literatureList",
@@ -191,7 +289,7 @@
          if (ele["socialList"] && ele["socialList"]?.length) {
            const data = this.changeLiterature(ele["socialList"], "socialList");
            order++;
            order += 15;
            this.getPersonInfo(
              data,
              "socialList",
@@ -203,12 +301,12 @@
          }
          if (ele["placeList"] && ele["placeList"]?.length) {
            const data = this.changeLiterature(ele["placeList"], "placeList");
            order++;
            order += 15;
            this.getPersonInfo(data, "placeList", newArr, order, 4, personInfo);
          }
          if (ele["schoolList"] && ele["schoolList"]?.length) {
            const data = this.changeLiterature(ele["schoolList"], "schoolList");
            order++;
            order += 15;
            this.getPersonInfo(
              data,
              "schoolList",
@@ -281,7 +379,6 @@
        let place = [];
        let school = [];
        if (res && res.success && res.object) {
          // console.log(res.object);
          this.infoOfPersons = res.object?.infoOfPersons;
          this.infoOfSchools = res.object?.infoOfSchools;
          if (res.object?.personChain) {
@@ -377,6 +474,7 @@
            ...place,
            ...school
          ];
          console.log(personData);
          // const k = personData.filter((item) => item.category == 0);
          // const t = personData.filter((item) => item.category == 1);
          // const l = personData.filter((item) => item.category == 2);
@@ -384,7 +482,7 @@
          // const p = personData.filter((item) => item.category == 4);
          // const s = personData.filter((item) => item.category == 5);
          // const nodesList = [...k, ...t, ...l, ...o, ...p, ...s];
          // console.log(nodesList);
          personData.forEach((item) => {
            let exists1 = this.nodes.some(
              (node) =>
@@ -427,6 +525,23 @@
      // 假设您有节点名称和它们之间的关系数据
      var nodes = this.deduplicateArray(this.nodes, "id");
      var relationships = this.relationships;
      nodes = nodes.map((item) => {
        let size = item.symbolSize;
        for (let i = 0; i < relationships.length; i++) {
          const linkItem = relationships[i];
          if (linkItem.source == item.parentName) {
            size += 5;
          }
          if (linkItem.target == item.parentName) {
            size += 5;
          }
        }
        return {
          ...item,
          symbolSize: size > 80 ? 80 : size
        };
      });
      let FontSize = 12; // 字体大小
      let BorderWidth = 2; // 边框大小
@@ -487,15 +602,17 @@
      });
      // 根据nodes动态生成节点数据
      var nodeData = nodes;
      console.log(nodeData);
      console.log(links);
      var option;
      option = {
        backgroundColor: {
          type: "image",
          image: "/static/image/characterRelationBg.png",
          size: "100% 100%", // 背景图片的尺寸,可以是百分比或者像素
          position: "center center" // 背景图片的位置,可以是 top, bottom, middle 或者百分比
        },
        tooltip: {},
        // backgroundColor: {
        //   type: "image",
        //   image: "/static/image/characterRelationBg.png",
        //   size: "100% 100%", // 背景图片的尺寸,可以是百分比或者像素
        //   position: "center center", // 背景图片的位置,可以是 top, bottom, middle 或者百分比
        // },
        // tooltip: {},
        legend: [
          {
            left: 20,
@@ -509,7 +626,7 @@
        series: [
          {
            type: "graph",
            legendHoverLink: true,
            legendHoverLink: false,
            layout: "force",
            symbolSize: 15,
            data: nodeData,
@@ -520,9 +637,6 @@
              show: true,
              position: "right",
              formatter: "{b}"
            },
            labelLayout: {
              hideOverlap: true
            },
            scaleLimit: {
              min: 0.4,
@@ -595,19 +709,50 @@
    },
    // 基础搜索
    onSearch(val, index) {
      console.log(val);
      if (index !== undefined) {
        // 热门搜索关键字,直接查询数据
        this.searchKey = "";
        this.hotAciveIndex = index;
        this.currentId = val.text.id;
        this.getData();
      } else {
        this.hotAciveIndex = "";
        // 搜索先显示人物列表
        this.personPageInfo.page = 1;
        this.searchPerson(val.text);
      }
      this.getData(val.text);
    },
    // 点击下面的朝代按钮
    dynastyBottomClick(item) {
      this.dynastyColor = item.id;
      this.onSearch({
        text: item.name
    // 根据关键字检索人物
    searchPerson(key) {
      academicSearch({
        keyword: key,
        page: this.personPageInfo.page,
        pageSize: this.personPageInfo.limit
      }).then((res) => {
        this.personList = res.list.map((item) => {
          return {
            id: item.personId,
            name: item.name,
            age:
              item.periodList && item.periodList.length
                ? item.periodList[0].content2
                : "-",
            nativePlace:
              item.nativePlaceList && item.nativePlaceList.length
                ? item.nativePlaceList[0].content1
                : "-",
            alias:
              item.aliasList && item.aliasList.length
                ? item.aliasList[0].content2
                : "-",
            division:
              item.medicalBranchList && item.medicalBranchList.length
                ? item.medicalBranchList[0].content1
                : "-"
          };
        });
        this.showPerson = true;
      });
    },
    // 关系图 点击里面的元素
@@ -636,7 +781,10 @@
        const indexList = Object.keys(res.object);
        indexList.sort((a, b) => parseInt(b) - parseInt(a));
        this.hotKeyList = indexList.map((item) => {
          return res.object[item];
          return {
            id: item,
            name: res.object[item]
          };
        });
      });
    },
@@ -650,16 +798,20 @@
      //     document.querySelector(".fbox1").style.height = box1Height + "px";
      //   }
      // });
    },
    }
  }
};
</script>
<style>
#relatio {
#relation {
  width: 100%;
  height: 100%;
  position: relative;
  background-image: url("../../static/image/characterRelationBg.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
}
.customDialog {
@@ -751,4 +903,26 @@
    }
  }
}
.personDialog {
  position: absolute;
  top: 0.68rem;
  z-index: 999;
  padding: 0.1rem;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 0 10px -3px #000;
  .closeBtn{
    position: absolute;
    right: -10px;
    top: -10px;
    width: 24px;
    height: 24px;
    font-size: 24px;
    background-color: #fff;
    border-radius: 50%;
    color: #F56C6C;
    cursor: pointer;
  }
}
</style>