#5926 - Worker/PDA docuware #387
|
@ -58,7 +58,7 @@ module.exports = {
|
||||||
rules: {
|
rules: {
|
||||||
'prefer-promise-reject-errors': 'off',
|
'prefer-promise-reject-errors': 'off',
|
||||||
'no-unused-vars': 'warn',
|
'no-unused-vars': 'warn',
|
||||||
"vue/no-multiple-template-root": "off" ,
|
'vue/no-multiple-template-root': 'off',
|
||||||
// allow debugger during development only
|
// allow debugger during development only
|
||||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,8 +4,15 @@ import { getUrl } from './getUrl';
|
||||||
const { getTokenMultimedia } = useSession();
|
const { getTokenMultimedia } = useSession();
|
||||||
const token = getTokenMultimedia();
|
const token = getTokenMultimedia();
|
||||||
|
|
||||||
export async function downloadFile(id, model = 'dms', urlPath = '/downloadFile', url) {
|
export async function downloadFile(
|
||||||
let appUrl = await getUrl('', 'lilium');
|
id,
|
||||||
|
model = 'dms',
|
||||||
|
urlPath = '/downloadFile',
|
||||||
|
url,
|
||||||
|
route = '',
|
||||||
|
app = 'lilium'
|
||||||
|
) {
|
||||||
|
let appUrl = await getUrl(route, app);
|
||||||
appUrl = appUrl.replace('/#/', '');
|
appUrl = appUrl.replace('/#/', '');
|
||||||
window.open(url ?? `${appUrl}/api/${model}/${id}${urlPath}?access_token=${token}`);
|
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
|
model: Model
|
||||||
serialNumber: Serial number
|
serialNumber: Serial number
|
||||||
removePDA: Deallocate PDA
|
removePDA: Deallocate PDA
|
||||||
|
sendToTablet: Send to sign
|
||||||
|
refresh: Refresh
|
||||||
|
download: Download
|
||||||
create:
|
create:
|
||||||
name: Name
|
name: Name
|
||||||
lastName: Last name
|
lastName: Last name
|
||||||
|
|
|
@ -881,6 +881,9 @@ worker:
|
||||||
model: Modelo
|
model: Modelo
|
||||||
serialNumber: Número de serie
|
serialNumber: Número de serie
|
||||||
removePDA: Desasignar PDA
|
removePDA: Desasignar PDA
|
||||||
|
sendToTablet: Enviar a tablet
|
||||||
|
refresh: Refrescar
|
||||||
|
download: Descargar justificante
|
||||||
create:
|
create:
|
||||||
name: Nombre
|
name: Nombre
|
||||||
lastName: Apellido
|
lastName: Apellido
|
||||||
|
|
|
@ -8,15 +8,16 @@ import useNotify from 'src/composables/useNotify.js';
|
||||||
import FetchData from 'components/FetchData.vue';
|
import FetchData from 'components/FetchData.vue';
|
||||||
import FormModelPopup from 'src/components/FormModelPopup.vue';
|
import FormModelPopup from 'src/components/FormModelPopup.vue';
|
||||||
import { useVnConfirm } from 'composables/useVnConfirm';
|
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||||
|
import { isProduction } from 'composables/useEnv';
|
||||||
|
|
||||||
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
|
const FILECABINET_ID = 'hr';
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
|
const loadingDocuware = ref(true);
|
||||||
const paginate = ref();
|
const paginate = ref();
|
||||||
const dialog = ref();
|
const dialog = ref();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
@ -48,6 +49,76 @@ function reloadData() {
|
||||||
initialData.value.simSerialNumber = null;
|
initialData.value.simSerialNumber = null;
|
||||||
paginate.value.fetch();
|
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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -57,6 +128,7 @@ function reloadData() {
|
||||||
@on-fetch="(data) => (deviceProductions = data)"
|
@on-fetch="(data) => (deviceProductions = data)"
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<VnPaginate
|
<VnPaginate
|
||||||
ref="paginate"
|
ref="paginate"
|
||||||
data-key="WorkerPda"
|
data-key="WorkerPda"
|
||||||
|
@ -64,6 +136,7 @@ function reloadData() {
|
||||||
:filter="{ where: { userFk: routeId } }"
|
:filter="{ where: { userFk: routeId } }"
|
||||||
order="id"
|
order="id"
|
||||||
auto-load
|
auto-load
|
||||||
|
@on-fetch="fetchDocuware"
|
||||||
>
|
>
|
||||||
<template #body="{ rows }">
|
<template #body="{ rows }">
|
||||||
<QCard
|
<QCard
|
||||||
|
@ -94,6 +167,7 @@ function reloadData() {
|
||||||
:model-value="row?.simSerialNumber"
|
:model-value="row?.simSerialNumber"
|
||||||
disable
|
disable
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<QBtn
|
<QBtn
|
||||||
flat
|
flat
|
||||||
icon="delete"
|
icon="delete"
|
||||||
|
@ -111,6 +185,51 @@ function reloadData() {
|
||||||
{{ t('worker.pda.removePDA') }}
|
{{ t('worker.pda.removePDA') }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QBtn>
|
</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>
|
</VnRow>
|
||||||
</QCard>
|
</QCard>
|
||||||
</template>
|
</template>
|
||||||
|
@ -128,10 +247,10 @@ function reloadData() {
|
||||||
<template #form-inputs="{ data }">
|
<template #form-inputs="{ data }">
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('worker.pda.newPDA')"
|
:label="t('PDA')"
|
||||||
v-model="data.deviceProductionFk"
|
v-model="data.deviceProductionFk"
|
||||||
:options="deviceProductions"
|
:options="deviceProductions"
|
||||||
option-label="id"
|
option-label="modelFk"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
id="deviceProductionFk"
|
id="deviceProductionFk"
|
||||||
hide-selected
|
hide-selected
|
||||||
|
@ -177,6 +296,7 @@ function reloadData() {
|
||||||
es:
|
es:
|
||||||
Model: Modelo
|
Model: Modelo
|
||||||
Serial number: Número de serie
|
Serial number: Número de serie
|
||||||
|
SIM serial number: (SIM) Número de serie
|
||||||
Current SIM: SIM actual
|
Current SIM: SIM actual
|
||||||
Add new device: Añadir nuevo dispositivo
|
Add new device: Añadir nuevo dispositivo
|
||||||
PDA deallocated: PDA desasignada
|
PDA deallocated: PDA desasignada
|
||||||
|
@ -184,4 +304,9 @@ es:
|
||||||
Do you want to remove this PDA?: ¿Desea eliminar este PDA?
|
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
|
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
|
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>
|
</i18n>
|
||||||
|
|
|
@ -5,6 +5,7 @@ describe('WorkerPda', () => {
|
||||||
cy.viewport(1920, 1080);
|
cy.viewport(1920, 1080);
|
||||||
cy.login('developer');
|
cy.login('developer');
|
||||||
cy.visit(`/#/worker/1110/pda`);
|
cy.visit(`/#/worker/1110/pda`);
|
||||||
|
cy.waitForElement('.q-page');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('assign pda', () => {
|
it('assign pda', () => {
|
||||||
|
@ -12,12 +13,69 @@ describe('WorkerPda', () => {
|
||||||
cy.get(deviceProductionField).type('{downArrow}{enter}');
|
cy.get(deviceProductionField).type('{downArrow}{enter}');
|
||||||
cy.get('.q-notification__message').should('have.text', 'Data created');
|
cy.get('.q-notification__message').should('have.text', 'Data created');
|
||||||
});
|
});
|
||||||
|
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', () => {
|
it('delete pda', () => {
|
||||||
cy.get('.btn-delete').click();
|
cy.get(
|
||||||
|
':nth-child(1) > .vn-row > :nth-child(5) > .q-btn__content > .q-icon'
|
||||||
|
).click();
|
||||||
cy.get(
|
cy.get(
|
||||||
'.q-card__actions > .q-btn--unelevated > .q-btn__content > .block'
|
'.q-card__actions > .q-btn--unelevated > .q-btn__content > .block'
|
||||||
).click();
|
).click();
|
||||||
cy.get('.q-notification__message').should('have.text', 'PDA deallocated');
|
cy.get('.q-notification__message').should('have.text', 'PDA deallocated');
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue