0
0
Fork 0

Compare commits

...

22 Commits

Author SHA1 Message Date
Alex Moreno 68729d2e77 refactor: order functions 2024-09-11 11:10:38 +02:00
Alex Moreno e83715ecbf Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into 5926_pda_worker_docuware 2024-09-11 08:48:52 +02:00
Javier Segarra 893217cdd2 Merge branch 'dev' into 5926_pda_worker_docuware 2024-07-23 21:09:12 +00:00
Javier Segarra 4faf1335ee Merge branch 'dev' into 5926_pda_worker_docuware 2024-07-12 23:02:30 +02:00
Javier Segarra ef1316d5b0 Merge branch 'dev' into 5926_pda_worker_docuware 2024-07-08 12:12:01 +00:00
Javier Segarra 67cd4f9212 feat: #5926 resolve comments 2024-07-08 12:23:52 +02:00
Javier Segarra 8c1048b5af feat: remove quasar.config event 2024-07-08 12:22:02 +02:00
Javier Segarra 55eaf3bd3e Merge branch 'dev' into 5926_pda_worker_docuware 2024-07-08 11:16:33 +02:00
Javier Segarra e224d172bb Merge branch 'dev' into 5926_pda_worker_docuware 2024-06-17 10:08:23 +02:00
Javier Segarra ea0398df61 fix: #5926 fix downdload function 2024-06-17 10:08:08 +02:00
Javier Segarra c626a10a98 updates 2024-06-07 01:59:10 +02:00
Javier Segarra 3eaefe8701 test: 5926: imrpove 2024-06-03 14:13:02 +02:00
Javier Segarra c3d08c94d1 feat: 5926: Refresh button 2024-06-03 12:24:06 +02:00
Javier Segarra 6c91fee139 test: #5926 Mock API REquest 2024-06-03 12:18:42 +02:00
Javier Segarra 035a3cd0ae feat: updates 2024-05-31 09:27:50 +02:00
Javier Segarra f3237adbb9 Merge branch 'dev' into 5926_pda_worker_docuware 2024-05-30 07:55:19 +02:00
Javier Segarra 6ff5c73a78 downloadFile 2024-05-22 15:42:14 +02:00
Javier Segarra 81e5bfd93c update 2024-05-22 12:33:28 +02:00
Javier Segarra c1fd150204 update 2024-05-22 09:07:39 +02:00
Javier Segarra 67db3bc5bb updates 2024-05-21 21:07:27 +02:00
Javier Segarra 2c2f2b3b0d Merge branch 'dev' into 5926_pda_worker_docuware 2024-05-21 11:15:39 +02:00
Javier Segarra 2e19e9baa9 refs #5926: Add QIcon 2024-05-20 22:39:05 +02:00
7 changed files with 216 additions and 14 deletions

View File

@ -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',
},

View File

@ -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}`);
}

View File

@ -0,0 +1,6 @@
export function isProduction(localAsProduction = true) {
return (
(!process.env.NODE_ENV && localAsProduction) ||
process.env.NODE_ENV == 'production'
);
}

View File

@ -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

View File

@ -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

View File

@ -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>

View File

@ -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');
});
});
});
});