change of models

This commit is contained in:
Julian Krauser 2025-05-14 14:42:00 +02:00
parent a49babe48d
commit ee700d9e02
28 changed files with 257 additions and 39 deletions

View file

@ -2,11 +2,11 @@
<div class="flex flex-col h-fit w-full border border-primary rounded-md">
<div class="bg-primary p-2 text-white flex flex-row justify-between items-center">
<p>
{{ damageReport.affected.name }}
{{ damageReport.related.name }}
</p>
</div>
<div class="p-2">
<p v-if="damageReport.affected">Code: {{ damageReport.affected.code }}</p>
<p v-if="damageReport.related">Code: {{ damageReport.related.code }}</p>
<p v-if="damageReport.description">Beschreibung: {{ damageReport.description }}</p>
</div>
</div>

View file

@ -4,7 +4,7 @@
class="flex flex-col h-fit w-full border border-primary rounded-md"
>
<div class="bg-primary p-2 text-white flex flex-row justify-between items-center">
<p>{{ inspectionPlan.title }} - {{ inspectionPlan.equipmentType.type }}</p>
<p>{{ inspectionPlan.title }} - {{ inspectionPlan.related.type }}</p>
</div>
<div class="p-2">
<p>Interval: {{ inspectionPlan.inspectionInterval }}</p>

View file

@ -9,5 +9,20 @@ export const damageReportDemoData: Array<DamageReportViewModel> = [
done: false,
description: "knjgljna g",
providedImage: undefined,
relatedId: "abc",
related: {
id: "abc",
code: "0456984224498",
name: "B-Schlauch",
location: "HLF",
equipmentTypeId: "xyz",
equipmentType: {
id: "xyz",
type: "B-Schlauch",
description: "Shläuche vom Typ B",
inspectionPlans: [],
},
inspections: [],
},
},
];

View file

@ -42,6 +42,13 @@ export const inspectionPlanDemoData: Array<InspectionPlanViewModel> = [
remindTime: "1-m",
created: new Date(),
inspectionPoints: [inspectionPointDemoData[0], inspectionPointDemoData[1], inspectionPointDemoData[2]],
relatedId: "xyz",
related: {
id: "xyz",
type: "B-Schlauch",
description: "Shläuche vom Typ B",
inspectionPlans: [],
},
},
{
id: "cba",
@ -51,6 +58,13 @@ export const inspectionPlanDemoData: Array<InspectionPlanViewModel> = [
remindTime: "22/10",
created: new Date(),
inspectionPoints: [inspectionPointDemoData[3]],
relatedId: "xyz",
related: {
id: "xyz",
type: "B-Schlauch",
description: "Shläuche vom Typ B",
inspectionPlans: [],
},
},
];
@ -94,6 +108,21 @@ export const inspectionDemoData: Array<InspectionViewModel> = [
nextInspection: undefined,
isOpen: true,
checks: [inspectionPointResultDemoData[0], inspectionPointResultDemoData[1], inspectionPointResultDemoData[2]],
relatedId: "abc",
related: {
id: "abc",
code: "0456984224498",
name: "B-Schlauch",
location: "HLF",
equipmentTypeId: "xyz",
equipmentType: {
id: "xyz",
type: "B-Schlauch",
description: "Shläuche vom Typ B",
inspectionPlans: [],
},
inspections: [],
},
},
{
id: "jkvshdfg",
@ -107,5 +136,20 @@ export const inspectionDemoData: Array<InspectionViewModel> = [
nextInspection: new Date(),
isOpen: false,
checks: [inspectionPointResultDemoData[0], inspectionPointResultDemoData[1], inspectionPointResultDemoData[2]],
relatedId: "abc",
related: {
id: "abc",
code: "0456984224498",
name: "B-Schlauch",
location: "HLF",
equipmentTypeId: "xyz",
equipmentType: {
id: "xyz",
type: "B-Schlauch",
description: "Shläuche vom Typ B",
inspectionPlans: [],
},
inspections: [],
},
},
];

