diff --git a/src/components/VnTable/VnTable.vue b/src/components/VnTable/VnTable.vue
index c6421719833..e8dd1b5263d 100644
--- a/src/components/VnTable/VnTable.vue
+++ b/src/components/VnTable/VnTable.vue
@@ -633,6 +633,7 @@ const rowCtrlClickFunction = computed(() => {
:data-key="$attrs['data-key']"
:columns="columns"
:redirect="redirect"
+ v-bind="$attrs?.['table-filter']"
>
route.params.id);
-
+const worker = computed(() => useArrayData('Worker').store.data);
const initialData = computed(() => {
return {
userFk: routeId.value,
@@ -31,154 +32,277 @@ const initialData = computed(() => {
};
});
-const deallocatePDA = async (deviceProductionFk) => {
- await axios.post(`Workers/${route.params.id}/deallocatePDA`, {
- pda: deviceProductionFk,
- });
- notify(t('PDA deallocated'), 'positive');
-
- paginate.value.fetch();
-};
+const columns = computed(() => [
+ {
+ align: 'center',
+ label: t('globals.state'),
+ name: 'state',
+ format: (row) => row?.docuware?.state,
+ columnFilter: false,
+ chip: {
+ condition: (_, row) => !!row.docuware,
+ color: (row) => (isSigned(row) ? 'bg-positive' : 'bg-warning'),
+ },
+ visible: false,
+ },
+ {
+ align: 'right',
+ label: t('worker.pda.currentPDA'),
+ name: 'deviceProductionFk',
+ columnClass: 'shrink',
+ cardVisible: true,
+ },
+ {
+ align: 'left',
+ label: t('Model'),
+ name: 'modelFk',
+ format: ({ deviceProduction }) => deviceProduction.modelFk,
+ cardVisible: true,
+ },
+ {
+ align: 'right',
+ label: t('Serial number'),
+ name: 'serialNumber',
+ format: ({ deviceProduction }) => deviceProduction.serialNumber,
+ cardVisible: true,
+ },
+ {
+ align: 'left',
+ label: t('Current SIM'),
+ name: 'simFk',
+ cardVisible: true,
+ },
+ {
+ align: 'right',
+ name: 'actions',
+ columnFilter: false,
+ cardVisible: true,
+ },
+]);
function reloadData() {
initialData.value.deviceProductionFk = null;
initialData.value.simFk = null;
- paginate.value.fetch();
+ tableRef.value.reload();
+}
+
+async function fetchDocuware() {
+ loadingDocuware.value = true;
+ const id = worker.value?.lastName + ' ' + worker.value?.firstName;
+ const promises = [];
+
+ for (const row of tableRef.value.CrudModelRef.formData) {
+ promises.push(
+ (async () => {
+ const { data } = await axios.post(`Docuwares/${id}/checkFile`, {
+ fileCabinet: 'hr',
+ signed: false,
+ mergeFilter: [
+ {
+ DBName: 'TIPO_DOCUMENTO',
+ Value: ['PDA'],
+ },
+ {
+ DBName: 'FILENAME',
+ Value: [row.deviceProductionFk + '-pda'],
+ },
+ ],
+ });
+ row.docuware = data;
+ })(),
+ );
+ }
+
+ await Promise.all(promises);
+ loadingDocuware.value = false;
+}
+
+async function sendToTablet(rows) {
+ const promises = [];
+ for (const row of rows) {
+ promises.push(
+ (async () => {
+ await axios.post(`Docuwares/upload-pda-pdf`, {
+ ids: [row.deviceProductionFk],
+ });
+ row.docuware = true;
+ })(),
+ );
+ }
+ await Promise.all(promises);
+ notify(t('PDF sended to signed'), 'positive');
+ tableRef.value.reload();
+}
+
+async function deallocatePDA(deviceProductionFk) {
+ await axios.post(`Workers/${route.params.id}/deallocatePDA`, {
+ pda: deviceProductionFk,
+ });
+ const index = tableRef.value.CrudModelRef.formData.findIndex(
+ (data) => data?.deviceProductionFk == deviceProductionFk,
+ );
+ delete tableRef.value.CrudModelRef.formData[index];
+ notify(t('PDA deallocated'), 'positive');
+}
+
+function isSigned(row) {
+ return row.docuware?.state === 'Firmado';
}
-
- (deviceProductions = data)"
- auto-load
- />
-
-
-
-
-
-
-
-
- deallocatePDA(row.deviceProductionFk),
- )
- "
- >
-
- {{ t('worker.pda.removePDA') }}
-
-
-
-
-
-
-
+ (deviceProductions = data)"
+ auto-load
+ />
+
+
+
+
+
+ deallocatePDA(row.deviceProductionFk),
+ )
+ "
+ data-cy="workerPda-remove"
>
-
-
-
-
-
-
-
-
- ID: {{ scope.opt?.id }}
-
- {{ scope.opt?.modelFk }},
- {{ scope.opt?.serialNumber }}
-
-
-
-
-
-
-
-
-
-
+
+ {{ t('worker.pda.removePDA') }}
+
-
- {{ t('globals.new') }}
-
-
-
+ sendToTablet([row]),
+ )
+ "
+ data-cy="workerPda-send"
+ >
+
+ {{ t('worker.pda.sendToTablet') }}
+
+
+
+
+ {{ t('worker.pda.download') }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ID: {{ scope.opt?.id }}
+
+ {{ scope.opt?.modelFk }},
+ {{ scope.opt?.serialNumber }}
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ t('globals.new') }}
+
+
-
es:
Model: Modelo
diff --git a/test/cypress/integration/worker/workerPda.spec.js b/test/cypress/integration/worker/workerPda.spec.js
index 31ec19eda0e..d00a81ffcac 100644
--- a/test/cypress/integration/worker/workerPda.spec.js
+++ b/test/cypress/integration/worker/workerPda.spec.js
@@ -1,23 +1,91 @@
describe('WorkerPda', () => {
- const select = '[data-cy="pda-dialog-select"]';
+ const deviceId = 4;
beforeEach(() => {
- cy.viewport(1920, 1080);
cy.login('developer');
cy.visit(`/#/worker/1110/pda`);
});
- it('assign pda', () => {
- cy.addBtnClick();
- cy.get(select).click();
- cy.get(select).type('{downArrow}{enter}');
- cy.get('.q-notification__message').should('have.text', 'Data created');
+ it('assign and delete pda', () => {
+ creatNewPDA();
+ cy.checkNotification('Data created');
+ cy.visit(`/#/worker/1110/pda`);
+ removeNewPDA();
+ cy.checkNotification('PDA deallocated');
});
- 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');
+ it('send to docuware', () => {
+ cy.intercept('POST', '/api/Docuwares/upload-pda-pdf', (req) => {
+ req.reply({
+ statusCode: 200,
+ body: {},
+ });
+ });
+
+ creatNewPDA();
+ cy.dataCy('workerPda-send').click();
+ confirmButton();
+ cy.checkNotification('PDF sended to signed');
+
+ removeNewPDA();
});
+
+ it('send 2 pdfs to docuware', () => {
+ cy.intercept('POST', '/api/Docuwares/upload-pda-pdf', (req) => {
+ req.reply({
+ statusCode: 200,
+ body: {},
+ });
+ });
+
+ creatNewPDA();
+ creatNewPDA(2);
+ cy.selectRows([1, 2]);
+ cy.get('#st-actions').contains('Send').click();
+
+ confirmButton();
+ cy.checkNotification('PDF sended to signed');
+
+ removeNewPDA();
+ });
+
+ it('download file', () => {
+ cy.intercept('POST', /\/api\/Docuwares\/Jones%20Jessica\/checkFile/, (req) => {
+ req.reply({
+ statusCode: 200,
+ body: {
+ id: deviceId,
+ state: 'Firmado',
+ },
+ });
+ });
+
+ cy.intercept('GET', '/api/Docuwares/download-pda-pdf**', (req) => {
+ req.reply({
+ statusCode: 200,
+ body: {},
+ });
+ });
+ cy.get('#st-actions').contains('refresh').click();
+
+ creatNewPDA();
+ cy.dataCy('workerPda-download').click();
+ removeNewPDA();
+ });
+
+ function creatNewPDA(id = deviceId) {
+ cy.addBtnClick();
+ cy.selectOption('[data-cy="pda-dialog-select"]', id);
+ cy.saveCard();
+ }
+
+ function removeNewPDA() {
+ cy.dataCy('workerPda-remove').first().click();
+ confirmButton();
+ }
+
+ function confirmButton() {
+ cy.get(
+ '.q-card__actions > .q-btn--unelevated > .q-btn__content > .block',
+ ).click();
+ }
});