CN-240 feat: 实体列表、详情细节完善

This commit is contained in:
chenjinsong
2022-01-05 23:56:27 +08:00
parent db27d6213f
commit 6e9b208818
24 changed files with 403 additions and 174 deletions

View File

@@ -36,7 +36,9 @@ export default {
data () {
return {
anchorPoints: [], // { id, label, top, height }
top: 0
top: 0,
scrollHeight: 0,
clientHeight: 0
}
},
setup (props, ctx) {
@@ -73,6 +75,9 @@ export default {
chartLoaded (chartList) {
this.anchorPoints = []
let anchorPoints = []
const panelDom = document.querySelector('#cn-panel')
this.scrollHeight = panelDom.scrollHeight
this.clientHeight = panelDom.clientHeight
chartList.forEach(chart => {
if (chart.params.anchorPoint) {
const dom = document.querySelector(`#${chart.params.anchorPoint}`)
@@ -128,11 +133,15 @@ export default {
},
currentAnchor () {
let currentAnchor = null
this.anchorPoints.forEach(anchor => {
if (anchor.top <= this.top) {
currentAnchor = anchor
}
})
if (this.top + this.clientHeight === this.scrollHeight) {
currentAnchor = this.anchorPoints[this.anchorPoints.length - 1]
} else {
this.anchorPoints.forEach(anchor => {
if (anchor.top <= this.top) {
currentAnchor = anchor
}
})
}
return currentAnchor
}
}