#5926 - Worker/PDA docuware #387

Open
jsegarra wants to merge 22 commits from 5926_pda_worker_docuware into dev
1 changed files with 73 additions and 3 deletions
Showing only changes of commit 2e19e9baa9 - Show all commits

View File

@ -8,13 +8,17 @@ import VnSelect from 'src/components/common/VnSelect.vue';
import useNotify from 'src/composables/useNotify.js';
import axios from 'axios';
import { useRole } from 'src/composables/useRole';
import { useVnConfirm } from 'src/composables/useVnConfirm';
const route = useRoute();
const { t } = useI18n();
const { notify } = useNotify();
const { hasAny } = useRole();
const downloadDocuware = ref(true);
const sendToTablet = ref(true);
const fetchCurrentDeviceRef = ref(null);
const docuwarePDARef = ref(null);
const deviceProductionsFilter = {
fields: ['id', 'serialNumber', 'modelFk'],
where: { stateFk: 'idle' },
@ -26,13 +30,18 @@ const currentPDA = ref(null);
const isAllowedToEdit = computed(() => hasAny(['hr', 'productionAssi']));
const setCurrentPDA = (data) => {
const setCurrentPDA = async (data) => {
currentPDA.value = data;
currentPDA.value.description = `ID: ${currentPDA.value.deviceProductionFk} ${t(
'worker.pda.model'
)}: ${currentPDA.value.deviceProduction.modelFk} ${t('worker.pda.serialNumber')}: ${
currentPDA.value.deviceProduction.serialNumber
}`;
await axios.get(
`Workers/${route.params.id}/${currentPDA.value.deviceProductionFk}/isPDASigned`
);
data.pda = null;
currentPDA.value = null;
};
const deallocatePDA = async (data) => {
@ -48,8 +57,21 @@ const deallocatePDA = async (data) => {
console.error('Error deallocating PDA');
}
};
const { openConfirmationModal } = useVnConfirm();
onMounted(async () => await fetchCurrentDeviceRef.value.fetch());
const handleSendToTablet = async () => {
try {
await axios.post(`Docuwares/upload`, {
fileCabinet: 'hr',
worker: route.params.id,
pda: currentPDA.value.deviceProductionFk,
});
jsegarra marked this conversation as resolved Outdated
Outdated
Review

checkFileDocuware

checkFileDocuware
notify(t('PDA Signed'), 'positive');
} catch (err) {
console.error('Error removing department');
}
};
const handleDownloadDocuware = async () => {};
</script>
<template>
@ -61,6 +83,15 @@ onMounted(async () => await fetchCurrentDeviceRef.value.fetch());
/>
<FetchData
ref="fetchCurrentDeviceRef"
@on-fetch="
(data) => {
downloadDocuware = true;
sendToTablet = true;
}
"
/>
<FetchData
ref="docuwarePDARef"
url="DeviceProductionUsers"
:filter="{
jsegarra marked this conversation as resolved Outdated
Outdated
Review
    console.error('Error removing department'); ?
console.error('Error removing department'); ?
where: { userFk: route.params.id },
@ -79,6 +110,15 @@ onMounted(async () => await fetchCurrentDeviceRef.value.fetch());
:default-buttons="{ save: { label: 'globals.assign', color: 'primary' } }"
@on-data-saved="(_, data) => setCurrentPDA(data)"
>
<!-- <template #moreActions>
<QBtn
:label="t('Download')"
class="q-mt-sm"
@click.stop="downloadDocueare()"
type="submit"
color="primary"
/>
</template> -->
<template #form="{ data }">
<QField
v-if="currentPDA && currentPDA.description"
@ -95,7 +135,7 @@ onMounted(async () => await fetchCurrentDeviceRef.value.fetch());
<template v-if="isAllowedToEdit" #append>
<QIcon
name="delete"
size="sm"
size="md"
class="cursor-pointer"
color="primary"
@click="deallocatePDA(data)"
@ -104,6 +144,36 @@ onMounted(async () => await fetchCurrentDeviceRef.value.fetch());
{{ t('worker.pda.removePDA') }}
</QTooltip>
</QIcon>
<QIcon
v-if="downloadDocuware"
name="cloud_download"
size="md"
class="cursor-pointer"
color="primary"
@click="handleDownloadDocuware(data)"
>
<QTooltip>
{{ t('worker.pda.removePDA') }}
</QTooltip>
</QIcon>
<QIcon
v-if="sendToTablet"
name="vn:client"
size="md"
class="cursor-pointer"
color="primary"
@click="
openConfirmationModal(
t('Are you sure you want to send it?'),
t('Sign PDA'),
handleSendToTablet
)
"
>
<QTooltip>
{{ t('worker.pda.removePDA') }}
</QTooltip>
</QIcon>
</template>
</QField>