diff --git a/src/components/common/VnDms.vue b/src/components/common/VnDms.vue index 08255f8a..daef5940 100644 --- a/src/components/common/VnDms.vue +++ b/src/components/common/VnDms.vue @@ -198,9 +198,11 @@ function addDefaultData(data) { en: contentTypesInfo: Allowed file types {allowedContentTypes} EntryDmsDescription: Reference {reference} + WorkersDescription: Working of employee id {reference} es: Generate identifier for original file: Generar identificador para archivo original contentTypesInfo: Tipos de archivo permitidos {allowedContentTypes} EntryDmsDescription: Referencia {reference} + WorkersDescription: Laboral del empleado {reference} diff --git a/src/components/common/VnDmsList.vue b/src/components/common/VnDmsList.vue index 9bf90230..8c3ffc80 100644 --- a/src/components/common/VnDmsList.vue +++ b/src/components/common/VnDmsList.vue @@ -5,11 +5,12 @@ import { useRoute } from 'vue-router'; import { useQuasar, QCheckbox, QBtn, QInput } from 'quasar'; import axios from 'axios'; -import FetchData from 'components/FetchData.vue'; +import VnPaginate from 'components/ui/VnPaginate.vue'; import VnDms from 'src/components/common/VnDms.vue'; import VnConfirm from 'components/ui/VnConfirm.vue'; +import VnInputDate from 'components/common/VnInputDate.vue'; +import VnUserLink from '../ui/VnUserLink.vue'; import { downloadFile } from 'src/composables/downloadFile'; -import { getUrlFindOne } from 'composables/getUrl'; const route = useRoute(); const quasar = useQuasar(); @@ -27,6 +28,11 @@ const $props = defineProps({ type: String, default: null, }, + downloadModel: { + type: String, + required: false, + default: null, + }, defaultDmsCode: { type: String, required: true, @@ -75,7 +81,7 @@ const dmsFilter = { ], }, }, - order: ['dmsFk DESC'], + where: { [$props.filter]: route.params.id }, }; const columns = computed(() => [ @@ -95,12 +101,12 @@ const columns = computed(() => [ props: (prop) => ({ readonly: true, borderless: true, - 'model-value': prop.row.dmsType.name, + 'model-value': prop.row.dmsType?.name, }), }, { align: 'left', - field: 'order', + field: 'hardCopyNumber', label: t('globals.order'), name: 'order', component: 'span', @@ -118,6 +124,7 @@ const columns = computed(() => [ label: t('globals.description'), name: 'description', component: 'span', + props: (prop) => ({ value: prop.value?.toUpperCase() }), }, { align: 'left', @@ -137,6 +144,28 @@ const columns = computed(() => [ name: 'file', component: 'span', }, + { + align: 'left', + field: 'worker', + label: t('globals.worker'), + name: 'worker', + component: VnUserLink, + props: (prop) => ({ + name: prop.row.worker?.user?.name.toLowerCase(), + workerId: prop.row.worker?.id, + }), + }, + { + align: 'left', + field: 'created', + label: t('globals.created'), + name: 'created', + component: VnInputDate, + props: (prop) => ({ + disable: true, + 'model-value': prop.row.created, + }), + }, { field: 'options', name: 'options', @@ -144,16 +173,24 @@ const columns = computed(() => [ { component: QBtn, name: 'download', + isDocuware: true, props: () => ({ icon: 'cloud_download', flat: true, color: 'primary', }), - click: (prop) => downloadFile(prop.row.id, prop.row.isDocuware), + click: (prop) => + downloadFile( + prop.row.id, + $props.downloadModel, + null, + prop.row.download + ), }, { component: QBtn, name: 'edit', + external: false, props: () => ({ icon: 'edit', flat: true, @@ -164,6 +201,7 @@ const columns = computed(() => [ { component: QBtn, name: 'delete', + external: false, props: () => ({ icon: 'delete', flat: true, @@ -173,20 +211,22 @@ const columns = computed(() => [ }, { component: QBtn, - name: 'openDocuware', + name: 'open', + external: true, props: () => ({ icon: 'open_in_new', flat: true, color: 'primary', }), - click: () => openDocuware(), + click: (prop) => open(prop.row.url), }, ], }, ]); function setData(data) { - const newData = data.map((value) => value.dms); + const newData = data.map((value) => value.dms || value); + newData.sort((a, b) => new Date(b.created) - new Date(a.created)); rows.value = newData; } @@ -221,100 +261,105 @@ function parseDms(data) { return data; } -async function openDocuware() { - const url = await getUrlFindOne('WebClient', 'docuware'); - if (url) window.open(url).focus(); +async function open(url) { + window.open(url).focus(); } -function shouldRenderButton(buttonName, isDocuware = false) { - // Renderizar el botón si no se llama 'openDocuware' o (se llama 'openDocuware' y props.row.isDocuware = true) - return buttonName !== 'openDocuware' || (buttonName === 'openDocuware' && isDocuware); +function shouldRenderButton(button, isExternal = false) { + if (button.name == 'download') return true; + return button.external === isExternal; }