View file

@ -7,16 +7,16 @@ export const vehicleDemoData: Array<VehicleViewModel> = [
code: "",
name: "HLF",
location: "Tor 1",
vehicleTypeId: "xyz",
vehicleTypeId: vehicleTypeDemoData[0].id,
vehicleType: vehicleTypeDemoData[0],
inspections: [],
},
{
id: "kjhb",
id: "kjhdfgb",
code: "",
name: "LF",
location: "Tor 2",
vehicleTypeId: "abc",
vehicleTypeId: vehicleTypeDemoData[1].id,
vehicleType: vehicleTypeDemoData[1],
inspections: [],
},

View file

@ -2,7 +2,7 @@ import type { VehicleTypeViewModel } from "@/viewmodels/admin/unit/vehicleType/v
export const vehicleTypeDemoData: Array<VehicleTypeViewModel> = [
{
id: "xyz",
id: "xyfgdghfz",
type: "HLF 20/10",
description: "HLF",
inspectionPlans: [],

View file

@ -3,7 +3,7 @@ import { wearableTypeDemoData } from "./wearableType";
export const wearableDemoData: Array<WearableViewModel> = [
{
id: "abc",
id: "absdfgc",
code: "0456984224498",
name: "Jacke",
location: "Spint",

View file

@ -484,10 +484,16 @@ const router = createRouter({
component: () => import("@/views/admin/unit/wearable/Overview.vue"),
props: true,
},
{
path: "maintenance",
name: "admin-unit-wearable-maintenance",
component: () => import("@/views/admin/ViewSelect.vue"),
props: true,
},
{
path: "report",
name: "admin-unit-wearable-damage_report",
component: () => import("@/views/admin/ViewSelect.vue"),
component: () => import("@/views/admin/unit/wearable/DamageReport.vue"),
props: true,
},
{

View file

@ -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 {

View file

@ -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;

View file

@ -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";

View file

@ -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

View file

@ -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 {

View file

@ -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;

View file

@ -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";

View 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";
});
},
},
});

View file

@ -1,3 +1,7 @@
import type { EquipmentViewModel } from "../equipment/equipment.models";
import type { VehicleViewModel } from "../vehicle/vehicle.models";
import type { WearableViewModel } from "../wearable/wearable.models";
export interface DamageReportViewModel {
id: string;
reported: Date;
@ -5,6 +9,8 @@ export interface DamageReportViewModel {
done: boolean;
description: string;
providedImage?: string;
relatedId: string;
related: EquipmentViewModel | VehicleViewModel | WearableViewModel;
}
export interface CreateDamageReportViewModel {

View file

@ -1,3 +1,8 @@
import type { EquipmentViewModel } from "../equipment/equipment.models";
import type { EquipmentTypeViewModel } from "../equipmentType/equipmentType.models";
import type { VehicleViewModel } from "../vehicle/vehicle.models";
import type { VehicleTypeViewModel } from "../vehicleType/vehicleType.models";
export type PlanTimeDefinition = `${number}-${"d" | "m" | "y"}` | `${number}/${number | "*"}`;
export interface InspectionPlanViewModel {
@ -8,6 +13,8 @@ export interface InspectionPlanViewModel {
version: number;
created: Date;
inspectionPoints: InspectionPointViewModel[];
relatedId: string;
related: EquipmentTypeViewModel | VehicleTypeViewModel;
}
export interface InspectionVersionedPlanViewModel {
@ -21,7 +28,7 @@ export interface CreateInspectionPlanViewModel {
title: string;
inspectionInterval: PlanTimeDefinition;
remindTime: PlanTimeDefinition;
typeId: string;
relatedId: string;
assigned: "vehicle" | "equipment";
}
@ -51,6 +58,8 @@ export interface InspectionViewModel {
isOpen: boolean;
nextInspection?: Date;
checks: Array<InspectionPointResultViewModel>;
relatedId: string;
related: EquipmentViewModel | VehicleViewModel;
}
export interface InspectionPointResultViewModel {

View file

@ -1,4 +1,4 @@
import type { MemberViewModel } from "@/club/member/member.models";
import type { MemberViewModel } from "@/viewmodels/admin/club/member/member.models";
export interface RespiratoryWearerViewModel {
id: string;

View file

@ -1,4 +1,4 @@
import type { MemberViewModel } from "@/club/member/member.models";
import type { MemberViewModel } from "@/viewmodels/admin/club/member/member.models";
import type { WearableTypeViewModel } from "../wearableType/wearableType.models";
export interface WearableViewModel {

View file

@ -61,7 +61,7 @@ export default defineComponent({
return {
tabs: [
{ route: "admin-unit-equipment-overview", title: "Übersicht" },
{ route: "admin-unit-equipment-maintenance", title: "Wartungen" },
{ route: "admin-unit-equipment-maintenance", title: "Wartungen/Reparaturen" },
{ route: "admin-unit-equipment-inspection", title: "Prüfungen" },
{ route: "admin-unit-equipment-damage_report", title: "Schadensmeldungen" },
],

View file

@ -7,7 +7,15 @@
<p v-else-if="loading == 'failed'" @click="fetchItem" class="cursor-pointer">&#8634; laden fehlgeschlagen</p>
</div>
<div class="flex flex-row gap-4">
<button v-if="can('create', 'unit', 'equipment_type')" primary class="w-fit!" @click="">Prüfplan erstellen</button>
<RouterLink
v-if="can('create', 'unit', 'equipment_type')"
:to="{ name: 'admin-unit-inspection_plan-create', query: { type: 'equipment', id: equipmentTypeId } }"
button
primary
class="w-fit!"
>
Prüfplan erstellen
</RouterLink>
</div>
</template>

View file

@ -31,7 +31,7 @@
</div>
</div>
<EquipmentTypeSearchSelect v-if="active == 'gear'" title="Typ" v-model="selectedType" />
<EquipmentTypeSearchSelect v-if="active == 'equipment'" title="Typ" v-model="selectedType" />
<VehicleTypeSearchSelect v-else title="Typ" v-model="selectedType" />
<div>
@ -114,22 +114,32 @@ export default defineComponent({
status: null as null | "loading" | { status: "success" | "failed"; reason?: string },
timeout: null as any,
selectedType: "" as string,
active: "gear" as string,
active: "equipment" as "equipment" | "vehicle",
tabs: [
{
key: "gear",
key: "equipment",
title: "Gerät",
},
{
key: "vehicle",
title: "Fahrzeug",
},
],
] as Array<{ key: "equipment" | "vehicle"; title: string }>,
};
},
computed: {
...mapState(useInspectionPlanStore, ["inspectionPlans"]),
},
mounted() {
let query = this.$route.query;
const queryType = Array.isArray(query.type) ? query.type[0] : query.type;
const queryId = Array.isArray(query.id) ? query.id[0] : query.id;
if (["vehicle", "equipment"].includes(queryType ?? "")) {
this.active = queryType as "equipment" | "vehicle";
this.selectedType = queryId as string;
}
console.log(query);
},
beforeUnmount() {
try {
clearTimeout(this.timeout);
@ -143,9 +153,10 @@ export default defineComponent({
let formData = e.target.elements;
let createInspectionPlan: CreateInspectionPlanViewModel = {
title: formData.name.value,
equipmentTypeId: "",
inspectionInterval: formData.name.value,
remindTime: formData.name.value,
relatedId: this.selectedType,
assigned: this.active,
};
this.status = "loading";
this.createInspectionPlan(createInspectionPlan)

View file

@ -1,16 +1,17 @@
<template>
<div class="flex flex-col gap-2 h-full w-full overflow-y-auto">
<div class="flex flex-col gap-2 h-full w-full overflow-hidden">
<div v-if="activeInspectionPlanObj != null" class="flex flex-col gap-2 w-full">
<div>
<label for="type">Typ</label>
<input type="text" id="type" :value="activeInspectionPlanObj.equipmentType.type" readonly />
<input type="text" id="type" :value="activeInspectionPlanObj.related.type" readonly />
</div>
<div>
<label for="interval">Intervall</label>
<input type="text" id="interval" :value="activeInspectionPlanObj.inspectionInterval" reaonly />
</div>
</div>
<div v-if="activeInspectionPlanObj?.inspectionPoints" class="flex flex-col gap-2">
<p>Prüfungspunkte</p>
<div v-if="activeInspectionPlanObj?.inspectionPoints" class="flex flex-col gap-2 grow overflow-y-scroll">
<div
v-for="point in activeInspectionPlanObj?.inspectionPoints"
class="flex flex-col h-fit w-full border border-primary rounded-md"

View file

@ -61,7 +61,7 @@ export default defineComponent({
return {
tabs: [
{ route: "admin-unit-vehicle-overview", title: "Übersicht" },
{ route: "admin-unit-vehicle-maintenance", title: "Wartungen" },
{ route: "admin-unit-vehicle-maintenance", title: "Wartungen/Reparaturen" },
{ route: "admin-unit-vehicle-inspection", title: "Prüfungen" },
{ route: "admin-unit-vehicle-damage_report", title: "Schadensmeldungen" },
],

View file

@ -8,7 +8,15 @@
</div>
<div class="flex flex-row gap-4">
<button v-if="can('create', 'unit', 'vehicle_type')" primary class="w-fit!" @click="">Prüfplan erstellen</button>
<RouterLink
v-if="can('create', 'unit', 'vehicle_type')"
:to="{ name: 'admin-unit-inspection_plan-create', query: { type: 'vehicle', id: vehicleTypeId } }"
button
primary
class="w-fit!"
>
Prüfplan erstellen
</RouterLink>
</div>
</template>

View file

@ -0,0 +1,55 @@
<template>
<div class="flex flex-col gap-2 h-full w-full">
<Pagination
:items="damageReports"
:totalCount="totalCount"
:indicateLoading="false"
@load-data="(offset, count, search) => {}"
@search="(search) => {}"
>
<template #pageRow="{ row }: { row: DamageReportViewModel }">
<div class="flex flex-col h-fit w-full border border-primary rounded-md">
<div class="bg-primary p-2 text-white flex flex-row gap-2 items-center">
<PencilSquareIcon v-if="!row.done" class="w-5 h-5" />
<PhotoIcon v-if="row.providedImage" />
<p>{{ row.reported }} - {{ row.status }}</p>
</div>
<div class="p-2">
<p>Beschreibung: {{ row.description }}</p>
</div>
</div>
</template>
</Pagination>
</div>
</template>
<script setup lang="ts">
import { defineComponent } from "vue";
import { mapActions, mapState } from "pinia";
import { useAbilityStore } from "@/stores/ability";
import { useWearableDamageReportStore } from "@/stores/admin/unit/wearable/damageReport";
import Pagination from "@/components/Pagination.vue";
import type { DamageReportViewModel } from "@/viewmodels/admin/unit/damageReport/damageReport.models";
import { PhotoIcon, PencilSquareIcon } from "@heroicons/vue/24/outline";
</script>
<script lang="ts">
export default defineComponent({
props: {
wearableId: String,
},
computed: {
...mapState(useAbilityStore, ["can"]),
...mapState(useWearableDamageReportStore, ["damageReports", "loading", "totalCount"]),
},
mounted() {
this.fetchItem();
},
methods: {
...mapActions(useWearableDamageReportStore, ["fetchDamageReportForWearable"]),
fetchItem() {
this.fetchDamageReportForWearable();
},
},
});
</script>

View file

@ -61,6 +61,7 @@ export default defineComponent({
return {
tabs: [
{ route: "admin-unit-wearable-overview", title: "Übersicht" },
{ route: "admin-unit-wearable-maintenance", title: "Reparaturen" },
{ route: "admin-unit-wearable-damage_report", title: "Schadensmeldungen" },
],
};