feat: 仪表板窗口变化 重置边界

This commit is contained in:
wangjiahao 2021-06-22 18:20:55 +08:00
parent aa38a4be51
commit aa8317b15a

View File

@ -101,6 +101,7 @@ import Area from './Area'
import eventBus from '@/components/canvas/utils/eventBus'
import Grid from './Grid'
import { changeStyleWithScale } from '@/components/canvas/utils/translate'
import { deepCopy } from '@/components/canvas/utils/utils'
export default {
components: { Shape, ContextMenu, MarkLine, Area, Grid, DeDrag },
@ -128,8 +129,10 @@ export default {
height: 0,
isShowArea: false,
conditions: [],
scaleWidth: 100,
scaleHeight: 100,
// 3
scaleWidth: 300,
scaleHeight: 300,
timer: null,
needToChangeHeight: [
'top',
@ -156,7 +159,10 @@ export default {
customStyleHistory: null,
showDrag: true,
vLine: [],
hLine: []
hLine: [],
changeIndex: 0,
timeMachine: null,
outStyleOld: null
}
},
computed: {
@ -165,7 +171,6 @@ export default {
width: this.format(this.canvasStyleData.width, this.scaleWidth) + 'px',
height: this.format(this.canvasStyleData.height, this.scaleHeight) + 'px'
}
// console.log('customStyle=>' + JSON.stringify(style))
if (this.canvasStyleData.openCommonStyle) {
if (this.canvasStyleData.panel.backgroundType === 'image' && this.canvasStyleData.panel.imageUrl) {
@ -180,6 +185,8 @@ export default {
}
}
}
// console.log('customStyle=>' + JSON.stringify(style) + JSON.stringify(this.canvasStyleData))
return style
},
panelInfo() {
@ -194,7 +201,7 @@ export default {
},
watch: {
customStyle: {
handler(newVal, oldVla) {
handler(newVal) {
//
// if (oldVla && newVal !== oldVla) {
// this.showDrag = false
@ -206,12 +213,21 @@ export default {
outStyle: {
handler(newVal, oldVla) {
this.changeScale()
console.log('newVal:' + JSON.stringify(newVal) + 'oldVla:' + JSON.stringify(this.outStyleOld))
if (this.outStyleOld && (newVal.width > this.outStyleOld.width || newVal.height > this.outStyleOld.height)) {
this.resizeParentBounds()
}
this.outStyleOld = deepCopy(newVal)
},
deep: true
},
canvasStyleData: {
handler(newVal, oldVla) {
this.changeScale()
//
if (this.changeIndex++ > 0) {
this.resizeParentBounds()
}
// this.changeScale()
},
deep: true
},
@ -509,6 +525,24 @@ export default {
const { vLine, hLine } = params
this.vLine = vLine
this.hLine = hLine
},
resizeParentBounds() {
this.destroyTimeMachine()
this.changeIndex++
this.parentBoundsChange(this.changeIndex)
},
parentBoundsChange(index) {
this.timeMachine = setTimeout(() => {
if (index === this.changeIndex) {
this.showDrag = false
this.$nextTick(() => (this.showDrag = true))
}
this.destroyTimeMachine()
}, 500)
},
destroyTimeMachine() {
this.timeMachine && clearTimeout(this.timeMachine)
this.timeMachine = null
}
}
}