mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
poprawki dzienników
This commit is contained in:
@@ -103,6 +103,7 @@ import { useStore } from '../../store/store';
|
|||||||
import { JournalTimetableFilter } from '../../types/Journal/JournalTimetablesTypes';
|
import { JournalTimetableFilter } from '../../types/Journal/JournalTimetablesTypes';
|
||||||
import ActionButton from '../Global/ActionButton.vue';
|
import ActionButton from '../Global/ActionButton.vue';
|
||||||
import SelectBox from '../Global/SelectBox.vue';
|
import SelectBox from '../Global/SelectBox.vue';
|
||||||
|
import { JournalFilterSection } from '../../scripts/enums/JournalFilterType';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: { SelectBox, ActionButton },
|
components: { SelectBox, ActionButton },
|
||||||
@@ -139,6 +140,7 @@ export default defineComponent({
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
showOptions: false,
|
showOptions: false,
|
||||||
|
JournalFilterSection,
|
||||||
|
|
||||||
driverSuggestions: [] as string[],
|
driverSuggestions: [] as string[],
|
||||||
dispatcherSuggestions: [] as string[],
|
dispatcherSuggestions: [] as string[],
|
||||||
|
|||||||
@@ -1,28 +1,28 @@
|
|||||||
import { JournalFilterType } from "../../scripts/enums/JournalFilterType";
|
import { JournalFilterSection, JournalFilterType } from '../../scripts/enums/JournalFilterType';
|
||||||
import { JournalTimetableFilter } from "../../types/Journal/JournalTimetablesTypes";
|
import { JournalTimetableFilter } from '../../types/Journal/JournalTimetablesTypes';
|
||||||
|
|
||||||
export const journalTimetableFilters: JournalTimetableFilter[] = [
|
export const journalTimetableFilters: JournalTimetableFilter[] = [
|
||||||
{
|
{
|
||||||
id: JournalFilterType.all,
|
id: JournalFilterType.ALL,
|
||||||
filterSection: 'timetable-status',
|
filterSection: JournalFilterSection.TIMETABLE_STATUS,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
id: JournalFilterType.active,
|
id: JournalFilterType.ACTIVE,
|
||||||
filterSection: 'timetable-status',
|
filterSection: JournalFilterSection.TIMETABLE_STATUS,
|
||||||
isActive: false,
|
isActive: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
id: JournalFilterType.fulfilled,
|
id: JournalFilterType.FULFILLED,
|
||||||
filterSection: 'timetable-status',
|
filterSection: JournalFilterSection.TIMETABLE_STATUS,
|
||||||
isActive: false,
|
isActive: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
id: JournalFilterType.abandoned,
|
id: JournalFilterType.ABANDONED,
|
||||||
filterSection: 'timetable-status',
|
filterSection: JournalFilterSection.TIMETABLE_STATUS,
|
||||||
isActive: false,
|
isActive: false,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
export const enum JournalFilterType {
|
export const enum JournalFilterType {
|
||||||
active = "active",
|
ACTIVE = 'active',
|
||||||
fulfilled = "fulfilled",
|
FULFILLED = 'fulfilled',
|
||||||
abandoned = "abandoned",
|
ABANDONED = 'abandoned',
|
||||||
all = "all"
|
ALL = 'all',
|
||||||
|
TWR = 'twr',
|
||||||
|
SKR = 'skr',
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum JournalFilterSection {
|
||||||
|
TIMETABLE_STATUS = 'timetable-status',
|
||||||
|
TWR = 'twr',
|
||||||
|
SKR = 'skr',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
import { JournalFilterType } from '../../scripts/enums/JournalFilterType';
|
import { JournalFilterSection, JournalFilterType } from '../../scripts/enums/JournalFilterType';
|
||||||
|
|
||||||
export type JournalTimetableSearchKey = 'search-driver' | 'search-train' | 'search-date' | 'search-dispatcher' | 'search-issuedFrom';
|
export type JournalTimetableSearchKey =
|
||||||
|
| 'search-driver'
|
||||||
|
| 'search-train'
|
||||||
|
| 'search-date'
|
||||||
|
| 'search-dispatcher'
|
||||||
|
| 'search-issuedFrom';
|
||||||
|
|
||||||
export type JournalTimetableSearchType = {
|
export type JournalTimetableSearchType = {
|
||||||
[key in JournalTimetableSearchKey]: string;
|
[key in JournalTimetableSearchKey]: string;
|
||||||
@@ -8,7 +13,7 @@ export type JournalTimetableSearchType = {
|
|||||||
|
|
||||||
export interface JournalTimetableFilter {
|
export interface JournalTimetableFilter {
|
||||||
id: JournalFilterType;
|
id: JournalFilterType;
|
||||||
filterSection: string;
|
filterSection: JournalFilterSection;
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,23 +58,26 @@
|
|||||||
import { defineComponent, provide, reactive, Ref, ref } from 'vue';
|
import { defineComponent, provide, reactive, Ref, ref } from 'vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
import DriverStats from '../components/JournalView/JournalDriverStats.vue';
|
import imageMixin from '../mixins/imageMixin';
|
||||||
import Loading from '../components/Global/Loading.vue';
|
|
||||||
import { JournalTimetableSorter } from '../types/Journal/JournalTimetablesTypes';
|
|
||||||
import dateMixin from '../mixins/dateMixin';
|
import dateMixin from '../mixins/dateMixin';
|
||||||
import routerMixin from '../mixins/routerMixin';
|
import routerMixin from '../mixins/routerMixin';
|
||||||
|
import modalTrainMixin from '../mixins/modalTrainMixin';
|
||||||
|
|
||||||
|
import DriverStats from '../components/JournalView/JournalDriverStats.vue';
|
||||||
|
import JournalOptions from '../components/JournalView/JournalOptions.vue';
|
||||||
|
import JournalStats from '../components/JournalView/JournalStats.vue';
|
||||||
|
import JournalHeader from '../components/JournalView/JournalHeader.vue';
|
||||||
|
import JournalTimetablesList from '../components/JournalView/JournalTimetablesList.vue';
|
||||||
|
import Loading from '../components/Global/Loading.vue';
|
||||||
|
|
||||||
|
import { JournalTimetableSorter } from '../types/Journal/JournalTimetablesTypes';
|
||||||
import { DataStatus } from '../scripts/enums/DataStatus';
|
import { DataStatus } from '../scripts/enums/DataStatus';
|
||||||
import { TimetableHistory } from '../scripts/interfaces/api/TimetablesAPIData';
|
import { TimetableHistory } from '../scripts/interfaces/api/TimetablesAPIData';
|
||||||
import { URLs } from '../scripts/utils/apiURLs';
|
import { URLs } from '../scripts/utils/apiURLs';
|
||||||
import { useStore } from '../store/store';
|
import { useStore } from '../store/store';
|
||||||
import JournalOptions from '../components/JournalView/JournalOptions.vue';
|
|
||||||
import { JournalTimetableSearchType } from '../types/Journal/JournalTimetablesTypes';
|
import { JournalTimetableSearchType } from '../types/Journal/JournalTimetablesTypes';
|
||||||
import modalTrainMixin from '../mixins/modalTrainMixin';
|
|
||||||
import imageMixin from '../mixins/imageMixin';
|
|
||||||
import JournalTimetablesList from '../components/JournalView/JournalTimetablesList.vue';
|
|
||||||
import { journalTimetableFilters } from '../constants/Journal/JournalTimetablesConsts';
|
import { journalTimetableFilters } from '../constants/Journal/JournalTimetablesConsts';
|
||||||
import JournalStats from '../components/JournalView/JournalStats.vue';
|
|
||||||
import JournalHeader from '../components/JournalView/JournalHeader.vue';
|
|
||||||
import { LocationQuery } from 'vue-router';
|
import { LocationQuery } from 'vue-router';
|
||||||
import { TimetablesQueryParams } from '../scripts/interfaces/api/TimetablesQueryParams';
|
import { TimetablesQueryParams } from '../scripts/interfaces/api/TimetablesQueryParams';
|
||||||
import { JournalFilterType } from '../scripts/enums/JournalFilterType';
|
import { JournalFilterType } from '../scripts/enums/JournalFilterType';
|
||||||
@@ -148,8 +151,8 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
currentQueryArray(q: string[]) {
|
currentQueryParams(q: TimetablesQueryParams) {
|
||||||
this.currentOptionsActive = q.length >= 2 || q.some((qv) => qv.startsWith('sortBy=') && qv.split('=')[1]);
|
this.currentOptionsActive = Object.values(q).some((v) => v !== undefined);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -181,15 +184,16 @@ export default defineComponent({
|
|||||||
if ('timetableId' in query) this.searchersValues['search-train'] = `#${query.timetableId}`;
|
if ('timetableId' in query) this.searchersValues['search-train'] = `#${query.timetableId}`;
|
||||||
},
|
},
|
||||||
|
|
||||||
setSearchers(date: string, driver: string, train: string, dispatcher: string) {
|
setSearchers(date: string, driver: string, train: string, dispatcher: string, issuedFrom: string) {
|
||||||
this.searchersValues['search-date'] = date;
|
this.searchersValues['search-date'] = date;
|
||||||
this.searchersValues['search-driver'] = driver;
|
this.searchersValues['search-driver'] = driver;
|
||||||
this.searchersValues['search-train'] = train;
|
this.searchersValues['search-train'] = train;
|
||||||
this.searchersValues['search-dispatcher'] = dispatcher;
|
this.searchersValues['search-dispatcher'] = dispatcher;
|
||||||
|
this.searchersValues['search-issuedFrom'] = issuedFrom;
|
||||||
},
|
},
|
||||||
|
|
||||||
resetOptions() {
|
resetOptions() {
|
||||||
this.setSearchers('', '', '', '');
|
this.setSearchers('', '', '', '', '');
|
||||||
|
|
||||||
this.journalFilterActive = this.journalTimetableFilters[0];
|
this.journalFilterActive = this.journalTimetableFilters[0];
|
||||||
this.sorterActive.id = 'timetableId';
|
this.sorterActive.id = 'timetableId';
|
||||||
@@ -229,37 +233,47 @@ export default defineComponent({
|
|||||||
const timestampFrom = dateString ? Date.parse(new Date(dateString).toISOString()) - 120 * 60 * 1000 : undefined;
|
const timestampFrom = dateString ? Date.parse(new Date(dateString).toISOString()) - 120 * 60 * 1000 : undefined;
|
||||||
const timestampTo = timestampFrom ? timestampFrom + 86400000 : undefined;
|
const timestampTo = timestampFrom ? timestampFrom + 86400000 : undefined;
|
||||||
|
|
||||||
|
const queryParams: TimetablesQueryParams = {};
|
||||||
|
|
||||||
switch (this.journalFilterActive.id) {
|
switch (this.journalFilterActive.id) {
|
||||||
case JournalFilterType.abandoned:
|
case JournalFilterType.ABANDONED:
|
||||||
this.currentQueryParams['fulfilled'] = 0;
|
queryParams['fulfilled'] = 0;
|
||||||
this.currentQueryParams['terminated'] = 1;
|
queryParams['terminated'] = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JournalFilterType.active:
|
case JournalFilterType.ACTIVE:
|
||||||
this.currentQueryParams['terminated'] = 0;
|
queryParams['fulfilled'] = undefined;
|
||||||
|
queryParams['terminated'] = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JournalFilterType.fulfilled:
|
case JournalFilterType.FULFILLED:
|
||||||
this.currentQueryParams['fulfilled'] = 1;
|
queryParams['terminated'] = undefined;
|
||||||
|
queryParams['fulfilled'] = 1;
|
||||||
|
break;
|
||||||
|
case JournalFilterType.ALL:
|
||||||
|
queryParams['terminated'] = undefined;
|
||||||
|
queryParams['fulfilled'] = undefined;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentQueryParams['driverName'] = driverName;
|
queryParams['driverName'] = driverName;
|
||||||
this.currentQueryParams['trainNo'] = trainNo;
|
queryParams['trainNo'] = trainNo;
|
||||||
|
|
||||||
this.currentQueryParams['countFrom'] = undefined;
|
queryParams['countFrom'] = undefined;
|
||||||
this.currentQueryParams['countLimit'] = undefined;
|
queryParams['countLimit'] = undefined;
|
||||||
|
|
||||||
this.currentQueryParams['authorName'] = authorName;
|
queryParams['authorName'] = authorName;
|
||||||
this.currentQueryParams['timestampFrom'] = timestampFrom;
|
queryParams['timestampFrom'] = timestampFrom;
|
||||||
this.currentQueryParams['timestampTo'] = timestampTo;
|
queryParams['timestampTo'] = timestampTo;
|
||||||
this.currentQueryParams['issuedFrom'] = issuedFrom;
|
queryParams['issuedFrom'] = issuedFrom;
|
||||||
this.currentQueryParams['sortBy'] = this.sorterActive.id != 'timetableId' ? this.sorterActive.id : undefined;
|
queryParams['sortBy'] = this.sorterActive.id != 'timetableId' ? this.sorterActive.id : undefined;
|
||||||
|
|
||||||
this.dataStatus = DataStatus.Loading;
|
if (JSON.stringify(this.currentQueryParams) != JSON.stringify(queryParams)) this.dataStatus = DataStatus.Loading;
|
||||||
|
|
||||||
|
this.currentQueryParams = queryParams;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const responseData: TimetableHistory[] = await (
|
const responseData: TimetableHistory[] = await (
|
||||||
|
|||||||
Reference in New Issue
Block a user