| | |
| | | // window.addEventListener("resize", this.relation); |
| | | this.innt(); |
| | | }, |
| | | onLoad(options) { |
| | | this.searchKey = options.keyword; |
| | | }, |
| | | methods: { |
| | | getData() { |
| | | getPersonList({ |
| | | keywords: "", //搜索框检索 |
| | | name: "", //姓名 |
| | | alias: "", //别名 |
| | | nativePlace: "", //机关 |
| | | tagId: null, //职业id |
| | | official: "", //职官 |
| | | genderType: null, //性别 |
| | | dynasty: null, //朝代名 |
| | | dynastyId: null, //朝代id |
| | | institution: "", //机构 |
| | | bookId: null, //来源id |
| | | page: 1, |
| | | pageSize: 100 |
| | | getFuzzySearch({ |
| | | keyword: this.searchKey ? this.searchKey : "" |
| | | }).then((res) => { |
| | | console.log(res); |
| | | this.nodes = []; |
| | | this.relationships = []; |
| | | if (res.success && res.list) { |
| | | res.list.forEach((item, index) => { |
| | | let exists1 = this.nodes.some( |
| | | (node) => node.id === item.identifier1 && node.name === item.name1 |
| | | ); |
| | | let exists2 = this.nodes.some( |
| | | (node) => node.id === item.identifier2 && node.name === item.name2 |
| | | ); |
| | | // 证明不存在 |
| | | if (exists1 !== true) { |
| | | this.nodes.push({ |
| | | name: item.name1, |
| | | id: item.identifier1 |
| | | }); |
| | | } |
| | | if (exists2 !== true) { |
| | | this.nodes.push({ |
| | | name: item.name2, |
| | | id: item.identifier2 |
| | | }); |
| | | } |
| | | let obj = { |
| | | source: item.name1, |
| | | target: item.name2, |
| | | relation: item.relationName || "" // 如果存在 relationName 字段则使用,否则为空字符串 |
| | | }; |
| | | this.relationships.push(obj); |
| | | }); |
| | | } |
| | | this.relation(); |
| | | }); |
| | | }, |
| | | // 关系图谱 |
| | |
| | | x: Math.random() * 2000, // 设置随机x坐标位置 |
| | | y: Math.random() * 600, // 设置随机y坐标位置 |
| | | itemStyle: { |
| | | color: getColorByIndex(), // 可以根据索引设置不同的颜色 |
| | | color: "#eae0eb", // 可以根据索引设置不同的颜色 |
| | | borderWidth: BorderWidth, |
| | | borderColor: getColorByIndex() |
| | | borderColor: "#996f9f" |
| | | } |
| | | }; |
| | | }); |
| | |
| | | var color = "#" + hexR + hexG + hexB; |
| | | return color; |
| | | } |
| | | console.log(links); |
| | | console.log(nodeData); |
| | | var option; |
| | | option = { |
| | | title: { |
| | |
| | | opacity: 0.9, |
| | | width: 2, |
| | | curveness: 0.3 |
| | | }, |
| | | emphasis: { |
| | | focus: "adjacency", |
| | | lineStyle: { |
| | | width: 10 |
| | | } |
| | | } |
| | | } |
| | | ] |
| | |
| | | // 基础搜索 |
| | | onSearch(val) { |
| | | this.searchKey = val.text; |
| | | getFuzzySearch({ keyword: val.text }).then((res) => { |
| | | if (res.list) { |
| | | this.nodes = []; |
| | | this.relationships = []; |
| | | res.list.forEach((item, index) => { |
| | | let exists1 = this.nodes.some( |
| | | (node) => node.id === item.identifier1 && node.name === item.name1 |
| | | ); |
| | | let exists2 = this.nodes.some( |
| | | (node) => node.id === item.identifier2 && node.name === item.name2 |
| | | ); |
| | | // 证明不存在 |
| | | if (exists1 !== true) { |
| | | this.nodes.push({ |
| | | name: item.name1, |
| | | id: item.identifier1 |
| | | }); |
| | | } |
| | | if (exists2 !== true) { |
| | | this.nodes.push({ |
| | | name: item.name2, |
| | | id: item.identifier2 |
| | | }); |
| | | } |
| | | let obj = { |
| | | source: item.name1, |
| | | target: item.name2, |
| | | relation: item.relationName || "" // 如果存在 relationName 字段则使用,否则为空字符串 |
| | | }; |
| | | this.relationships.push(obj); |
| | | }); |
| | | } |
| | | this.relation(); |
| | | }); |
| | | this.getData(); |
| | | }, |
| | | // 高级搜索 |
| | | onSubmit(val) { |