0
0
Fork 0

refactor: CustomerNotifications use VnTable

This commit is contained in:
Alex Moreno 2024-07-15 14:54:31 +02:00
parent fd11259f74
commit bfa61d9bea
1 changed files with 30 additions and 80 deletions

View File

@ -5,41 +5,12 @@ import { QBtn } from 'quasar';
import CustomerNotificationsFilter from './CustomerNotificationsFilter.vue';
import CustomerDescriptorProxy from '../Card/CustomerDescriptorProxy.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import VnPaginate from 'src/components/ui/VnPaginate.vue';
import CustomerNotificationsCampaignConsumption from './CustomerNotificationsCampaignConsumption.vue';
import RightMenu from 'src/components/common/RightMenu.vue';
import VnTable from 'src/components/VnTable/VnTable.vue';
const { t } = useI18n();
const selected = ref([]);
const selectedCustomerId = ref(0);
const tableColumnComponents = {
id: {
component: QBtn,
props: () => ({ flat: true, color: 'blue' }),
event: (prop) => selectCustomerId(prop.row.id),
},
socialName: {
component: 'span',
props: () => {},
event: () => {},
},
city: {
component: 'span',
props: () => {},
event: () => {},
},
phone: {
component: 'span',
props: () => {},
event: () => {},
},
email: {
component: 'span',
props: () => {},
event: () => {},
},
};
const columns = computed(() => [
{
@ -53,6 +24,15 @@ const columns = computed(() => [
field: 'socialName',
label: t('Social name'),
name: 'socialName',
columnFilter: {
component: 'select',
attrs: {
url: 'Clients',
fields: ['id', 'socialName'],
optionLabel: 'socialName',
},
},
class: 'expand',
},
{
align: 'left',
@ -73,10 +53,6 @@ const columns = computed(() => [
name: 'email',
},
]);
const selectCustomerId = (id) => {
selectedCustomerId.value = id;
};
</script>
<template>
@ -86,7 +62,7 @@ const selectCustomerId = (id) => {
</template>
</RightMenu>
<VnSubToolbar class="justify-end">
<template #st-data>
<template #st-actions>
<CustomerNotificationsCampaignConsumption
:selected-rows="selected.length > 0"
:clients="selected"
@ -94,51 +70,25 @@ const selectCustomerId = (id) => {
/>
</template>
</VnSubToolbar>
<QPage class="column items-center q-pa-md">
<VnPaginate data-key="CustomerNotifications" url="Clients" auto-load>
<template #body="{ rows }">
<div class="q-pa-md">
<QTable
:columns="columns"
:rows="rows"
class="full-width q-mt-md"
row-key="id"
selection="multiple"
v-model:selected="selected"
>
<template #body-cell="props">
<QTd :props="props">
<QTr :props="props" class="cursor-pointer">
<component
:is="
tableColumnComponents[props.col.name]
.component
"
class="col-content"
v-bind="
tableColumnComponents[props.col.name].props(
props
)
"
@click="
tableColumnComponents[props.col.name].event(
props
)
"
>
{{ props.value }}
<CustomerDescriptorProxy
:id="selectedCustomerId"
/>
</component>
</QTr>
</QTd>
</template>
</QTable>
</div>
</template>
</VnPaginate>
</QPage>
<VnTable
data-key="CustomerNotifications"
url="Clients"
:table="{
'row-key': 'id',
selection: 'multiple',
}"
v-model:selected="selected"
:columns="columns"
:use-model="true"
auto-load
>
<template #column-id="{ row }">
<span class="link">
{{ row.id }}
<CustomerDescriptorProxy :id="row.id" />
</span>
</template>
</VnTable>
</template>
<style lang="scss" scoped>