2025-07-17 09:32:18 +02:00
|
|
|
<template>
|
|
|
|
<div class="flex flex-col gap-2 h-full w-full overflow-y-auto">
|
|
|
|
<div v-if="activeDamageReportObj != null" class="flex flex-col gap-2 w-full">
|
|
|
|
<div>
|
|
|
|
<label for="status">Status</label>
|
2025-07-17 10:37:40 +02:00
|
|
|
<input id="status" ref="status" type="text" :readonly="!editStatus" :value="activeDamageReportObj.status" />
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<label for="noteByWorker">Anmerkung durch Bearbeiter</label>
|
|
|
|
<textarea
|
|
|
|
id="noteByWorker"
|
|
|
|
ref="noteByWorker"
|
|
|
|
:readonly="!editStatus"
|
|
|
|
placeholder="---"
|
|
|
|
:value="activeDamageReportObj.noteByWorker"
|
|
|
|
></textarea>
|
|
|
|
</div>
|
|
|
|
<button
|
|
|
|
v-if="!editStatus && !activeDamageReportObj.done"
|
|
|
|
primary
|
|
|
|
class="w-fit! self-end"
|
|
|
|
@click="editStatus = true"
|
|
|
|
>
|
|
|
|
Status ändern
|
|
|
|
</button>
|
|
|
|
<div v-else-if="!activeDamageReportObj.done" class="flex flex-row gap-2 justify-end">
|
|
|
|
<button primary-outline class="w-fit!" @click="saveStatus(true)">speichern und abschließen</button>
|
|
|
|
<button primary class="w-fit!" @click="saveStatus(false)">Status speichern</button>
|
2025-07-17 09:32:18 +02:00
|
|
|
</div>
|
|
|
|
<br />
|
|
|
|
<div>
|
|
|
|
<label for="description">Beschreibung des Schadens</label>
|
|
|
|
<textarea id="description" readonly :value="activeDamageReportObj.description"></textarea>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<label for="location">Fundort</label>
|
2025-07-17 10:37:40 +02:00
|
|
|
<textarea id="location" readonly placeholder="---" :value="activeDamageReportObj.location"></textarea>
|
2025-07-17 09:32:18 +02:00
|
|
|
</div>
|
|
|
|
<div>
|
2025-07-17 10:37:40 +02:00
|
|
|
<label for="noteByReporter">Anmerkung für Bearbeiter</label>
|
|
|
|
<textarea
|
|
|
|
id="noteByReporter"
|
|
|
|
readonly
|
|
|
|
placeholder="---"
|
|
|
|
:value="activeDamageReportObj.noteByReporter"
|
|
|
|
></textarea>
|
2025-07-17 09:32:18 +02:00
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<label for="reportedBy">Gemeldet von</label>
|
2025-07-17 10:37:40 +02:00
|
|
|
<input id="reportedBy" type="text" readonly placeholder="---" :value="activeDamageReportObj.reportedBy" />
|
2025-07-17 09:32:18 +02:00
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<label>Bild</label>
|
2025-07-17 10:37:40 +02:00
|
|
|
<div ref="imgs">
|
|
|
|
<small v-if="activeDamageReportObj.images.length == 0">Keine Bilder hochgeladen</small>
|
|
|
|
</div>
|
2025-07-17 09:32:18 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { defineComponent } from "vue";
|
2025-07-17 10:37:40 +02:00
|
|
|
import { mapActions, mapState, mapWritableState } from "pinia";
|
2025-07-17 09:32:18 +02:00
|
|
|
import { useAbilityStore } from "@/stores/ability";
|
2025-07-19 11:02:03 +02:00
|
|
|
import { useDamageReportStore } from "@/stores/admin/unit/damageReport";
|
2025-07-17 10:37:40 +02:00
|
|
|
import type { DamageReportViewModel, UpdateDamageReportViewModel } from "@/viewmodels/admin/unit/damageReport.models";
|
2025-07-17 09:32:18 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
export default defineComponent({
|
|
|
|
props: {
|
|
|
|
damageReportId: String,
|
|
|
|
},
|
2025-07-17 10:37:40 +02:00
|
|
|
watch: {
|
|
|
|
activeDamageReportObj(val: DamageReportViewModel, oldVal: DamageReportViewModel | null) {
|
|
|
|
if (val && oldVal == null) this.loadImages();
|
|
|
|
},
|
|
|
|
},
|
2025-07-17 09:32:18 +02:00
|
|
|
data() {
|
2025-07-17 10:37:40 +02:00
|
|
|
return {
|
|
|
|
editStatus: false as boolean,
|
|
|
|
loading: undefined as undefined | "loading" | "success" | "failed",
|
|
|
|
};
|
2025-07-17 09:32:18 +02:00
|
|
|
},
|
|
|
|
computed: {
|
2025-07-17 10:37:40 +02:00
|
|
|
...mapWritableState(useDamageReportStore, ["activeDamageReportObj"]),
|
2025-07-17 09:32:18 +02:00
|
|
|
...mapState(useAbilityStore, ["can"]),
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.loadImages();
|
|
|
|
},
|
|
|
|
methods: {
|
2025-07-17 10:37:40 +02:00
|
|
|
...mapActions(useDamageReportStore, ["loadDamageReportImage", "updateDamageReport"]),
|
2025-07-17 09:32:18 +02:00
|
|
|
loadImages() {
|
|
|
|
for (const i of this.activeDamageReportObj?.images ?? []) {
|
|
|
|
this.loadDamageReportImage(i)
|
|
|
|
.then((response) => {
|
|
|
|
const contentType =
|
|
|
|
response.headers && response.headers["content-type"] ? response.headers["content-type"] : "image/*";
|
|
|
|
const blob = new Blob([response.data], { type: contentType });
|
|
|
|
const img = document.createElement("img");
|
|
|
|
img.src = window.URL.createObjectURL(blob);
|
|
|
|
img.alt = "Schadensbild";
|
|
|
|
img.classList = "h-35 w-auto";
|
|
|
|
(this.$refs.imgs as HTMLElement).appendChild(img);
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
console.log(err);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2025-07-17 10:37:40 +02:00
|
|
|
saveStatus(finish: boolean) {
|
|
|
|
if (this.activeDamageReportObj == null) return;
|
|
|
|
this.loading = "loading";
|
|
|
|
let update: UpdateDamageReportViewModel = {
|
|
|
|
id: this.activeDamageReportObj.id,
|
|
|
|
status: (this.$refs.status as HTMLInputElement).value,
|
|
|
|
noteByWorker: (this.$refs.noteByWorker as HTMLInputElement).value,
|
|
|
|
done: finish,
|
|
|
|
};
|
|
|
|
this.updateDamageReport(update)
|
|
|
|
.then((res) => {
|
|
|
|
this.activeDamageReportObj!.done = update.done;
|
|
|
|
this.activeDamageReportObj!.status = update.status;
|
|
|
|
this.activeDamageReportObj!.noteByWorker = update.noteByWorker;
|
|
|
|
this.loading = "success";
|
|
|
|
this.editStatus = false;
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
this.loading = "failed";
|
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
this.loading = undefined;
|
|
|
|
}, 2000);
|
|
|
|
});
|
|
|
|
},
|
2025-07-17 09:32:18 +02:00
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|