NEZ-2563 fix:dashboard 图表位置调整不能正确保存

This commit is contained in:
zyh
2023-02-15 17:46:15 +08:00
parent 2e10c72cee
commit 663ffd8f74
3 changed files with 16 additions and 10 deletions

View File

@@ -346,6 +346,9 @@ export default {
} }
}, },
onScroll (scrollTop = 0, groupTop = 0) { onScroll (scrollTop = 0, groupTop = 0) {
if (!this.variablesInit) { // 变量未加载完成 不请求数据
return
}
const self = this const self = this
if (this.scrollTopTimer) { if (this.scrollTopTimer) {
clearTimeout(this.scrollTopTimer) clearTimeout(this.scrollTopTimer)
@@ -557,7 +560,6 @@ export default {
if (!this.panelLock) { if (!this.panelLock) {
return false return false
} }
this.copyDataList = JSON.parse(JSON.stringify(this.tempList))
for (let i = 0; i < this.copyDataList.length; i++) { for (let i = 0; i < this.copyDataList.length; i++) {
const item = this.copyDataList[i] const item = this.copyDataList[i]
if ((this.$loadsh.get(this.showHidden[item.id], 'visibility') && this.$loadsh.get(this.showHidden[item.id], 'visibility') === 'hidden') && item.id !== -2) { if ((this.$loadsh.get(this.showHidden[item.id], 'visibility') && this.$loadsh.get(this.showHidden[item.id], 'visibility') === 'hidden') && item.id !== -2) {
@@ -565,11 +567,11 @@ export default {
i-- i--
} }
} }
// this.tempList.forEach(item => { this.tempList.forEach(item => {
// if ((!this.$loadsh.get(this.showHidden[item.id], 'visibility') || this.$loadsh.get(this.showHidden[item.id], 'visibility') === 'show') && item.id !== -2 && !this.copyDataList.find(chart => chart.id === item.id)) { if ((!this.$loadsh.get(this.showHidden[item.id], 'visibility') || this.$loadsh.get(this.showHidden[item.id], 'visibility') === 'show') && item.id !== -2 && !this.copyDataList.find(chart => chart.id === item.id)) {
// this.copyDataList.push(item) this.copyDataList.push(item)
// } }
// }) })
this.onScroll(this.scrollTop) this.onScroll(this.scrollTop)
}, },
@@ -716,6 +718,7 @@ export default {
if (!flag) { if (!flag) {
this.tempList.forEach(item => { this.tempList.forEach(item => {
if (!this.copyDataList.find(chart => chart.id === item.id)) { if (!this.copyDataList.find(chart => chart.id === item.id)) {
item.y -= 0.03
this.copyDataList.push(item) this.copyDataList.push(item)
} }
}) })
@@ -746,7 +749,7 @@ export default {
const position = getLayoutPosition(n) const position = getLayoutPosition(n)
this.$store.commit('setChartLastPosition', position) this.$store.commit('setChartLastPosition', position)
} }
let tempList = n.map(item => { const tempList = n.map(item => {
let param = '' let param = ''
let height = '' let height = ''
if (this.isPhone && item.type !== 'group') { if (this.isPhone && item.type !== 'group') {
@@ -809,7 +812,6 @@ export default {
this.compareVariables() this.compareVariables()
this.repeatVariableFn() this.repeatVariableFn()
tempList = null
setTimeout(() => { setTimeout(() => {
this.gridLayoutShow = true this.gridLayoutShow = true
if (!this.isGroup) { if (!this.isGroup) {

View File

@@ -860,7 +860,9 @@ export default {
}, },
getPanelData () { getPanelData () {
this.variablesInit = true this.variablesInit = true
this.$refs.chartList.onScroll(this.scrollbarWrap.scrollTop) this.$nextTick(() => {
this.$refs.chartList.onScroll(this.scrollbarWrap.scrollTop)
})
} }
}, },
mounted () { mounted () {

View File

@@ -1118,7 +1118,9 @@ export default {
}, },
getPanelData () { getPanelData () {
this.variablesInit = true this.variablesInit = true
this.$refs.chartList.onScroll(this.scrollbarWrap.scrollTop) this.$nextTick(() => {
this.$refs.chartList.onScroll(this.scrollbarWrap.scrollTop)
})
} }
}, },
created () { created () {