From 6a7fe3910a91355467295b4f81f71405fb1b1e75 Mon Sep 17 00:00:00 2001
From: YM <479443481@qq.com>
Date: 星期二, 23 七月 2024 16:00:56 +0800
Subject: [PATCH] 1

---
 src/pages/academicSchools/index.vue |  391 +++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 331 insertions(+), 60 deletions(-)

diff --git a/src/pages/academicSchools/index.vue b/src/pages/academicSchools/index.vue
index 0aab590..f47fabd 100644
--- a/src/pages/academicSchools/index.vue
+++ b/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="
+        padding-left: 0.6rem;
+        margin-top: 0.1rem;
+        display: flex;
+        position: relative;
+      "
+    >
       <advancedSearch
         @onSearch="onSearch"
         placehold="璇疯緭鍏ュ叧閿瓧"
@@ -30,12 +37,137 @@
             @click="onSearch({ text: item }, index)"
             :class="{ cursor: true, active: hotAciveIndex === index }"
             v-for="(item, index) in hotKeyList"
-            :key="item"
+            :key="item.name"
           >
-            {{ item }}
+            {{ item.name }}
           </li>
         </ul>
       </view>
+      <view v-if="isAdvancedSearch" class="searchDialog">
+        <h3 style="margin-bottom: 0.2rem">楂樼骇鎼滅储</h3>
+        <el-form
+          label-width="100px"
+          :model="formData"
+          ref="searchForm"
+          size="mini"
+        >
+          <el-row>
+            <el-col :span="8">
+              <el-form-item label="濮撳悕/鍒悕锛�">
+                <el-input v-model="formData.name"></el-input>
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="娲诲姩鍦帮細">
+                <div class="selectActivelyBox" @click="selectActively">
+                  <p v-if="formData.actively.length == 0">璇烽�夋嫨娲诲姩鍦�</p>
+                  <el-tag
+                    v-for="item in formData.actively"
+                    :key="item.id"
+                    size="small"
+                    closable
+                    >{{ item.name }}</el-tag
+                  >
+                </div>
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="浣滃搧锛�">
+                <el-input v-model="formData.works"></el-input>
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row>
+            <el-col :span="8">
+              <el-form-item label="浜虹墿鏍囩锛�">
+                <el-select
+                  multiple
+                  style="width: 100%"
+                  v-model="formData.personTags"
+                  placeholder="璇烽�夋嫨浜虹墿鏍囩"
+                >
+                  <el-option
+                    v-for="item in personTag"
+                    :key="item.id"
+                    :label="item.name"
+                    :value="item.id"
+                  ></el-option>
+                </el-select>
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="绀句細韬唤锛�">
+                <el-select
+                  multiple
+                  style="width: 100%"
+                  v-model="formData.socialIdentity"
+                  placeholder="璇烽�夋嫨绀句細韬唤"
+                >
+                  <el-option
+                    v-for="item in socialDistinction"
+                    :key="item.id"
+                    :label="item.name"
+                    :value="item.id"
+                  ></el-option>
+                </el-select>
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="鏃舵湡锛�">
+                <el-select
+                  multiple
+                  style="width: 100%"
+                  v-model="formData.period"
+                  placeholder="璇烽�夋嫨鏃舵湡"
+                >
+                  <el-option
+                    v-for="item in dynastyData"
+                    :key="item.dynastyId"
+                    :label="item.name"
+                    :value="item.dynastyId"
+                  ></el-option>
+                </el-select>
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <div style="text-align: right">
+            <el-button type="primary" size="mini" @click="searchFun"
+              >鎼滅储</el-button
+            >
+            <el-button size="mini" @click="resetForm">閲嶇疆</el-button>
+          </div>
+        </el-form>
+      </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>
 
     <!-- 鍏崇郴琛ㄥ湴鍥� -->
@@ -69,8 +201,7 @@
           font-size: 0.2rem;
           color: #666;
         "
-      >
-      </div>
+      ></div>
     </div>
     <div id="customDialog" class="customDialog">
       <div class="title">
@@ -86,6 +217,14 @@
       </div>
       <div class="btn" @click="spaceTimeArr(detailData.id)">鏌ョ湅鏇村>>></div>
     </div>
