diff --git a/src/utils/index.js b/src/utils/index.js index 8b3204716..cf921a389 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -144,6 +144,7 @@ export function deepClone(item) { return target; } +// 对象深拷贝并赋值 export function deepAssign(obj, item) { const target = item.constructor === Array ? [] : {}; // 判断复制的目标是数组还是对象 for (const keys in item) { diff --git a/src/views/newMap/newMapdraft/mapoperate/section/index.vue b/src/views/newMap/newMapdraft/mapoperate/section/index.vue index 6f8bd1d46..946450d04 100644 --- a/src/views/newMap/newMapdraft/mapoperate/section/index.vue +++ b/src/views/newMap/newMapdraft/mapoperate/section/index.vue @@ -234,9 +234,6 @@ export default { rightStopPointOffset: [ { required: true, message: this.$t('rules.rightStopPointOffset'), trigger: 'blur' } ], - // destinationCode: [ - // { required: true, message: this.$t('rules.destinationCode'), trigger: 'blur' } - // ], 'destinationCodePoint.x': [ { required: true, message: this.$t('rules.destinationCodePointX'), trigger: 'blur' } ], @@ -403,7 +400,7 @@ export default { this.editModel = deepAssign(this.editModel, selected); this.editModel.logicSectionNum = selected.type === '01' ? selected.logicSectionNum : [0]; this.editModel.points = JSON.parse(JSON.stringify(selected.points)); - this.editModel.lengthFact = selected.lengthFact || 0; + this.editModel.lengthFact = selected.lengthFact || 0; // 过滤非正常数值 this.oldPoint = JSON.parse(JSON.stringify(selected.points)); this.oldLeftSectionCode = selected.leftSectionCode; this.oldRightSectionCode = selected.rightSectionCode; @@ -488,7 +485,7 @@ export default { if (section.parentCode === model.code) { const copySection = deepAssign({}, section); copySection.logicSectionShow = model.logicSectionShow; - // copySection.lengthFact = (Number(model.lengthFact) / model.logicSectionCodeList.length).toFixed(3); + // copySection.lengthFact = (Number(model.lengthFact) / model.logicSectionCodeList.length).toFixed(3); // 容易变成正无穷 或者 NaN copySection.stationCode = model.stationCode; // 给元素 子逻辑区段设置 设备集中站 models.push(copySection); } else if (model.code !== section.code && (section.type === '01' || section.type === '03')) { diff --git a/src/views/newMap/newMapdraft/mapoperate/section/logicBlock.vue b/src/views/newMap/newMapdraft/mapoperate/section/logicBlock.vue index 6ce986529..dc5039e17 100644 --- a/src/views/newMap/newMapdraft/mapoperate/section/logicBlock.vue +++ b/src/views/newMap/newMapdraft/mapoperate/section/logicBlock.vue @@ -81,7 +81,10 @@ export default { this.tableData.forEach((ele, index) => { totalNum += Number(ele.num); }); - const lineLength = lengthFact / totalNum; // 均分逻辑区段偏移量 + let lineLength = 0; // 默认实际长度为0 + if (totalNum) { + lineLength = lengthFact / totalNum; // 均分逻辑区段偏移量 + } this.tableData.forEach((ele, index) => { models = [...models, ...this.createLogicalSections(Number(ele.num), sectionPoints[index], sectionPoints[index + 1], this.editModel, counts, lineLength, totalNum)]; allNotZeros = Number(ele.num) && allNotZeros; @@ -173,7 +176,7 @@ export default { trainPosType: model.trainPosType, points: points, curve: false, - lengthFact: lineLength.toFixed(3), + lengthFact: lineLength ? lineLength.toFixed(3) : lineLength, trainWindowCode: '', kmRangeRight: model.kmRangeRight, kmRangeLeft: model.kmRangeLeft,