From 0b8b542244e0e13fa83b7819cd239029d527120a Mon Sep 17 00:00:00 2001
From: wangjiahao <1522128093@qq.com>
Date: Thu, 27 Oct 2022 15:22:32 +0800
Subject: [PATCH] =?UTF-8?q?refactor(=E4=BB=AA=E8=A1=A8=E6=9D=BF):=20?=
=?UTF-8?q?=E6=96=87=E6=9C=AC=E7=9F=A9=E5=BD=A2=E7=AD=89=E6=82=AC=E6=B5=AE?=
=?UTF-8?q?=E5=B7=A5=E5=85=B7=E6=A0=8F=E9=80=82=E9=85=8D=E6=96=B0=E7=94=BB?=
=?UTF-8?q?=E5=B8=83?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
frontend/src/components/canvas/DeCanvas.vue | 17 +-----
.../components/canvas/components/TextAttr.vue | 2 +-
.../src/components/widget/DeWidget/DeTabs.vue | 59 ++++++++++++++++++-
frontend/src/views/panel/edit/index.vue | 16 ++++-
4 files changed, 72 insertions(+), 22 deletions(-)
diff --git a/frontend/src/components/canvas/DeCanvas.vue b/frontend/src/components/canvas/DeCanvas.vue
index 921f978d4d..5b2d437d4c 100644
--- a/frontend/src/components/canvas/DeCanvas.vue
+++ b/frontend/src/components/canvas/DeCanvas.vue
@@ -88,13 +88,6 @@
-
-
@@ -239,13 +232,6 @@ export default {
mobileLayoutStatus() {
this.restore()
}
- // //监控当前组件移动 检查是否靠近tab
- // curComponent: {
- // handler(newVal, oldVla) {
- // // this.restore()
- // },
- // deep: true
- // },
},
created() {
},
@@ -301,8 +287,7 @@ export default {
}
},
canvasScroll(e) {
- this.scrollLeft = e.target.scrollLeft
- this.scrollTop = e.target.scrollTop
+ this.$emit('canvasScroll', { scrollLeft: e.target.scrollLeft, scrollTop: e.target.scrollTop })
bus.$emit('onScroll')
},
// handleDrop(e) {
diff --git a/frontend/src/components/canvas/components/TextAttr.vue b/frontend/src/components/canvas/components/TextAttr.vue
index 7e3b2e874e..20a9bacfa8 100644
--- a/frontend/src/components/canvas/components/TextAttr.vue
+++ b/frontend/src/components/canvas/components/TextAttr.vue
@@ -588,7 +588,7 @@ export default {
mainStyle() {
const style = {
left: (this.getPositionX(this.curComponent.style.left) - this.scrollLeft) + 'px',
- top: (this.getPositionY(this.curComponent.style.top) - this.scrollTop + 25) + 'px'
+ top: (this.getPositionY(this.curComponent.style.top) - this.scrollTop + 20) + 'px'
}
return style
},
diff --git a/frontend/src/components/widget/DeWidget/DeTabs.vue b/frontend/src/components/widget/DeWidget/DeTabs.vue
index b9b3db6631..edb11049dd 100644
--- a/frontend/src/components/widget/DeWidget/DeTabs.vue
+++ b/frontend/src/components/widget/DeWidget/DeTabs.vue
@@ -64,6 +64,7 @@
:canvas-id="element.id+'-'+item.name"
class="tab_canvas"
:class="moveActive ? 'canvas_move_in':''"
+ @canvasScroll="canvasScroll"
/>
@@ -211,11 +219,16 @@ import { findPanelElementInfo } from '@/api/panel/panel'
import { getNowCanvasComponentData } from '@/components/canvas/utils/utils'
import DeCanvasTab from '@/components/canvas/DeCanvas'
import Preview from '@/components/canvas/components/Editor/Preview'
+import TextAttr from '@/components/canvas/components/TextAttr'
export default {
name: 'DeTabs',
- components: { Preview, DeCanvasTab, TabUseList, ViewSelect, DataeaseTabs },
+ components: { TextAttr, Preview, DeCanvasTab, TabUseList, ViewSelect, DataeaseTabs },
props: {
+ canvasId: {
+ type: String,
+ default: 'canvas-main'
+ },
element: {
type: Object,
default: null
@@ -252,6 +265,20 @@ export default {
},
data() {
return {
+ scrollLeft: 50,
+ scrollTop: 10,
+ // 需要展示属性设置的组件类型
+ showAttrComponent: [
+ 'custom',
+ 'v-text',
+ 'picture-add',
+ 'de-tabs',
+ 'rect-shape',
+ 'de-show-date',
+ 'de-video',
+ 'de-stream-media',
+ 'de-frame'
+ ],
activeTabName: null,
tabIndex: 1,
dialogVisible: false,
@@ -264,6 +291,23 @@ export default {
}
},
computed: {
+ curCanvasScaleSelf() {
+ return this.curCanvasScaleMap[this.canvasId]
+ },
+ showAttr() {
+ if (this.mobileLayoutStatus) {
+ return false
+ } else if (this.curComponent && this.showAttrComponent.includes(this.curComponent.type)) {
+ // 过滤组件有标题才显示
+ if (this.curComponent.type === 'custom' && (!this.curComponent.options.attrs.showTitle || !this.curComponent.options.attrs.title)) {
+ return false
+ } else {
+ return true
+ }
+ } else {
+ return false
+ }
+ },
moveActive() {
return this.tabMoveInActiveId && this.tabMoveInActiveId === this.element.id
},
@@ -285,7 +329,8 @@ export default {
'curComponent',
'mobileLayoutStatus',
'canvasStyleData',
- 'tabMoveInActiveId'
+ 'tabMoveInActiveId',
+ 'curCanvasScaleMap'
]),
fontColor() {
return this.element && this.element.style && this.element.style.headFontColor || 'none'
@@ -360,6 +405,16 @@ export default {
bus.$off('add-new-tab', this.addNewTab)
},
methods: {
+ initScroll() {
+ this.scrollLeft = 50
+ this.scrollTop = 10
+ },
+ canvasScroll(scrollInfo) {
+ this.scrollLeft = scrollInfo.scrollLeft + 50
+ this.scrollTop = scrollInfo.scrollTop + 10
+ console.log('scrollInfo=' + JSON.stringify(scrollInfo))
+ bus.$emit('onScroll')
+ },
tabCanvasComponentData(tabName) {
const result = getNowCanvasComponentData(this.element.id + '-' + tabName)
return result
diff --git a/frontend/src/views/panel/edit/index.vue b/frontend/src/views/panel/edit/index.vue
index 3e59bb4386..f4c3d7454e 100644
--- a/frontend/src/views/panel/edit/index.vue
+++ b/frontend/src/views/panel/edit/index.vue
@@ -178,6 +178,7 @@
:component-data="mainCanvasComponentData"
:canvas-id="canvasId"
:canvas-pid="'0'"
+ @canvasScroll="canvasScroll"
>
@@ -466,6 +467,13 @@
+
+
@@ -519,10 +527,12 @@ import { listenGlobalKeyDown } from '@/components/canvas/utils/shortcutKey'
import { adaptCurThemeCommonStyle } from '@/components/canvas/utils/style'
import eventBus from '@/components/canvas/utils/eventBus'
import DeCanvas from '@/components/canvas/DeCanvas'
+import TextAttr from '@/components/canvas/components/TextAttr'
export default {
name: 'PanelEdit',
components: {
+ TextAttr,
DeCanvas,
Multiplexing,
ChartStyleBatchSet,
@@ -1309,9 +1319,9 @@ export default {
// 打开属性栏
bus.$emit('change_panel_right_draw', true)
},
- canvasScroll(event) {
- this.scrollLeft = event.target.scrollLeft
- this.scrollTop = event.target.scrollTop
+ canvasScroll(scrollInfo) {
+ this.scrollLeft = scrollInfo.scrollLeft
+ this.scrollTop = scrollInfo.scrollTop
bus.$emit('onScroll')
},
destroyTimeMachine() {