This commit is contained in:
2022-08-27 14:04:02 +02:00
parent 9994a541b1
commit aae51d4139
+8 -16
View File
@@ -30,72 +30,64 @@ import modalTrainMixin from '../../mixins/modalTrainMixin';
import returnBtnMixin from '../../mixins/returnBtnMixin'; import returnBtnMixin from '../../mixins/returnBtnMixin';
import Train from '../../scripts/interfaces/Train'; import Train from '../../scripts/interfaces/Train';
import { useStore } from '../../store/store'; import { useStore } from '../../store/store';
import Loading from '../Global/Loading.vue';
import TrainInfo from './TrainInfo.vue';
export default defineComponent({ export default defineComponent({
components: { Loading, TrainInfo },
props: { props: {
trains: { trains: {
type: Array as PropType<Train[]>, type: Array as PropType<Train[]>,
required: true, required: true,
}, },
}, },
mixins: [returnBtnMixin, modalTrainMixin], mixins: [returnBtnMixin, modalTrainMixin],
setup(props) { setup(props) {
const store = useStore(); const store = useStore();
const searchedTrain = inject('searchedTrain') as Ref<string>; const searchedTrain = inject('searchedTrain') as Ref<string>;
const searchedDriver = inject('searchedDriver') as Ref<string>; const searchedDriver = inject('searchedDriver') as Ref<string>;
const currentTrains = computed(() => { const currentTrains = computed(() => {
return props.trains; return props.trains;
}); });
return { return {
searchedTrain, searchedTrain,
searchedDriver, searchedDriver,
currentTrains, currentTrains,
store, store,
sorterActive: inject('sorterActive') as { id: string | number; dir: number }, sorterActive: inject('sorterActive') as {
id: string | number;
dir: number;
},
distanceLimitExceeded: computed( distanceLimitExceeded: computed(
() => props.trains.findIndex(({ timetableData }) => timetableData && timetableData.routeDistance > 200) != -1 () => props.trains.findIndex(({ timetableData }) => timetableData && timetableData.routeDistance > 200) != -1
), ),
}; };
}, },
activated() { activated() {
const query = this.$route.query; const query = this.$route.query;
if (query.trainNo && query.driverName) { if (query.trainNo && query.driverName) {
this.searchedDriver = query.driverName.toString(); this.searchedDriver = query.driverName.toString();
this.searchedTrain = query.trainNo.toString(); this.searchedTrain = query.trainNo.toString();
setTimeout(() => { setTimeout(() => {
this.selectModalTrain(query.driverName! + query.trainNo!.toString()); this.selectModalTrain(query.driverName! + query.trainNo!.toString());
}, 20); }, 20);
} }
}, },
methods: { methods: {
enter(el: HTMLElement) { enter(el: HTMLElement) {
const maxHeight = getComputedStyle(el).height; const maxHeight = getComputedStyle(el).height;
el.style.height = '0px'; el.style.height = '0px';
getComputedStyle(el); getComputedStyle(el);
setTimeout(() => { setTimeout(() => {
el.style.height = maxHeight; el.style.height = maxHeight;
}, 10); }, 10);
}, },
afterEnter(el: HTMLElement) { afterEnter(el: HTMLElement) {
el.style.height = 'auto'; el.style.height = 'auto';
}, },
leave(el: HTMLElement) { leave(el: HTMLElement) {
el.style.height = getComputedStyle(el).height; el.style.height = getComputedStyle(el).height;
setTimeout(() => { setTimeout(() => {
el.style.height = '0px'; el.style.height = '0px';
}, 10); }, 10);