1
YM
2024-07-17 d5f572496c5fb12fec2fe346b847bf58331299c9
src/pages/character/detail.vue
@@ -1,6 +1,6 @@
<template>
  <view class="relative">
    <headNav :idIndex="1 + ''" text="中医人物数据库" />
    <headNav :idIndex="1 + ''" text="历代人物" />
    <view class="Midde flex">
      <el-button class="MiddeBack flex flex-center" @click="goBack"
        >返回</el-button
@@ -73,12 +73,17 @@
        <view
          id="copyBox"
          class="fz font-family"
          :title="biogData.length ? biogData[0].content : ''"
          style="
            font-size: 0.13rem;
            font-size: 0.14rem;
            font-weight: normal;
            line-height: 0.2rem;
            line-height: 2;
            letter-spacing: 0.03rem;
            cursor: pointer;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 4;
            overflow: hidden;
          "
        >
          {{ biogData.length ? biogData[0].content : "-" }}
@@ -94,7 +99,6 @@
              <img src="@/static/image/yinyong.png" alt="" />引用</el-button
            >
          </view>
          <!-- v-if="biogData.length > 1" -->
          <view
            style="font-size: 0.12rem; color: #244a7b; cursor: pointer"
            @click="ProfileClick"
@@ -154,6 +158,7 @@
              <span>时空地图</span>
              <!-- <el-button icon="el-icon-rank" style="float: right; padding: 3px 0" type="text"></el-button> -->
              <img
                v-if="markerList && markerList.length > 0"
                src="@/static/image/fangda.png"
                @click="fangdaClick(2)"
                style="width: 0.18rem; height: 0.18rem; cursor: pointer"
@@ -162,7 +167,19 @@
            <view
              id="spaceTime"
              style="height: 1.51rem; width: 100%; position: relative"
            ></view>
            >
              <p
                v-if="markerList && markerList.length == 0"
                style="
                  margin-top: 0.5rem;
                  color: #666;
                  text-align: center;
                  font-size: 12px;
                "
              >
                暂无数据
              </p>
            </view>
          </el-card>
          <el-card style="width: 100%; height: 2.06rem">
            <div
@@ -222,7 +239,7 @@
            class="box-card"
            style="min-height: 1.91rem; margin: 0.2rem 0"
          >
            <el-tabs ref="tabs" v-model="activeName" @tab-click="handleClick">
            <el-tabs ref="tabs" v-model="activeName">
              <el-tab-pane label="代表著作" data-id="1" name="representative">
                <Table1
                  :data="tableData1"
@@ -272,14 +289,22 @@
              <span>相关附表/图像</span>
            </div>
            <view>
              <div class="flex">
                <el-image
                  v-for="item in imageList"
                  :key="item"
                  style="width: 2.05rem; height: 2.4rem"
                  :src="item"
                  fit="fill"
                ></el-image>
              <div style="overflow: auto;display: flex;">
                <div v-for="item in imageList" :key="item" :title="item.name">
                  <el-image
                    :title="item.name"
                    :alt="item.name"
                    style="
                      width: 2.05rem;
                      height: 2.4rem;
                      margin-right: 0.2rem;
                      margin-bottom: 0.1rem;
                    "
                    :src="item.src"
                    :preview-src-list="imageList.map((item) => item.src)"
                    fit="contain"
                  ></el-image>
                </div>
              </div>
              <div
                v-if="imageList.length == 0"
@@ -300,8 +325,9 @@
            >
              <span>现代研究</span>
            </div>
            <ul class="font-family" style="font-size: 0.13rem; line-height: 2">
            <ul class="fileul" style="font-size: 0.13rem; line-height: 2">
              <li
                style="cursor: pointer"
                v-for="(item, index) in personResearchList"
                :key="index"
                @click="toLink(item)"
@@ -309,7 +335,7 @@
                {{ "[" + Number(index + 1) + "]" + item.achievementName }}
              </li>
              <div
                v-if="personResearchList.length == 0"
                v-if="!personResearchList || personResearchList.length == 0"
                style="color: #666; text-align: center; font-size: 16px"
              >
                暂无数据
