forked from verdnatura/salix-front
fix: CustomerMandates
This commit is contained in:
parent
8fc7e3cfb4
commit
24f4af712e
|
@ -1,20 +1,19 @@
|
|||
<script setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import { toDateTimeFormat } from 'src/filters/date';
|
||||
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||
import { dashIfEmpty } from 'src/filters';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
|
||||
const rows = ref([]);
|
||||
|
||||
const filter = {
|
||||
include: [
|
||||
{ relation: 'mandateType', scope: { fields: ['id', 'name'] } },
|
||||
{ relation: 'mandateType', scope: { fields: ['id', 'code'] } },
|
||||
{ relation: 'company', scope: { fields: ['id', 'code'] } },
|
||||
],
|
||||
where: { clientFk: route.params.id },
|
||||
|
@ -22,114 +21,61 @@ const filter = {
|
|||
limit: 20,
|
||||
};
|
||||
|
||||
const tableColumnComponents = {
|
||||
id: {
|
||||
component: 'span',
|
||||
props: () => {},
|
||||
event: () => {},
|
||||
},
|
||||
company: {
|
||||
component: 'span',
|
||||
props: () => {},
|
||||
event: () => {},
|
||||
},
|
||||
type: {
|
||||
component: 'span',
|
||||
props: () => {},
|
||||
event: () => {},
|
||||
},
|
||||
registerDate: {
|
||||
component: 'span',
|
||||
props: () => {},
|
||||
event: () => {},
|
||||
},
|
||||
endDate: {
|
||||
component: 'span',
|
||||
props: () => {},
|
||||
event: () => {},
|
||||
},
|
||||
};
|
||||
|
||||
const columns = computed(() => [
|
||||
{
|
||||
align: 'left',
|
||||
field: 'id',
|
||||
label: t('Id'),
|
||||
name: 'id',
|
||||
label: t('globals.id'),
|
||||
field: 'id',
|
||||
isId: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: (row) => row.company.code,
|
||||
label: t('Company'),
|
||||
cardVisible: true,
|
||||
format: ({ company }) => company.code,
|
||||
label: t('globals.company'),
|
||||
name: 'company',
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: (row) => row.mandateType.name,
|
||||
label: t('Type'),
|
||||
cardVisible: true,
|
||||
format: ({ mandateType }) => mandateType.code,
|
||||
label: t('globals.type'),
|
||||
name: 'type',
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: 'created',
|
||||
cardVisible: true,
|
||||
label: t('Register date'),
|
||||
name: 'registerDate',
|
||||
format: (value) => toDateTimeFormat(value),
|
||||
name: 'created',
|
||||
format: ({ created }) => toDateTimeFormat(created),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: 'finished',
|
||||
align: 'right',
|
||||
cardVisible: true,
|
||||
name: 'finished',
|
||||
label: t('End date'),
|
||||
name: 'endDate',
|
||||
format: (value) => (value ? toDateTimeFormat(value) : '-'),
|
||||
format: ({ finished }) => dashIfEmpty(toDateTimeFormat(finished)),
|
||||
},
|
||||
]);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FetchData
|
||||
:filter="filter"
|
||||
@on-fetch="(data) => (rows = data)"
|
||||
auto-load
|
||||
url="Mandates"
|
||||
/>
|
||||
|
||||
<QPage class="column items-center q-pa-md">
|
||||
<QTable
|
||||
<VnTable
|
||||
:filter="filter"
|
||||
auto-load
|
||||
url="Mandates"
|
||||
:columns="columns"
|
||||
:pagination="{ rowsPerPage: 12 }"
|
||||
:rows="rows"
|
||||
class="full-width q-mt-md"
|
||||
row-key="id"
|
||||
v-if="rows?.length"
|
||||
>
|
||||
<template #body-cell="props">
|
||||
<QTd :props="props">
|
||||
<QTr :props="props" class="cursor-pointer">
|
||||
<component
|
||||
:is="tableColumnComponents[props.col.name].component"
|
||||
@click="tableColumnComponents[props.col.name].event(props)"
|
||||
class="rounded-borders q-pa-sm"
|
||||
v-bind="tableColumnComponents[props.col.name].props(props)"
|
||||
>
|
||||
{{ props.value }}
|
||||
</component>
|
||||
</QTr>
|
||||
</QTd>
|
||||
</template>
|
||||
</QTable>
|
||||
|
||||
<h5 class="flex justify-center color-vn-label" v-else>
|
||||
{{ t('globals.noResults') }}
|
||||
</h5>
|
||||
:right-search="false"
|
||||
:row-click="false"
|
||||
/>
|
||||
</QPage>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
es:
|
||||
Id: Id
|
||||
Company: Empresa
|
||||
Type: Tipo
|
||||
Register date: Fecha alta
|
||||
End date: Fecha baja
|
||||
</i18n>
|
||||
|
|
Loading…
Reference in New Issue