forked from verdnatura/salix-front
Invoice out list and summary changes
This commit is contained in:
parent
af12512de9
commit
41e5110a8a
|
@ -2,7 +2,6 @@
|
||||||
import { onMounted, onUnmounted, ref } from 'vue';
|
import { onMounted, onUnmounted, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { exportFile, useQuasar } from 'quasar';
|
|
||||||
|
|
||||||
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
||||||
import InvoiceOutSummary from './Card/InvoiceOutSummary.vue';
|
import InvoiceOutSummary from './Card/InvoiceOutSummary.vue';
|
||||||
|
@ -16,12 +15,14 @@ import InvoiceOutFilter from './InvoiceOutFilter.vue';
|
||||||
import { toDate, toCurrency } from 'src/filters/index';
|
import { toDate, toCurrency } from 'src/filters/index';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||||
|
import { useSession } from 'src/composables/useSession';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const selectedCards = ref(new Map());
|
const selectedCards = ref(new Map());
|
||||||
const quasar = useQuasar();
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
|
const session = useSession();
|
||||||
|
const token = session.getToken();
|
||||||
const { viewSummary } = useSummaryDialog();
|
const { viewSummary } = useSummaryDialog();
|
||||||
|
|
||||||
onMounted(() => (stateStore.rightDrawer = true));
|
onMounted(() => (stateStore.rightDrawer = true));
|
||||||
|
@ -55,35 +56,31 @@ const toggleAllCards = (cardsData) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const downloadCsv = () => {
|
const openPdf = () => {
|
||||||
if (selectedCards.value.size === 0) return;
|
try {
|
||||||
const selectedCardsArray = Array.from(selectedCards.value.values());
|
if (selectedCards.value.size === 0) return;
|
||||||
let file;
|
const selectedCardsArray = Array.from(selectedCards.value.values());
|
||||||
for (var i = 0; i < selectedCardsArray.length; i++) {
|
|
||||||
if (i == 0) file += Object.keys(selectedCardsArray[i]).join(';') + '\n';
|
if (selectedCards.value.size === 1) {
|
||||||
file +=
|
const [invoiceOut] = selectedCardsArray;
|
||||||
Object.keys(selectedCardsArray[i])
|
const url = `api/InvoiceOuts/${invoiceOut.id}/download?access_token=${token}`;
|
||||||
.map(function (key) {
|
window.open(url, '_blank');
|
||||||
return selectedCardsArray[i][key];
|
} else {
|
||||||
})
|
const invoiceOutIdsArray = selectedCardsArray.map(
|
||||||
.join(';') + '\n';
|
(invoiceOut) => invoiceOut.id
|
||||||
}
|
);
|
||||||
const status = exportFile('file.csv', file, {
|
const invoiceOutIds = invoiceOutIdsArray.join(',');
|
||||||
encoding: 'windows-1252',
|
|
||||||
mimeType: 'text/csv;charset=windows-1252;',
|
const params = new URLSearchParams({
|
||||||
});
|
access_token: token,
|
||||||
if (status === true) {
|
ids: invoiceOutIds,
|
||||||
quasar.notify({
|
});
|
||||||
message: t('fileAllowed'),
|
|
||||||
color: 'positive',
|
const url = `api/InvoiceOuts/downloadZip?${params}`;
|
||||||
icon: 'check',
|
window.open(url, '_blank');
|
||||||
});
|
}
|
||||||
} else {
|
} catch (err) {
|
||||||
quasar.notify({
|
console.error('Error opening PDF');
|
||||||
message: t('fileDenied'),
|
|
||||||
color: 'negative',
|
|
||||||
icon: 'warning',
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -129,13 +126,14 @@ const downloadCsv = () => {
|
||||||
<VnSubToolbar class="bg-vn-dark justify-end">
|
<VnSubToolbar class="bg-vn-dark justify-end">
|
||||||
<template #st-actions>
|
<template #st-actions>
|
||||||
<QBtn
|
<QBtn
|
||||||
@click="downloadCsv()"
|
@click="openPdf()"
|
||||||
class="q-mr-xl"
|
class="q-mr-xl"
|
||||||
color="primary"
|
color="primary"
|
||||||
:disable="selectedCards.size === 0"
|
:disable="selectedCards.size === 0"
|
||||||
:label="t('globals.download')"
|
:label="t('globals.download')"
|
||||||
/>
|
>
|
||||||
|
<QTooltip>{{ t('downloadPdf') }}</QTooltip>
|
||||||
|
</QBtn>
|
||||||
<QCheckbox
|
<QCheckbox
|
||||||
left-label
|
left-label
|
||||||
:label="t('globals.markAll')"
|
:label="t('globals.markAll')"
|
||||||
|
@ -167,7 +165,6 @@ const downloadCsv = () => {
|
||||||
:label="t('invoiceOut.list.amount')"
|
:label="t('invoiceOut.list.amount')"
|
||||||
:value="toCurrency(row.amount)"
|
:value="toCurrency(row.amount)"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<VnLv :label="t('invoiceOut.list.client')">
|
<VnLv :label="t('invoiceOut.list.client')">
|
||||||
<template #value>
|
<template #value>
|
||||||
<span class="link" @click.stop>
|
<span class="link" @click.stop>
|
||||||
|
@ -216,9 +213,11 @@ en:
|
||||||
fileDenied: Browser denied file download...
|
fileDenied: Browser denied file download...
|
||||||
fileAllowed: Successful download of CSV file
|
fileAllowed: Successful download of CSV file
|
||||||
youCanSearchByInvoiceReference: You can search by invoice reference
|
youCanSearchByInvoiceReference: You can search by invoice reference
|
||||||
|
downloadPdf: Download PDF
|
||||||
es:
|
es:
|
||||||
searchInvoice: Buscar factura emitida
|
searchInvoice: Buscar factura emitida
|
||||||
fileDenied: El navegador denegó la descarga de archivos...
|
fileDenied: El navegador denegó la descarga de archivos...
|
||||||
fileAllowed: Descarga exitosa de archivo CSV
|
fileAllowed: Descarga exitosa de archivo CSV
|
||||||
youCanSearchByInvoiceReference: Puedes buscar por referencia de la factura
|
youCanSearchByInvoiceReference: Puedes buscar por referencia de la factura
|
||||||
|
downloadPdf: Download PDF
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
Loading…
Reference in New Issue