From 41e022e610ca40d1a94693ff87f5a022edd6d6d7 Mon Sep 17 00:00:00 2001 From: carlosfonseca Date: Mon, 27 Nov 2023 16:36:36 -0500 Subject: [PATCH] Se crea logica para descargar datos en formato csv --- src/pages/InvoiceOut/InvoiceOutList.vue | 118 ++++++++++++++++++++++-- 1 file changed, 110 insertions(+), 8 deletions(-) diff --git a/src/pages/InvoiceOut/InvoiceOutList.vue b/src/pages/InvoiceOut/InvoiceOutList.vue index 7b1b3d0ca..0af5b9ea3 100644 --- a/src/pages/InvoiceOut/InvoiceOutList.vue +++ b/src/pages/InvoiceOut/InvoiceOutList.vue @@ -2,7 +2,7 @@ import { onMounted, onUnmounted, ref } from 'vue'; import { useI18n } from 'vue-i18n'; import { useRouter } from 'vue-router'; -import { useQuasar } from 'quasar'; +import { exportFile, useQuasar } from 'quasar'; import { useStateStore } from 'stores/useStateStore'; import VnPaginate from 'src/components/ui/VnPaginate.vue'; import InvoiceOutSummaryDialog from './Card/InvoiceOutSummaryDialog.vue'; @@ -14,6 +14,7 @@ import CardList2 from 'src/components/ui/CardList2.vue'; const { t } = useI18n(); const manageCheckboxes = ref(false); +const showSelect = ref(false); const quasar = useQuasar(); const router = useRouter(); const stateStore = useStateStore(); @@ -33,14 +34,53 @@ function viewSummary(id) { }, }); } + +const setShowSelect = () => { + showSelect.value = !showSelect.value; +}; + +const setManageCheckboxes = (downloadType) => { + console.log(downloadType); +}; + +const downloadCsv = (rows) => { + let file; + for (var i = 0; i < rows.length; i++) { + if (i == 0) file += Object.keys(rows[i]).join(';') + '\n'; + file += + Object.keys(rows[i]) + .map(function (key) { + return rows[i][key]; + }) + .join(';') + '\n'; + } + const status = exportFile('file.csv', file, { + encoding: 'windows-1252', + mimeType: 'text/csv;charset=windows-1252;', + }); + + if (status === true) { + quasar.notify({ + message: t('fileAllowed'), + color: 'positive', + icon: 'check', + }); + } else { + quasar.notify({ + message: t('fileDenied'), + color: 'negative', + icon: 'warning', + }); + } +};