Merge pull request #2126 from dataease/pr@dev@refactor_aided-design

refactor: 优化辅助设计
This commit is contained in:
王嘉豪 2022-04-17 16:30:06 +08:00 committed by GitHub
commit c23b20dbe9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 19 deletions

View File

@ -16,7 +16,7 @@
<!-- 网格线 -->
<Grid v-if="showGrid" :matrix-style="matrixStyle" />
<!-- positionBox:{{positionBoxInfo}}-->
<!-- <PGrid v-if="psDebug" :position-box="positionBoxInfoArray" :matrix-style="matrixStyle" />-->
<PGrid v-if="psDebug" :position-box="positionBoxInfoArray" :matrix-style="matrixStyle" />
<!-- 仪表板联动清除按钮-->
<canvas-opt-bar />
@ -293,15 +293,20 @@ function resetPositionBox() {
* @param {any} item
*/
function addItemToPositionBox(item) {
const pb = positionBox
if (item.x <= 0 || item.y <= 0) return
try {
const pb = positionBox
if (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++) {
if (pb[j][i]) {
pb[j][i].el = item
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++) {
if (pb[j][i]) {
pb[j][i].el = item
}
}
}
} catch (e) {
// igonre
console.log('addItemToPositionBox failed')
}
}
@ -1014,8 +1019,10 @@ export default {
watch: {
matrixCount: {
handler(newVal, oldVal) {
const pointScale = newVal.x / oldVal.x
this.changeScale(pointScale)
if (newVal && oldVal) {
this.changeComponentSizePoint(newVal.x / oldVal.x)
}
this.changeScale()
}
},
customStyle: {
@ -1241,17 +1248,17 @@ export default {
},
//
changeComponentSizePoint(pointScale) {
this.componentData.forEach((item, index) => {
item.x = (item.x - 1) * pointScale + 1
item.y = (item.y - 1) * pointScale + 1
item.sizex = item.sizex * pointScale
item.sizey = item.sizey * pointScale
// this.componentData[index] = item
})
if (pointScale) {
this.componentData.forEach((item, index) => {
item.x = (item.x - 1) * pointScale + 1
item.y = (item.y - 1) * pointScale + 1
item.sizex = item.sizex * pointScale
item.sizey = item.sizey * pointScale
})
}
},
changeScale(pointScale) {
this.changeComponentSizePoint(pointScale)
changeScale() {
// 1.3 1600*900 scaleWidth
// scaleHeight = scaleWidth 128*72 12.5*12.5

View File

@ -6,7 +6,7 @@
width="400"
trigger="click"
>
<el-col>
<el-col v-if="aidedDesign">
<el-form ref="aidedForm" label-width="110px" size="mini">
<el-form-item :label="'辅助网格'" class="form-item form-item-slider">
<el-checkbox v-model="aidedDesign.showGrid" size="mini" @change="onChangePanelStyle" />