maintainance view and wearable inspection integration
This commit is contained in:
parent
50fa0128ea
commit
6575948841
26 changed files with 877 additions and 66 deletions
|
@ -123,6 +123,9 @@ export const useNavigationStore = defineStore("navigation", {
|
|||
...(abilityStore.can("read", "unit", "damage_report")
|
||||
? [{ key: "damage_report", title: "Schadensmeldungen" }]
|
||||
: []),
|
||||
...(abilityStore.can("read", "unit", "maintenance")
|
||||
? [{ key: "maintenance", title: "Wartungen / Reparaturen" }]
|
||||
: []),
|
||||
{ key: "divider1", title: "Basisdaten" },
|
||||
...(abilityStore.can("read", "unit", "equipment_type")
|
||||
? [{ key: "equipment_type", title: "Geräte-Typen" }]
|
||||
|
|
74
src/stores/admin/unit/maintenance/maintenance.ts
Normal file
74
src/stores/admin/unit/maintenance/maintenance.ts
Normal file
|
@ -0,0 +1,74 @@
|
|||
import { defineStore } from "pinia";
|
||||
import type {
|
||||
MaintenanceViewModel,
|
||||
CreateMaintenanceViewModel,
|
||||
UpdateMaintenanceViewModel,
|
||||
} from "@/viewmodels/admin/unit/maintenance.models";
|
||||
import { http } from "@/serverCom";
|
||||
import type { AxiosResponse } from "axios";
|
||||
|
||||
export const useMaintenanceStore = defineStore("maintenance", {
|
||||
state: () => {
|
||||
return {
|
||||
maintenances: [] as Array<MaintenanceViewModel & { tab_pos: number }>,
|
||||
totalCount: 0 as number,
|
||||
loading: "loading" as "loading" | "fetched" | "failed",
|
||||
};
|
||||
},
|
||||
actions: {
|
||||
fetchMaintenances(offset = 0, count = 25, search = "", clear = false) {
|
||||
if (clear) this.maintenances = [];
|
||||
this.loading = "loading";
|
||||
//TODO enable fetch of done reports
|
||||
http
|
||||
.get(`/admin/maintenance?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}`)
|
||||
.then((result) => {
|
||||
this.totalCount = result.data.total;
|
||||
result.data.maintenances
|
||||
.filter((elem: MaintenanceViewModel) => this.maintenances.findIndex((m) => m.id == elem.id) == -1)
|
||||
.map((elem: MaintenanceViewModel, index: number): MaintenanceViewModel & { tab_pos: number } => {
|
||||
return {
|
||||
...elem,
|
||||
tab_pos: index + offset,
|
||||
};
|
||||
})
|
||||
.forEach((elem: MaintenanceViewModel & { tab_pos: number }) => {
|
||||
this.maintenances.push(elem);
|
||||
});
|
||||
this.loading = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loading = "failed";
|
||||
});
|
||||
},
|
||||
async getAllMaintenances(): Promise<AxiosResponse<any, any>> {
|
||||
return await http.get(`/admin/maintenance?noLimit=true`).then((res) => {
|
||||
return { ...res, data: res.data.maintenances };
|
||||
});
|
||||
},
|
||||
async getMaintenancesByIds(ids: Array<string>): Promise<AxiosResponse<any, any>> {
|
||||
return await http
|
||||
.post(`/admin/maintenance/ids`, {
|
||||
ids,
|
||||
})
|
||||
.then((res) => {
|
||||
return { ...res, data: res.data.maintenances };
|
||||
});
|
||||
},
|
||||
async searchMaintenances(search: string): Promise<AxiosResponse<any, any>> {
|
||||
return await http.get(`/admin/maintenance?search=${search}&noLimit=true`).then((res) => {
|
||||
return { ...res, data: res.data.maintenances };
|
||||
});
|
||||
},
|
||||
fetchMaintenanceById(id: string) {
|
||||
return http.get(`/admin/maintenance/${id}`);
|
||||
},
|
||||
async updateMaintenance(maintenance: UpdateMaintenanceViewModel): Promise<AxiosResponse<any, any>> {
|
||||
const result = await http.patch(`/admin/maintenance/${maintenance.id}`, {
|
||||
// TODO: data
|
||||
});
|
||||
this.fetchMaintenances();
|
||||
return result;
|
||||
},
|
||||
},
|
||||
});
|
43
src/stores/admin/unit/wearable/inspection.ts
Normal file
43
src/stores/admin/unit/wearable/inspection.ts
Normal file
|
@ -0,0 +1,43 @@
|
|||
import { defineStore } from "pinia";
|
||||
import { http } from "@/serverCom";
|
||||
import type { InspectionViewModel } from "@/viewmodels/admin/unit/inspection/inspection.models";
|
||||
import { useWearableStore } from "./wearable";
|
||||
|
||||
export const useWearableInspectionStore = defineStore("wearableInspection", {
|
||||
state: () => {
|
||||
return {
|
||||
inspections: [] as Array<InspectionViewModel & { tab_pos: number }>,
|
||||
totalCount: 0 as number,
|
||||
loading: "loading" as "loading" | "fetched" | "failed",
|
||||
};
|
||||
},
|
||||
actions: {
|
||||
fetchInspectionForWearable(offset = 0, count = 25, search = "", clear = false) {
|
||||
const wearableId = useWearableStore().activeWearable;
|
||||
if (clear) this.inspections = [];
|
||||
this.loading = "loading";
|
||||
http
|
||||
.get(
|
||||
`/admin/inspection/wearable/${wearableId}?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}`
|
||||
)
|
||||
.then((result) => {
|
||||
this.totalCount = result.data.total;
|
||||
result.data.inspections
|
||||
.filter((elem: InspectionViewModel) => this.inspections.findIndex((m) => m.id == elem.id) == -1)
|
||||
.map((elem: InspectionViewModel, index: number): InspectionViewModel & { tab_pos: number } => {
|
||||
return {
|
||||
...elem,
|
||||
tab_pos: index + offset,
|
||||
};
|
||||
})
|
||||
.forEach((elem: InspectionViewModel & { tab_pos: number }) => {
|
||||
this.inspections.push(elem);
|
||||
});
|
||||
this.loading = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loading = "failed";
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
29
src/stores/admin/unit/wearableType/inspectionPlan.ts
Normal file
29
src/stores/admin/unit/wearableType/inspectionPlan.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
import { defineStore } from "pinia";
|
||||
import { http } from "@/serverCom";
|
||||
import type { InspectionPlanViewModel } from "@/viewmodels/admin/unit/inspection/inspectionPlan.models";
|
||||
import { useWearableTypeStore } from "./wearableType";
|
||||
|
||||
export const useWearableTypeInspectionPlanStore = defineStore("wearableTypeInspectionPlan", {
|
||||
state: () => {
|
||||
return {
|
||||
inspectionPlans: [] as Array<InspectionPlanViewModel>,
|
||||
totalCount: 0 as number,
|
||||
loading: "loading" as "loading" | "fetched" | "failed",
|
||||
};
|
||||
},
|
||||
actions: {
|
||||
fetchInspectionPlanForWearableType() {
|
||||
const wearableTypeId = useWearableTypeStore().activeWearableType;
|
||||
this.loading = "loading";
|
||||
http
|
||||
.get(`/admin/inspectionPlan/wearableType/${wearableTypeId}`)
|
||||
.then((result) => {
|
||||
this.inspectionPlans = result.data;
|
||||
this.loading = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loading = "failed";
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
|
@ -13,6 +13,9 @@ export const useWearableTypeStore = defineStore("wearableType", {
|
|||
wearableTypes: [] as Array<WearableTypeViewModel & { tab_pos: number }>,
|
||||
totalCount: 0 as number,
|
||||
loading: "loading" as "loading" | "fetched" | "failed",
|
||||
activeWearableType: null as string | null,
|
||||
activeWearableTypeObj: null as WearableTypeViewModel | null,
|
||||
loadingActive: "loading" as "loading" | "fetched" | "failed",
|
||||
};
|
||||
},
|
||||
actions: {
|
||||
|
@ -50,6 +53,18 @@ export const useWearableTypeStore = defineStore("wearableType", {
|
|||
return { ...res, data: res.data.wearableTypes };
|
||||
});
|
||||
},
|
||||
fetchWearableTypeByActiveId() {
|
||||
this.loadingActive = "loading";
|
||||
http
|
||||
.get(`/admin/wearableType/${this.activeWearableType}`)
|
||||
.then((res) => {
|
||||
this.activeWearableTypeObj = res.data;
|
||||
this.loadingActive = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loadingActive = "failed";
|
||||
});
|
||||
},
|
||||
fetchWearableTypeById(id: string) {
|
||||
return http.get(`/admin/wearableType/${id}`);
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue