inspection plans and vehicle types
This commit is contained in:
parent
00fad29b25
commit
e25d91802c
32 changed files with 1384 additions and 172 deletions
|
@ -126,9 +126,15 @@ export const useNavigationStore = defineStore("navigation", {
|
|||
...(abilityStore.can("read", "unit", "equipment_type")
|
||||
? [{ key: "equipment_type", title: "Geräte-Typen" }]
|
||||
: []),
|
||||
...(abilityStore.can("read", "unit", "vehicle_type")
|
||||
? [{ key: "vehicle_type", title: "Fahrzeug-Arten" }]
|
||||
: []),
|
||||
...(abilityStore.can("read", "unit", "wearable_type")
|
||||
? [{ key: "wearable_type", title: "Kleidungs-Arten" }]
|
||||
: []),
|
||||
...(abilityStore.can("read", "unit", "inspection_plan")
|
||||
? [{ key: "inspection_plan", title: "Prüfpläne" }]
|
||||
: []),
|
||||
],
|
||||
},
|
||||
configuration: {
|
||||
|
|
110
src/stores/admin/unit/inspectionPlan/inspectionPlan.ts
Normal file
110
src/stores/admin/unit/inspectionPlan/inspectionPlan.ts
Normal file
|
@ -0,0 +1,110 @@
|
|||
import { defineStore } from "pinia";
|
||||
import type {
|
||||
InspectionPlanViewModel,
|
||||
CreateInspectionPlanViewModel,
|
||||
UpdateInspectionPlanViewModel,
|
||||
} from "@/viewmodels/admin/unit/inspectionPlan/inspectionPlan.models";
|
||||
import { http } from "@/serverCom";
|
||||
import type { AxiosResponse } from "axios";
|
||||
import { inspectionPlanDemoData } from "@/demodata/inspectionPlan";
|
||||
|
||||
export const useInspectionPlanStore = defineStore("inspectionPlan", {
|
||||
state: () => {
|
||||
return {
|
||||
inspectionPlans: [] as Array<InspectionPlanViewModel & { tab_pos: number }>,
|
||||
totalCount: 0 as number,
|
||||
loading: "loading" as "loading" | "fetched" | "failed",
|
||||
activeInspectionPlan: null as string | null,
|
||||
activeInspectionPlanObj: null as InspectionPlanViewModel | null,
|
||||
loadingActive: "loading" as "loading" | "fetched" | "failed",
|
||||
};
|
||||
},
|
||||
actions: {
|
||||
fetchInspectionPlans(offset = 0, count = 25, search = "", clear = false) {
|
||||
this.inspectionPlans = inspectionPlanDemoData.map((e, i) => ({ ...e, tab_pos: i }));
|
||||
this.totalCount = this.inspectionPlans.length;
|
||||
this.loading = "fetched";
|
||||
return;
|
||||
if (clear) this.inspectionPlans = [];
|
||||
this.loading = "loading";
|
||||
http
|
||||
.get(`/admin/inspectionPlan?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}`)
|
||||
.then((result) => {
|
||||
this.totalCount = result.data.total;
|
||||
result.data.inspectionPlans
|
||||
.filter((elem: InspectionPlanViewModel) => this.inspectionPlans.findIndex((m) => m.id == elem.id) == -1)
|
||||
.map((elem: InspectionPlanViewModel, index: number): InspectionPlanViewModel & { tab_pos: number } => {
|
||||
return {
|
||||
...elem,
|
||||
tab_pos: index + offset,
|
||||
};
|
||||
})
|
||||
.forEach((elem: InspectionPlanViewModel & { tab_pos: number }) => {
|
||||
this.inspectionPlans.push(elem);
|
||||
});
|
||||
this.loading = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loading = "failed";
|
||||
});
|
||||
},
|
||||
async getAllInspectionPlans(): Promise<AxiosResponse<any, any>> {
|
||||
return await http.get(`/admin/inspectionPlan?noLimit=true`).then((res) => {
|
||||
return { ...res, data: res.data.inspectionPlans };
|
||||
});
|
||||
},
|
||||
async getInspectionPlansByIds(ids: Array<string>): Promise<AxiosResponse<any, any>> {
|
||||
return await http
|
||||
.post(`/admin/inspectionPlan/ids`, {
|
||||
ids,
|
||||
})
|
||||
.then((res) => {
|
||||
return { ...res, data: res.data.inspectionPlans };
|
||||
});
|
||||
},
|
||||
async searchInspectionPlans(search: string): Promise<AxiosResponse<any, any>> {
|
||||
return await http.get(`/admin/inspectionPlan?search=${search}&noLimit=true`).then((res) => {
|
||||
return { ...res, data: res.data.inspectionPlans };
|
||||
});
|
||||
},
|
||||
fetchInspectionPlanByActiveId() {
|
||||
this.activeInspectionPlanObj = inspectionPlanDemoData.find(
|
||||
(e) => e.id == this.activeInspectionPlan
|
||||
) as InspectionPlanViewModel;
|
||||
this.loading = "fetched";
|
||||
return;
|
||||
this.loadingActive = "loading";
|
||||
http
|
||||
.get(`/admin/inspectionPlan/${this.activeInspectionPlan}`)
|
||||
.then((res) => {
|
||||
this.activeInspectionPlanObj = res.data;
|
||||
this.loadingActive = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loadingActive = "failed";
|
||||
});
|
||||
},
|
||||
fetchInspectionPlanById(id: string) {
|
||||
return http.get(`/admin/inspectionPlan/${id}`);
|
||||
},
|
||||
async createInspectionPlan(inspectionPlan: CreateInspectionPlanViewModel): Promise<AxiosResponse<any, any>> {
|
||||
const result = await http.post(`/admin/inspectionPlan`, {
|
||||
// TODO: data
|
||||
});
|
||||
this.fetchInspectionPlans();
|
||||
return result;
|
||||
},
|
||||
async updateActiveInspectionPlan(inspectionPlan: UpdateInspectionPlanViewModel): Promise<AxiosResponse<any, any>> {
|
||||
const result = await http.patch(`/admin/inspectionPlan/${inspectionPlan.id}`, {
|
||||
// TODO: data
|
||||
});
|
||||
this.fetchInspectionPlans();
|
||||
return result;
|
||||
},
|
||||
async deleteInspectionPlan(inspectionPlan: number): Promise<AxiosResponse<any, any>> {
|
||||
const result = await http.delete(`/admin/inspectionPlan/${inspectionPlan}`);
|
||||
this.fetchInspectionPlans();
|
||||
return result;
|
||||
},
|
||||
},
|
||||
});
|
101
src/stores/admin/unit/vehicleType/vehicleType.ts
Normal file
101
src/stores/admin/unit/vehicleType/vehicleType.ts
Normal file
|
@ -0,0 +1,101 @@
|
|||
import { defineStore } from "pinia";
|
||||
import type {
|
||||
VehicleTypeViewModel,
|
||||
CreateVehicleTypeViewModel,
|
||||
UpdateVehicleTypeViewModel,
|
||||
} from "@/viewmodels/admin/unit/vehicleType/vehicleType.models";
|
||||
import { http } from "@/serverCom";
|
||||
import type { AxiosResponse } from "axios";
|
||||
import { vehicleTypeDemoData } from "../../../../demodata/vehicleType";
|
||||
|
||||
export const useVehicleTypeStore = defineStore("vehicleType", {
|
||||
state: () => {
|
||||
return {
|
||||
vehicleTypes: [] as Array<VehicleTypeViewModel & { tab_pos: number }>,
|
||||
totalCount: 0 as number,
|
||||
loading: "loading" as "loading" | "fetched" | "failed",
|
||||
activeVehicleType: null as string | null,
|
||||
activeVehicleTypeObj: null as VehicleTypeViewModel | null,
|
||||
loadingActive: "loading" as "loading" | "fetched" | "failed",
|
||||
};
|
||||
},
|
||||
actions: {
|
||||
fetchVehicleTypes(offset = 0, count = 25, search = "", clear = false) {
|
||||
this.vehicleTypes = vehicleTypeDemoData.map((e, i) => ({ ...e, tab_pos: i }));
|
||||
this.totalCount = this.vehicleTypes.length;
|
||||
this.loading = "fetched";
|
||||
return;
|
||||
if (clear) this.vehicleTypes = [];
|
||||
this.loading = "loading";
|
||||
http
|
||||
.get(`/admin/vehicleType?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}`)
|
||||
.then((result) => {
|
||||
this.totalCount = result.data.total;
|
||||
result.data.vehicles
|
||||
.filter((elem: VehicleTypeViewModel) => this.vehicleTypes.findIndex((m) => m.id == elem.id) == -1)
|
||||
.map((elem: VehicleTypeViewModel, index: number): VehicleTypeViewModel & { tab_pos: number } => {
|
||||
return {
|
||||
...elem,
|
||||
tab_pos: index + offset,
|
||||
};
|
||||
})
|
||||
.forEach((elem: VehicleTypeViewModel & { tab_pos: number }) => {
|
||||
this.vehicleTypes.push(elem);
|
||||
});
|
||||
this.loading = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loading = "failed";
|
||||
});
|
||||
},
|
||||
async getAllVehicleTypes(): Promise<AxiosResponse<any, any>> {
|
||||
return await http.get(`/admin/vehicleType?noLimit=true`).then((res) => {
|
||||
return { ...res, data: res.data.vehicles };
|
||||
});
|
||||
},
|
||||
async searchVehicleTypes(search: string): Promise<AxiosResponse<any, any>> {
|
||||
return await http.get(`/admin/vehicleType?search=${search}&noLimit=true`).then((res) => {
|
||||
return { ...res, data: res.data.vehicles };
|
||||
});
|
||||
},
|
||||
fetchVehicleTypeByActiveId() {
|
||||
this.activeVehicleTypeObj = vehicleTypeDemoData.find(
|
||||
(e) => e.id == this.activeVehicleType
|
||||
) as VehicleTypeViewModel;
|
||||
this.loadingActive = "fetched";
|
||||
return;
|
||||
this.loadingActive = "loading";
|
||||
http
|
||||
.get(`/admin/vehicleType/${this.activeVehicleType}`)
|
||||
.then((res) => {
|
||||
this.activeVehicleTypeObj = res.data;
|
||||
this.loadingActive = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loadingActive = "failed";
|
||||
});
|
||||
},
|
||||
fetchVehicleTypeById(id: string) {
|
||||
return http.get(`/admin/vehicleType/${id}`);
|
||||
},
|
||||
async createVehicleType(vehicleType: CreateVehicleTypeViewModel): Promise<AxiosResponse<any, any>> {
|
||||
const result = await http.post(`/admin/vehicleType`, {
|
||||
// TODO: data
|
||||
});
|
||||
this.fetchVehicleTypes();
|
||||
return result;
|
||||
},
|
||||
async updateActiveVehicleType(vehicleType: UpdateVehicleTypeViewModel): Promise<AxiosResponse<any, any>> {
|
||||
const result = await http.patch(`/admin/vehicleType/${vehicleType.id}`, {
|
||||
// TODO: data
|
||||
});
|
||||
this.fetchVehicleTypes();
|
||||
return result;
|
||||
},
|
||||
async deleteVehicleType(vehicleType: number): Promise<AxiosResponse<any, any>> {
|
||||
const result = await http.delete(`/admin/vehicleType/${vehicleType}`);
|
||||
this.fetchVehicleTypes();
|
||||
return result;
|
||||
},
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue