feat: download report
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 8s
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 8s
This commit is contained in:
parent
7522c967d9
commit
e6f2a8df4e
3 changed files with 106 additions and 9 deletions
|
|
@ -15,9 +15,7 @@ defineProps<{
|
||||||
:default-opened="defaultOpened"
|
:default-opened="defaultOpened"
|
||||||
>
|
>
|
||||||
<template #header>
|
<template #header>
|
||||||
<span>
|
|
||||||
<slot name="header" />
|
<slot name="header" />
|
||||||
</span>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<main class="surface-1 q-pa-md full-width">
|
<main class="surface-1 q-pa-md full-width">
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import useFlowStore from 'src/stores/flow';
|
||||||
import { useReportStore } from 'src/stores/report';
|
import { useReportStore } from 'src/stores/report';
|
||||||
import BadgeComponent from 'src/components/BadgeComponent.vue';
|
import BadgeComponent from 'src/components/BadgeComponent.vue';
|
||||||
import Expansion from 'src/components/14_report/Expansion.vue';
|
import Expansion from 'src/components/14_report/Expansion.vue';
|
||||||
|
import { SaveButton } from 'src/components/button';
|
||||||
|
|
||||||
// NOTE: Variable
|
// NOTE: Variable
|
||||||
const navigatorStore = useNavigator();
|
const navigatorStore = useNavigator();
|
||||||
|
|
@ -166,7 +167,17 @@ watch([() => pageState.currentTab], async () => {
|
||||||
<!-- Quotatio -->
|
<!-- Quotatio -->
|
||||||
|
|
||||||
<Expansion default-opened>
|
<Expansion default-opened>
|
||||||
<template #header>{{ $t('quotation.title') }}</template>
|
<template #header>
|
||||||
|
<div class="flex full-width items-center">
|
||||||
|
{{ $t('quotation.title') }}
|
||||||
|
<SaveButton
|
||||||
|
style="margin-left: auto"
|
||||||
|
:icon="'material-symbols:download'"
|
||||||
|
:label="$t('general.download')"
|
||||||
|
@click.stop="reportStore.downloadReportQuotation()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template #main>
|
<template #main>
|
||||||
<TableReport
|
<TableReport
|
||||||
|
|
@ -185,7 +196,17 @@ watch([() => pageState.currentTab], async () => {
|
||||||
|
|
||||||
<!-- Invoice -->
|
<!-- Invoice -->
|
||||||
<Expansion default-opened>
|
<Expansion default-opened>
|
||||||
<template #header>{{ $t('invoice.title') }}</template>
|
<template #header>
|
||||||
|
<div class="flex full-width items-center">
|
||||||
|
{{ $t('invoice.title') }}
|
||||||
|
<SaveButton
|
||||||
|
style="margin-left: auto"
|
||||||
|
:icon="'material-symbols:download'"
|
||||||
|
:label="$t('general.download')"
|
||||||
|
@click.stop="reportStore.downloadReportInvoice()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
<template #main>
|
<template #main>
|
||||||
<TableReport :row="dataReportInvoice" :columns="colReport">
|
<TableReport :row="dataReportInvoice" :columns="colReport">
|
||||||
<template #status="{ item }">
|
<template #status="{ item }">
|
||||||
|
|
@ -200,7 +221,17 @@ watch([() => pageState.currentTab], async () => {
|
||||||
|
|
||||||
<!-- Receipt -->
|
<!-- Receipt -->
|
||||||
<Expansion default-opened>
|
<Expansion default-opened>
|
||||||
<template #header>{{ $t('receipt.title') }}</template>
|
<template #header>
|
||||||
|
<div class="flex full-width items-center">
|
||||||
|
{{ $t('receipt.title') }}
|
||||||
|
<SaveButton
|
||||||
|
style="margin-left: auto"
|
||||||
|
:icon="'material-symbols:download'"
|
||||||
|
:label="$t('general.download')"
|
||||||
|
@click.stop="reportStore.downloadReportReceipt()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
<template #main>
|
<template #main>
|
||||||
<TableReport :row="dataReportReceipt" :columns="colReport">
|
<TableReport :row="dataReportReceipt" :columns="colReport">
|
||||||
<template #status="{ item }">
|
<template #status="{ item }">
|
||||||
|
|
@ -217,7 +248,17 @@ watch([() => pageState.currentTab], async () => {
|
||||||
|
|
||||||
<template v-if="pageState.currentTab === ViewMode.Invoice">
|
<template v-if="pageState.currentTab === ViewMode.Invoice">
|
||||||
<Expansion default-opened>
|
<Expansion default-opened>
|
||||||
<template #header>{{ $t('invoice.title') }}</template>
|
<template #header>
|
||||||
|
<div class="flex full-width items-center">
|
||||||
|
{{ $t('invoice.title') }}
|
||||||
|
<SaveButton
|
||||||
|
style="margin-left: auto"
|
||||||
|
:icon="'material-symbols:download'"
|
||||||
|
:label="$t('general.download')"
|
||||||
|
@click.stop="reportStore.downloadReportInvoice()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
<template #main>
|
<template #main>
|
||||||
<TableReport :row="dataReportInvoice" :columns="colReport">
|
<TableReport :row="dataReportInvoice" :columns="colReport">
|
||||||
<template #status="{ item }">
|
<template #status="{ item }">
|
||||||
|
|
@ -233,7 +274,17 @@ watch([() => pageState.currentTab], async () => {
|
||||||
|
|
||||||
<template v-if="pageState.currentTab === ViewMode.Product">
|
<template v-if="pageState.currentTab === ViewMode.Product">
|
||||||
<Expansion default-opened>
|
<Expansion default-opened>
|
||||||
<template #header>{{ $t('productService.title') }}</template>
|
<template #header>
|
||||||
|
<div class="flex full-width items-center">
|
||||||
|
{{ $t('productService.title') }}
|
||||||
|
<SaveButton
|
||||||
|
style="margin-left: auto"
|
||||||
|
:icon="'material-symbols:download'"
|
||||||
|
:label="$t('general.download')"
|
||||||
|
@click.stop="reportStore.downloadReportInvoice()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
<template #main>
|
<template #main>
|
||||||
<TableReport
|
<TableReport
|
||||||
:row="dataReportProduct"
|
:row="dataReportProduct"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { Pagination, Status } from '../types';
|
|
||||||
import { api } from 'src/boot/axios';
|
import { api } from 'src/boot/axios';
|
||||||
import {
|
import {
|
||||||
Report,
|
Report,
|
||||||
|
|
@ -9,9 +8,33 @@ import {
|
||||||
ReportQuotation,
|
ReportQuotation,
|
||||||
ReportSale,
|
ReportSale,
|
||||||
} from './types';
|
} from './types';
|
||||||
|
import { baseUrl } from '../utils';
|
||||||
|
import { getToken } from 'src/services/keycloak';
|
||||||
|
|
||||||
const ENDPOINT = 'report';
|
const ENDPOINT = 'report';
|
||||||
|
|
||||||
|
async function _download(url: string, filename?: string) {
|
||||||
|
const res = await fetch(url, {
|
||||||
|
headers: { ['Authorization']: 'Bearer ' + (await getToken()) },
|
||||||
|
});
|
||||||
|
const text = await res.json();
|
||||||
|
const blob = new Blob([text], { type: 'text/csv' });
|
||||||
|
if (res.ok && blob) {
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.download = (filename || 'report') + '.csv';
|
||||||
|
a.href = window.URL.createObjectURL(blob);
|
||||||
|
a.click();
|
||||||
|
a.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function downloadReportQuotation() {
|
||||||
|
await _download(
|
||||||
|
baseUrl + '/' + ENDPOINT + '/quotation/download',
|
||||||
|
'quotation-report',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export async function getReportQuotation() {
|
export async function getReportQuotation() {
|
||||||
const res = await api.get<ReportQuotation[]>(`/${ENDPOINT}/quotation`);
|
const res = await api.get<ReportQuotation[]>(`/${ENDPOINT}/quotation`);
|
||||||
if (res.status < 400) {
|
if (res.status < 400) {
|
||||||
|
|
@ -21,6 +44,13 @@ export async function getReportQuotation() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function downloadReportInvoice() {
|
||||||
|
await _download(
|
||||||
|
baseUrl + '/' + ENDPOINT + '/invoice/download',
|
||||||
|
'invoice-report',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export async function getReportInvoice() {
|
export async function getReportInvoice() {
|
||||||
const res = await api.get<Report[]>(`/${ENDPOINT}/invoice`);
|
const res = await api.get<Report[]>(`/${ENDPOINT}/invoice`);
|
||||||
if (res.status < 400) {
|
if (res.status < 400) {
|
||||||
|
|
@ -29,6 +59,13 @@ export async function getReportInvoice() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function downloadReportReceipt() {
|
||||||
|
await _download(
|
||||||
|
baseUrl + '/' + ENDPOINT + '/receipt/download',
|
||||||
|
'receipt-report',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export async function getReportReceipt() {
|
export async function getReportReceipt() {
|
||||||
const res = await api.get<Report[]>(`/${ENDPOINT}/receipt`);
|
const res = await api.get<Report[]>(`/${ENDPOINT}/receipt`);
|
||||||
if (res.status < 400) {
|
if (res.status < 400) {
|
||||||
|
|
@ -46,6 +83,13 @@ export async function getReportSale() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function downloadReportProduct() {
|
||||||
|
await _download(
|
||||||
|
baseUrl + '/' + ENDPOINT + '/receipt/download',
|
||||||
|
'product-report',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export async function getReportProduct() {
|
export async function getReportProduct() {
|
||||||
const res = await api.get<ReportProduct[]>(`/${ENDPOINT}/product`);
|
const res = await api.get<ReportProduct[]>(`/${ENDPOINT}/product`);
|
||||||
if (res.status < 400) {
|
if (res.status < 400) {
|
||||||
|
|
@ -78,10 +122,14 @@ export const useReportStore = defineStore('report-store', () => {
|
||||||
dataReportProduct,
|
dataReportProduct,
|
||||||
dataReportPayment,
|
dataReportPayment,
|
||||||
|
|
||||||
|
downloadReportQuotation,
|
||||||
getReportQuotation,
|
getReportQuotation,
|
||||||
|
downloadReportInvoice,
|
||||||
getReportInvoice,
|
getReportInvoice,
|
||||||
|
downloadReportReceipt,
|
||||||
getReportReceipt,
|
getReportReceipt,
|
||||||
getReportSale,
|
getReportSale,
|
||||||
|
downloadReportProduct,
|
||||||
getReportProduct,
|
getReportProduct,
|
||||||
getReportPayment,
|
getReportPayment,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue