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