This commit is contained in:
zyy 2020-05-11 17:36:39 +08:00
commit 18fbae9114

View File

@ -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');