From 249bef48021ae2b273529f3d06c690a107f680af Mon Sep 17 00:00:00 2001 From: zyy <1787816799@qq.com> Date: Tue, 15 Dec 2020 14:41:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=81=93=E5=B2=94=E7=94=9F?= =?UTF-8?q?=E6=88=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmapNew/utils/parser.js | 30 ++++++++--- .../newMapdraft/mapoperate/section/create.vue | 52 +++++++++---------- 2 files changed, 49 insertions(+), 33 deletions(-) diff --git a/src/jmapNew/utils/parser.js b/src/jmapNew/utils/parser.js index ae1c91b28..f09e4c9cd 100644 --- a/src/jmapNew/utils/parser.js +++ b/src/jmapNew/utils/parser.js @@ -185,29 +185,45 @@ export function parser(data, skinCode, showConfig) { } let sectionCStar, sectionCEnd; if (handleResetPoint(rnodeSection.points)) { - sectionCStar = rnodeSection.points[0]; + sectionCStar = rnodeSection.points[rnodeSection.points.length - 2]; sectionCEnd = rnodeSection.points[1]; } else { sectionCStar = rnodeSection.points[1]; - sectionCEnd = rnodeSection.points[0]; + sectionCEnd = rnodeSection.points[rnodeSection.points.length - 2]; + } + let intersectionStar, intersectionEnd; + if (handleResetPoint(cnodeSection.points)) { + intersectionStar = cnodeSection.points[0]; + intersectionEnd = cnodeSection.points[cnodeSection.points.length - 1]; + } else { + intersectionStar = cnodeSection.points[cnodeSection.points.length - 1]; + intersectionEnd = cnodeSection.points[0]; } if (cnodeSection.points[0].x == lnodeSection.points[lnodeSection.points.length - 1].x && cnodeSection.points[0].y == lnodeSection.points[lnodeSection.points.length - 1].y) { mapDevice[elem.code].intersection = { - x: cnodeSection.points[0].x, - y: cnodeSection.points[0].y + x: intersectionStar.x, + y: intersectionStar.y + // x: cnodeSection.points[0].x, + // y: cnodeSection.points[0].y }; mapDevice[elem.code].skew = { x: sectionCStar.x, y: sectionCStar.y + // x: rnodeSection.points[rnodeSection.points.length - 2].x, + // y: rnodeSection.points[rnodeSection.points.length - 2].y }; } else if (cnodeSection.points[cnodeSection.points.length - 1].x == lnodeSection.points[0].x && cnodeSection.points[cnodeSection.points.length - 1].y == lnodeSection.points[0].y) { mapDevice[elem.code].intersection = { - x: cnodeSection.points[cnodeSection.points.length - 1].x, - y: cnodeSection.points[cnodeSection.points.length - 1].y + x: intersectionEnd.x, + y: intersectionEnd.y + // x: cnodeSection.points[cnodeSection.points.length - 1].x, + // y: cnodeSection.points[cnodeSection.points.length - 1].y }; mapDevice[elem.code].skew = { x: sectionCEnd.x, y: sectionCEnd.y + // x: rnodeSection.points[1].x, + // y: rnodeSection.points[1].y }; } @@ -264,7 +280,7 @@ export function parser(data, skinCode, showConfig) { // 重置坐标点 function handleResetPoint(points) { - return (points[points.length - 1].x >= points[0].x) && (points[points.length - 1].y >= points[0].y); + return (points[points.length - 1].x >= points[0].x); } // 同步绘制数据到原始数据 diff --git a/src/views/newMap/newMapdraft/mapoperate/section/create.vue b/src/views/newMap/newMapdraft/mapoperate/section/create.vue index dff9f0e94..3af9ba21a 100644 --- a/src/views/newMap/newMapdraft/mapoperate/section/create.vue +++ b/src/views/newMap/newMapdraft/mapoperate/section/create.vue @@ -260,33 +260,33 @@ export default { const end_x = endModel.points[0].x; const start_y = startModel.points[startModel.points.length - 1].y; const end_y = endModel.points[0].y; - // if (end_x > start_x) { - if (this.createModel.leftSectionCode === this.createModel.rightSectionCode) { - this.$messageBox('左关联区段不能和右关联区段相同'); - return; + if (end_x > start_x) { + if (this.createModel.leftSectionCode === this.createModel.rightSectionCode) { + this.$messageBox('左关联区段不能和右关联区段相同'); + return; + } + if (start_x === end_x && start_y === end_y) { + this.$messageBox('左关联区段终点不能和右关联区段起点相同'); + return; + } + model.points = [ + { x: start_x, y: start_y }, + { x: end_x, y: end_y } + ]; + const models = []; + model.leftSectionCode = this.createModel.leftSectionCode; + startModel.rightSectionCode = model.code; + endModel.leftSectionCode = model.code; + model.rightSectionCode = this.createModel.rightSectionCode; + models.push(model); + models.push(startModel); + models.push(endModel); + this.$emit('updateMapModel', models); + } else { + this.$messageBox('画图顺序应左往右绘制, 请求重新定义左右关联区段'); + this.createModel.rightSectionCode = ''; + this.createModel.leftSectionCode = ''; } - if (start_x === end_x && start_y === end_y) { - this.$messageBox('左关联区段终点不能和右关联区段起点相同'); - return; - } - model.points = [ - { x: start_x, y: start_y }, - { x: end_x, y: end_y } - ]; - const models = []; - model.leftSectionCode = this.createModel.leftSectionCode; - startModel.rightSectionCode = model.code; - endModel.leftSectionCode = model.code; - model.rightSectionCode = this.createModel.rightSectionCode; - models.push(model); - models.push(startModel); - models.push(endModel); - this.$emit('updateMapModel', models); - // } else { - // this.$messageBox('画图顺序应左往右绘制, 请求重新定义左右关联区段'); - // this.createModel.rightSectionCode = ''; - // this.createModel.leftSectionCode = ''; - // } }, // 创建区段 create() {