调整区段计算

This commit is contained in:
zyy 2020-04-10 16:19:37 +08:00
parent 48ca2388cb
commit 057b627c0d
3 changed files with 8 additions and 7 deletions

View File

@ -144,6 +144,7 @@ export function deepClone(item) {
return target; return target;
} }
// 对象深拷贝并赋值
export function deepAssign(obj, item) { export function deepAssign(obj, item) {
const target = item.constructor === Array ? [] : {}; // 判断复制的目标是数组还是对象 const target = item.constructor === Array ? [] : {}; // 判断复制的目标是数组还是对象
for (const keys in item) { for (const keys in item) {

View File

@ -234,9 +234,6 @@ export default {
rightStopPointOffset: [ rightStopPointOffset: [
{ required: true, message: this.$t('rules.rightStopPointOffset'), trigger: 'blur' } { required: true, message: this.$t('rules.rightStopPointOffset'), trigger: 'blur' }
], ],
// destinationCode: [
// { required: true, message: this.$t('rules.destinationCode'), trigger: 'blur' }
// ],
'destinationCodePoint.x': [ 'destinationCodePoint.x': [
{ required: true, message: this.$t('rules.destinationCodePointX'), trigger: 'blur' } { required: true, message: this.$t('rules.destinationCodePointX'), trigger: 'blur' }
], ],
@ -403,7 +400,7 @@ export default {
this.editModel = deepAssign(this.editModel, selected); this.editModel = deepAssign(this.editModel, selected);
this.editModel.logicSectionNum = selected.type === '01' ? selected.logicSectionNum : [0]; this.editModel.logicSectionNum = selected.type === '01' ? selected.logicSectionNum : [0];
this.editModel.points = JSON.parse(JSON.stringify(selected.points)); 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.oldPoint = JSON.parse(JSON.stringify(selected.points));
this.oldLeftSectionCode = selected.leftSectionCode; this.oldLeftSectionCode = selected.leftSectionCode;
this.oldRightSectionCode = selected.rightSectionCode; this.oldRightSectionCode = selected.rightSectionCode;
@ -488,7 +485,7 @@ export default {
if (section.parentCode === model.code) { if (section.parentCode === model.code) {
const copySection = deepAssign({}, section); const copySection = deepAssign({}, section);
copySection.logicSectionShow = model.logicSectionShow; 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; // copySection.stationCode = model.stationCode; //
models.push(copySection); models.push(copySection);
} else if (model.code !== section.code && (section.type === '01' || section.type === '03')) { } else if (model.code !== section.code && (section.type === '01' || section.type === '03')) {

View File

@ -81,7 +81,10 @@ export default {
this.tableData.forEach((ele, index) => { this.tableData.forEach((ele, index) => {
totalNum += Number(ele.num); totalNum += Number(ele.num);
}); });
const lineLength = lengthFact / totalNum; // let lineLength = 0; // 0
if (totalNum) {
lineLength = lengthFact / totalNum; //
}
this.tableData.forEach((ele, index) => { this.tableData.forEach((ele, index) => {
models = [...models, ...this.createLogicalSections(Number(ele.num), sectionPoints[index], sectionPoints[index + 1], this.editModel, counts, lineLength, totalNum)]; models = [...models, ...this.createLogicalSections(Number(ele.num), sectionPoints[index], sectionPoints[index + 1], this.editModel, counts, lineLength, totalNum)];
allNotZeros = Number(ele.num) && allNotZeros; allNotZeros = Number(ele.num) && allNotZeros;
@ -173,7 +176,7 @@ export default {
trainPosType: model.trainPosType, trainPosType: model.trainPosType,
points: points, points: points,
curve: false, curve: false,
lengthFact: lineLength.toFixed(3), lengthFact: lineLength ? lineLength.toFixed(3) : lineLength,
trainWindowCode: '', trainWindowCode: '',
kmRangeRight: model.kmRangeRight, kmRangeRight: model.kmRangeRight,
kmRangeLeft: model.kmRangeLeft, kmRangeLeft: model.kmRangeLeft,