Merge pull request #178 from dataease/pr@dev@panel

fix:矩形组件和文本组件在非自适应画布区域的模式下对应悬浮组件定位问题
This commit is contained in:
王嘉豪 2021-07-07 19:10:30 +08:00 committed by GitHub
commit 66760cdf9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 12 deletions

View File

@ -58,6 +58,16 @@
<script> <script>
import { mapState } from 'vuex' import { mapState } from 'vuex'
export default { export default {
props: {
scrollLeft: {
type: Number,
default: 0
},
scrollTop: {
type: Number,
default: 0
}
},
data() { data() {
return { return {
lineStyle: [{ lineStyle: [{
@ -113,8 +123,8 @@ export default {
mainStyle() { mainStyle() {
const style = { const style = {
left: this.getPositionX(this.curComponent.style.left) + 'px', left: this.getPositionX(this.curComponent.style.left - this.scrollLeft) + 'px',
top: (this.getPositionY(this.curComponent.style.top) - 3) + 'px' top: (this.getPositionY(this.curComponent.style.top) - this.scrollTop - 3) + 'px'
} }
return style return style
}, },
@ -139,7 +149,7 @@ export default {
if (this.canvasStyleData.selfAdaption) { if (this.canvasStyleData.selfAdaption) {
return (x * this.curCanvasScale.scaleWidth / 100) + 60 return (x * this.curCanvasScale.scaleWidth / 100) + 60
} else { } else {
return x + 190 return x + 60
} }
}, },
getPositionY(y) { getPositionY(y) {

View File

@ -58,6 +58,16 @@
<script> <script>
import { mapState } from 'vuex' import { mapState } from 'vuex'
export default { export default {
props: {
scrollLeft: {
type: Number,
default: 0
},
scrollTop: {
type: Number,
default: 0
}
},
data() { data() {
return { return {
lineStyle: [{ lineStyle: [{
@ -113,8 +123,8 @@ export default {
mainStyle() { mainStyle() {
const style = { const style = {
left: this.getPositionX(this.curComponent.style.left) + 'px', left: this.getPositionX(this.curComponent.style.left - this.scrollLeft) + 'px',
top: (this.getPositionY(this.curComponent.style.top) - 3) + 'px' top: (this.getPositionY(this.curComponent.style.top) - this.scrollTop - 3) + 'px'
} }
return style return style
}, },
@ -139,7 +149,7 @@ export default {
if (this.canvasStyleData.selfAdaption) { if (this.canvasStyleData.selfAdaption) {
return (x * this.curCanvasScale.scaleWidth / 100) + 60 return (x * this.curCanvasScale.scaleWidth / 100) + 60
} else { } else {
return x + 190 return x + 60
} }
}, },
getPositionY(y) { getPositionY(y) {

View File

@ -67,6 +67,16 @@
<script> <script>
import { mapState } from 'vuex' import { mapState } from 'vuex'
export default { export default {
props: {
scrollLeft: {
type: Number,
default: 0
},
scrollTop: {
type: Number,
default: 0
}
},
data() { data() {
return { return {
textAlignOptions: [ textAlignOptions: [
@ -106,8 +116,8 @@ export default {
mainStyle() { mainStyle() {
const style = { const style = {
left: this.getPositionX(this.curComponent.style.left) + 'px', left: (this.getPositionX(this.curComponent.style.left) - this.scrollLeft) + 'px',
top: (this.getPositionY(this.curComponent.style.top) - 3) + 'px' top: (this.getPositionY(this.curComponent.style.top) - this.scrollTop - 3) + 'px'
} }
return style return style
}, },
@ -132,7 +142,7 @@ export default {
if (this.canvasStyleData.selfAdaption) { if (this.canvasStyleData.selfAdaption) {
return (x * this.curCanvasScale.scaleWidth / 100) + 60 return (x * this.curCanvasScale.scaleWidth / 100) + 60
} else { } else {
return x + 190 return x + 60
} }
}, },
getPositionY(y) { getPositionY(y) {

View File

@ -101,6 +101,7 @@
@dragover="handleDragOver" @dragover="handleDragOver"
@mousedown="handleMouseDown" @mousedown="handleMouseDown"
@mouseup="deselectCurComponent" @mouseup="deselectCurComponent"
@scroll="canvasScroll"
> >
<Editor v-if="!previewVisible" :out-style="outStyle" /> <Editor v-if="!previewVisible" :out-style="outStyle" />
</div> </div>
@ -158,8 +159,8 @@
<input id="input" ref="files" type="file" accept="image/*" hidden @change="handleFileChange"> <input id="input" ref="files" type="file" accept="image/*" hidden @change="handleFileChange">
<!--矩形样式组件--> <!--矩形样式组件-->
<RectangleAttr v-if="curComponent&&curComponent.type==='rect-shape'" /> <RectangleAttr v-if="curComponent&&curComponent.type==='rect-shape'" :scroll-left="scrollLeft" :scroll-top="scrollTop" />
<TextAttr v-if="curComponent&&curComponent.type==='v-text'" /> <TextAttr v-if="curComponent&&curComponent.type==='v-text'" :scroll-left="scrollLeft" :scroll-top="scrollTop" />
<!--复用ChartGroup组件 不做显示--> <!--复用ChartGroup组件 不做显示-->
<ChartGroup <ChartGroup
@ -269,7 +270,9 @@ export default {
beforeDialogValue: [], beforeDialogValue: [],
styleDialogVisible: false, styleDialogVisible: false,
currentDropElement: null, currentDropElement: null,
adviceGroupId: null adviceGroupId: null,
scrollLeft: 0,
scrollTop: 0
} }
}, },
@ -307,6 +310,8 @@ export default {
// this.restore() // this.restore()
// //
listenGlobalKeyDown() listenGlobalKeyDown()
this.$store.commit('setCurComponent', { component: null, index: null })
}, },
mounted() { mounted() {
// this.insertToBody() // this.insertToBody()
@ -662,6 +667,11 @@ export default {
this.$store.dispatch('chart/setViewId', this.curComponent.propValue.viewId) this.$store.dispatch('chart/setViewId', this.curComponent.propValue.viewId)
bus.$emit('PanelSwitchComponent', { name: 'ChartEdit', param: { 'id': this.curComponent.propValue.viewId, 'optType': 'edit' }}) bus.$emit('PanelSwitchComponent', { name: 'ChartEdit', param: { 'id': this.curComponent.propValue.viewId, 'optType': 'edit' }})
} }
},
canvasScroll(event) {
debugger
this.scrollLeft = event.target.scrollLeft
this.scrollTop = event.target.scrollTop
} }
} }
} }