refactor: stock & vehicle typings

This commit is contained in:
2024-04-15 18:32:19 +02:00
parent 61c7f15fcf
commit 541572e415
13 changed files with 175 additions and 133 deletions
+10 -11
View File
@@ -14,19 +14,18 @@ export default defineComponent({
methods: {
previewStock(stock: IStock) {
if (stock.isLoco) {
const chosenLoco = this.store.locoDataList.find((v) => v.type == stock.type) || null;
this.store.chosenVehicle = chosenLoco;
this.store.chosenLoco = chosenLoco;
this.store.chosenCargo = null;
this.store.chosenLocoGroup = stock.group as LocoGroupType;
} else {
const chosenCar = this.store.carDataList.find((v) => v.type == stock.type) || null;
this.store.chosenVehicle = chosenCar;
this.store.chosenCar = chosenCar;
const vehicleRef = stock.vehicleRef;
this.store.chosenVehicle = vehicleRef;
if (isTractionUnit(vehicleRef)) {
this.store.chosenLoco = vehicleRef;
this.store.chosenCargo = null;
this.store.chosenLocoGroup = vehicleRef.group as LocoGroupType;
} else {
this.store.chosenCar = vehicleRef;
this.store.chosenCargo = stock.cargo || null;
this.store.chosenCarGroup = stock.group as WagonGroupType;
this.store.chosenCarGroup = vehicleRef.group as WagonGroupType;
}
},