From 6c91fee1394a1463ff0ed66d3b91d8d2b78635ae Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 3 Jun 2024 12:18:42 +0200 Subject: [PATCH] test: #5926 Mock API REquest --- src/pages/Worker/Card/WorkerPda.vue | 70 ++++++++++------ .../integration/worker/workerPda.spec.js | 84 +++++++++++++++++-- 2 files changed, 122 insertions(+), 32 deletions(-) diff --git a/src/pages/Worker/Card/WorkerPda.vue b/src/pages/Worker/Card/WorkerPda.vue index 57397801c..3d7380fc2 100644 --- a/src/pages/Worker/Card/WorkerPda.vue +++ b/src/pages/Worker/Card/WorkerPda.vue @@ -17,7 +17,7 @@ import VnInput from 'src/components/common/VnInput.vue'; const { t } = useI18n(); const { notify } = useNotify(); - +const loadingDocuware = ref(true); const paginate = ref(); const dialog = ref(); const route = useRoute(); @@ -94,6 +94,27 @@ const handleDownloadDocuware = async (row) => { console.error('Error removing department'); } }; + +async function fetchDocuware(deviceProductions) { + let promises = deviceProductions.map(({ deviceProductionFk }) => + axios.post(`Docuwares/${deviceProductionFk}/checkFile`, { + fileCabinet: 'hr', + signed: true, + }) + ); + promises = await Promise.all(promises); + promises.forEach((promise) => { + const id = +promise.config.url.match(/\d+/)[0]; + const deviceProduction = deviceProductions.find( + ({ deviceProductionFk }) => deviceProductionFk === id + ); + if (!deviceProduction) return; + if (promise.data) deviceProduction.isSigned = promise.data; + deviceProduction.isDocuware = promise.data; + }); + + loadingDocuware.value = false; +}