diff --git a/src/pages/Worker/Card/WorkerPda.vue b/src/pages/Worker/Card/WorkerPda.vue index 5b4181119..c6f1366e7 100644 --- a/src/pages/Worker/Card/WorkerPda.vue +++ b/src/pages/Worker/Card/WorkerPda.vue @@ -50,59 +50,6 @@ function reloadData() { paginate.value.fetch(); } -const handleSendToTablet = async (row) => { - try { - if (isProduction(false)) { - const { deviceProductionFk } = row; - await axios.post(`Docuwares/upload`, { - fileCabinet: FILECABINET_ID, - ids: [deviceProductionFk], - }); - } - notify(t('PDF sended to signed'), 'positive'); - row.isDocuware = true; - } catch (err) { - console.error('Error sending to sign'); - } -}; -function checkFileDocuware({ deviceProductionFk }, signed) { - return axios.post(`Docuwares/${deviceProductionFk}/checkFile`, { - fileCabinet: FILECABINET_ID, - signed, - }); -} -const handleRefreshDocuware = async (row) => { - try { - if (isProduction()) { - await checkFileDocuware(row, true); - } - notify(t('PDA Signed'), 'positive'); - row.isSigned = true; - } catch (err) { - console.error('Error refreshing docuware call'); - } -}; -const handleDownloadDocuware = async (row) => { - try { - if (isProduction(false)) { - const { deviceProductionFk } = row; - await axios.post(`Docuwares/download`, { - fileCabinet: FILECABINET_ID, - ids: [deviceProductionFk], - }); - } - notify(t('PDF downloaded'), 'positive'); - } catch (err) { - console.error('Error downloading docuware'); - } -}; -function handlePromiseDocuware(promise, deviceProductions) { - const id = +promise.config.url.match(/\d+/)[0]; - const deviceProduction = deviceProductions.find( - ({ deviceProductionFk }) => deviceProductionFk === id - ); - return deviceProduction; -} async function fetchDocuware(deviceProductions) { const promisesIsDocuware = await Promise.allSettled( deviceProductions.map((device) => checkFileDocuware(device, false)) @@ -128,6 +75,50 @@ async function fetchDocuware(deviceProductions) { loadingDocuware.value = false; } + +function checkFileDocuware({ deviceProductionFk }, signed) { + return axios.post(`Docuwares/${deviceProductionFk}/checkFile`, { + fileCabinet: FILECABINET_ID, + signed, + }); +} + +async function sendToTablet(row) { + if (isProduction(false)) { + const { deviceProductionFk } = row; + await axios.post(`Docuwares/upload`, { + fileCabinet: FILECABINET_ID, + ids: [deviceProductionFk], + }); + } + notify(t('PDF sended to signed'), 'positive'); + row.isDocuware = true; +} + +const refreshDocuware = async (row) => { + if (isProduction()) { + await checkFileDocuware(row, true); + } + notify(t('PDA Signed'), 'positive'); + row.isSigned = true; +}; +const downloadDocuware = async (row) => { + if (isProduction(false)) { + const { deviceProductionFk } = row; + await axios.post(`Docuwares/download`, { + fileCabinet: FILECABINET_ID, + ids: [deviceProductionFk], + }); + } + notify(t('PDF downloaded'), 'positive'); +}; +function handlePromiseDocuware(promise, deviceProductions) { + const id = +promise.config.url.match(/\d+/)[0]; + const deviceProduction = deviceProductions.find( + ({ deviceProductionFk }) => deviceProductionFk === id + ); + return deviceProduction; +}