refactor:仪表板编辑时,文字组件、矩形组件、过滤组件样式设置面板强制在画布区域内

This commit is contained in:
wangjiahao 2021-08-25 17:11:52 +08:00
parent f6b99f8128
commit 01cab0770f
4 changed files with 56 additions and 8 deletions

View File

@ -109,6 +109,13 @@ export default {
styleInfo() { styleInfo() {
return this.$store.state.curComponent.style return this.$store.state.curComponent.style
}, },
canvasWidth() {
let scaleWidth = 1
if (this.canvasStyleData.selfAdaption) {
scaleWidth = this.curCanvasScale.scaleWidth / 100
}
return this.canvasStyleData.width * scaleWidth
},
...mapState([ ...mapState([
'curComponent', 'curComponent',
'curCanvasScale', 'curCanvasScale',
@ -124,10 +131,19 @@ export default {
this.$refs.backgroundColorPicker.handleTrigger() this.$refs.backgroundColorPicker.handleTrigger()
}, },
getPositionX(x) { getPositionX(x) {
let ps = 0
if (this.canvasStyleData.selfAdaption) { if (this.canvasStyleData.selfAdaption) {
return (x * this.curCanvasScale.scaleWidth / 100) + 60 ps = (x * this.curCanvasScale.scaleWidth / 100) + 60
} else { } else {
return x + 60 ps = x + 60
}
// toolbar
const xGap = ps + 295 - this.canvasWidth
// console.log('canvasWidth:' + this.canvasWidth + ';xGap:' + xGap)
if (xGap > 0) {
return ps - xGap
} else {
return ps
} }
}, },
getPositionY(y) { getPositionY(y) {

View File

@ -161,6 +161,13 @@ export default {
styleInfo() { styleInfo() {
return this.$store.state.curComponent.style return this.$store.state.curComponent.style
}, },
canvasWidth() {
let scaleWidth = 1
if (this.canvasStyleData.selfAdaption) {
scaleWidth = this.curCanvasScale.scaleWidth / 100
}
return this.canvasStyleData.width * scaleWidth
},
...mapState([ ...mapState([
'curComponent', 'curComponent',
'curCanvasScale', 'curCanvasScale',
@ -176,10 +183,19 @@ export default {
this.$refs.backgroundColorPicker.handleTrigger() this.$refs.backgroundColorPicker.handleTrigger()
}, },
getPositionX(x) { getPositionX(x) {
let ps = 0
if (this.canvasStyleData.selfAdaption) { if (this.canvasStyleData.selfAdaption) {
return (x * this.curCanvasScale.scaleWidth / 100) + 60 ps = (x * this.curCanvasScale.scaleWidth / 100) + 60
} else { } else {
return x + 60 ps = x + 60
}
// toolbar
const xGap = ps + 345 - this.canvasWidth
// console.log('canvasWidth:' + this.canvasWidth + ';xGap:' + xGap)
if (xGap > 0) {
return ps - xGap
} else {
return ps
} }
}, },
getPositionY(y) { getPositionY(y) {

View File

@ -124,6 +124,13 @@ export default {
styleInfo() { styleInfo() {
return this.$store.state.curComponent.style return this.$store.state.curComponent.style
}, },
canvasWidth() {
let scaleWidth = 1
if (this.canvasStyleData.selfAdaption) {
scaleWidth = this.curCanvasScale.scaleWidth / 100
}
return this.canvasStyleData.width * scaleWidth
},
...mapState([ ...mapState([
'curComponent', 'curComponent',
'curCanvasScale', 'curCanvasScale',
@ -139,10 +146,19 @@ export default {
this.$refs.backgroundColorPicker.handleTrigger() this.$refs.backgroundColorPicker.handleTrigger()
}, },
getPositionX(x) { getPositionX(x) {
let ps = 0
if (this.canvasStyleData.selfAdaption) { if (this.canvasStyleData.selfAdaption) {
return (x * this.curCanvasScale.scaleWidth / 100) + 60 ps = (x * this.curCanvasScale.scaleWidth / 100) + 60
} else { } else {
return x + 60 ps = x + 60
}
// toolbar
const xGap = ps + 395 - this.canvasWidth
// console.log('canvasWidth:' + this.canvasWidth + ';xGap:' + xGap)
if (xGap > 0) {
return ps - xGap
} else {
return ps
} }
}, },
getPositionY(y) { getPositionY(y) {

View File

@ -214,8 +214,8 @@ import toast from '@/components/canvas/utils/toast'
import { commonStyle, commonAttr } from '@/components/canvas/custom-component/component-list' import { commonStyle, commonAttr } from '@/components/canvas/custom-component/component-list'
import generateID from '@/components/canvas/utils/generateID' import generateID from '@/components/canvas/utils/generateID'
import RectangleAttr from '@/components/canvas/components/RectangleAttr' import RectangleAttr from '@/components/canvas/components/RectangleAttr'
import TextAttr from '@/views/Tinymce/TextAttr' import TextAttr from '@/components/canvas/components/TextAttr'
import FilterTextAttr from '@/views/Tinymce/FilterTextAttr' import FilterTextAttr from '@/components/canvas/components/FilterTextAttr'
export default { export default {
name: 'PanelEdit', name: 'PanelEdit',