From 0b0e73d65bf07565dbdd3a587e2673627ab6fe70 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 15 Feb 2023 15:15:59 +0100 Subject: [PATCH] feat(claim_photo): fix html add uploadFile --- src/i18n/en/index.js | 4 + src/i18n/es/index.js | 6 +- src/pages/Claim/Card/ClaimPhoto.vue | 162 ++++++++++++++++++---------- 3 files changed, 113 insertions(+), 59 deletions(-) diff --git a/src/i18n/en/index.js b/src/i18n/en/index.js index cd0be31ba..b0323421d 100644 --- a/src/i18n/en/index.js +++ b/src/i18n/en/index.js @@ -294,6 +294,10 @@ export default { picked: 'Picked', returnOfMaterial: 'Return of material authorization (RMA)', }, + photo: { + fileDescription: + 'Reclamacion ID {{claimId}} del cliente {{clientName}} id {{clientId}}', + }, }, invoiceOut: { pageTitles: { diff --git a/src/i18n/es/index.js b/src/i18n/es/index.js index 7de7c5263..09ffb9d15 100644 --- a/src/i18n/es/index.js +++ b/src/i18n/es/index.js @@ -13,7 +13,7 @@ export default { darkMode: 'Modo oscuro', logOut: 'Cerrar sesión', dataSaved: 'Datos guardados', - dataDeleted: 'Data deleted', + dataDeleted: 'Datos eliminados', add: 'Añadir', create: 'Crear', save: 'Guardar', @@ -293,6 +293,10 @@ export default { picked: 'Recogida', returnOfMaterial: 'Autorización de retorno de materiales (RMA)', }, + photo: { + fileDescription: + 'Claim id {{claimId}} from client {{clientName}} id {{clientId}}', + }, }, invoiceOut: { pageTitles: { diff --git a/src/pages/Claim/Card/ClaimPhoto.vue b/src/pages/Claim/Card/ClaimPhoto.vue index affb6c28b..9a7431fae 100644 --- a/src/pages/Claim/Card/ClaimPhoto.vue +++ b/src/pages/Claim/Card/ClaimPhoto.vue @@ -17,18 +17,21 @@ const session = useSession(); const token = session.getToken(); const quasar = useQuasar(); -const entityId = computed(function () { +const claimId = computed(function () { return router.currentRoute.value.params.id; }); -const multimedia = ref([]); +const claimDms = ref([]); +const dmsType = ref({}); +const config = ref({}); +const dms = ref({}); const claimDmsFilter = ref({ include: [ { relation: 'dms', }, ], - where: { claimFk: entityId }, + where: { claimFk: claimId.value }, }); const multimediaDialog = ref(); @@ -59,31 +62,72 @@ function viewDeleteDms(dmsId) { async function deleteDms(index) { console.log(index); - const dmsId = multimedia.value[index].dmsFk; + const dmsId = claimDms.value[index].dmsFk; await axios.post(`ClaimDms/${dmsId}/removeFile`); - console.log(multimedia.value.splice(index, 1)); - multimedia.value = multimedia.value.splice(index, 1); - console.log(index, multimedia.value); + quasar.notify({ + message: t('globals.dataDeleted'), + type: 'positive', + icon: 'delete', + }); + claimDms.value.splice(index, 1); } -function setMultimedia(data) { - multimedia.value = data.map((media) => { +function setClaimDms(data) { + claimDms.value = data.map((media) => { media.isVideo = media.dms.contentType == 'video/mp4'; return media; }); } -//cover fill contain none scale-down + +function uploadFile() { + const element = document.createElement('input'); + element.setAttribute('type', 'file'); + element.setAttribute('multiple', true); + element.click(); + + element.addEventListener('change', () => setDefaultParams()); +} + +function setDefaultParams() { + console.log(config.value); + console.log(dmsType.value); + dms.value = { + hasFile: false, + hasFileAttached: false, + reference: claimId.value, + warehouseId: config.value.warehouseFk, + companyId: config.value.companyFk, + dmsTypeId: dmsType.value.id, + description: t('claim.photo.fileDescription', { + claimId: claimId.value, + clientId: claimDms.value.clientFk, + clientName: claimDms.value.clientName, + }).toUpperCase(), + }; + console.log(dms.value); +}