#5926 - Worker/PDA docuware #387
|
@ -58,7 +58,7 @@ module.exports = {
|
|||
rules: {
|
||||
'prefer-promise-reject-errors': 'off',
|
||||
'no-unused-vars': 'warn',
|
||||
"vue/no-multiple-template-root": "off" ,
|
||||
'vue/no-multiple-template-root': 'off',
|
||||
// allow debugger during development only
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||
},
|
||||
|
|
|
@ -4,8 +4,15 @@ import { getUrl } from './getUrl';
|
|||
const { getTokenMultimedia } = useSession();
|
||||
const token = getTokenMultimedia();
|
||||
|
||||
export async function downloadFile(id, model = 'dms', urlPath = '/downloadFile', url) {
|
||||
let appUrl = await getUrl('', 'lilium');
|
||||
export async function downloadFile(
|
||||
id,
|
||||
model = 'dms',
|
||||
urlPath = '/downloadFile',
|
||||
url,
|
||||
route = '',
|
||||
app = 'lilium'
|
||||
) {
|
||||
let appUrl = await getUrl(route, app);
|
||||
appUrl = appUrl.replace('/#/', '');
|
||||
window.open(url ?? `${appUrl}/api/${model}/${id}${urlPath}?access_token=${token}`);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
export function isProduction(localAsProduction = true) {
|
||||
return (
|
||||
(!process.env.NODE_ENV && localAsProduction) ||
|
||||
process.env.NODE_ENV == 'production'
|
||||
);
|
||||
}
|
|
@ -884,6 +884,9 @@ worker:
|
|||
model: Model
|
||||
serialNumber: Serial number
|
||||
removePDA: Deallocate PDA
|
||||
sendToTablet: Send to sign
|
||||
refresh: Refresh
|
||||
download: Download
|
||||
create:
|
||||
name: Name
|
||||
lastName: Last name
|
||||
|
|
|
@ -881,6 +881,9 @@ worker:
|
|||
model: Modelo
|
||||
serialNumber: Número de serie
|
||||
removePDA: Desasignar PDA
|
||||
sendToTablet: Enviar a tablet
|
||||
refresh: Refrescar
|
||||
download: Descargar justificante
|
||||
create:
|
||||
name: Nombre
|
||||
lastName: Apellido
|
||||
|
|
|
@ -8,15 +8,16 @@ 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';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
|
||||
const FILECABINET_ID = 'hr';
|
||||
const { t } = useI18n();
|
||||
const { notify } = useNotify();
|
||||
|
||||
const loadingDocuware = ref(true);
|
||||
const paginate = ref();
|
||||
const dialog = ref();
|
||||
const route = useRoute();
|
||||
|
@ -48,6 +49,76 @@ function reloadData() {
|
|||
initialData.value.simSerialNumber = null;
|
||||
paginate.value.fetch();
|
||||
}
|
||||
|
||||
async function fetchDocuware(deviceProductions) {
|
||||
const promisesIsDocuware = await Promise.allSettled(
|
||||
deviceProductions.map((device) => checkFileDocuware(device, false))
|
||||
);
|
||||
|
||||
let promisesIsSigned = [];
|
||||
promisesIsDocuware.forEach(({ value: promise }) => {
|
||||
const deviceProduction = handlePromiseDocuware(promise, deviceProductions);
|
||||
if (!deviceProduction) return;
|
||||
|
||||
deviceProduction.isDocuware = promise.data;
|
||||
if (promise.data)
|
||||
promisesIsSigned.push(checkFileDocuware(deviceProduction, true));
|
||||
});
|
||||
|
||||
promisesIsSigned = await Promise.allSettled(promisesIsSigned);
|
||||
promisesIsSigned.forEach(({ value: promise }) => {
|
||||
const deviceProduction = handlePromiseDocuware(promise, deviceProductions);
|
||||
if (!deviceProduction) return;
|
||||
|
||||
deviceProduction.isSigned = !!promise.data.id;
|
||||
});
|
||||
|
||||
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;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -57,6 +128,7 @@ function reloadData() {
|
|||
@on-fetch="(data) => (deviceProductions = data)"
|
||||
auto-load
|
||||
/>
|
||||
|
||||
<VnPaginate
|
||||
ref="paginate"
|
||||
data-key="WorkerPda"
|
||||
|
@ -64,6 +136,7 @@ function reloadData() {
|
|||
:filter="{ where: { userFk: routeId } }"
|
||||
order="id"
|
||||
auto-load
|
||||
@on-fetch="fetchDocuware"
|
||||
>
|
||||
<template #body="{ rows }">
|
||||
<QCard
|
||||
|
@ -94,6 +167,7 @@ function reloadData() {
|
|||
:model-value="row?.simSerialNumber"
|
||||
disable
|
||||
/>
|
||||
|
||||
<QBtn
|
||||
flat
|
||||
icon="delete"
|
||||
|
@ -111,6 +185,51 @@ function reloadData() {
|
|||
{{ t('worker.pda.removePDA') }}
|
||||
</QTooltip>
|
||||
</QBtn>
|
||||
|
||||
<QBtn
|
||||
:loading="loadingDocuware"
|
||||
icon="send"
|
||||
flat
|
||||
class="btn-delete"
|
||||
color="primary"
|
||||
@click="
|
||||
openConfirmationModal(
|
||||
t('Sign PDA'),
|
||||
t('Are you sure you want to send it?'),
|
||||
|
||||
() => sendToTablet(row)
|
||||
)
|
||||
"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('worker.pda.sendToTablet') }}
|
||||
</QTooltip>
|
||||
</QBtn>
|
||||
|
||||
<QBtn
|
||||
:loading="loadingDocuware"
|
||||
icon="refresh"
|
||||
flat
|
||||
class="btn-delete"
|
||||
color="primary"
|
||||
@click="refreshDocuware(row)"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('worker.pda.refresh') }}
|
||||
</QTooltip>
|
||||
</QBtn>
|
||||
<QBtn
|
||||
:loading="loadingDocuware"
|
||||
icon="cloud_download"
|
||||
flat
|
||||
class="btn-delete"
|
||||
color="primary"
|
||||
@click="downloadDocuware(row)"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('worker.pda.download') }}
|
||||
</QTooltip>
|
||||
</QBtn>
|
||||
</VnRow>
|
||||
</QCard>
|
||||
</template>
|
||||
|
@ -128,10 +247,10 @@ function reloadData() {
|
|||
<template #form-inputs="{ data }">
|
||||
<VnRow>
|
||||
<VnSelect
|
||||
:label="t('worker.pda.newPDA')"
|
||||
:label="t('PDA')"
|
||||
v-model="data.deviceProductionFk"
|
||||
:options="deviceProductions"
|
||||
option-label="id"
|
||||
option-label="modelFk"
|
||||
option-value="id"
|
||||
id="deviceProductionFk"
|
||||
hide-selected
|
||||
|
@ -177,6 +296,7 @@ function reloadData() {
|
|||
es:
|
||||
Model: Modelo
|
||||
Serial number: Número de serie
|
||||
SIM serial number: (SIM) Número de serie
|
||||
Current SIM: SIM actual
|
||||
Add new device: Añadir nuevo dispositivo
|
||||
PDA deallocated: PDA desasignada
|
||||
|
@ -184,4 +304,9 @@ es:
|
|||
Do you want to remove this PDA?: ¿Desea eliminar este PDA?
|
||||
You can only have one PDA: Solo puedes tener un PDA si no eres autonomo
|
||||
This PDA is already assigned to another user: Este PDA ya está asignado a otro usuario
|
||||
Are you sure you want to send it?: ¿Estás seguro que lo quieres enviar?
|
||||
Sign PDA: Firmar PDA
|
||||
PDF sended to signed: PDF enviado para firmar
|
||||
PDA signed: PDA firmado
|
||||
PDF download: PDF descargado
|
||||
</i18n>
|
||||
|
|
|
@ -5,6 +5,7 @@ describe('WorkerPda', () => {
|
|||
cy.viewport(1920, 1080);
|
||||
cy.login('developer');
|
||||
cy.visit(`/#/worker/1110/pda`);
|
||||
cy.waitForElement('.q-page');
|
||||
});
|
||||
|
||||
it('assign pda', () => {
|
||||
|
@ -12,12 +13,69 @@ describe('WorkerPda', () => {
|
|||
cy.get(deviceProductionField).type('{downArrow}{enter}');
|
||||
cy.get('.q-notification__message').should('have.text', 'Data created');
|
||||
});
|
||||
|
||||
it('delete pda', () => {
|
||||
cy.get('.btn-delete').click();
|
||||
cy.get(
|
||||
'.q-card__actions > .q-btn--unelevated > .q-btn__content > .block'
|
||||
).click();
|
||||
cy.get('.q-notification__message').should('have.text', 'PDA deallocated');
|
||||
describe(' Row Actions', () => {
|
||||
describe(' Docuware Flow ', () => {
|
||||
describe(' NOT Signed ', () => {
|
||||
beforeEach(() => {
|
||||
cy.intercept('POST', '**/checkFile', 'false').as('not_signed');
|
||||
});
|
||||
it('docuware', () => {
|
||||
// Btn icon-client is present
|
||||
cy.get(
|
||||
':nth-child(1) > .vn-row > :nth-child(6) > .q-btn__content > .q-icon'
|
||||
).should('have.class', 'icon-client');
|
||||
// Btn icon-client is clicked
|
||||
cy.get(
|
||||
':nth-child(1) > .vn-row > :nth-child(6) > .q-btn__content > .q-icon'
|
||||
).click();
|
||||
// Btn confirm is clicked
|
||||
cy.get(
|
||||
'.q-card__actions > .q-btn--unelevated > .q-btn__content > .block'
|
||||
).click();
|
||||
// Btn refresh is present
|
||||
cy.get(
|
||||
':nth-child(1) > .vn-row > :nth-child(6) > .q-btn__content > .q-icon'
|
||||
).should('have.text', 'refresh');
|
||||
// Btn refresh is clicked
|
||||
cy.get(
|
||||
':nth-child(1) > .vn-row > :nth-child(6) > .q-btn__content > .q-icon'
|
||||
).click();
|
||||
// Btn cloud_download is present
|
||||
cy.get(
|
||||
':nth-child(1) > .vn-row > :nth-child(6) > .q-btn__content > .q-icon'
|
||||
).should('have.text', 'cloud_download');
|
||||
// Btn cloud_download is clicked
|
||||
cy.get(
|
||||
':nth-child(1) > .vn-row > :nth-child(6) > .q-btn__content > .q-icon'
|
||||
).click();
|
||||
});
|
||||
});
|
||||
describe(' Is Signed ', () => {
|
||||
beforeEach(() => {
|
||||
cy.intercept('POST', '**/checkFile', { id: 1 }).as('not_docuware');
|
||||
});
|
||||
it('docuware', () => {
|
||||
// Btn cloud_download is present
|
||||
cy.get(
|
||||
':nth-child(1) > .vn-row > :nth-child(6) > .q-btn__content > .q-icon'
|
||||
).should('have.text', 'cloud_download');
|
||||
// Btn cloud_download is clicked
|
||||
cy.get(
|
||||
':nth-child(1) > .vn-row > :nth-child(6) > .q-btn__content > .q-icon'
|
||||
).click();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe(' Other actions ', () => {
|
||||
it('delete pda', () => {
|
||||
cy.get(
|
||||
':nth-child(1) > .vn-row > :nth-child(5) > .q-btn__content > .q-icon'
|
||||
).click();
|
||||
cy.get(
|
||||
'.q-card__actions > .q-btn--unelevated > .q-btn__content > .block'
|
||||
).click();
|
||||
cy.get('.q-notification__message').should('have.text', 'PDA deallocated');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue