| | |
| | | <view class="icon" style="background: #244a7b"></view> |
| | | <view>社会关系</view> |
| | | </view> |
| | | <view class="viewChangeBtn"> |
| | | <p>{{ viewType == 1 ? "横版视图" : "竖版视图" }}</p> |
| | | <view class="imgBox"> |
| | | <img |
| | | v-if="viewType == 1" |
| | | src="@/static/image/inherit/1-a.png" |
| | | alt="" |
| | | /> |
| | | <img |
| | | v-else |
| | | src="@/static/image/inherit/1.png" |
| | | @click="viewChange(1)" |
| | | /> |
| | | </view> |
| | | <view class="imgBox"> |
| | | <img |
| | | v-if="viewType == 2" |
| | | src="@/static/image/inherit/2-a.png" |
| | | alt="" |
| | | /> |
| | | <img |
| | | v-else |
| | | src="@/static/image/inherit/2.png" |
| | | @click="viewChange(2)" |
| | | /> |
| | | </view> |
| | | <p style="position: absolute;bottom: -40px;font-size: 12px;width: 200px;color: #999;">注:箭头指向为当前“人物”的X关系</p> |
| | | </view> |
| | | </view> |
| | | <!-- echarts图 --> |
| | | <div v-if="showType == 1" class="barChart" id="barChart"></div> |
| | |
| | | culture1: null, |
| | | culture2: null, |
| | | culture3: null, |
| | | viewType: 1, |
| | | }; |
| | | }, |
| | | onLoad(options) { |
| | |
| | | if (this.type) { |
| | | this.changeType(this.type); |
| | | } |
| | | this.getData(); |
| | | this.getData(this.socialMapping); |
| | | }, |
| | | methods: { |
| | | getData() { |
| | | getData(socialFlag) { |
| | | inheritMedicalRelationList({ |
| | | identifier: this.idIndex, |
| | | socialFlag: true, |
| | | socialFlag: socialFlag, |
| | | }).then((res) => { |
| | | this.dataList = res.object; |
| | | // 处理节点颜色 |
| | |
| | | this.culture3 = res.list.find((item) => item.typeName == "家训"); |
| | | }); |
| | | }, |
| | | viewChange(data) { |
| | | this.viewType = data; |
| | | document.getElementById("barChart").innerHTML = ""; |
| | | this.initG6Chart(); |
| | | }, |
| | | showSocialMapping() { |
| | | this.socialMapping = !this.socialMapping; |
| | | if (!this.socialMapping) { |
| | | this.socialRelationsData(this.dataList.children); |
| | | console.log(this.dataList, "dataList"); |
| | | document.getElementById("barChart").innerHTML = ""; |
| | | this.initG6Chart(); |
| | | // this.initG6Chart(); |
| | | this.getData(this.socialMapping); |
| | | } else { |
| | | this.getData(); |
| | | this.getData(this.socialMapping); |
| | | } |
| | | // this.initBarChart(newDataList, newLinks); |
| | | }, |
| | |
| | | if (dataList && dataList.length) { |
| | | const G6Data = dataList.map((f) => { |
| | | return { |
| | | id: f.name, |
| | | id: f.value + "-" + f.name, |
| | | name: f.name, |
| | | personId: f.personId, |
| | | relationInfo: f?.relationInfo?.relation |
| | | ? f.relationInfo.relation |
| | |
| | | const data = { |
| | | isRoot: true, |
| | | id: this.dataList.name, |
| | | name: this.dataList.name, |
| | | style: { |
| | | fill: "red", |
| | | }, |
| | |
| | | height, |
| | | linkCenter: true, |
| | | modes: { |
| | | default: [ |
| | | // { |
| | | // type: "collapse-expand", |
| | | // onChange: function onChange(item, collapsed) { |
| | | // const data = item.get("model"); |
| | | // data.collapsed = collapsed; |
| | | // return true; |
| | | // }, |
| | | // }, |
| | | "drag-canvas", |
| | | "zoom-canvas", |
| | | ], |
| | | default: ["drag-canvas", "zoom-canvas"], |
| | | }, |
| | | defaultNode: { |
| | | size: 30, |
| | | type: "tree-node", |
| | | }, |
| | | defaultEdge: { |
| | | type: this.viewType == 1 ? "cubic-horizontal" : "cubic-vertical", |
| | | style: { |
| | | endArrow: { |
| | | path: G6.Arrow.vee(10, 10, 18), // 使用内置箭头路径函数,参数为箭头的 宽度、长度、偏移量(默认为 0,与 d 对应) |
| | | d: 15, |
| | | }, |
| | | }, |
| | | }, |
| | | layout: { |
| | | type: "compactBox", |
| | | direction: "LR", |
| | | direction: this.viewType == 1 ? "LR" : "TB", |
| | | getId: function getId(d) { |
| | | return d.id; |
| | | }, |
| | |
| | | getWidth: function getWidth() { |
| | | return 16; |
| | | }, |
| | | getVGap: function getVGap() { |
| | | return 30; |
| | | getVGap: () => { |
| | | console.log(this.viewType); |
| | | return this.viewType == 1 ? 20 : 110; |
| | | }, |
| | | getHGap: function getHGap() { |
| | | return 100; |
| | | getHGap: () => { |
| | | return this.viewType == 1 ? 100 : 50; |
| | | }, |
| | | }, |
| | | }); |
| | |
| | | fill: node.relationType ? "#EDF4FF" : "#FCEFE3", |
| | | stroke: node.relationType ? "#5E7AA7" : "#D3791E", |
| | | }, |
| | | label: node.id, |
| | | label: node.name, |
| | | labelCfg: { |
| | | position: "center", |
| | | offset: 5, |
| | |
| | | }, |
| | | }; |
| | | }); |
| | | let that = this; |
| | | const edgeType = |
| | | this.viewType == 1 ? "cubic-horizontal" : "cubic-vertical"; |
| | | this.graph.edge(function (node) { |
| | | return { |
| | | type: "cubic-horizontal", |
| | | type: edgeType, |
| | | color: "#A3B1BF", |
| | | label: node.target._cfg?.model.relationInfo, |
| | | label: |
| | | that.viewType == 1 |
| | | ? node.target._cfg?.model.relationInfo |
| | | : that.textStyle(node.target._cfg?.model.relationInfo), |
| | | }; |
| | | }); |
| | | this.graph.on("node:click", (e) => { |
| | |
| | | //进行渲染 |
| | | myChart.setOption(option); |
| | | }, |
| | | |
| | | textStyle(str) { |
| | | return str.replace(/(.{4})/g, "$1\n"); |
| | | }, |
| | | |
| | | // 返回按钮 |
| | | goBack() { |
| | | this.$router.go(-1); |
| | |
| | | margin-right: 0.06rem; |
| | | } |
| | | |
| | | .viewChangeBtn { |
| | | position: absolute; |
| | | right: 1.2rem; |
| | | top: 0.17rem; |
| | | display: flex; |
| | | } |
| | | |
| | | .viewChangeBtn p { |
| | | line-height: 0.36rem; |
| | | margin-right: 0.2rem; |
| | | } |
| | | |
| | | .viewChangeBtn .imgBox { |
| | | width: 0.36rem; |
| | | height: 0.36rem; |
| | | } |
| | | |
| | | .viewChangeBtn img { |
| | | width: 100%; |
| | | height: 100%; |
| | | cursor: pointer; |
| | | } |
| | | |
| | | .legend { |
| | | display: flex; |
| | | align-items: center; |