patches v1.3.3 #75
3 changed files with 78 additions and 1 deletions
63
src/components/admin/club/member/MemberPrintModal.vue
Normal file
63
src/components/admin/club/member/MemberPrintModal.vue
Normal file
|
@ -0,0 +1,63 @@
|
|||
<template>
|
||||
<div class="w-full h-full flex flex-col gap-2">
|
||||
<Spinner v-if="status == 'loading'" />
|
||||
<div class="grow">
|
||||
<iframe ref="viewer" class="w-full h-full" />
|
||||
</div>
|
||||
|
||||
<div class="flex flex-row gap-2 justify-end">
|
||||
<a ref="download" button primary class="!w-fit">download</a>
|
||||
<button primary-outline class="!w-fit" @click="closeModal">schließen</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineComponent } from "vue";
|
||||
import { mapState, mapActions } from "pinia";
|
||||
import { useModalStore } from "@/stores/modal";
|
||||
import Spinner from "@/components/Spinner.vue";
|
||||
import type { AxiosResponse } from "axios";
|
||||
import { useMemberStore } from "@/stores/admin/club/member/member";
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default defineComponent({
|
||||
data() {
|
||||
return {
|
||||
status: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapState(useModalStore, ["data"]),
|
||||
...mapState(useMemberStore, ["activeMemberObj"]),
|
||||
},
|
||||
mounted() {
|
||||
this.fetchItem();
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useModalStore, ["closeModal"]),
|
||||
...mapActions(useMemberStore, ["printMemberByActiveId"]),
|
||||
fetchItem() {
|
||||
this.status = "loading";
|
||||
this.printMemberByActiveId()
|
||||
.then((response) => {
|
||||
this.status = { status: "success" };
|
||||
const blob = new Blob([response.data], { type: "application/pdf" });
|
||||
(this.$refs.viewer as HTMLIFrameElement).src = window.URL.createObjectURL(blob);
|
||||
|
||||
const fileURL = window.URL.createObjectURL(new Blob([response.data]));
|
||||
const fileLink = this.$refs.download as HTMLAnchorElement;
|
||||
fileLink.href = fileURL;
|
||||
fileLink.setAttribute(
|
||||
"download",
|
||||
`Mitglied-Ausdruck ${this.activeMemberObj?.firstname}_${this.activeMemberObj?.lastname}.pdf`
|
||||
);
|
||||
})
|
||||
.catch(() => {
|
||||
this.status = { status: "failed" };
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
|
@ -87,6 +87,11 @@ export const useMemberStore = defineStore("member", {
|
|||
})
|
||||
.catch((err) => {});
|
||||
},
|
||||
async printMemberByActiveId() {
|
||||
return http.get(`/admin/member/${this.activeMember}/print`, {
|
||||
responseType: "blob",
|
||||
});
|
||||
},
|
||||
fetchMemberStatisticsById(id: string) {
|
||||
return http.get(`/admin/member/${id}/statistics`);
|
||||
},
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
{{ activeMemberObj?.lastname }}, {{ activeMemberObj?.firstname }}
|
||||
{{ activeMemberObj?.nameaffix ? `- ${activeMemberObj?.nameaffix}` : "" }}
|
||||
</h1>
|
||||
|
||||
<div title="Mitgliederliste drucken" @click="openPrintModal">
|
||||
<DocumentTextIcon class="w-5 h-5 cursor-pointer" />
|
||||
</div>
|
||||
<RouterLink v-if="can('update', 'club', 'member')" :to="{ name: 'admin-club-member-edit' }">
|
||||
<PencilIcon class="w-5 h-5" />
|
||||
</RouterLink>
|
||||
|
@ -49,7 +53,7 @@ import { mapActions, mapState } from "pinia";
|
|||
import MainTemplate from "@/templates/Main.vue";
|
||||
import { RouterLink, RouterView } from "vue-router";
|
||||
import { useMemberStore } from "@/stores/admin/club/member/member";
|
||||
import { PencilIcon, TrashIcon } from "@heroicons/vue/24/outline";
|
||||
import { PencilIcon, TrashIcon, DocumentTextIcon } from "@heroicons/vue/24/outline";
|
||||
import { useModalStore } from "@/stores/modal";
|
||||
import { useAbilityStore } from "@/stores/ability";
|
||||
</script>
|
||||
|
@ -87,6 +91,11 @@ export default defineComponent({
|
|||
parseInt(this.memberId ?? "")
|
||||
);
|
||||
},
|
||||
openPrintModal() {
|
||||
this.openModal(
|
||||
markRaw(defineAsyncComponent(() => import("@/components/admin/club/member/MemberPrintModal.vue")))
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Add table
Reference in a new issue