代码调整

This commit is contained in:
joylink_cuiweidong 2020-05-09 17:49:25 +08:00
parent 3215ac97ab
commit de024b9a45

View File

@ -374,24 +374,28 @@ export default {
this.addStartSectionData(true);
},
changeStartSection(data) {
this.judgeAllowSelected();
const result = this.addStartSectionData(false);
if (result) {
const section = this.$store.getters['map/getDeviceByCode'](data);
if (section.belongStation) {
this.addModel.startStationCode = section.belongStation;
}
this.judgeAllowSelected();
this.addStartSectionData(false);
}
},
changeEndStation() {
this.judgeAllowSelected();
this.addEndSectionData(true);
},
changeEndSection(data) {
this.judgeAllowSelected();
const result = this.addEndSectionData(false);
if (result) {
const section = this.$store.getters['map/getDeviceByCode'](data);
if (section.belongStation) {
this.addModel.startStationCode = section.belongStation;
this.addModel.endStationCode = section.belongStation;
}
}
this.judgeAllowSelected();
this.addEndSectionData(false);
},
judgeAllowSelected() {
if (this.addModel.startStationCode != '' && this.addModel.startSectionCode != '' && this.addModel.endStationCode != '' && this.addModel.endSectionCode != '') {
@ -403,13 +407,17 @@ export default {
addStartSectionData(isStation) {
if (this.addModel.startStationCode != '' && this.addModel.startSectionCode != '') {
this.isStartSelected = true;
this.pushSection({stationCode: this.addModel.startStationCode, sectionCode: this.addModel.startSectionCode}, 'top', isStation);
const result = this.pushSection({stationCode: this.addModel.startStationCode, sectionCode: this.addModel.startSectionCode}, 'top', isStation);
return result;
}
return false;
},
addEndSectionData(isStation) {
if (this.addModel.endStationCode != '' && this.addModel.endSectionCode != '') {
this.pushSection({stationCode: this.addModel.endStationCode, sectionCode: this.addModel.endSectionCode}, 'bottom', isStation);
const result = this.pushSection({stationCode: this.addModel.endStationCode, sectionCode: this.addModel.endSectionCode}, 'bottom', isStation);
return result;
}
return false;
},
hover(field) {
this.field = field === this.field ? '' : field;
@ -429,25 +437,25 @@ export default {
this.addEndSectionData(true);
} else if (selected._type.toUpperCase() === 'Section'.toUpperCase() && this.field.toUpperCase() === 'startSectionCode'.toUpperCase()) {
if (selected.standTrack || selected.reentryTrack || selected.transferTrack) {
if (selected.belongStation) {
this.addModel.startStationCode = selected.belongStation;
}
this.addModel.startSectionCode = selected.code;
this.judgeAllowSelected();
this.addStartSectionData(false);
const result = this.addStartSectionData(false);
if (selected.belongStation && result) {
this.addModel.startStationCode = selected.belongStation;
}
} else {
// (//)
this.$message.error('请选择正确的起始区段');
}
} else if (selected._type.toUpperCase() === 'Section'.toUpperCase() && this.field.toUpperCase() === 'endSectionCode'.toUpperCase()) {
if (selected.standTrack || selected.reentryTrack || selected.transferTrack) {
if (selected.belongStation) {
this.addModel.endStationCode = selected.belongStation;
}
this.addModel.endSectionCode = selected.code;
this.judgeAllowSelected();
this.addEndSectionData(false);
const result = this.addEndSectionData(false);
this.addModel.destinationCode = selected.destinationCode || '';
if (selected.belongStation && result) {
this.addModel.endStationCode = selected.belongStation;
}
} else {
this.$message.error('请选择正确的终到区段');
}
@ -470,36 +478,44 @@ export default {
case 'center': {
if (index < 0) {
list.splice(list.length - 1, 0, data);
return true;
} else {
this.$messageBox('该区段已经在交路区段中存在');
return false;
}
break;
}
case 'top': {
if (isStation) {
list.splice(0, 1, data);
return true;
} else {
if (index < 0) {
list.splice(0, 1, data);
return true;
} else {
if (index == list.length - 1 && list.length >= 2) {
this.$messageBox('起始区段和终到区段不能相同');
this.addModel.startSectionCode = list[0].sectionCode;
return false;
} else if (index != list.length - 1 && index != 0) {
this.$messageBox('该区段已经在交路区段中存在');
return false;
}
return false;
}
}
}
break;
}
case 'bottom': {
if (isStation) {
if (list.length >= 2) {
list.splice(list.length - 1, 1, data);
return true;
} else {
if (index < 0) {
list.push(data);
return true;
}
return false;
}
} else {
if (index < 0) {
@ -508,24 +524,28 @@ export default {
} else {
list.push(data);
}
return true;
} else {
if (index == 0 && list.length >= 2) {
this.$messageBox('起始区段和终到区段不能相同');
this.addModel.endSectionCode = list[list.length - 1].sectionCode;
return false;
} else if (index != list.length - 1 && index != 0) {
this.$messageBox('该区段已经在交路区段中存在');
return false;
}
return false;
}
}
}
break;
}
default: {
if (index < 0) {
list.splice(list.length - 1, 0, data);
return true;
} else {
this.$messageBox(this.$t('tip.routeSameID'));
return false;
}
break;
}
}
this.sectionCode = '';
@ -583,7 +603,7 @@ export default {
this.changeSectionSelected(this.addModel.parkSectionCodeList, flag);
},
changeSectionSelected(selectedList, flag) {
if (this.addModel.parkSectionCodeList.length > 0) {
if (this.addModel.parkSectionCodeList && this.addModel.parkSectionCodeList.length > 0) {
if (flag) {
if (this.oldsection.length > 0) {
this.oldsection.forEach((section)=>{