+    <el-drawer
+      title="鍦板潃鍒楄〃"
+      :visible.sync="drawer"
+      direction="rtl"
+      :before-close="handleClose"
+    >
+      <span>鎴戞潵鍟�!</span>
+    </el-drawer>
   </view>
 </template>
 
@@ -93,9 +232,14 @@
 import {
   getPersonData,
   getHotSearch,
-  getPDataStatistics
+  getPDataStatistics,
+  academicSearch,
+  getPersonTag,
+  getSocialDistinction,
+  getDynastyAll
 } from "@/api/index.js";
 import * as echarts from "echarts";
+import MyForm from "@/components/form/form.vue";
 export default {
   data() {
     return {
@@ -121,13 +265,33 @@
       detailData: {
         name: ""
       },
-      isAdvancedSearch: false
+      isAdvancedSearch: false,
+      formData: {
+        name: "",
+        actively: [],
+        works: "",
+        personTags: "",
+        socialIdentity: "",
+        period: ""
+      },
+      showPerson: false,
+      personList: [],
+      personPageInfo: {
+        totalCount: 0,
+        page: 1,
+        limit: 10
+      },
+      personTag: [],
+      socialDistinction: [],
+      dynastyData: [],
+      drawer:false,
     };
   },
   mounted() {
     this.getData();
-    // this.echartsArr();
     this.hotSearch();
+    // 鑾峰彇浜虹墿鏍囩銆佺ぞ浼氳韩浠�
+    this.getOptionInfo();
     // 鐩戝惉绐楀彛澶у皬鍙樺寲
     window.addEventListener("resize", this.relation);
   },
@@ -135,6 +299,36 @@
     this.searchKey = options.keyword;
   },
   methods: {
+    getOptionInfo() {
+      getDynastyAll().then((res) => {
+        this.dynastyData = res.list;
+      });
+      getPersonTag().then((res) => {
+        this.personTag = res.list;
+      });
+      getSocialDistinction().then((res) => {
+        this.socialDistinction = res.list;
+      });
+    },
+    resetForm(formName) {
+      this.formData = {
+        name: "",
+        actively: [],
+        works: "",
+        personTags: "",
+        socialIdentity: "",
+        period: ""
+      };
+    },
+    searchFun() {
+      console.log(this.formData);
+    },
+    selectActively() {
+      this.drawer = true;
+    },
+    handleClose(done) {
+      done();
+    },
     // 鑾峰彇浜虹墿鍏崇郴
     getPersonInfo(arr, str, newArr, order, type, parent) {
       for (let i = 0; i < arr.length; i++) {
@@ -146,12 +340,11 @@
           const obj = {
             personId: ele.personId,
             parentId: parent.id,
-            id2: personInfo.id,
             relationTypeName: ele.relationTypeName,
             parentName: parent?.NAME[0]?.content1 ?? parent.parentName,
-            name2: personInfo?.NAME[0]?.content1,
+            name: personInfo?.NAME[0]?.content1,
             category: type,
-            symbolSize: order,
+            symbolSize: 15
           };
           if (order > 80) {
             order = 80;
@@ -247,16 +440,16 @@
         if (!ele.personId && ele.personList?.length) {
           ele.literatureList = [];
           ele.personId = this.ownInfo.id;
-          if (ele[str] && ele[str]?.length) {
-            for (let j = 0; j < ele.personList.length; j++) {
-              const item = ele.personList[j];
+          if (ele["personList"] && ele["personList"]?.length) {
+            for (let j = 0; j < ele["personList"].length; j++) {
+              const item = ele["personList"][j];
               const data = item[str]?.map((e) => {
                 return {
                   ...e,
                   personId: item.personId
                 };
               });
-              if (data?.length) {
+              if (ele[str] && data?.length) {
                 ele[str].push(...data);
               }
             }
@@ -265,6 +458,8 @@
       }
       return arr;
     },
+
+    // 鏂囩尞
 
     //鏁扮粍鍘婚噸
     deduplicateArray(arr, idKey) {
@@ -299,9 +494,9 @@
         let place = [];
         let school = [];
         if (res && res.success && res.object) {
-
           this.infoOfPersons = res.object?.infoOfPersons;
           this.infoOfSchools = res.object?.infoOfSchools;
+          console.log(res.object);
           if (res.object?.personChain) {
             this.ownInfo = this.infoOfPersons.find(
               (item) => item.id == res.object?.personChain.personId
@@ -369,6 +564,7 @@
               this.categories.push({ name: "娲诲姩鍦�" });
               let newArr = [];
               const data = this.changeLiterature(obj.placeList, "placeList");
+              console.log(data, "place");
               this.getPersonInfo(data, "placeList", newArr, 1, 4, this.ownInfo);
               place = [...newArr];
             }
@@ -387,9 +583,6 @@
               school = [...newArr];
             }
           }
-          console.log(kinData);
-          console.log(kinData.map(item=>item.name2).join("銆�"));
-          debugger
           const personData = [
             ...kinData,
             ...teacher,
@@ -398,40 +591,16 @@
             ...place,
             ...school
           ];
-          // const k = personData.filter((item) => item.category == 0);
-          // const t = personData.filter((item) => item.category == 1);
-          // const l = personData.filter((item) => item.category == 2);
-          // const o = personData.filter((item) => item.category == 3);
-          // 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) =>
-                node.id === item.parentId && node.name === item.parentName
-            );
-            let exists2 = this.nodes.some(
-              (node) => node.id === item.parentId && node.name === item.name2
-            );
-            // 璇佹槑涓嶅瓨鍦�
-            if (item.name1 && exists1 !== true) {
-              this.nodes.push({
-                name: item.parentName,
-                id: item.parentId,
-                ...item
-              });
-            }
-            if (item.name2 && exists2 !== true) {
-              this.nodes.push({
-                name: item.name2,
-                id: item.id2,
-                ...item
-              });
-            }
+            this.nodes.push({
+              name: item.name,
+              id: item.personId,
+              ...item
+            });
             let obj = {
               source: item.parentName,
-              target: item.name2,
+              target: item.name,
               relation: item.relationTypeName || "" // 濡傛灉瀛樺湪 relationName 瀛楁鍒欎娇鐢紝鍚﹀垯涓虹┖瀛楃涓�
             };
             this.relationships.push(obj);
@@ -448,6 +617,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; // 杈规澶у皬
@@ -474,7 +660,7 @@
       var links = [];
       relationships.forEach((relationship, i) => {
         var sourceIndex = nodes.findIndex(
-          (node) => node.name === relationship.source
+          (node) => node.parentName === relationship.source
         );
         var targetIndex = nodes.findIndex(
           (node) => node.name === relationship.target
@@ -613,19 +799,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);
     },
-    // 鐐瑰嚮涓嬮潰鐨勬湞浠f寜閽�
-    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;
       });
     },
     // 鍏崇郴鍥� 鐐瑰嚮閲岄潰鐨勫厓绱�
@@ -654,7 +871,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]
+          };
         });
       });
     },
