2023-02-28 08:29:30 +00:00
|
|
|
<template>
|
|
|
|
<DocSectionText v-bind="$attrs">
|
|
|
|
<p>
|
|
|
|
Rows are grouped with the <i>groupRowsBy</i> property. When <i>rowGroupMode</i> is set as <i>subheader</i>, a header and footer can be displayed for each group. The content of a group header is provided with <i>groupheader</i> and footer
|
|
|
|
with <i>groupfooter</i> slots.
|
|
|
|
</p>
|
|
|
|
</DocSectionText>
|
2023-12-31 14:08:33 +00:00
|
|
|
<DeferredDemo @load="loadDemoData">
|
|
|
|
<div class="card">
|
|
|
|
<DataTable :value="customers" rowGroupMode="subheader" groupRowsBy="representative.name" sortMode="single" sortField="representative.name" :sortOrder="1" scrollable scrollHeight="400px" tableStyle="min-width: 50rem">
|
|
|
|
<template #groupheader="slotProps">
|
2023-02-28 08:29:30 +00:00
|
|
|
<div class="flex align-items-center gap-2">
|
2023-12-31 14:08:33 +00:00
|
|
|
<img :alt="slotProps.data.representative.name" :src="`https://primefaces.org/cdn/primevue/images/avatar/${slotProps.data.representative.image}`" width="32" style="vertical-align: middle" />
|
|
|
|
<span>{{ slotProps.data.representative.name }}</span>
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
2023-12-31 14:08:33 +00:00
|
|
|
<Column field="representative.name" header="Representative"></Column>
|
|
|
|
<Column field="name" header="Name" style="min-width: 200px"></Column>
|
|
|
|
<Column field="country" header="Country" style="min-width: 200px">
|
|
|
|
<template #body="slotProps">
|
|
|
|
<div class="flex align-items-center gap-2">
|
|
|
|
<img alt="flag" src="https://primefaces.org/cdn/primevue/images/flag/flag_placeholder.png" :class="`flag flag-${slotProps.data.country.code}`" style="width: 24px" />
|
|
|
|
<span>{{ slotProps.data.country.name }}</span>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<Column field="company" header="Company" style="min-width: 200px"></Column>
|
|
|
|
<Column field="status" header="Status" style="min-width: 200px">
|
|
|
|
<template #body="slotProps">
|
|
|
|
<Tag :value="slotProps.data.status" :severity="getSeverity(slotProps.data.status)" />
|
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<Column field="date" header="Date" style="min-width: 200px"></Column>
|
|
|
|
<template #groupfooter="slotProps">
|
|
|
|
<div class="flex justify-content-end font-bold w-full">Total Customers: {{ calculateCustomerTotal(slotProps.data.representative.name) }}</div>
|
2023-02-28 08:29:30 +00:00
|
|
|
</template>
|
2023-12-31 14:08:33 +00:00
|
|
|
</DataTable>
|
|
|
|
</div>
|
|
|
|
</DeferredDemo>
|
2023-02-28 08:29:30 +00:00
|
|
|
<DocSectionCode :code="code" :service="['CustomerService']" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { CustomerService } from '@/service/CustomerService';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
customers: null,
|
|
|
|
code: {
|
2023-09-22 12:54:14 +00:00
|
|
|
basic: `
|
|
|
|
<DataTable :value="customers" rowGroupMode="subheader" groupRowsBy="representative.name" sortMode="single"
|
2023-02-28 08:29:30 +00:00
|
|
|
sortField="representative.name" :sortOrder="1" scrollable scrollHeight="400px" tableStyle="min-width: 50rem">
|
|
|
|
<Column field="representative.name" header="Representative"></Column>
|
|
|
|
<Column field="name" header="Name" style="min-width: 200px"></Column>
|
|
|
|
<Column field="country" header="Country" style="min-width: 200px">
|
|
|
|
<template #body="slotProps">
|
|
|
|
<div class="flex align-items-center gap-2">
|
|
|
|
<img alt="flag" src="https://primefaces.org/cdn/primevue/images/flag/flag_placeholder.png" :class="\`flag flag-\${slotProps.data.country.code}\`" style="width: 24px" />
|
|
|
|
<span>{{ slotProps.data.country.name }}</span>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<Column field="company" header="Company" style="min-width: 200px"></Column>
|
|
|
|
<Column field="status" header="Status" style="min-width: 200px">
|
|
|
|
<template #body="slotProps">
|
|
|
|
<Tag :value="slotProps.data.status" :severity="getSeverity(slotProps.data.status)" />
|
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<Column field="date" header="Date" style="min-width: 200px"></Column>
|
|
|
|
<template #groupheader="slotProps">
|
|
|
|
<div class="flex align-items-center gap-2">
|
|
|
|
<img :alt="slotProps.data.representative.name" :src="\`https://primefaces.org/cdn/primevue/images/avatar/\${slotProps.data.representative.image}\`" width="32" style="vertical-align: middle" />
|
|
|
|
<span>{{ slotProps.data.representative.name }}</span>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<template #groupfooter="slotProps">
|
2023-03-27 11:14:09 +00:00
|
|
|
<div class="flex justify-content-end font-bold w-full">Total Customers: {{ calculateCustomerTotal(slotProps.data.representative.name) }}</div>
|
2023-02-28 08:29:30 +00:00
|
|
|
</template>
|
2023-10-15 09:38:39 +00:00
|
|
|
</DataTable>
|
|
|
|
`,
|
2023-09-22 12:54:14 +00:00
|
|
|
options: `
|
|
|
|
<template>
|
2023-02-28 08:29:30 +00:00
|
|
|
<div class="card">
|
|
|
|
<DataTable :value="customers" rowGroupMode="subheader" groupRowsBy="representative.name" sortMode="single"
|
|
|
|
sortField="representative.name" :sortOrder="1" scrollable scrollHeight="400px" tableStyle="min-width: 50rem">
|
|
|
|
<Column field="representative.name" header="Representative"></Column>
|
|
|
|
<Column field="name" header="Name" style="min-width: 200px"></Column>
|
|
|
|
<Column field="country" header="Country" style="min-width: 200px">
|
|
|
|
<template #body="slotProps">
|
|
|
|
<div class="flex align-items-center gap-2">
|
|
|
|
<img alt="flag" src="https://primefaces.org/cdn/primevue/images/flag/flag_placeholder.png" :class="\`flag flag-\${slotProps.data.country.code}\`" style="width: 24px" />
|
|
|
|
<span>{{ slotProps.data.country.name }}</span>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<Column field="company" header="Company" style="min-width: 200px"></Column>
|
|
|
|
<Column field="status" header="Status" style="min-width: 200px">
|
|
|
|
<template #body="slotProps">
|
|
|
|
<Tag :value="slotProps.data.status" :severity="getSeverity(slotProps.data.status)" />
|
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<Column field="date" header="Date" style="min-width: 200px"></Column>
|
|
|
|
<template #groupheader="slotProps">
|
|
|
|
<div class="flex align-items-center gap-2">
|
|
|
|
<img :alt="slotProps.data.representative.name" :src="\`https://primefaces.org/cdn/primevue/images/avatar/\${slotProps.data.representative.image}\`" width="32" style="vertical-align: middle" />
|
|
|
|
<span>{{ slotProps.data.representative.name }}</span>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<template #groupfooter="slotProps">
|
2023-03-27 11:14:09 +00:00
|
|
|
<div class="flex justify-content-end font-bold w-full">Total Customers: {{ calculateCustomerTotal(slotProps.data.representative.name) }}</div>
|
2023-02-28 08:29:30 +00:00
|
|
|
</template>
|
|
|
|
</DataTable>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { CustomerService } from '@/service/CustomerService';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
customers: null
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
CustomerService.getCustomersMedium().then((data) => (this.customers = data));
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
calculateCustomerTotal(name) {
|
|
|
|
let total = 0;
|
|
|
|
|
|
|
|
if (this.customers) {
|
|
|
|
for (let customer of this.customers) {
|
|
|
|
if (customer.representative.name === name) {
|
|
|
|
total++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return total;
|
|
|
|
},
|
|
|
|
getSeverity(status) {
|
|
|
|
switch (status) {
|
|
|
|
case 'unqualified':
|
|
|
|
return 'danger';
|
|
|
|
|
|
|
|
case 'qualified':
|
|
|
|
return 'success';
|
|
|
|
|
|
|
|
case 'new':
|
|
|
|
return 'info';
|
|
|
|
|
|
|
|
case 'negotiation':
|
|
|
|
return 'warning';
|
|
|
|
|
|
|
|
case 'renewal':
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2023-10-15 09:38:39 +00:00
|
|
|
<\/script>
|
|
|
|
`,
|
2023-09-22 12:54:14 +00:00
|
|
|
composition: `
|
|
|
|
<template>
|
2023-02-28 08:29:30 +00:00
|
|
|
<div class="card">
|
|
|
|
<DataTable :value="customers" rowGroupMode="subheader" groupRowsBy="representative.name" sortMode="single"
|
|
|
|
sortField="representative.name" :sortOrder="1" scrollable scrollHeight="400px" tableStyle="min-width: 50rem">
|
|
|
|
<Column field="representative.name" header="Representative"></Column>
|
|
|
|
<Column field="name" header="Name" style="min-width: 200px"></Column>
|
|
|
|
<Column field="country" header="Country" style="min-width: 200px">
|
|
|
|
<template #body="slotProps">
|
|
|
|
<div class="flex align-items-center gap-2">
|
|
|
|
<img alt="flag" src="https://primefaces.org/cdn/primevue/images/flag/flag_placeholder.png" :class="\`flag flag-\${slotProps.data.country.code}\`" style="width: 24px" />
|
|
|
|
<span>{{ slotProps.data.country.name }}</span>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<Column field="company" header="Company" style="min-width: 200px"></Column>
|
|
|
|
<Column field="status" header="Status" style="min-width: 200px">
|
|
|
|
<template #body="slotProps">
|
|
|
|
<Tag :value="slotProps.data.status" :severity="getSeverity(slotProps.data.status)" />
|
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<Column field="date" header="Date" style="min-width: 200px"></Column>
|
|
|
|
<template #groupheader="slotProps">
|
|
|
|
<div class="flex align-items-center gap-2">
|
|
|
|
<img :alt="slotProps.data.representative.name" :src="\`https://primefaces.org/cdn/primevue/images/avatar/\${slotProps.data.representative.image}\`" width="32" style="vertical-align: middle" />
|
|
|
|
<span>{{ slotProps.data.representative.name }}</span>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<template #groupfooter="slotProps">
|
2023-03-27 11:14:09 +00:00
|
|
|
<div class="flex justify-content-end font-bold w-full">Total Customers: {{ calculateCustomerTotal(slotProps.data.representative.name) }}</div>
|
2023-02-28 08:29:30 +00:00
|
|
|
</template>
|
|
|
|
</DataTable>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import { ref, onMounted } from 'vue';
|
|
|
|
import { CustomerService } from '@/service/CustomerService';
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
CustomerService.getCustomersMedium().then((data) => (customers.value = data));
|
|
|
|
});
|
|
|
|
|
|
|
|
const customers = ref();
|
|
|
|
const calculateCustomerTotal = (name) => {
|
|
|
|
let total = 0;
|
|
|
|
|
|
|
|
if (customers.value) {
|
|
|
|
for (let customer of customers.value) {
|
|
|
|
if (customer.representative.name === name) {
|
|
|
|
total++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-12-31 14:08:33 +00:00
|
|
|
|
2023-02-28 08:29:30 +00:00
|
|
|
return total;
|
|
|
|
};
|
|
|
|
const getSeverity = (status) => {
|
|
|
|
switch (status) {
|
|
|
|
case 'unqualified':
|
|
|
|
return 'danger';
|
|
|
|
|
|
|
|
case 'qualified':
|
|
|
|
return 'success';
|
|
|
|
|
|
|
|
case 'new':
|
|
|
|
return 'info';
|
|
|
|
|
|
|
|
case 'negotiation':
|
|
|
|
return 'warning';
|
|
|
|
|
|
|
|
case 'renewal':
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
};
|
2023-10-15 09:38:39 +00:00
|
|
|
<\/script>
|
|
|
|
`,
|
2023-02-28 08:29:30 +00:00
|
|
|
data: `
|
|
|
|
{
|
|
|
|
id: 1000,
|
|
|
|
name: 'James Butt',
|
|
|
|
country: {
|
|
|
|
name: 'Algeria',
|
|
|
|
code: 'dz'
|
|
|
|
},
|
|
|
|
company: 'Benton, John B Jr',
|
|
|
|
date: '2015-09-13',
|
|
|
|
status: 'unqualified',
|
|
|
|
verified: true,
|
|
|
|
activity: 17,
|
|
|
|
representative: {
|
|
|
|
name: 'Ioni Bowcher',
|
|
|
|
image: 'ionibowcher.png'
|
|
|
|
},
|
|
|
|
balance: 70663
|
|
|
|
},
|
|
|
|
...`
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
2023-12-31 14:08:33 +00:00
|
|
|
loadDemoData() {
|
|
|
|
CustomerService.getCustomersMedium().then((data) => (this.customers = data));
|
|
|
|
},
|
2023-02-28 08:29:30 +00:00
|
|
|
calculateCustomerTotal(name) {
|
|
|
|
let total = 0;
|
|
|
|
|
|
|
|
if (this.customers) {
|
|
|
|
for (let customer of this.customers) {
|
|
|
|
if (customer.representative.name === name) {
|
|
|
|
total++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return total;
|
|
|
|
},
|
|
|
|
getSeverity(status) {
|
|
|
|
switch (status) {
|
|
|
|
case 'unqualified':
|
|
|
|
return 'danger';
|
|
|
|
|
|
|
|
case 'qualified':
|
|
|
|
return 'success';
|
|
|
|
|
|
|
|
case 'new':
|
|
|
|
return 'info';
|
|
|
|
|
|
|
|
case 'negotiation':
|
|
|
|
return 'warning';
|
|
|
|
|
|
|
|
case 'renewal':
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|