0
0
Fork 0

refs #5509 feat: VnDmsList

This commit is contained in:
Alex Moreno 2024-02-08 07:25:23 +01:00
parent 64b7a07d41
commit 18b76e5e12
3 changed files with 215 additions and 3 deletions

View File

@ -17,12 +17,17 @@ const props = defineProps({
type: String,
required: true,
},
defaultDmsCode: {
type: String,
required: true,
},
});
const warehouses = ref();
const companies = ref();
const dmsTypes = ref();
const allowedContentTypes = ref();
const config = ref({});
const dms = ref({});
function onFileChange(files) {
@ -39,6 +44,25 @@ function parseDms(data) {
console.log(data);
dms.value = data;
}
function mapperDms(data) {
const formData = new FormData();
const { files } = data;
if (files) formData.append(files?.name, files);
console.log('data', data);
delete data.files;
const dms = {
hasFile: false,
hasFileAttached: false,
reference: data.id,
warehouseId: config.value.warehouseFk,
companyId: config.value.companyFk,
dmsTypeId: data.dmsTypeFk,
description: 'ASD',
};
return [formData, { params: dms }];
}
</script>
<template>
<FetchData url="Warehouses" @on-fetch="(data) => (warehouses = data)" auto-load />
@ -49,6 +73,11 @@ function parseDms(data) {
@on-fetch="(data) => (allowedContentTypes = data.join(','))"
auto-load
/>
<FetchData
url="UserConfigs/getUserConfig"
@on-fetch="(data) => (config = data)"
auto-load
/>
<FormModel
:url="`Dms/${route.params.id}`"
update-type="post"
@ -56,6 +85,7 @@ function parseDms(data) {
@on-fetch="parseDms"
model="dms"
:auto-load="!!route.params.id"
:mapper="mapperDms"
>
<template #form>
<div class="q-gutter-y-ms">
@ -93,11 +123,12 @@ function parseDms(data) {
v-model="dms.description"
type="textarea"
/>
{{ allowedContentTypes }}
<QFile
:label="t('entry.buys.file')"
v-model="dms.files"
:multiple="false"
accept=".json"
:accept="allowedContentTypes"
@update:model-value="onFileChange(dms.files)"
class="required"
:display-value="dms.file"

View File

@ -0,0 +1,181 @@
<script setup>
import { ref, computed } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import FetchData from 'components/FetchData.vue';
import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
import VnInput from 'src/components/common/VnInput.vue';
import { QCheckbox, QBtn } from 'quasar';
const route = useRoute();
const { t } = useI18n();
const rows = ref();
const $props = defineProps({
model: {
type: String,
required: true,
},
defaultDmsCode: {
type: String,
required: true,
},
entity: {
type: String,
default: 'entryFk',
},
});
const dmsFilter = {
include: {
relation: 'dms',
scope: {
fields: [
'dmsTypeFk',
'reference',
'hardCopyNumber',
'workerFk',
'description',
'hasFile',
'file',
'created',
],
include: [
{
relation: 'dmsType',
scope: {
fields: ['name'],
},
},
{
relation: 'worker',
scope: {
fields: ['id'],
include: {
relation: 'user',
scope: {
fields: ['name'],
},
},
},
},
],
},
},
};
const columns = computed(() => [
{
align: 'left',
field: 'id',
label: t('id'),
name: 'id',
component: 'span',
},
{
align: 'left',
field: 'type',
label: t('type'),
name: 'type',
component: 'span',
},
{
align: 'left',
field: 'order',
label: t('order'),
name: 'order',
component: 'span',
},
{
align: 'left',
field: 'reference',
label: t('reference'),
name: 'reference',
component: 'span',
},
{
align: 'left',
field: 'description',
label: t('description'),
name: 'description',
component: 'span',
},
{
align: 'left',
field: 'hasFile',
label: t('hasFile'),
name: 'hasFile',
component: QCheckbox,
},
{
align: 'left',
field: 'file',
label: t('file'),
name: 'file',
component: 'span',
},
{
align: 'center',
field: 'options',
name: 'options',
},
]);
function setData(data) {
const newData = data.map((value) => value.dms);
console.log(newData);
rows.value = newData;
}
</script>
<template>
<FetchData
:url="$props.model"
:where="{ [$props.entity]: route.params.id }"
:filter="dmsFilter"
@on-fetch="setData"
auto-load
/>
<QTable
:columns="columns"
:pagination="{ rowsPerPage: 0 }"
:rows="rows"
class="full-width q-mt-md"
hide-bottom
row-key="clientFk"
selection="multiple"
v-model:selected="selected"
>
<template #body-cell="props">
<QTd :props="props">
<QTr :props="props" class="cursor-pointer">
<component
v-if="props.col.component"
:is="props.col.component"
v-bind="props.col.props && props.col.props(props)"
@click="props.col.event(props)"
>
{{ props.value }}
<!-- <QBtn -->
</component>
</QTr>
</QTd>
</template>
asd
</QTable>
</template>
<style scoped>
.q-gutter-y-ms {
display: grid;
row-gap: 20px;
}
</style>
<i18n>
en:
contentTypesInfo: Allowed file types {allowedContentTypes}
es:
contentTypesInfo: Tipos de archivo permitidos {allowedContentTypes}
Generate identifier for original file: Generar identificador para archivo original
</i18n>

View File

@ -1,7 +1,7 @@
<script setup>
import VnDms from 'src/components/common/VnDms.vue';
import VnDmsList from 'src/components/common/VnDmsList.vue';
</script>
<template>
<VnDms model="Clients" />
<VnDmsList model="EntryDms" default-dms-code="entry" />
<!-- CHANGE ME-->
</template>