@@ -668,7 +888,7 @@
       //     document.querySelector(".fbox1").style.height = box1Height + "px";
       //   }
       // });
-    },
+    }
   }
 };
 </script>
@@ -678,7 +898,7 @@
   width: 100%;
   height: 100%;
   position: relative;
-  background-image: url('../../static/image/characterRelationBg.png');
+  background-image: url("../../static/image/characterRelationBg.png");
   background-size: 100% 100%;
   background-repeat: no-repeat;
   background-position: center;
@@ -773,4 +993,55 @@
     }
   }
 }
+
+.searchDialog {
+  position: absolute;
+  top: 0.68rem;
+  left: 0;
+  right: 0;
+  z-index: 999;
+  padding: 0.1rem 0.4rem;
+  background: #fff;
+  min-height: 2rem;
+}
+
+.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;
+  }
+}
+
+.selectActivelyBox {
+  cursor: pointer;
+  border: 1px solid #dcdfe6;
+  border-radius: 4px;
+  padding: 0 0.12rem;
+  font-size: 12px;
+  color: #c0c4cc;
+}
+
+.el-drawer__wrapper{
+  top: 0.86rem;
+}
+
+::v-deep .el-drawer__open .el-drawer.rtl{
+  width: 50% !important;
+}
+
 </style>

--
Gitblit v1.9.1