diff --git a/src/composables/useEnv.js b/src/composables/useEnv.js new file mode 100644 index 000000000..2aa576e1e --- /dev/null +++ b/src/composables/useEnv.js @@ -0,0 +1,6 @@ +export function isProduction(localAsProduction = true) { + return ( + (!process.env.NODE_ENV && localAsProduction) || + process.env.NODE_ENV == 'production' + ); +} diff --git a/src/pages/Worker/Card/WorkerPda.vue b/src/pages/Worker/Card/WorkerPda.vue index a6c3a03bc..57397801c 100644 --- a/src/pages/Worker/Card/WorkerPda.vue +++ b/src/pages/Worker/Card/WorkerPda.vue @@ -8,6 +8,7 @@ import useNotify from 'src/composables/useNotify.js'; import FetchData from 'components/FetchData.vue'; import FormModelPopup from 'src/components/FormModelPopup.vue'; import { useVnConfirm } from 'composables/useVnConfirm'; +import { isProduction } from 'composables/useEnv'; import VnPaginate from 'src/components/ui/VnPaginate.vue'; import VnRow from 'components/ui/VnRow.vue'; @@ -18,7 +19,6 @@ const { t } = useI18n(); const { notify } = useNotify(); const paginate = ref(); -const isDocuware = ref(false); const dialog = ref(); const route = useRoute(); const { openConfirmationModal } = useVnConfirm(); @@ -50,18 +50,50 @@ function reloadData() { paginate.value.fetch(); } -const handleSendToTablet = async (deviceProductionFk) => { +const handleSendToTablet = async (row) => { try { - await axios.post(`Docuwares/upload`, { - fileCabinet: 'hr', - ids: [deviceProductionFk], - }); - notify(t('PDA Signed'), 'positive'); + if (isProduction(false)) { + const { deviceProductionFk } = row; + await axios.post(`Docuwares/upload`, { + fileCabinet: 'hr', + ids: [deviceProductionFk], + }); + } + notify(t('PDF sended to signed'), 'positive'); + row.isDocuware = true; + } catch (err) { + console.error('Error removing department'); + } +}; +const handleRefreshDocuware = async (row) => { + try { + if (isProduction()) { + const { deviceProductionFk } = row; + await axios.post(`Docuwares/upload`, { + fileCabinet: 'hr', + ids: [deviceProductionFk], + }); + } + notify(t('PDA Signed'), 'positive'); + row.isSigned = true; + } catch (err) { + console.error('Error removing department'); + } +}; +const handleDownloadDocuware = async (row) => { + try { + if (isProduction(false)) { + const { deviceProductionFk } = row; + await axios.post(`Docuwares/upload`, { + fileCabinet: 'hr', + ids: [deviceProductionFk], + }); + } + notify(t('PDF downloaded'), 'positive'); } catch (err) { console.error('Error removing department'); } }; -const handleDownloadDocuware = async (deviceProductionFk) => {}; @@ -147,10 +223,10 @@ const handleDownloadDocuware = async (deviceProductionFk) => {};