refactor:仪表板矩形,文字组件,间隙等默认样

This commit is contained in:
wangjiahao 2021-09-17 17:48:58 +08:00
parent 24589b12aa
commit 26e2110434
6 changed files with 84 additions and 3 deletions

View File

@ -0,0 +1,69 @@
<template>
<div style="z-index:-1" :style="style" />
</template>
<script>
import { mapState } from 'vuex'
export default {
replace: true,
name: 'MoveInShadow',
props: {
w: {
type: Number,
required: true
},
h: {
type: Number,
required: true
},
x: {
type: Number,
required: true
},
y: {
type: Number,
required: true
},
z: {
type: Number,
required: true
}
},
computed: {
style() {
//
let left = this.x
let top = this.y
let width = this.w
let height = this.h
if (this.canvasStyleData.auxiliaryMatrix) {
left = Math.round(left / this.curCanvasScale.matrixStyleWidth) * this.curCanvasScale.matrixStyleWidth
width = Math.round(width / this.curCanvasScale.matrixStyleWidth) * this.curCanvasScale.matrixStyleWidth
top = Math.round(top / this.curCanvasScale.matrixStyleHeight) * this.curCanvasScale.matrixStyleHeight
height = Math.round(height / this.curCanvasScale.matrixStyleHeight) * this.curCanvasScale.matrixStyleHeight
}
const style = {
transform: `translate(${left}px, ${top}px) rotate(0deg)`,
width: width + 'px',
height: height + 'px',
opacity: 0.4,
background: 'gray',
position: 'absolute'
}
// console.log('style=>' + JSON.stringify(style))
return style
},
...mapState([
'curComponent',
'editor',
'curCanvasScale',
'canvasStyleData',
'linkageSettingStatus'
])
}
}
</script>
<style scoped>
</style>

View File

@ -1,5 +1,5 @@
<template> <template>
<div style="z-index:-1" :style="style" /> <div style="z-index:1" :style="style" />
</template> </template>
<script> <script>

View File

@ -670,7 +670,7 @@ export default {
} }
.gap_class{ .gap_class{
padding:5px; padding:3px;
} }
// //

View File

@ -58,7 +58,9 @@ const data = {
// 和当前组件联动的目标组件 // 和当前组件联动的目标组件
targetLinkageInfo: [], targetLinkageInfo: [],
// 当前仪表板联动 下钻 上卷等信息 // 当前仪表板联动 下钻 上卷等信息
nowPanelTrackInfo: {} nowPanelTrackInfo: {},
// 拖拽的组件信息
dragComponentInfo: null
}, },
mutations: { mutations: {
...animation.mutations, ...animation.mutations,
@ -254,6 +256,12 @@ const data = {
} }
}) })
// state.styleChangeTimes++ // state.styleChangeTimes++
},
setDragComponentInfo(state, dragComponentInfo) {
state.dragComponentInfo = dragComponentInfo
},
clearDragComponentInfo(state) {
state.dragComponentInfo = null
} }
}, },
modules: { modules: {

View File

@ -105,11 +105,13 @@ export default {
}) })
}, },
handleDragStart(node, ev) { handleDragStart(node, ev) {
this.$store.commit('setDragComponentInfo', node)
ev.dataTransfer.effectAllowed = 'copy' ev.dataTransfer.effectAllowed = 'copy'
const dataTrans = { const dataTrans = {
type: 'view', type: 'view',
id: node.data.id id: node.data.id
} }
ev.dataTransfer.setData('componentInfo', JSON.stringify(dataTrans)) ev.dataTransfer.setData('componentInfo', JSON.stringify(dataTrans))
}, },

View File

@ -440,6 +440,7 @@ export default {
return data return data
}, },
handleDrop(e) { handleDrop(e) {
this.$store.commit('clearDragComponentInfo')
this.currentDropElement = e this.currentDropElement = e
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
@ -509,6 +510,7 @@ export default {
}, },
handleDragOver(e) { handleDragOver(e) {
console.log('handleDragOver=>x:' + this.getPositionX(e.layerX) + ';y=' + this.getPositionY(e.layerY) + e.dataTransfer.getData('componentInfo'))
e.preventDefault() e.preventDefault()
e.dataTransfer.dropEffect = 'copy' e.dataTransfer.dropEffect = 'copy'
}, },