@@ -321,9 +347,17 @@
    </div>
    <!-- 返回顶部 -->
    <el-col style="position: absolute; bottom: 1rem; left: 1.2rem">
    <el-col
      style="
        position: absolute;
        bottom: 1rem;
        left: 1.2rem;
        width: 0.6rem;
        height: 0.6rem;
      "
    >
      <el-button
        style="width: 0.5rem; height: 0.5rem; font-size: 0.3rem"
        style="font-size: 0.3rem"
        icon="el-icon-top"
        circle
        @click="scrollToTop"
@@ -374,7 +408,9 @@
import {
  getFuzzySearch,
  getPersonInfo,
  getRelationTypeTreeList,
  getWebBasic,
  getDynastyAll,
  getIntroduction,
  getSource,
  getPersonImages,
@@ -382,6 +418,7 @@
  getPersonWritings,
  getPersonRelationAtSchool,
  getSpaceTime,
  getDynastyData,
} from "@/api/index.js";
import { getImg } from "@/static/tool.js";
import L from "leaflet";
@@ -444,6 +481,8 @@
        },
        {
          prop: "d",
          width: 300,
          showOverflowTooltip: true,
          label: "出处",
        },
      ],
@@ -473,6 +512,7 @@
      nodes: [],
      relationships: [],
      personResearchList: [],
      markerList: [],
    };
  },
  onLoad(options) {
@@ -494,21 +534,21 @@
    // 获取时空地图
    this.getMapInfo();
    this.$nextTick(() => {
      // 获取第一个选项卡的 DOM 元素
      const firstTab = this.$refs.tabs.$el.querySelector(
        ".el-tabs__active-bar"
      );
      firstTab.style.transform = "translateX(" + "-.2rem" + ")";
    });
    // this.$nextTick(() => {
    //   // 获取第一个选项卡的 DOM 元素
    //   const firstTab = this.$refs.tabs.$el.querySelector(
    //     ".el-tabs__active-bar"
    //   );
    //   firstTab.style.transform = "translateX(" + "-.2rem" + ")";
    // });
    // 监听窗口大小变化
    window.addEventListener("resize", this.relation);
  },
  methods: {
    copyText() {
      console.log(navigator.clipboard);
      const textToCopy = this.biogData[0].content + ";来源:中医医学人物数据库";
      const textToCopy =
        this.biogData[0].content + "\n来源:中医医学人物知识库";
      const textarea = document.createElement("textarea");
      textarea.value = textToCopy;
      document.body.appendChild(textarea);
@@ -521,7 +561,12 @@
      });
    },
    toLink(item) {
      window.open(item.url);
      if (item.url) {
        window.open(item.url);
      }
      if (item.filePath) {
        window.open(getImg(item.filePath));
      }
    },
    getData() {
      // 基本信息
@@ -542,11 +587,25 @@
              : fieldItem.content1;
          }
        }
        console.log(obj);
        this.detailInfo = obj;
        getDynastyAll().then((dynastyData) => {
          getWebBasic({
            personId: this.detailId,
          }).then((res) => {
            const obj = res.object;
            if (obj.school) {
              getIntroduction(Number(obj.school)).then((sres) => {
                this.handleData(obj, sres, dynastyData.list);
              });
            } else {
              this.handleData(obj, null, dynastyData.list);
            }
          });
        });
        // 关系图谱
        this.getMappingData(this.detailInfo.NAME);
        this.getMappingData();
      });
      //现代研究
      getPersonInfo({
        id: this.detailId,
@@ -554,57 +613,31 @@
      }).then((res) => {
        this.personResearchList = res.object.personResearchList;
      });
      getPersonRelationAtSchool({
        personId: this.detailId,
      }).then((res) => {
        console.log(res, "PERSON_RELATIONS");
        // this.personRelationList = res.object.personRelationList;
        // if (this.personRelationList.length) {
        //   this.tableData4 = this.personRelationList.map((f) => {
        //     return {
        //       a: f.nodeName,
        //       b: f.relationTypeName,
        //     };
        //   });
        // }
      });
      getWebBasic({
        personId: this.detailId,
      }).then((res) => {
        console.log(res, "resres");
        const obj = res.object;
        if (obj.school) {
          getIntroduction(Number(obj.school)).then((sres) => {
            console.log(sres, "sres");
            handleData(obj, sres);
          });
        } else {
          handleData(obj);
        }
      });
      // 活动年谱
      getPersonInfo({
        id: this.detailId,
        type: "PERSON_SPACE_TIME",
      }).then((res) => {
        this.tableData5 = res.object.personSpaceTimeList.map((item) => {
          return {
            a: item.time,
            b: item.activityName,
            c: item.activityAddrOld,
            d: item.desc, // 这里缺少活动描述字段
          };
        });
        if (res.object.personSpaceTimeList) {
          this.tableData5 = res.object.personSpaceTimeList.map((item) => {
            return {
              a: item.time,
              b: item.activityName,
              c: item.activityAddrOld,
              d: item.desc,
            };
          });
        }
      });
    },
    handleData(obj, sres) {
    handleData(obj, sres, dynastyData) {
      this.tableArr = [
        {
          list: [
            {
              name: "别名",
              value: obj.alias || "-",
              name: "姓名",
              value: obj.name || "-",
            },
            {
              name: "字",
@@ -616,7 +649,16 @@
            },
            {
              name: "所处时期",
              value: obj.dynastyDesc || "-",
              value:
                dynastyData.find((item) => item.dynastyId == obj.dynastyId)
                  .name || "-",
              valueClick: () => {
                uni.navigateTo({
                  url:
                    "/pages/knowledgeBase/knowledgeBase?dynasty=" +
                    obj.dynastyId,
                });
              },
            },
            {
              name: "民族",
@@ -637,6 +679,13 @@
            {
              name: "职官",
              value: obj.official || "-",
              valueClick: () => {
                uni.navigateTo({
                  url:
                    "/pages/knowledgeBase/knowledgeBase?isAdvancedSearch=1&official=" +
                    obj.official,
                });
              },
            },
            {
              name: "流派",
@@ -667,7 +716,12 @@
      getPersonImages({
        personId: this.detailId,
      }).then((res) => {
        this.imageList = res.list.map((item) => getImg(item.filePath));
        this.imageList = res.list.map((item) => {
          return {
            src: getImg(item.filePath),
            name: item.desc,
          };
        });
      });
    },
    getBiog() {
@@ -677,7 +731,27 @@
        this.biogData = res.list.map((item) => {
          return {
            content: item.content1,
            bookName: "《" + item.bookName + "》 " + "P " + item.pageNo, // 这里只有bookid无法匹配到书名
            bookName:
              "《" +
              item.bookName +
              "》 " +
              (item.pageNo ? "P " + item.pageNo : ""), // 这里只有bookid无法匹配到书名
          };
        });
      });
    },
    getBiog() {
      getPersonBiog({
        personId: this.detailId,
      }).then((res) => {
        this.biogData = res.list.map((item) => {
          return {
            content: item.content1,
            bookName:
              "《" +
              item.bookName +
              "》 " +
              (item.pageNo ? "P " + item.pageNo : ""), // 这里只有bookid无法匹配到书名
          };
        });
      });
@@ -698,17 +772,72 @@
      });
    },
    getRelationship() {
      getPersonRelationAtSchool({
        personId: this.detailId,
        // relationSearchTypeEO: "SOCIAL"
      getPersonInfo({
        id: this.detailId,
        type: "PERSON_RELATIONS",
      }).then((res) => {
        console.log(res, "getPersonRelationAtSchool");
        // 这里接口有问题
        this.tableData4;
        if (res.object.personRelationMap.kin.length) {
          this.tableData2 = res.object.personRelationMap.kin.map((f) => {
            return {
              a: f.nodeName,
              b: f.relationTypeName,
              c: f.textualResearch,
              d:
                res.object.bookList &&
                res.object.bookList.find((citem) => citem.id == f.bookId)
                  ? "《" +
                    res.object.bookList.find((citem) => citem.id == f.bookId)
                      .name +
                    "》 P" +
                    f.pageNo
                  : "",
            };
          });
        }
        if (res.object.personRelationMap.teacherStudent.length) {
          this.tableData3 = res.object.personRelationMap.teacherStudent.map(
            (f) => {
              return {
                a: f.nodeName,
                b: f.relationTypeName,
                c: f.textualResearch,
                d:
                  res.object.bookList &&
                  res.object.bookList.find((citem) => citem.id == f.bookId)
                    ? "《" +
                      res.object.bookList.find((citem) => citem.id == f.bookId)
                        .name +
                      "》 P" +
                      f.pageNo
                    : "",
              };
            }
          );
        }
        if (res.object.personRelationMap.social.length) {
          this.tableData4 = res.object.personRelationMap.social.map((f) => {
            return {
              a: f.nodeName,
              b: f.relationTypeName,
              c: f.textualResearch,
              d:
                res.object.bookList &&
                res.object.bookList.find((citem) => citem.id == f.bookId)
                  ? "《" +
                    res.object.bookList.find((citem) => citem.id == f.bookId)
                      .name +
                    "》 P" +
                    f.pageNo
                  : "",
            };
          });
        }
      });
    },
    getMappingData(name) {
    getMappingData() {
      getFuzzySearch({
        keyword: name,
        personId: this.detailId,
      }).then((res) => {
        this.nodes = [];
        this.relationships = [];
@@ -721,13 +850,13 @@
              (node) => node.id === item.identifier2 && node.name === item.name2
            );
            // 证明不存在
            if (exists1 !== true) {
            if (item.name1 && exists1 !== true) {
              this.nodes.push({
                name: item.name1,
                id: item.identifier1,
              });
            }
            if (exists2 !== true) {
            if (item.name2 && exists2 !== true) {
              this.nodes.push({
                name: item.name2,
                id: item.identifier2,
@@ -748,15 +877,26 @@
      getSpaceTime({
        personId: this.detailId,
      }).then((res) => {
        console.log(res, "getSpaceTime");
        const data = res.list.map((item) => {
          return {
            name: item.activityName,
            value: [item.xcoord, item.ycoord],
          };
        });
        // 时空地图
        this.initMap(data[0]);
        if (res.list && res.list.length) {
          const data = [];
          for (let i = 0; i < res.list.length; i++) {
            const item = res.list[i];
            if (item.xcoord && item.ycoord) {
              const obj = {
                name: item.activityName,
                value: [item.xcoord, item.ycoord],
              };
              data.push(obj);
            }
          }
          this.markerList = data;
          // 时空地图
          // 这里只取了第一条,需要全部数据
          if (data && data.length) {
            this.initMap(data);
          }
        }
        // loadBMap("1NJdwrI1CfT6lrykVhDkmWgsO6O2bjQK").then(() => {
        //   this.spaceTime(data);
        // });
@@ -766,9 +906,16 @@
      var map = L.map("spaceTime", {
        preferCanvas: true,
        attributionControl: false,
      }).setView([markerList.value[1], markerList.value[0]], 13);
      }).setView([markerList[0].value[1], markerList[0].value[0]], 13);
      L.tileLayer
        .chinaProvider("TianDiTu.Normal.Map", {
          key: "76bc34ead7e30e663a4eded8aeaf5860",
          maxZoom: 18,
          minZoom: 3,
        })
        .addTo(map);
      L.tileLayer
        .chinaProvider("TianDiTu.Normal.Annotion", {
          key: "76bc34ead7e30e663a4eded8aeaf5860",
          maxZoom: 18,
          minZoom: 3,
@@ -783,6 +930,14 @@
      const temp_mark = L.marker([markerList.value[1], markerList.value[0]], {
        icon: icon,
      }).addTo(map);
      if (markerList.length) {
        for (let i = 0; i < markerList.length; i++) {
          const item = markerList[i];
          const temp_mark = L.marker([item.value[1], item.value[0]], {
            icon: icon,
          }).addTo(map);
        }
      }
    },
    // 放大地图跳转
    fangdaClick(index) {
@@ -837,30 +992,6 @@
        .join("&");
      window.open(`#/pages/fileDetail/index?${queryString}`);
    },
    handleClick(tab) {
      let index = tab.$attrs["data-id"] - 1;
      this.$nextTick(() => {
        let firstTab = this.$refs.tabs.$el.querySelector(
          ".el-tabs__active-bar"
        );
        if (index == 0) {
          firstTab.style.transform = "translateX(-" + 0.2 + "rem)";
        } else if (index == 1) {
          firstTab.style.transform = "translateX(" + 0.85 * index + "rem)";
        } else if (index == 2) {
          firstTab.style.transform = "translateX(" + 0.93 * index + "rem)";
        } else if (index == 3) {
          firstTab.style.transform = "translateX(" + 0.95 * index + "rem)";
        } else if (index == 4) {
          firstTab.style.transform = "translateX(" + 0.97 * index + "rem)";
        } else {
          let firstTab = this.$refs.tabs.$el.querySelector(
            ".el-tabs__active-bar"
          );
          firstTab.style.transform = "translateX(" + "-.2" + "rem)";
        }
      });
    },
    // 关系图谱
    relation() {
      var chartDom = document.getElementById("relation");
@@ -871,25 +1002,8 @@
      let FontSize = 12; // 字体大小
      let BorderWidth = 2; // 边框大小
      let SymbolSize = 80; // 尺寸距离
      let SymbolSize = 50; // 尺寸距离
      let Distance = 10;
      // 不同尺寸下修改echarts的字体
      if (window.innerWidth > 2560 && window.innerWidth <= 3840) {
        FontSize = 28;
        BorderWidth = 5;
        SymbolSize = 100;
        Distance = 33;
      } else if (window.innerWidth > 1920 && window.innerWidth <= 2560) {
        FontSize = 28;
        BorderWidth = 4;
        SymbolSize = 90;
        Distance = 22;
      } else if (window.innerWidth >= 1366 && window.innerWidth <= 1920) {
        FontSize = 18;
        BorderWidth = 4;
        SymbolSize = 70;
        Distance = 22;
      }
      // 根据关系数据生成连接线
      var links = [];
      relationships.forEach((relationship, i) => {
@@ -1229,9 +1343,7 @@
  width: 70%;
}
::v-deep .el-tabs__content {
  line-height: 1;
}
/* 个人小传 ------------------*/
::v-deep .el-dialog__header {
@@ -1240,10 +1352,6 @@
::v-deep .el-dialog__body {
  padding: 0;
}
::v-deep .el-dialog__wrapper {
  z-index: 999999999999999 !important;
}
.ProfileNav {
@@ -1257,12 +1365,6 @@
}
/* ------------------- */
img {
  width: 100%;
  height: 100%;
}
* {
  box-sizing: border-box;
}
@@ -1368,10 +1470,12 @@
}
::v-deep .el-tabs__item {
  width: 1rem;
  width: 1.4rem;
  font-size: 0.14rem;
  line-height: 0.4rem;
  height: 0.4rem;
  padding: 0 20px !important;
  text-align: center;
}
::v-deep .el-tabs__header {
@@ -1379,12 +1483,8 @@
}
::v-deep .el-tabs__active-bar {
  /* 设置滚动条宽度 */
  width: 1rem !important;
  height: 0.03rem !important;
  background-color: #597aa5;
  transform: translateX(-20px);
  /* margin-top: .09rem; */
}
::v-deep .el-tabs__active-bar {
@@ -1433,4 +1533,8 @@
    opacity: 0;
  }
}
.fileul li:hover {
  color: #597aa5;
}
</style>