change of models
This commit is contained in:
parent
a49babe48d
commit
ee700d9e02
28 changed files with 257 additions and 39 deletions
|
@ -15,7 +15,9 @@ export const useEquipmentDamageReportStore = defineStore("equipmentDamageReport"
|
|||
actions: {
|
||||
fetchDamageReportForEquipment(offset = 0, count = 25, search = "", clear = false) {
|
||||
const equipmentId = useEquipmentStore().activeEquipment;
|
||||
this.damageReports = damageReportDemoData.map((e, i) => ({ ...e, tab_pos: i }));
|
||||
this.damageReports = damageReportDemoData
|
||||
.filter((drdd) => drdd.relatedId == equipmentId)
|
||||
.map((e, i) => ({ ...e, tab_pos: i }));
|
||||
this.totalCount = this.damageReports.length;
|
||||
this.loading = "fetched";
|
||||
return;
|
||||
|
@ -23,11 +25,11 @@ export const useEquipmentDamageReportStore = defineStore("equipmentDamageReport"
|
|||
this.loading = "loading";
|
||||
http
|
||||
.get(
|
||||
`/admin/equipment/${equipmentId}/inspection?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}`
|
||||
`/admin/equipment/${equipmentId}/damageReport?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}`
|
||||
)
|
||||
.then((result) => {
|
||||
this.totalCount = result.data.total;
|
||||
result.data.inspections
|
||||
result.data.reports
|
||||
.filter((elem: DamageReportViewModel) => this.damageReports.findIndex((m) => m.id == elem.id) == -1)
|
||||
.map((elem: DamageReportViewModel, index: number): DamageReportViewModel & { tab_pos: number } => {
|
||||
return {
|
||||
|
|
|
@ -15,7 +15,9 @@ export const useEquipmentInspectionStore = defineStore("equipmentInspection", {
|
|||
actions: {
|
||||
fetchInspectionForEquipment(offset = 0, count = 25, search = "", clear = false) {
|
||||
const equipmentId = useEquipmentStore().activeEquipment;
|
||||
this.inspections = inspectionDemoData.map((e, i) => ({ ...e, tab_pos: i }));
|
||||
this.inspections = inspectionDemoData
|
||||
.filter((idd) => idd.relatedId == equipmentId)
|
||||
.map((e, i) => ({ ...e, tab_pos: i }));
|
||||
this.totalCount = this.inspections.length;
|
||||
this.loading = "fetched";
|
||||
return;
|
||||
|
|
|
@ -21,9 +21,7 @@ export const useEquipmentTypeInspectionPlanStore = defineStore("equipmentTypeIns
|
|||
actions: {
|
||||
fetchInspectionPlanForEquipmentType() {
|
||||
const equipmentTypeId = useEquipmentTypeStore().activeEquipmentType;
|
||||
this.inspectionPlans = inspectionPlanDemoData.filter(
|
||||
(ipdd) => ipdd.typeId == equipmentTypeId && ipdd.assigned == "equipment"
|
||||
);
|
||||
this.inspectionPlans = inspectionPlanDemoData.filter((ipdd) => ipdd.relatedId == equipmentTypeId);
|
||||
this.loading = "fetched";
|
||||
return;
|
||||
this.loading = "loading";
|
||||
|
|
|
@ -71,7 +71,7 @@ export const useInspectionPlanStore = defineStore("inspectionPlan", {
|
|||
this.activeInspectionPlanObj = inspectionPlanDemoData.find(
|
||||
(e) => e.id == this.activeInspectionPlan
|
||||
) as InspectionPlanViewModel;
|
||||
this.loading = "fetched";
|
||||
this.loadingActive = "fetched";
|
||||
return;
|
||||
this.loadingActive = "loading";
|
||||
http
|
||||
|
|
|
@ -15,7 +15,9 @@ export const useVehicleDamageReportStore = defineStore("vehicleDamageReport", {
|
|||
actions: {
|
||||
fetchDamageReportForVehicle(offset = 0, count = 25, search = "", clear = false) {
|
||||
const vehicleId = useVehicleStore().activeVehicle;
|
||||
this.damageReports = damageReportDemoData.map((e, i) => ({ ...e, tab_pos: i }));
|
||||
this.damageReports = damageReportDemoData
|
||||
.filter((drdd) => drdd.relatedId == vehicleId)
|
||||
.map((e, i) => ({ ...e, tab_pos: i }));
|
||||
this.totalCount = this.damageReports.length;
|
||||
this.loading = "fetched";
|
||||
return;
|
||||
|
@ -23,11 +25,11 @@ export const useVehicleDamageReportStore = defineStore("vehicleDamageReport", {
|
|||
this.loading = "loading";
|
||||
http
|
||||
.get(
|
||||
`/admin/vehicle/${vehicleId}/inspection?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}`
|
||||
`/admin/vehicle/${vehicleId}/damageReport?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}`
|
||||
)
|
||||
.then((result) => {
|
||||
this.totalCount = result.data.total;
|
||||
result.data.inspections
|
||||
result.data.reports
|
||||
.filter((elem: DamageReportViewModel) => this.damageReports.findIndex((m) => m.id == elem.id) == -1)
|
||||
.map((elem: DamageReportViewModel, index: number): DamageReportViewModel & { tab_pos: number } => {
|
||||
return {
|
||||
|
|
|
@ -15,7 +15,9 @@ export const useVehicleInspectionStore = defineStore("vehicleInspection", {
|
|||
actions: {
|
||||
fetchInspectionForVehicle(offset = 0, count = 25, search = "", clear = false) {
|
||||
const vehicleId = useVehicleStore().activeVehicle;
|
||||
this.inspections = inspectionDemoData.map((e, i) => ({ ...e, tab_pos: i }));
|
||||
this.inspections = inspectionDemoData
|
||||
.filter((idd) => idd.relatedId == vehicleId)
|
||||
.map((e, i) => ({ ...e, tab_pos: i }));
|
||||
this.totalCount = this.inspections.length;
|
||||
this.loading = "fetched";
|
||||
return;
|
||||
|
|
|
@ -22,9 +22,7 @@ export const useVehicleTypeInspectionPlanStore = defineStore("vehicleTypeInspect
|
|||
actions: {
|
||||
fetchInspectionPlanForVehicleType() {
|
||||
const vehicleTypeId = useVehicleTypeStore().activeVehicleType;
|
||||
this.inspectionPlans = inspectionPlanDemoData.filter(
|
||||
(ipdd) => ipdd.typeId == vehicleTypeId && ipdd.assigned == "vehicle"
|
||||
);
|
||||
this.inspectionPlans = inspectionPlanDemoData.filter((ipdd) => ipdd.relatedId == vehicleTypeId);
|
||||
this.loading = "fetched";
|
||||
return;
|
||||
this.loading = "loading";
|
||||
|
|
50
src/stores/admin/unit/wearable/damageReport.ts
Normal file
50
src/stores/admin/unit/wearable/damageReport.ts
Normal file
|
@ -0,0 +1,50 @@
|
|||
import { defineStore } from "pinia";
|
||||
import { http } from "@/serverCom";
|
||||
import { useWearableStore } from "./wearable";
|
||||
import type { DamageReportViewModel } from "@/viewmodels/admin/unit/damageReport/damageReport.models";
|
||||
import { damageReportDemoData } from "@/demodata/damageReport";
|
||||
|
||||
export const useWearableDamageReportStore = defineStore("wearableDamageReport", {
|
||||
state: () => {
|
||||
return {
|
||||
damageReports: [] as Array<DamageReportViewModel & { tab_pos: number }>,
|
||||
totalCount: 0 as number,
|
||||
loading: "loading" as "loading" | "fetched" | "failed",
|
||||
};
|
||||
},
|
||||
actions: {
|
||||
fetchDamageReportForWearable(offset = 0, count = 25, search = "", clear = false) {
|
||||
const wearableId = useWearableStore().activeWearable;
|
||||
this.damageReports = damageReportDemoData
|
||||
.filter((drdd) => drdd.relatedId == wearableId)
|
||||
.map((e, i) => ({ ...e, tab_pos: i }));
|
||||
this.totalCount = this.damageReports.length;
|
||||
this.loading = "fetched";
|
||||
return;
|
||||
if (clear) this.damageReports = [];
|
||||
this.loading = "loading";
|
||||
http
|
||||
.get(
|
||||
`/admin/wearable/${wearableId}/damageReport?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}`
|
||||
)
|
||||
.then((result) => {
|
||||
this.totalCount = result.data.total;
|
||||
result.data.reports
|
||||
.filter((elem: DamageReportViewModel) => this.damageReports.findIndex((m) => m.id == elem.id) == -1)
|
||||
.map((elem: DamageReportViewModel, index: number): DamageReportViewModel & { tab_pos: number } => {
|
||||
return {
|
||||
...elem,
|
||||
tab_pos: index + offset,
|
||||
};
|
||||
})
|
||||
.forEach((elem: DamageReportViewModel & { tab_pos: number }) => {
|
||||
this.damageReports.push(elem);
|
||||
});
|
||||
this.loading = "fetched";
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loading = "failed";
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue