diff --git a/src/components/panel/page.vue b/src/components/panel/page.vue index 8d107fb..bd51132 100644 --- a/src/components/panel/page.vue +++ b/src/components/panel/page.vue @@ -9,44 +9,28 @@ - + - + - + (mm) - + (mm) @@ -61,6 +45,24 @@ export default { return this.$vptd.state.page }, }, + methods: { + // 宽度与高度的比例必须约等于纸张宽度与纸张高度的比例,否则拖拽组件将错位 + shapeChanged(element) { + if (element === "width") { + const proportion = this.pageInfo.width / this.pageInfo.height + this.pageInfo.pageWidth = Math.ceil(proportion * this.pageInfo.pageHeight) + } else if (element === "height") { + const proportion = this.pageInfo.height / this.pageInfo.width + this.pageInfo.pageHeight = Math.ceil(proportion * this.pageInfo.pageWidth) + } else if (element === "pageWidth") { + const proportion = this.pageInfo.pageWidth / this.pageInfo.pageHeight + this.pageInfo.width = Math.ceil(proportion * this.pageInfo.height) + } else if (element === "pageHeight") { + const proportion = this.pageInfo.pageHeight / this.pageInfo.pageWidth + this.pageInfo.height = Math.ceil(proportion * this.pageInfo.width) + } + } + } } diff --git a/src/components/panel/style.vue b/src/components/panel/style.vue index 9f0f1c2..9428e02 100644 --- a/src/components/panel/style.vue +++ b/src/components/panel/style.vue @@ -5,44 +5,28 @@ - + - + - + - + @@ -50,60 +34,40 @@ - + - + - + - + - + - + 左对齐 居中 右对齐 @@ -113,50 +77,31 @@ - + - - + + - + - +