|
|
@ -52,29 +52,60 @@ Component({ |
|
|
|
getFamilyRelationshipList(params).then(({ |
|
|
|
data |
|
|
|
}) => { |
|
|
|
let resiName = data.filter(item=>item.id === this.data.resiId)[0].name |
|
|
|
let nodeList = data.map((item, index) => ({ |
|
|
|
'name': item.name, |
|
|
|
'id':index+1, |
|
|
|
'category':0, |
|
|
|
'symbolSize': item.id == this.data.resiId ? 50 : 30, |
|
|
|
'symbol':item.type == 1?'image://https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/internal/20240402/a6cdfe6f699040f58fd8b2c10486b41d.png': item.houseHolderRel == '丈夫' ? 'image://https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/internal/20240402/1e21790833b04e9abe61e2a8f40446cb.png' : 'image://https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/internal/20240402/1e21790833b04e9abe61e2a8f40446cb.png', |
|
|
|
// 'data': {
|
|
|
|
// id: item.id,
|
|
|
|
// type: item.type,
|
|
|
|
// name: item.name
|
|
|
|
// },
|
|
|
|
})) |
|
|
|
let index = data.findIndex(item => item.id == this.data.resiId); |
|
|
|
if (index !== -1) { |
|
|
|
const [item] = data.splice(index, 1); |
|
|
|
data.unshift(item); |
|
|
|
} |
|
|
|
let nodeList = data.map((item, index) => { |
|
|
|
let symbolUrl = ''; |
|
|
|
if (item.type === 1) { |
|
|
|
symbolUrl = 'image://https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/internal/20240402/a6cdfe6f699040f58fd8b2c10486b41d.png'; |
|
|
|
} else { |
|
|
|
// 如果 type 不等于 1,则根据 gender 进行判断
|
|
|
|
if (item.gender === '1') { |
|
|
|
// 如果 gender 等于 1,则根据 age 进行进一步的判断
|
|
|
|
symbolUrl = item.age > 18 && item.age < 60 ? |
|
|
|
'image://https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/internal/20240402/1e21790833b04e9abe61e2a8f40446cb.png' : |
|
|
|
item.age < 18 ? |
|
|
|
'image://https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/internal/20240402/62c2b6a1ce834f8dae081b562b2579b9.png' : |
|
|
|
item.age > 60 ? |
|
|
|
'image://https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/internal/20240402/bd586a4e7d0f4b3aa68c79067dfe1428.png' : |
|
|
|
''; |
|
|
|
} else if (item.gender === '2') { |
|
|
|
// 如果 gender 等于 2,则根据 age 进行进一步的判断
|
|
|
|
symbolUrl = item.age > 18 && item.age < 60 ? |
|
|
|
'image://https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/internal/20240402/3b44e3495dcd4d96a3c07baad1bd7c5e.png' : |
|
|
|
item.age < 18 ? |
|
|
|
'image://https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/internal/20240402/0c38251bba644a6b8e4a925aea74c9a7.png' : |
|
|
|
item.age > 60 ? |
|
|
|
'image://https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/internal/20240402/2465ff7633a94413bf4ed2aa778c2765.png' : |
|
|
|
''; |
|
|
|
} |
|
|
|
} |
|
|
|
return { |
|
|
|
'name': item.name, |
|
|
|
'id': index + 1, |
|
|
|
'category': 0, |
|
|
|
'symbolSize': item.id == this.data.resiId ? 50 : 30, |
|
|
|
'symbol': symbolUrl, |
|
|
|
label: { |
|
|
|
"position": "bottom" |
|
|
|
} |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
let links = data.map((item, index) => ({ |
|
|
|
"source": 0, |
|
|
|
"target": index+1, |
|
|
|
"name": item.houseHolderRel||'暂不清楚', |
|
|
|
"label": { |
|
|
|
"align": "center", |
|
|
|
"fontSize": 12 |
|
|
|
"fontSize": 12, |
|
|
|
"color":"#9cbbf9" |
|
|
|
}, |
|
|
|
"lineStyle": { |
|
|
|
"color": "#ff7d18" |
|
|
|
"color": "#9cbbf9" |
|
|
|
} |
|
|
|
})) |
|
|
|
links.splice(links.length-1,1) |
|
|
@ -82,16 +113,11 @@ Component({ |
|
|
|
"name":item.houseHolderRel||'暂不清楚', |
|
|
|
"id":index+1, |
|
|
|
"itemStyle": { |
|
|
|
"color": 'red' |
|
|
|
"color": '#9cbbf9' |
|
|
|
}, |
|
|
|
"lineStyle": { |
|
|
|
"color": "#ff7d18" |
|
|
|
} |
|
|
|
})) |
|
|
|
|
|
|
|
console.log(nodeList,links,categories); |
|
|
|
console.log(JSON.stringify(nodeList)); |
|
|
|
console.log(JSON.stringify(links)); |
|
|
|
console.log(JSON.stringify(categories)); |
|
|
|
|
|
|
|
var option = { |
|
|
|
|
|
|
@ -103,10 +129,24 @@ Component({ |
|
|
|
series: [{ |
|
|
|
type: 'graph', |
|
|
|
layout: 'force', |
|
|
|
symbolSize: 10, |
|
|
|
// symbolSize: 10,
|
|
|
|
force: { |
|
|
|
repulsion: 80, |
|
|
|
gravity: 0, |
|
|
|
edgeLength: 100,//线条长度
|
|
|
|
layoutAnimation: true, |
|
|
|
}, |
|
|
|
draggable: true, |
|
|
|
roam: false, |
|
|
|
nodeScaleRatio: 0, |
|
|
|
focusNodeAdjacency: false, |
|
|
|
lineStyle: { |
|
|
|
normal: { |
|
|
|
opacity: 0.5, |
|
|
|
width: 1.5, |
|
|
|
curveness: 0 |
|
|
|
} |
|
|
|
}, |
|
|
|
categories: categories, |
|
|
|
edgeSymbol: ['', 'arrow'], |
|
|
|
// edgeSymbolSize: [80, 10],
|
|
|
@ -124,10 +164,7 @@ Component({ |
|
|
|
label: { |
|
|
|
show: true |
|
|
|
}, |
|
|
|
force: { |
|
|
|
repulsion: 2000, |
|
|
|
edgeLength: 120 |
|
|
|
}, |
|
|
|
|
|
|
|
data: nodeList, |
|
|
|
links: links |
|
|
|
}] |
|
|
|