inspection plan execute
This commit is contained in:
parent
b359044cb5
commit
70e9b47483
17 changed files with 429 additions and 134 deletions
|
@ -1,6 +1,6 @@
|
|||
import { defineStore } from "pinia";
|
||||
import { http } from "@/serverCom";
|
||||
import type { InspectionViewModel } from "@/viewmodels/admin/unit/inspectionPlan/inspectionPlan.models";
|
||||
import type { InspectionViewModel } from "@/viewmodels/admin/unit/inspection/inspection.models";
|
||||
import { inspectionDemoData } from "@/demodata/inspectionPlan";
|
||||
import { useEquipmentStore } from "./equipment";
|
||||
|
||||
|
|
55
src/stores/admin/unit/inspection/inspection.ts
Normal file
55
src/stores/admin/unit/inspection/inspection.ts
Normal file
|
@ -0,0 +1,55 @@
|
|||
import { defineStore } from "pinia";
|
||||
import { http } from "@/serverCom";
|
||||
import type { AxiosResponse } from "axios";
|
||||
import { inspectionDemoData } from "@/demodata/inspectionPlan";
|
||||
import type { InspectionViewModel } from "@/viewmodels/admin/unit/inspection/inspection.models";
|
||||
|
||||
export const useInspectionStore = defineStore("inspection", {
|
||||
state: () => {
|
||||
return {
|
||||
activeInspection: null as string | null,
|
||||
activeInspectionObj: null as InspectionViewModel | null,
|
||||
loadingActive: "loading" as "loading" | "fetched" | "failed",
|
||||
};
|
||||
},
|
||||
actions: {
|
||||
fetchInspectionByActiveId() {
|
||||
this.loadingActive = "loading";
|
||||
this.activeInspectionObj = inspectionDemoData.find((e) => e.id == this.activeInspection) as InspectionViewModel;
|
||||
this.loadingActive = "fetched";
|
||||
return;
|
||||
this.loadingActive = "loading";
|
||||
http
|
||||
.get(`/admin/inspection/${this.activeInspection}`)
|
||||
.then((res) => {
|
||||
this.activeInspectionObj = res.data;
|
||||
this.loadingActive = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loadingActive = "failed";
|
||||
});
|
||||
},
|
||||
fetchInspectionById(id: string) {
|
||||
return http.get(`/admin/inspection/${id}`);
|
||||
},
|
||||
async createInspection(inspection: any): Promise<AxiosResponse<any, any>> {
|
||||
const result = await http.post(`/admin/inspection`, {
|
||||
// TODO: data
|
||||
});
|
||||
this.fetchInspectionByActiveId();
|
||||
return result;
|
||||
},
|
||||
async updateActiveInspection(inspection: any): Promise<AxiosResponse<any, any>> {
|
||||
const result = await http.patch(`/admin/inspection/${inspection.id}`, {
|
||||
// TODO: data
|
||||
});
|
||||
this.fetchInspectionByActiveId();
|
||||
return result;
|
||||
},
|
||||
async deleteInspection(inspection: number): Promise<AxiosResponse<any, any>> {
|
||||
const result = await http.delete(`/admin/inspection/${inspection}`);
|
||||
this.fetchInspectionByActiveId();
|
||||
return result;
|
||||
},
|
||||
},
|
||||
});
|
|
@ -1,6 +1,6 @@
|
|||
import { defineStore } from "pinia";
|
||||
import { http } from "@/serverCom";
|
||||
import type { InspectionViewModel } from "@/viewmodels/admin/unit/inspectionPlan/inspectionPlan.models";
|
||||
import type { InspectionViewModel } from "@/viewmodels/admin/unit/inspection/inspection.models";
|
||||
import { inspectionDemoData } from "@/demodata/inspectionPlan";
|
||||
import { useVehicleStore } from "./vehicle";
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue