NEZ-1925 fix:Projects编辑拓扑图时选择不同Metric会出现界面卡死现象

This commit is contained in:
zhangyu
2022-06-14 11:13:39 +08:00
parent a25022acac
commit bee63f211f
2 changed files with 34 additions and 22 deletions

View File

@@ -226,7 +226,6 @@ export default {
.enter().append('g')
.attr('class', 'node animation')
.attr('id', function (d) {
console.log(d)
return 'node' + d.id
})
.attr('style', function (d) {
@@ -477,7 +476,6 @@ export default {
.join(
enter => enter.append('g').attr('class', 'node')
.attr('id', function (child) {
console.log(child)
return 'node' + child.id
}
)
@@ -516,13 +514,11 @@ export default {
const prevParentId = d.parentId ? d.parentId[d.parentId.length - 1] : ''
simulation.stop()
nodes = nodes.filter(child => child.parentId.indexOf(d.id) === -1)
console.log(nodes, 'hide')
node = node
.data(nodes)
.join(
enter => enter.append('g').attr('class', 'node')
.attr('id', function (child) {
console.log(child)
return 'node' + child.id
})
.call(drag(simulation))
@@ -558,7 +554,6 @@ export default {
}
function render () {
console.log(node.nodes())
node.nodes().forEach(item => {
const box = d3.select(item)
const d = box.data()[0]
@@ -722,7 +717,6 @@ export default {
str += 0.05
return str + ';cursor:pointer'
}).duration(300)
console.log(svg, item, node, linkCopy)
},
graphIconLeave (item) {
const svg = d3.select('#svgHex' + this.chartId)
@@ -743,7 +737,6 @@ export default {
watch: {
'data.nodes': {
handler (n) {
console.log(n, 'data.nodes')
this.graphIconArr = []
this.data.nodes.forEach(item => {
if (this.graphIconArr.indexOf(item.type) === -1) {

View File

@@ -898,20 +898,21 @@ export default {
const children = this.$store.state.metricsList.find(item => item.value === data.value).children
resolve(children)
}).then((children) => {
const childrenCopy = JSON.parse(JSON.stringify(children))
this.metricOptions.find(item => item.label === data.label).children = childrenCopy
// if (childrenCopy.length > 100) {
// childrenCopy.splice(100, children.length)
// childrenCopy.push({
// label: 'More',
// value: false,
// parent: data.label,
// more: true
// })
// this.metricOptions.find(item => item.label === data.label).children = childrenCopy
// } else {
// this.metricOptions.find(item => item.label === data.label).children = childrenCopy
// }
let childrenCopy = JSON.parse(JSON.stringify(children))
const findChild = this.metricOptions.find(item => item.label === data.label)
if (childrenCopy.length > 100) {
childrenCopy.splice(100, childrenCopy.length)
childrenCopy.push({
label: 'More',
value: false,
parent: data.label,
more: true
})
findChild.children = childrenCopy
} else {
findChild.children = childrenCopy
}
})
})
} else if (data.more) {
@@ -920,7 +921,25 @@ export default {
const children = this.$store.state.metricsList.find(item => item.label === data.parent).children
resolve(children)
}).then((children) => {
this.metricOptions.find(item => item.label === data.parent).children = children
let childrenCopy = JSON.parse(JSON.stringify(children))
const findChild = this.metricOptions.find(item => item.label === data.parent)
if (childrenCopy.length > 100) {
childrenCopy = childrenCopy.splice(findChild.children.length, findChild.children.length + 101)
findChild.children.splice(findChild.children.length - 1, 1)
findChild.children.push(...childrenCopy)
if (findChild.children.length < children.length) {
findChild.children.push({
label: 'More',
value: false,
parent: data.parent,
more: true
})
} else {
findChild.children.splice(findChild.children.length - 1, 1)
}
} else {
findChild.children = childrenCopy
}
})
})
}