Merge branch 'features/ms_64_extended_list_correcciones' of https://gitea.verdnatura.es/hyervoni/salix-front-mindshore into dev

This commit is contained in:
William Buezas 2023-12-20 15:18:44 -03:00
commit 2c604b842d
3 changed files with 183 additions and 59 deletions

View File

@ -1,11 +1,19 @@
<script setup> <script setup>
import { ref, computed, onBeforeMount } from 'vue'; import { ref, computed, onBeforeMount } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import { QBtn } from 'quasar';
import { useArrayData } from 'composables/useArrayData';
import { useStateStore } from 'stores/useStateStore';
import CustomerDescriptorProxy from 'src/pages/Customer/Card/CustomerDescriptorProxy.vue';
import CustomerExtendedListActions from './CustomerExtendedListActions.vue';
import CustomerExtendedListFilter from './CustomerExtendedListFilter.vue'; import CustomerExtendedListFilter from './CustomerExtendedListFilter.vue';
import { useStateStore } from 'stores/useStateStore'; const { t } = useI18n();
import { useArrayData } from 'composables/useArrayData'; const router = useRouter();
const stateStore = useStateStore(); const stateStore = useStateStore();
const arrayData = ref(null); const arrayData = ref(null);
@ -16,17 +24,18 @@ onBeforeMount(async () => {
limit: 0, limit: 0,
}); });
await arrayData.value.fetch({ append: false }); await arrayData.value.fetch({ append: false });
stateStore.rightDrawer = true; stateStore.rightDrawer = true;
}); });
const rows = computed(() => arrayData.value.store.data); const rows = computed(() => arrayData.value.store.data);
const selectedCustomerId = ref(0);
const tableColumnComponents = { const tableColumnComponents = {
id: { id: {
component: 'span', component: QBtn,
props: () => {}, props: () => ({ flat: true, color: 'blue' }),
event: () => {}, event: (prop) => selectCustomerId(prop.row.id),
}, },
socialName: { socialName: {
component: 'span', component: 'span',
@ -53,46 +62,75 @@ const tableColumnComponents = {
props: () => {}, props: () => {},
event: () => {}, event: () => {},
}, },
actions: {
component: CustomerExtendedListActions,
props: (prop) => ({
id: prop.row.id,
}),
event: () => {},
},
}; };
const columns = ref([ const columns = computed(() => {
{ return [
align: 'left', {
field: 'id', align: 'left',
label: 'Identifier', field: 'id',
name: 'id', label: t('Identifier'),
}, name: 'id',
{ },
align: 'left', {
field: 'socialName', align: 'left',
label: 'Social name', field: 'socialName',
name: 'socialName', label: t('Social name'),
}, name: 'socialName',
{ },
align: 'left', {
field: 'salesPerson', align: 'left',
label: 'Salesperson', field: 'salesPerson',
name: 'salesPerson', label: t('Salesperson'),
}, name: 'salesPerson',
{ },
align: 'left', {
field: 'phone', align: 'left',
label: 'Phone', field: 'phone',
name: 'phone', label: t('Phone'),
}, name: 'phone',
{ },
align: 'left', {
field: 'city', align: 'left',
label: 'City', field: 'city',
name: 'city', label: t('City'),
}, name: 'city',
{ },
align: 'left', {
field: 'email', align: 'left',
label: 'Email', field: 'email',
name: 'email', label: t('Email'),
}, name: 'email',
]); },
{
align: 'right',
field: 'actions',
label: '',
name: 'actions',
},
];
});
const stopEventPropagation = (event, col) => {
if (!['ref', 'id', 'supplier'].includes(col.name)) return;
event.preventDefault();
event.stopPropagation();
};
const navigateToTravelId = (id) => {
router.push({ path: `/customer/${id}` });
};
const selectCustomerId = (id) => {
selectedCustomerId.value = id;
};
</script> </script>
<template> <template>
@ -111,23 +149,35 @@ const columns = ref([
<QPage class="column items-center q-pa-md"> <QPage class="column items-center q-pa-md">
<QTable <QTable
:columns="columns" :columns="columns"
:pagination="{ rowsPerPage: 0 }"
:rows="rows" :rows="rows"
class="full-width q-mt-md"
hide-bottom hide-bottom
row-key="id" row-key="id"
:pagination="{ rowsPerPage: 0 }"
class="full-width q-mt-md"
> >
<template #body-cell="props"> <template #body="props">
<QTd :props="props"> <QTr
<component :props="props"
:is="tableColumnComponents[props.col.name].component" @click="navigateToTravelId(props.row.id)"
class="col-content" class="cursor-pointer"
v-bind="tableColumnComponents[props.col.name].props(props)" >
@click="tableColumnComponents[props.col.name].event(props)" <QTd
v-for="col in props.cols"
:key="col.name"
:props="props"
@click="stopEventPropagation($event, col)"
> >
{{ props.value }} <component
</component> :is="tableColumnComponents[col.name].component"
</QTd> class="col-content"
v-bind="tableColumnComponents[col.name].props(props)"
@click="tableColumnComponents[col.name].event(props)"
>
{{ col.value }}
<CustomerDescriptorProxy :id="selectedCustomerId" />
</component>
</QTd>
</QTr>
</template> </template>
</QTable> </QTable>
</QPage> </QPage>
@ -139,3 +189,13 @@ const columns = ref([
padding: 6px 6px 6px 6px; padding: 6px 6px 6px 6px;
} }
</style> </style>
<i18n>
es:
Identifier: Identificador
Social name: Razón social
Salesperson: Comercial
Phone: Teléfono
City: Población
Email: Email
</i18n>

View File

@ -0,0 +1,64 @@
<script setup>
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import { useQuasar } from 'quasar';
import CustomerSummaryDialog from './Card/CustomerSummaryDialog.vue';
const { t } = useI18n();
const quasar = useQuasar();
const router = useRouter();
const $props = defineProps({
id: {
type: Number,
required: true,
},
});
const redirectToCreateView = () => {
router.push({
name: 'TicketList',
query: {
params: JSON.stringify({
clientFk: $props.id,
}),
},
});
};
const viewSummary = () => {
quasar.dialog({
component: CustomerSummaryDialog,
componentProps: {
id: $props.id,
},
});
};
</script>
<template>
<QIcon @click.stop="redirectToCreateView" color="primary" name="vn:ticket" size="sm">
<QTooltip>
{{ t('Client ticket list') }}
</QTooltip>
</QIcon>
<QIcon
@click.stop="viewSummary"
class="q-ml-md"
color="primary"
name="preview"
size="sm"
>
<QTooltip>
{{ t('Preview') }}
</QTooltip>
</QIcon>
</template>
<i18n>
es:
Client ticket list: Listado de tickets del cliente
Preview: Vista previa
</i18n>

View File

@ -60,8 +60,8 @@ const workers = ref();
v-model="params.socialName" v-model="params.socialName"
@update:model-value="searchFn()" @update:model-value="searchFn()"
:options="clients" :options="clients"
option-value="id" option-value="socialName"
option-label="name" option-label="socialName"
emit-value emit-value
map-options map-options
use-input use-input