代码调整

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