fix:修改 block 默认高度的问题

This commit is contained in:
zhangyu
2022-01-25 18:43:16 +08:00
parent fa52e1ec4a
commit 9778665d04
3 changed files with 28 additions and 15 deletions

View File

@@ -45,7 +45,7 @@ import { ref } from 'vue'
import { panelTypeAndRouteMapping } from '@/utils/constants' import { panelTypeAndRouteMapping } from '@/utils/constants'
import { api, getPanelList, getChartList } from '@/utils/api' import { api, getPanelList, getChartList } from '@/utils/api'
import { getNowTime } from '@/utils/date-util' import { getNowTime } from '@/utils/date-util'
import {getGroupHeight, getTypeCategory} from "@/views/charts/charts/tools"; import { getGroupHeight, getTypeCategory } from '@/views/charts/charts/tools'
export default { export default {
name: 'Panel', name: 'Panel',
@@ -119,13 +119,19 @@ export default {
chart.params = { chart.params = {
collpase: false collpase: false
} }
chart.h = getGroupHeight(chart.children) + 2 chart.h = getGroupHeight(chart.children) + 1.5
if (chart.params.collpase) { if (chart.params.collpase) {
chart.h = 1 chart.h = 1
} }
} }
if (chart.type === 95) { if (chart.type === 95) {
chart.h += 0 let sumGroup = 0
chart.children.forEach(item => {
if (item.type === 94) {
sumGroup++
}
})
chart.h += sumGroup * 0.5
} }
if (!this.$_.isEmpty(chart.children)) { if (!this.$_.isEmpty(chart.children)) {
chart.children.forEach(c => { chart.children.forEach(c => {

View File

@@ -121,7 +121,7 @@ export default {
if (item.params.collpase) { if (item.params.collpase) {
item.h = 1 item.h = 1
} else { } else {
item.h = getGroupHeight(item.children) + 1 item.h = getGroupHeight(item.children) + 1.5
} }
} }
}) })
@@ -129,12 +129,19 @@ export default {
this.emitter.emit('groupParentCalcHeight', { chart, childrenList: this.copyDataList }) this.emitter.emit('groupParentCalcHeight', { chart, childrenList: this.copyDataList })
}, },
groupParentCalcHeight (chart, childrenList) { groupParentCalcHeight (chart, childrenList) {
console.log(chart, childrenList)
setTimeout(() => { setTimeout(() => {
const parent = this.copyDataList.find(chartitem => chartitem.id === chart.parent.id) const parent = this.copyDataList.find(chartitem => chartitem.id === chart.parent.id)
const children = parent.children.find(item => item.id === chart.id) const children = parent.children.find(item => item.id === chart.id)
children.h = chart.h children.h = chart.h
children.params = chart.params children.params = chart.params
parent.h = getGroupHeight(childrenList) + 2 let sumGroup = 0
childrenList.forEach(item => {
if (item.type === 94) {
sumGroup++
}
})
parent.h = getGroupHeight(childrenList) + sumGroup * 0.5
this.copyDataList = [...this.copyDataList] this.copyDataList = [...this.copyDataList]
}, 100) }, 100)
} }

View File

@@ -24,16 +24,16 @@ export default {
} }
}, },
watch: { watch: {
'chartInfo.children': { // 'chartInfo.children': {
immediate: true, // immediate: true,
deep: true, // deep: true,
handle (n) { // handle (n) {
if (!this.firstShow) { // if (!this.firstShow) {
this.dataList = JSON.parse(JSON.stringify(this.chartInfo.children)) // this.dataList = JSON.parse(JSON.stringify(this.chartInfo.children))
this.firstShow = true // this.firstShow = true
} // }
} // }
} // }
}, },
mounted () { mounted () {
this.dataList = JSON.parse(JSON.stringify(this.chartInfo.children)) this.dataList = JSON.parse(JSON.stringify(this.chartInfo.children))