From e8e63f2976a8b6c2f46815045cc9cd28ef05bdf1 Mon Sep 17 00:00:00 2001 From: fan <18706759286@163.com> Date: Mon, 11 May 2020 16:54:53 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=8C=BA=E6=AE=B5=E5=A7=8B?= =?UTF-8?q?=E7=BB=88=E7=82=B9=E5=81=8F=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapoperate/section/batchSettings.vue | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/views/newMap/newMapdraft/mapoperate/section/batchSettings.vue b/src/views/newMap/newMapdraft/mapoperate/section/batchSettings.vue index ed82942dd..96c775e40 100644 --- a/src/views/newMap/newMapdraft/mapoperate/section/batchSettings.vue +++ b/src/views/newMap/newMapdraft/mapoperate/section/batchSettings.vue @@ -281,23 +281,28 @@ export default { }, setLogicOffset() { const models = []; + // 正常情况下logicSectionCodeList下逻辑区段为从左向右 this.sectionList.forEach(section => { - let startPoint = section.points[0]; + let startPoint = section.points[0].x + 's' + section.points[0].y; let startOffset = 0; - if (section.logicSectionCodeList) { + const sectionMap = {}; + if (section.logicSectionCodeList && section.logicSectionCodeList.length) { section.logicSectionCodeList.forEach(sectionCode => { const logicSection = this.$store.getters['map/getDeviceByCode'](sectionCode); - if (logicSection.points[0].x === startPoint.x && logicSection.points[0].y === startPoint.y) { - const model = deepAssign({}, logicSection); - model.logicSectionStartOffset = startOffset; - model.logicSectionEndOffset = section.lengthFact - startOffset; - models.push(model); - startOffset += logicSection.lengthFact; - startPoint = logicSection.points[logicSection.points.length - 1]; - } else { - console.log('error', logicSection, section ); - } + sectionMap[logicSection.points[0].x + 's' + logicSection.points[0].y] = logicSection; }); + while (sectionMap[startPoint]) { + const model = deepAssign({}, sectionMap[startPoint]); + model.logicSectionStartOffset = startOffset; + model.logicSectionEndOffset = (section.lengthFact * 1000 - startOffset * 1000) / 1000; + models.push(model); + if (!model.lengthFact) { + const length = section.lengthFact / section.logicSectionCodeList.length; + model.lengthFact = length.toFixed(3); + } + startOffset = (startOffset * 1000 + model.lengthFact * 1000) / 1000; + startPoint = model.points[model.points.length - 1].x + 's' + model.points[model.points.length - 1].y; + } } }); this.$emit('updateMapModel', models, 'five');