diff --git a/frontend/package.json b/frontend/package.json index c40395ad4f..fce213e62e 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -49,6 +49,7 @@ "vue-codemirror": "^4.0.6", "vue-fullscreen": "^2.5.2", "vue-i18n": "7.3.2", + "vue-proportion-directive": "^1.1.0", "vue-router": "3.0.6", "vue-to-pdf": "^1.0.0", "vue-uuid": "2.0.2", diff --git a/frontend/src/components/DeDrag/index.vue b/frontend/src/components/DeDrag/index.vue index 49adf6b611..20dd0b5074 100644 --- a/frontend/src/components/DeDrag/index.vue +++ b/frontend/src/components/DeDrag/index.vue @@ -29,7 +29,8 @@ ]" :style="mainSlotStyle" > - + +
{ if (!this.handleInfo.switch) return { display: this.enabled ? 'block' : 'none' } @@ -534,6 +543,7 @@ export default { 'curCanvasScale', 'canvasStyleData', 'linkageSettingStatus', + 'mobileLayoutStatus', 'componentGap' ]) }, diff --git a/frontend/src/components/canvas/components/Editor/ComponentWrapper.vue b/frontend/src/components/canvas/components/Editor/ComponentWrapper.vue index 6e87cbab95..80e62ee3bb 100644 --- a/frontend/src/components/canvas/components/Editor/ComponentWrapper.vue +++ b/frontend/src/components/canvas/components/Editor/ComponentWrapper.vue @@ -37,9 +37,10 @@ import { mixins } from '@/components/canvas/utils/events' import { mapState } from 'vuex' import DeOutWidget from '@/components/dataease/DeOutWidget' import EditBar from '@/components/canvas/components/Editor/EditBar' +import MobileCheckBar from '@/components/canvas/components/Editor/MobileCheckBar' export default { - components: { DeOutWidget, EditBar }, + components: { MobileCheckBar, DeOutWidget, EditBar }, mixins: [mixins], props: { config: { @@ -71,6 +72,7 @@ export default { return this.canvasStyleData.panel.gap === 'yes' && this.config.auxiliaryMatrix ? this.componentGap : 0 }, ...mapState([ + 'mobileLayoutStatus', 'canvasStyleData', 'curComponent', 'componentGap' @@ -96,7 +98,6 @@ export default { } if (prop === 'top') { const top = this.format(style['top'], this.scaleHeight) - // console.log('top:' + top) return top } }, @@ -107,19 +108,33 @@ export default { getOutStyleDefault(style) { const result = { padding: this.curGap + 'px' - }; - ['width', 'left'].forEach(attr => { - result[attr] = style[attr] + 'px' - }); - ['height', 'top'].forEach(attr => { - result[attr] = style[attr] + 'px' - }) - result['rotate'] = style['rotate'] + } + // 移动端编辑状态 且 未被移动端选中的组件 放满容器 + if (this.mobileLayoutStatus && !this.config.mobileSelected) { + result.width = '100%' + result.height = '100%' + } else { + ['width', 'left'].forEach(attr => { + result[attr] = style[attr] + 'px' + }); + ['height', 'top'].forEach(attr => { + result[attr] = style[attr] + 'px' + }) + result['rotate'] = style['rotate'] + } return result }, getComponentStyleDefault(style) { - return getStyle(style, ['top', 'left', 'width', 'height', 'rotate']) + // 移动端编辑状态 且 未被移动端选中的组件 放满容器 + if (this.mobileLayoutStatus && !this.config.mobileSelected) { + return { + width: '100%', + height: '100%' + } + } else { + return getStyle(style, ['top', 'left', 'width', 'height', 'rotate']) + } }, handleClick() { diff --git a/frontend/src/components/canvas/components/Editor/EditBar.vue b/frontend/src/components/canvas/components/Editor/EditBar.vue index 18014443ea..932598dc01 100644 --- a/frontend/src/components/canvas/components/Editor/EditBar.vue +++ b/frontend/src/components/canvas/components/Editor/EditBar.vue @@ -3,7 +3,6 @@
-
@@ -26,9 +25,6 @@ - - -
@@ -39,7 +35,6 @@ import { mapState } from 'vuex' import bus from '@/utils/bus' import SettingMenu from '@/components/canvas/components/Editor/SettingMenu' import LinkageField from '@/components/canvas/components/Editor/LinkageField' -import { deepCopy } from '@/components/canvas/utils/utils' export default { components: { SettingMenu, LinkageField }, @@ -73,7 +68,6 @@ export default { } }, mounted() { - // this.createTimer() }, computed: { existLinkage() { @@ -106,7 +100,6 @@ export default { ]) }, beforeDestroy() { - // this.destroyTimer() }, methods: { createTimer() { @@ -172,9 +165,7 @@ export default { if (this.curComponent.type === 'custom') { bus.$emit('component-dialog-edit') } - // 编辑样式组件 - if (this.curComponent.type === 'v-text' || this.curComponent.type === 'rect-shape') { bus.$emit('component-dialog-style') } diff --git a/frontend/src/components/canvas/components/Editor/MobileCheckBar.vue b/frontend/src/components/canvas/components/Editor/MobileCheckBar.vue new file mode 100644 index 0000000000..8f248b0219 --- /dev/null +++ b/frontend/src/components/canvas/components/Editor/MobileCheckBar.vue @@ -0,0 +1,86 @@ + + + + + diff --git a/frontend/src/components/canvas/components/Editor/index.vue b/frontend/src/components/canvas/components/Editor/index.vue index 92a19670eb..4dbfb37a78 100644 --- a/frontend/src/components/canvas/components/Editor/index.vue +++ b/frontend/src/components/canvas/components/Editor/index.vue @@ -22,6 +22,7 @@ x:' + item.x + ';y:' + item.y + ';sizex:' + item.sizex + ';sizey:' + item.sizey) if (!item || item.x <= 0 || item.y <= 0) return for (let i = item.x - 1; i < item.x - 1 + item.sizex; i++) { for (let j = item.y - 1; j < item.y - 1 + item.sizey; j++) { @@ -313,20 +306,10 @@ function removeItemFromPositionBox(item) { * */ function recalcCellWidth() { - // const containerNode = this.$refs['container'] - // this.outStyle.width && this.outStyle.height - // const containerWidth = this.outStyle.width - - // const cells = Math.round(containerWidth / this.cellWidth) this.maxCell = this.matrixCount.x - - // if (containerWidth % this.cellWidth !=== 0) { - // this.cellWidth += containerWidth % this.cellWidth / cells; - // } } function init() { - // console.log('init-cellWidth') this.cellWidth = this.baseWidth + this.baseMarginLeft this.cellHeight = this.baseHeight + this.baseMarginTop this.yourList = this.getList() @@ -342,12 +325,9 @@ function init() { itemMaxX = 0 const vm = this - recalcCellWidth.call(this) - resetPositionBox.call(this) let i = 0 - // console.log('initList:' + JSON.stringify(vm.yourList)) const timeid = setInterval(function() { if (i >= vm.yourList.length) { clearInterval(timeid) @@ -364,15 +344,12 @@ function init() { } function resizePlayer(item, newSize) { - // console.log('resizePlayer') const vm = this removeItemFromPositionBox(item) const belowItems = findBelowItems.call(this, item) - _.forEach(belowItems, function(upItem) { const canGoUpRows = canItemGoUp(upItem) - if (canGoUpRows > 0) { moveItemUp.call(vm, upItem, canGoUpRows) } @@ -394,13 +371,9 @@ function resizePlayer(item, newSize) { } emptyTargetCell.call(this, item) - addItemToPositionBox.call(this, item) - changeItemCoord.call(this, item) - const canGoUpRows = canItemGoUp(item) - if (canGoUpRows > 0) { moveItemUp.call(this, item, canGoUpRows) } @@ -413,7 +386,6 @@ function resizePlayer(item, newSize) { * @param {any} position */ function checkItemPosition(item, position) { - // console.log('checkItemPosition-info' + JSON.stringify(item)) position = position || {} position.x = position.x || item.x position.y = position.y || item.y @@ -459,12 +431,10 @@ function checkItemPosition(item, position) { * @param {any} position */ function movePlayer(item, position) { - // console.log('movePlayer') const vm = this removeItemFromPositionBox(item) const belowItems = findBelowItems.call(this, item) - _.forEach(belowItems, function(upItem) { const canGoUpRows = canItemGoUp(upItem) if (canGoUpRows > 0) { @@ -474,17 +444,11 @@ function movePlayer(item, position) { item.x = position.x item.y = position.y - // console.log('checkItemPosition3') checkItemPosition.call(this, item, position) - emptyTargetCell.call(this, item) - addItemToPositionBox.call(this, item) - changeItemCoord.call(this, item) - const canGoUpRows = canItemGoUp(item) - if (canGoUpRows > 0) { moveItemUp.call(this, item, canGoUpRows) } @@ -496,12 +460,8 @@ function removeItem(index) { removeItemFromPositionBox(item) const belowItems = findBelowItems.call(this, item) - - // $(this.$refs['item' + item._dragId][0]).remove(); - _.forEach(belowItems, function(upItem) { const canGoUpRows = canItemGoUp(upItem) - if (canGoUpRows > 0) { moveItemUp.call(vm, upItem, canGoUpRows) } @@ -516,23 +476,17 @@ function addItem(item, index) { index = this.yourList.length } item._dragId = index - - // console.log('checkItemPosition4') checkItemPosition.call(this, item, { x: item.x, y: item.y }) emptyTargetCell.call(this, item) - addItemToPositionBox.call(this, item) - const canGoUpRows = canItemGoUp(item) - if (canGoUpRows > 0) { moveItemUp.call(this, item, canGoUpRows) } - // 生成坐标点 // makeCoordinate.call(this, item); } @@ -645,7 +599,6 @@ function changeItemCoord(item) { * @param {any} item */ function emptyTargetCell(item) { - // console.log('emptyTargetCell') const vm = this const belowItems = findBelowItems(item) @@ -687,9 +640,7 @@ function canItemGoUp(item) { function moveItemDown(item, size) { const vm = this removeItemFromPositionBox(item) - const belowItems = findBelowItems(item) - _.forEach(belowItems, function(downItem, index) { if (downItem._dragId === item._dragId) return const moveSize = calcDiff(item, downItem, size) @@ -697,23 +648,17 @@ function moveItemDown(item, size) { moveItemDown.call(vm, downItem, moveSize) } }) - const targetPosition = { y: item.y + size } setPlayerPosition.call(this, item, targetPosition) - // console.log('checkItemPosition1') checkItemPosition.call(this, item, targetPosition) - addItemToPositionBox.call(this, item) - changeItemCoord.call(this, item) } function setPlayerPosition(item, position) { - const vm = this position = position || {} - const targetX = position.x || item.x const targetY = position.y || item.y @@ -721,14 +666,8 @@ function setPlayerPosition(item, position) { item.y = targetY // 还原到像素 - // item.style.left = (item.x - 1) * this.matrixStyle.width - // item.style.top = (item.y - 1) * this.matrixStyle.height item.style.left = ((item.x - 1) * this.matrixStyle.width) / this.scalePointWidth item.style.top = ((item.y - 1) * this.matrixStyle.height) / this.scalePointHeight - // console.log('setPlayerPosition:' + item._dragId + '--' + item.x + '--' + item.y + '--top' + item.style.top) - - // console.log('setPlayerPosition:x=' + item.style.left + ';y=' + item.style.top + 'componentData:' + JSON.stringify(this.componentData)) - if (item.y + item.sizey > itemMaxY) { itemMaxY = item.y + item.sizey } @@ -762,14 +701,11 @@ function calcDiff(parent, son, size) { } function moveItemUp(item, size) { - // console.log('moveItemUp') const vm = this removeItemFromPositionBox(item) const belowItems = findBelowItems.call(this, item) - - // item.y -= size; setPlayerPosition.call(this, item, { y: item.y - size }) @@ -857,6 +793,16 @@ export default { required: false, type: Function, default: function() {} + }, + matrixCount: { + required: false, + type: Object, + default: () => { + return { + x: 36, + y: 18 + } + } } }, data() { @@ -900,11 +846,6 @@ export default { originWidth: 80, // 原始尺寸 originHeight: 20 }, - // 矩阵数量 默认 128 * 72 - matrixCount: { - x: 36, - y: 18 - }, customStyleHistory: null, showDrag: true, vLine: [], @@ -940,9 +881,6 @@ export default { return this.chartDetailsVisible || this.linkJumpSetVisible }, // 挤占式画布设计 - // positionBoxInfo() { - // return getoPsitionBox() - // }, coordinates() { return coordinates }, @@ -965,8 +903,6 @@ export default { } } } - // console.log('customStyle=>' + JSON.stringify(style) + JSON.stringify(this.canvasStyleData)) - return style }, panelInfo() { @@ -983,65 +919,44 @@ export default { 'linkageSettingStatus', 'curLinkageView', 'doSnapshotIndex', - 'componentGap' + 'componentGap', + 'mobileLayoutStatus' ]) }, watch: { customStyle: { handler(newVal) { // 获取当前宽高(宽高改变后重新渲染画布) - // if (oldVla && newVal !== oldVla) { - // this.showDrag = false - // this.$nextTick(() => (this.showDrag = true)) - // } }, deep: true }, outStyle: { handler(newVal, oldVla) { + this.resizeParentBoundsRef() this.changeScale() - // console.log('newVal:' + JSON.stringify(newVal) + 'oldVla:' + JSON.stringify(this.outStyleOld)) - if (this.outStyleOld && (newVal.width > this.outStyleOld.width || newVal.height > this.outStyleOld.height)) { - this.resizeParentBounds() - } this.outStyleOld = deepCopy(newVal) }, deep: true }, - // canvasStyleData: { - // handler(newVal, oldVla) { - // // 第一次变化 不需要 重置边界 待改进 - // if (this.changeIndex++ > 0) { - // // this.resizeParentBounds() - // this.$store.state.styleChangeTimes++ - // } - // // this.changeScale() - // }, - // deep: true - // }, componentData: { handler(newVal, oldVla) { - // console.log('newVal:' + JSON.stringify(newVal) + ';oldVla:' + JSON.stringify(oldVla)) // 初始化时componentData 加载可能出现慢的情况 此时重新初始化一下matrix if (newVal.length !== this.lastComponentDataLength) { this.lastComponentDataLength = newVal.length - // console.log('.initMatrix2') this.initMatrix() + // console.log('componentData-initMatrix') } }, deep: true }, positionBox: { handler(newVal, oldVla) { - // console.log('positionBox:' + JSON.stringify(positionBox)) }, deep: true }, // 镜像索引有变化 刷新一下矩阵(撤销重做等) doSnapshotIndex: { handler(newVal, oldVla) { - // console.log('snapshotIndexChange:' + newVal) - // console.log('.initMatrix3') this.initMatrix() }, deep: true @@ -1053,22 +968,12 @@ export default { this.changeScale() this.editShow = true }, 500) - // this.changeScale() // 获取编辑器元素 this.$store.commit('getEditor') const _this = this - // bus.$on('auxiliaryMatrixChange', this.initMatrix) - // bus.$on('auxiliaryMatrixChange', () => { - // _this.$nextTick(() => { - // _this.initMatrix() - // }) - // }) eventBus.$on('hideArea', () => { this.hideArea() }) - // bus.$on('delete-condition', condition => { - // this.deleteCondition(condition) - // }) eventBus.$on('startMoveIn', this.startMoveIn) eventBus.$on('openChartDetailsDialog', this.openChartDetailsDialog) bus.$on('onRemoveLastItem', this.removeLastItem) @@ -1081,7 +986,6 @@ export default { } }, created() { - // this.$store.dispatch('conditions/clear') }, methods: { changeStyleWithScale, @@ -1090,9 +994,7 @@ export default { if (!this.curComponent || (this.curComponent.component !== 'v-text' && this.curComponent.component !== 'rect-shape')) { e.preventDefault() } - this.hideArea() - // 获取编辑器的位移信息,每次点击时都需要获取一次。主要是为了方便开发时调试用。 const rectInfo = this.editor.getBoundingClientRect() this.editorX = rectInfo.x @@ -1116,19 +1018,15 @@ export default { this.start.y = moveEvent.clientY - this.editorY } } - const up = (e) => { document.removeEventListener('mousemove', move) document.removeEventListener('mouseup', up) - if (e.clientX === startX && e.clientY === startY) { this.hideArea() return } - this.createGroup() } - document.addEventListener('mousemove', move) document.addEventListener('mouseup', up) @@ -1337,7 +1235,6 @@ export default { } }, getRefLineParams(params) { - // console.log(JSON.stringify(params)) const { vLine, hLine } = params this.vLine = vLine this.hLine = hLine @@ -1350,11 +1247,11 @@ export default { parentBoundsChange(index) { this.timeMachine = setTimeout(() => { if (index === this.changeIndex) { - this.showDrag = false - this.$nextTick(() => (this.showDrag = true)) + this.changeScale() + console.log('changeScale') } this.destroyTimeMachine() - }, 500) + }, 1500) }, destroyTimeMachine() { this.timeMachine && clearTimeout(this.timeMachine) @@ -1408,7 +1305,6 @@ export default { // 挤占式画布设计 startResize(e, item, index) { - // console.log('startResize:' + index) if (!this.resizable) return this.resizeStart.call(null, e, item, index) @@ -1418,9 +1314,6 @@ export default { if (!this.infoBox) { this.infoBox = {} } - - const itemNode = target.parents('.item') - this.infoBox.resizeItem = item this.infoBox.resizeItemIndex = index // this.onStartMove(e, item, index) @@ -1432,22 +1325,14 @@ export default { if (!this.infoBox) { this.infoBox = {} } - // console.log('containerMouseDown=' + e.pageX + ';' + e.pageY) - this.infoBox.startX = e.pageX this.infoBox.startY = e.pageY }, onStartMove(e, item, index) { - // console.log('onStartMove:' + index) - const vm = this - // e.preventDefault(); - if (!this.infoBox) { this.infoBox = {} } const infoBox = this.infoBox - const target = $(e.target) - this.dragStart.call(null, e, item, index) infoBox.moveItem = item infoBox.moveItemIndex = index @@ -1485,15 +1370,9 @@ export default { const infoBox = this.infoBox const resizeItem = _.get(infoBox, 'resizeItem') const vm = this - // console.log('resizeItem') - vm.$set(resizeItem, 'isPlayer', true) - const nowItemIndex = infoBox.resizeItemIndex - // const cloneItem = infoBox.cloneItem const startX = infoBox.startX const startY = infoBox.startY - const oldSizeX = infoBox.oldSizeX - const oldSizeY = infoBox.oldSizeY const moveXSize = e.pageX - startX // X方向移动的距离 const moveYSize = e.pageY - startY // Y方向移动的距离 @@ -1534,8 +1413,6 @@ export default { const infoBox = this.infoBox const moveItem = _.get(infoBox, 'moveItem') const vm = this - // console.log('onDragging') - scrollScreen(e) if (!vm.draggable) return vm.dragging.call(null, e, moveItem, moveItem._dragId) @@ -1584,10 +1461,7 @@ export default { } }, getList() { - // console.log('getList:') - // 不使用copy 保持原有对象 - // const returnList = _.sortBy(_.cloneDeep(this.componentData), 'y') const finalList = [] _.forEach(this.componentData, function(item, index) { if (_.isEmpty(item)) return @@ -1598,7 +1472,6 @@ export default { } }) return finalList - // return this.componentData }, /** * 获取x最大值 @@ -1649,8 +1522,6 @@ export default { if (this.$store.state.dragComponentInfo.auxiliaryMatrix) { const moveInItemInfo = this.$store.state.dragComponentInfo this.addItemBox(moveInItemInfo) - // console.log('startMoveIn:') - const vm = this // e.preventDefault(); if (!this.infoBox) { this.infoBox = {} @@ -1672,6 +1543,13 @@ export default { }, closeJumpSetDialog() { this.linkJumpSetVisible = false + }, + // 调整父级组件边界 + resizeParentBoundsRef() { + const _this = this + _this.componentData.forEach(function(data, index) { + _this.$refs.deDragRef && _this.$refs.deDragRef[index] && _this.$refs.deDragRef[index].checkParentSize() + }) } } } diff --git a/frontend/src/components/canvas/components/Toolbar.vue b/frontend/src/components/canvas/components/Toolbar.vue index 9c5a0a99e9..1e7ed3c4f8 100644 --- a/frontend/src/components/canvas/components/Toolbar.vue +++ b/frontend/src/components/canvas/components/Toolbar.vue @@ -1,37 +1,28 @@ + + + + diff --git a/frontend/src/views/panel/edit/index.vue b/frontend/src/views/panel/edit/index.vue index 4fc7b10657..992125f75c 100644 --- a/frontend/src/views/panel/edit/index.vue +++ b/frontend/src/views/panel/edit/index.vue @@ -21,7 +21,7 @@ -
+
@@ -94,11 +94,11 @@ +
- +
+ + + +
+ + + + + +
+
+ + + +
- - - - -