refactor: 视图矩阵和悬浮相互切换显示优化

This commit is contained in:
wangjiahao 2021-10-10 20:58:22 +08:00
parent 0a49003cdf
commit e2626d0423
3 changed files with 27 additions and 7 deletions

View File

@ -21,7 +21,7 @@
@mouseenter="enter" @mouseenter="enter"
@mouseleave="leave" @mouseleave="leave"
> >
<edit-bar v-if="active||linkageSettingStatus" style="transform: translateZ(10px)" :active-model="'edit'" :element="element" @showViewDetails="showViewDetails" @amRemoveItem="amRemoveItem" @amAddItem="amAddItem" /> <edit-bar v-if="active||linkageSettingStatus" style="transform: translateZ(10px)" :active-model="'edit'" :element="element" @showViewDetails="showViewDetails" @amRemoveItem="amRemoveItem" @amAddItem="amAddItem" @resizeView="resizeView" />
<div v-if="resizing" style="transform: translateZ(11px);position: absolute; z-index: 3" :style="resizeShadowStyle" /> <div v-if="resizing" style="transform: translateZ(11px);position: absolute; z-index: 3" :style="resizeShadowStyle" />
<div <div
v-for="(handlei, indexi) in actualHandles" v-for="(handlei, indexi) in actualHandles"
@ -1680,6 +1680,9 @@ export default {
}, },
amRemoveItem() { amRemoveItem() {
this.$emit('amRemoveItem') this.$emit('amRemoveItem')
},
resizeView() {
this.$emit('resizeView')
} }
} }

View File

@ -39,6 +39,7 @@ import { mapState } from 'vuex'
import bus from '@/utils/bus' import bus from '@/utils/bus'
import SettingMenu from '@/components/canvas/components/Editor/SettingMenu' import SettingMenu from '@/components/canvas/components/Editor/SettingMenu'
import LinkageField from '@/components/canvas/components/Editor/LinkageField' import LinkageField from '@/components/canvas/components/Editor/LinkageField'
import { deepCopy } from '@/components/canvas/utils/utils'
export default { export default {
components: { SettingMenu, LinkageField }, components: { SettingMenu, LinkageField },
@ -126,10 +127,6 @@ export default {
}, },
auxiliaryMatrixChange() { auxiliaryMatrixChange() {
if (this.curComponent.auxiliaryMatrix) { if (this.curComponent.auxiliaryMatrix) {
this.curComponent.style.left = (this.curComponent.x - 1) * this.curCanvasScale.matrixStyleOriginWidth
this.curComponent.style.top = (this.curComponent.y - 1) * this.curCanvasScale.matrixStyleOriginHeight
this.curComponent.style.width = this.curComponent.sizex * this.curCanvasScale.matrixStyleOriginWidth
this.curComponent.style.height = this.curComponent.sizey * this.curCanvasScale.matrixStyleOriginHeight
this.curComponent.auxiliaryMatrix = false this.curComponent.auxiliaryMatrix = false
this.$emit('amRemoveItem') this.$emit('amRemoveItem')
} else { } else {
@ -140,9 +137,29 @@ export default {
this.curComponent.auxiliaryMatrix = true this.curComponent.auxiliaryMatrix = true
this.$emit('amAddItem') this.$emit('amAddItem')
} }
setTimeout(() => {
this.recordMatrixCurShadowStyle()
}, 50)
this.$store.state.styleChangeTimes++ this.$store.state.styleChangeTimes++
bus.$emit('auxiliaryMatrixChange') bus.$emit('auxiliaryMatrixChange')
}, },
//
recordMatrixCurShadowStyle() {
// debugger
const left = (this.curComponent.x - 1) * this.curCanvasScale.matrixStyleWidth
const top = (this.curComponent.y - 1) * this.curCanvasScale.matrixStyleHeight
const width = this.curComponent.sizex * this.curCanvasScale.matrixStyleWidth
const height = this.curComponent.sizey * this.curCanvasScale.matrixStyleHeight
const style = {
left: left,
top: top,
width: width,
height: height
}
this.$store.commit('setShapeStyle', style)
// resize
this.$emit('resizeView')
},
edit() { edit() {
// //
this.$store.dispatch('panel/setComponentDataTemp', JSON.stringify(this.componentData)) this.$store.dispatch('panel/setComponentDataTemp', JSON.stringify(this.componentData))

View File

@ -13,9 +13,9 @@
@scroll="canvasScroll" @scroll="canvasScroll"
> >
<!-- 网格线 --> <!-- 网格线 -->
<!-- <Grid v-if="canvasStyleData.auxiliaryMatrix&&!linkageSettingStatus" :matrix-style="matrixStyle" />--> <!-- <Grid v-if="canvasStyleData.auxiliaryMatrix&&!linkageSettingStatus" :matrix-style="matrixStyle" />-->
<!-- positionBox:{{positionBoxInfo}}--> <!-- positionBox:{{positionBoxInfo}}-->
<!-- <PGrid :position-box="positionBoxInfoArray" :matrix-style="matrixStyle" />--> <PGrid :position-box="positionBoxInfoArray" :matrix-style="matrixStyle" />
<!-- 仪表板联动清除按钮--> <!-- 仪表板联动清除按钮-->
<canvas-opt-bar /> <canvas-opt-bar />