2021-09-16 18:42:11 +08:00
|
|
|
<template>
|
2021-10-10 17:04:23 +08:00
|
|
|
<div class="main-shadow" style="z-index:-1" :style="styleInfo">
|
2021-10-09 00:02:06 +08:00
|
|
|
<!-- {{ curComponent }}-->
|
|
|
|
</div>
|
2021-09-16 18:42:11 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapState } from 'vuex'
|
|
|
|
export default {
|
|
|
|
replace: true,
|
|
|
|
name: 'Shadow',
|
|
|
|
computed: {
|
2021-09-22 16:51:41 +08:00
|
|
|
styleInfo() {
|
|
|
|
// console.log('styleInfo==>')
|
|
|
|
// debugger
|
|
|
|
// console.log('dragComponentInfo==>' + this.dragComponentInfo.shadowStyle.x)
|
|
|
|
let left = 0
|
|
|
|
let top = 0
|
|
|
|
let width = 0
|
|
|
|
let height = 0
|
2021-10-09 00:02:06 +08:00
|
|
|
// if (this.dragComponentInfo && !this.dragComponentInfo.auxiliaryMatrix) {
|
2021-09-22 16:51:41 +08:00
|
|
|
if (this.dragComponentInfo) {
|
2021-10-10 17:04:23 +08:00
|
|
|
// console.log('shadowDrag=')
|
2021-09-22 16:51:41 +08:00
|
|
|
// 组件移入
|
2021-10-09 00:02:06 +08:00
|
|
|
if (this.dragComponentInfo.auxiliaryMatrix) {
|
|
|
|
left = (this.dragComponentInfo.x - 1) * this.curCanvasScale.matrixStyleWidth
|
|
|
|
top = (this.dragComponentInfo.y - 1) * this.curCanvasScale.matrixStyleHeight
|
|
|
|
|
|
|
|
width = this.dragComponentInfo.sizex * this.curCanvasScale.matrixStyleWidth
|
|
|
|
height = this.dragComponentInfo.sizey * this.curCanvasScale.matrixStyleHeight
|
|
|
|
} else {
|
|
|
|
left = this.dragComponentInfo.shadowStyle.x
|
|
|
|
top = this.dragComponentInfo.shadowStyle.y
|
|
|
|
width = this.dragComponentInfo.style.width
|
|
|
|
height = this.dragComponentInfo.style.height
|
|
|
|
}
|
|
|
|
|
2021-09-22 16:51:41 +08:00
|
|
|
// console.log('left:' + left + 'top:' + top + 'width:' + width + 'height:' + height)
|
|
|
|
} else {
|
2021-10-09 00:02:06 +08:00
|
|
|
// temp 临时测试
|
|
|
|
// left = this.curComponent.style.left * this.curCanvasScale.scaleWidth / 100
|
|
|
|
// top = this.curComponent.style.top * this.curCanvasScale.scaleHeight / 100
|
|
|
|
left = (this.curComponent.x - 1) * this.curCanvasScale.matrixStyleWidth
|
|
|
|
top = (this.curComponent.y - 1) * this.curCanvasScale.matrixStyleHeight
|
|
|
|
|
|
|
|
width = this.curComponent.style.width * this.curCanvasScale.scalePointWidth
|
|
|
|
height = this.curComponent.style.height * this.curCanvasScale.scalePointHeight
|
2021-09-22 16:51:41 +08:00
|
|
|
// console.log('curComponent left:' + left + 'top:' + top + 'width:' + width + 'height:' + height)
|
|
|
|
}
|
2021-09-16 18:42:11 +08:00
|
|
|
// 当前默认为自适应
|
2021-10-09 00:02:06 +08:00
|
|
|
// 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
|
|
|
|
// }
|
2021-09-22 18:44:30 +08:00
|
|
|
|
|
|
|
// 防止阴影区超出边界
|
|
|
|
const xGap = left + width - this.canvasWidth
|
|
|
|
// console.log('canvasWidth:' + this.canvasWidth + ';xGap:' + xGap)
|
|
|
|
if (xGap > 0) {
|
|
|
|
left = left - xGap
|
|
|
|
}
|
2021-09-16 18:42:11 +08:00
|
|
|
const style = {
|
|
|
|
transform: `translate(${left}px, ${top}px) rotate(0deg)`,
|
|
|
|
width: width + 'px',
|
2021-10-11 23:27:48 +08:00
|
|
|
height: height + 'px'
|
2021-09-16 18:42:11 +08:00
|
|
|
}
|
2021-09-17 10:51:22 +08:00
|
|
|
// console.log('style=>' + JSON.stringify(style))
|
2021-09-22 16:51:41 +08:00
|
|
|
// 记录外部拖拽进入仪表板时阴影区域宽高
|
|
|
|
if (this.dragComponentInfo) {
|
|
|
|
this.recordShadowStyle(left, top, width, height)
|
|
|
|
}
|
2021-09-16 18:42:11 +08:00
|
|
|
return style
|
|
|
|
},
|
2021-09-22 16:51:41 +08:00
|
|
|
dragComponentInfo() {
|
|
|
|
return this.$store.state.dragComponentInfo
|
|
|
|
},
|
2021-09-22 18:44:30 +08:00
|
|
|
canvasWidth() {
|
|
|
|
const scaleWidth = this.curCanvasScale.scaleWidth / 100
|
|
|
|
return this.canvasStyleData.width * scaleWidth
|
|
|
|
},
|
2021-09-16 18:42:11 +08:00
|
|
|
...mapState([
|
|
|
|
'curComponent',
|
|
|
|
'editor',
|
|
|
|
'curCanvasScale',
|
|
|
|
'canvasStyleData',
|
|
|
|
'linkageSettingStatus'
|
|
|
|
])
|
2021-09-22 16:51:41 +08:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
recordShadowStyle(x, y, width, height) {
|
|
|
|
this.dragComponentInfo.shadowStyle.width = this.scaleW(width)
|
|
|
|
this.dragComponentInfo.shadowStyle.x = this.scaleW(x)
|
|
|
|
this.dragComponentInfo.shadowStyle.height = this.scaleH(height)
|
|
|
|
this.dragComponentInfo.shadowStyle.y = this.scaleH(y)
|
|
|
|
},
|
|
|
|
scaleH(h) {
|
2021-10-09 00:02:06 +08:00
|
|
|
return h / this.curCanvasScale.scalePointHeight
|
2021-09-22 16:51:41 +08:00
|
|
|
},
|
|
|
|
scaleW(w) {
|
2021-10-09 00:02:06 +08:00
|
|
|
return w / this.curCanvasScale.scalePointWidth
|
2021-09-22 16:51:41 +08:00
|
|
|
}
|
2021-09-16 18:42:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<style scoped>
|
2021-10-10 17:04:23 +08:00
|
|
|
.main-shadow{
|
2021-10-11 23:27:48 +08:00
|
|
|
transition: 0.2s;
|
|
|
|
opacity: 0.4;
|
|
|
|
background: #409eff;
|
|
|
|
position: absolute;
|
2021-10-10 17:04:23 +08:00
|
|
|
}
|
2021-09-16 18:42:11 +08:00
|
|
|
|
|
|
|
</style>
|