From b7d5f0b86c8840068d73e7433ff13b9f23b94c5d Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Sun, 10 Oct 2021 17:04:23 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=94=BB=E5=B8=83=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/DeDrag/drag.js | 16 ++++++++-------- frontend/src/components/DeDrag/drag.vue | 16 ++++++++-------- frontend/src/components/DeDrag/index.vue | 12 +++++++++--- frontend/src/components/DeDrag/shadow.vue | 7 +++++-- .../canvas/components/Editor/EditBar.vue | 13 +++++++++---- .../canvas/components/Editor/SettingMenu.vue | 1 + .../canvas/components/Editor/index.vue | 11 +++++++---- frontend/src/store/index.js | 4 ++-- 8 files changed, 49 insertions(+), 31 deletions(-) diff --git a/frontend/src/components/DeDrag/drag.js b/frontend/src/components/DeDrag/drag.js index 23530987a8..881d0b173d 100644 --- a/frontend/src/components/DeDrag/drag.js +++ b/frontend/src/components/DeDrag/drag.js @@ -671,7 +671,7 @@ export default { methods: { removeItem: removeItem, startResize(e, item, index) { - console.log('startResize:' + index) + // console.log('startResize:' + index) if (!this.resizable) return this.resizeStart.call(null, e, item, index) @@ -688,7 +688,7 @@ export default { this.infoBox.resizeItemIndex = index }, containerMouseDown(e) { - console.log('containerMouseDown:') + // console.log('containerMouseDown:') // e.preventDefault(); if (!this.infoBox) { @@ -699,7 +699,7 @@ export default { this.infoBox.startY = e.pageY }, startMove(e, item, index) { - console.log('startMove:' + index) + // console.log('startMove:' + index) const vm = this // e.preventDefault(); @@ -752,7 +752,7 @@ export default { const resizeItem = _.get(infoBox, 'resizeItem') if (resizeItem) { // 调整大小时 - console.log('resizeItem') + // console.log('resizeItem') vm.resizing.call(null, e, resizeItem, resizeItem._dragId) vm.$set(resizeItem, 'isPlayer', true) @@ -793,7 +793,7 @@ export default { height: nowHeight }) } else if (moveItem) { - console.log('moveItem') + // console.log('moveItem') scrollScreen(e) if (!vm.draggable) return @@ -886,7 +886,7 @@ export default { } }, getList() { - console.log('getList:') + // console.log('getList:') const returnList = _.sortBy(_.cloneDeep(this.yourList), 'y') const finalList = [] @@ -904,7 +904,7 @@ export default { * @returns */ getMaxCell() { - console.log('getMaxCell:') + // console.log('getMaxCell:') return this.maxCell }, @@ -914,7 +914,7 @@ export default { * @returns */ getRenderState() { - console.log('getRenderState:') + // console.log('getRenderState:') return this.moveAnimate }, diff --git a/frontend/src/components/DeDrag/drag.vue b/frontend/src/components/DeDrag/drag.vue index 51de27065f..f8d9d74a6d 100644 --- a/frontend/src/components/DeDrag/drag.vue +++ b/frontend/src/components/DeDrag/drag.vue @@ -709,7 +709,7 @@ export default { methods: { removeItem: removeItem, startResize(e, item, index) { - console.log('startResize:' + index) + // console.log('startResize:' + index) if (!this.resizable) return this.resizeStart.call(null, e, item, index) @@ -737,7 +737,7 @@ export default { this.infoBox.startY = e.pageY }, startMove(e, item, index) { - console.log('startMove:' + index) + // console.log('startMove:' + index) const vm = this // e.preventDefault(); @@ -790,7 +790,7 @@ export default { const resizeItem = _.get(infoBox, 'resizeItem') if (resizeItem) { // 调整大小时 - console.log('resizeItem') + // console.log('resizeItem') vm.resizing.call(null, e, resizeItem, resizeItem._dragId) vm.$set(resizeItem, 'isPlayer', true) @@ -831,7 +831,7 @@ export default { height: nowHeight }) } else if (moveItem) { - console.log('moveItem') + // console.log('moveItem') scrollScreen(e) if (!vm.draggable) return @@ -922,11 +922,11 @@ export default { left: (this.cellWidth * (item.x - 1) + this.baseMarginLeft) + 'px', top: (this.cellHeight * (item.y - 1) + this.baseMarginTop) + 'px' } - console.log('nowItemStyle:' + JSON.stringify(style)) + // console.log('nowItemStyle:' + JSON.stringify(style)) return style }, getList() { - console.log('getList:') + // console.log('getList:') const returnList = _.sortBy(_.cloneDeep(this.yourList), 'y') const finalList = [] @@ -944,7 +944,7 @@ export default { * @returns */ getMaxCell() { - console.log('getMaxCell:') + // console.log('getMaxCell:') return this.maxCell }, @@ -954,7 +954,7 @@ export default { * @returns */ getRenderState() { - console.log('getRenderState:') + // console.log('getRenderState:') return this.moveAnimate }, diff --git a/frontend/src/components/DeDrag/index.vue b/frontend/src/components/DeDrag/index.vue index 6a5d81bd09..df959d58a6 100644 --- a/frontend/src/components/DeDrag/index.vue +++ b/frontend/src/components/DeDrag/index.vue @@ -21,7 +21,7 @@ @mouseenter="enter" @mouseleave="leave" > - +
-
+
@@ -20,7 +20,7 @@ export default { let height = 0 // if (this.dragComponentInfo && !this.dragComponentInfo.auxiliaryMatrix) { if (this.dragComponentInfo) { - console.log('shadowDrag=') + // console.log('shadowDrag=') // 组件移入 if (this.dragComponentInfo.auxiliaryMatrix) { left = (this.dragComponentInfo.x - 1) * this.curCanvasScale.matrixStyleWidth @@ -109,5 +109,8 @@ export default { } diff --git a/frontend/src/components/canvas/components/Editor/EditBar.vue b/frontend/src/components/canvas/components/Editor/EditBar.vue index 1e4f878832..7bbb767846 100644 --- a/frontend/src/components/canvas/components/Editor/EditBar.vue +++ b/frontend/src/components/canvas/components/Editor/EditBar.vue @@ -6,7 +6,7 @@
- + @@ -26,9 +26,9 @@ - - - + + +
@@ -131,12 +131,14 @@ export default { this.curComponent.style.width = this.curComponent.sizex * this.curCanvasScale.matrixStyleOriginWidth this.curComponent.style.height = this.curComponent.sizey * this.curCanvasScale.matrixStyleOriginHeight this.curComponent.auxiliaryMatrix = false + this.$emit('amRemoveItem') } else { this.curComponent.x = Math.round(this.curComponent.style.left / this.curCanvasScale.matrixStyleOriginWidth) + 1 this.curComponent.y = Math.round(this.curComponent.style.top / this.curCanvasScale.matrixStyleOriginHeight) + 1 this.curComponent.sizex = Math.round(this.curComponent.style.width / this.curCanvasScale.matrixStyleOriginWidth) this.curComponent.sizey = Math.round(this.curComponent.style.height / this.curCanvasScale.matrixStyleOriginHeight) this.curComponent.auxiliaryMatrix = true + this.$emit('amAddItem') } this.$store.state.styleChangeTimes++ bus.$emit('auxiliaryMatrixChange') @@ -162,6 +164,9 @@ export default { }, linkageEdit() { + }, + amRemoveItem() { + this.$emit('amRemoveItem') }, // 清除相同sourceViewId 的 联动条件 clearLinkage() { diff --git a/frontend/src/components/canvas/components/Editor/SettingMenu.vue b/frontend/src/components/canvas/components/Editor/SettingMenu.vue index b15258661d..339f9f3268 100644 --- a/frontend/src/components/canvas/components/Editor/SettingMenu.vue +++ b/frontend/src/components/canvas/components/Editor/SettingMenu.vue @@ -91,6 +91,7 @@ export default { }, deleteComponent() { + this.$emit('amRemoveItem') this.deleteCurCondition() this.$store.commit('deleteComponent') this.$store.commit('recordSnapshot', 'deleteComponent') diff --git a/frontend/src/components/canvas/components/Editor/index.vue b/frontend/src/components/canvas/components/Editor/index.vue index 48612c0856..57d95d9558 100644 --- a/frontend/src/components/canvas/components/Editor/index.vue +++ b/frontend/src/components/canvas/components/Editor/index.vue @@ -51,6 +51,8 @@ @onDragging="onDragging" @onResizing="onResizing" @elementMouseDown="containerMouseDown" + @amRemoveItem="removeItem(item._dragId)" + @amAddItme="addItemBox(item)" > @@ -221,11 +223,11 @@ function debounce(func, time) { function scrollScreen(e) { if (e.clientY + 50 >= window.innerHeight) { - console.log('scrollScreen+') + // console.log('scrollScreen+') const body = $(document.body) body.scrollTop(body.scrollTop() + 20) } else if (e.clientY <= 150) { - console.log('scrollScreen-') + // console.log('scrollScreen-') const body = $(document.body) body.scrollTop(body.scrollTop() - 20) } @@ -288,7 +290,7 @@ function fillPositionBox(maxY) { } itemMaxY = maxY - console.log('height:' + ((itemMaxY) * this.cellHeight) + 'px') + // console.log('height:' + ((itemMaxY) * this.cellHeight) + 'px') // $(this.$el).css('height', ((itemMaxY) * this.cellHeight) + 'px') } @@ -1005,7 +1007,7 @@ export default { handler(newVal, oldVla) { // console.log('newVal:' + JSON.stringify(newVal) + ';oldVla:' + JSON.stringify(oldVla)) // 初始化时componentData 加载可能出现慢的情况 此时重新初始化一下matrix - if (newVal.length !== this.lastComponentDataLength) { + if (this.lastComponentDataLength === 0 && newVal.length > 0) { this.lastComponentDataLength = newVal.length this.initMatrix() } @@ -1656,6 +1658,7 @@ export default { return this.moveAnimate }, addItem: addItem, + removeItem: removeItem, initMatrix: init, afterInitOk(func) { const timeid = setInterval(() => { diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js index fa6f88a070..c44db2bf77 100644 --- a/frontend/src/store/index.js +++ b/frontend/src/store/index.js @@ -115,7 +115,7 @@ const data = { // }, setShapeStyle({ curComponent, canvasStyleData, curCanvasScale }, { top, left, width, height, rotate }) { - console.log('cw:' + curComponent.style.width + ';w:' + width + ';sp:' + curCanvasScale.scalePointWidth) + // console.log('cw:' + curComponent.style.width + ';w:' + width + ';sp:' + curCanvasScale.scalePointWidth) const ow = curComponent.style.width if (top || top === 0) curComponent.style.top = (top / curCanvasScale.scalePointHeight) + 0.0000001 if (left || left === 0) curComponent.style.left = (left / curCanvasScale.scalePointWidth) + 0.0000001 @@ -123,7 +123,7 @@ const data = { if (height || height === 0) curComponent.style.height = (height / curCanvasScale.scalePointHeight) + 0.0000001 if (rotate || rotate === 0) curComponent.style.rotate = rotate // console.log('setShapeStyle:curComponent' + 'top:' + top + ';left:' + left + '====' + JSON.stringify(curComponent)) - console.log('setShapeStyle:curComponent' + 'w:' + curComponent.style.width + ';ow:' + ow) + // console.log('setShapeStyle:curComponent' + 'w:' + curComponent.style.width + ';ow:' + ow) }, setShapeSingleStyle({ curComponent }, { key, value }) {