2023-02-28 08:29:30 +00:00
|
|
|
<template>
|
|
|
|
<DocSectionText v-bind="$attrs">
|
|
|
|
<p>Custom content at <i>header</i> and <i>footer</i> sections are supported via templating.</p>
|
|
|
|
</DocSectionText>
|
2023-12-31 14:08:33 +00:00
|
|
|
<DeferredDemo @load="loadDemoData">
|
|
|
|
<div class="card">
|
|
|
|
<DataTable :value="products" tableStyle="min-width: 50rem">
|
|
|
|
<template #header>
|
|
|
|
<div class="flex flex-wrap align-items-center justify-content-between gap-2">
|
|
|
|
<span class="text-xl text-900 font-bold">Products</span>
|
|
|
|
<Button icon="pi pi-refresh" rounded raised />
|
|
|
|
</div>
|
2023-02-28 08:29:30 +00:00
|
|
|
</template>
|
2023-12-31 14:08:33 +00:00
|
|
|
<Column field="name" header="Name"></Column>
|
|
|
|
<Column header="Image">
|
|
|
|
<template #body="slotProps">
|
2024-01-24 10:57:05 +00:00
|
|
|
<img :src="`https://primefaces.org/cdn/primevue/images/product/${slotProps.data.image}`" :alt="slotProps.data.image" class="w-6rem border-round" />
|
2023-12-31 14:08:33 +00:00
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<Column field="price" header="Price">
|
|
|
|
<template #body="slotProps">
|
|
|
|
{{ formatCurrency(slotProps.data.price) }}
|
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<Column field="category" header="Category"></Column>
|
|
|
|
<Column field="rating" header="Reviews">
|
|
|
|
<template #body="slotProps">
|
|
|
|
<Rating :modelValue="slotProps.data.rating" readonly :cancel="false" />
|
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<Column header="Status">
|
|
|
|
<template #body="slotProps">
|
|
|
|
<Tag :value="slotProps.data.inventoryStatus" :severity="getSeverity(slotProps.data)" />
|
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<template #footer> In total there are {{ products ? products.length : 0 }} products. </template>
|
|
|
|
</DataTable>
|
|
|
|
</div>
|
|
|
|
</DeferredDemo>
|
2023-02-28 08:29:30 +00:00
|
|
|
<DocSectionCode :code="code" :service="['ProductService']" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { ProductService } from '@/service/ProductService';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
products: null,
|
|
|
|
code: {
|
2023-09-22 12:54:14 +00:00
|
|
|
basic: `
|
|
|
|
<DataTable :value="products" tableStyle="min-width: 50rem">
|
2023-02-28 08:29:30 +00:00
|
|
|
<template #header>
|
|
|
|
<div class="flex flex-wrap align-items-center justify-content-between gap-2">
|
|
|
|
<span class="text-xl text-900 font-bold">Products</span>
|
2023-03-03 12:15:20 +00:00
|
|
|
<Button icon="pi pi-refresh" rounded raised />
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<Column field="name" header="Name"></Column>
|
|
|
|
<Column header="Image">
|
|
|
|
<template #body="slotProps">
|
2024-01-24 10:57:05 +00:00
|
|
|
<img :src="\`https://primefaces.org/cdn/primevue/images/product/\${slotProps.data.image}\`" :alt="slotProps.data.image" class="w-6rem border-round" />
|
2023-02-28 08:29:30 +00:00
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<Column field="price" header="Price">
|
|
|
|
<template #body="slotProps">
|
|
|
|
{{ formatCurrency(slotProps.data.price) }}
|
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<Column field="category" header="Category"></Column>
|
|
|
|
<Column field="rating" header="Reviews">
|
|
|
|
<template #body="slotProps">
|
|
|
|
<Rating :modelValue="slotProps.data.rating" readonly :cancel="false" />
|
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<Column header="Status">
|
|
|
|
<template #body="slotProps">
|
|
|
|
<Tag :value="slotProps.data.inventoryStatus" :severity="getSeverity(slotProps.data)" />
|
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<template #footer> In total there are {{ products ? products.length : 0 }} products. </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="products" tableStyle="min-width: 50rem">
|
|
|
|
<template #header>
|
|
|
|
<div class="flex flex-wrap align-items-center justify-content-between gap-2">
|
|
|
|
<span class="text-xl text-900 font-bold">Products</span>
|
2023-03-03 12:15:20 +00:00
|
|
|
<Button icon="pi pi-refresh" rounded raised />
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<Column field="name" header="Name"></Column>
|
|
|
|
<Column header="Image">
|
|
|
|
<template #body="slotProps">
|
2024-01-24 10:57:05 +00:00
|
|
|
<img :src="\`https://primefaces.org/cdn/primevue/images/product/\${slotProps.data.image}\`" :alt="slotProps.data.image" class="w-6rem border-round" />
|
2023-02-28 08:29:30 +00:00
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<Column field="price" header="Price">
|
|
|
|
<template #body="slotProps">
|
|
|
|
{{ formatCurrency(slotProps.data.price) }}
|
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<Column field="category" header="Category"></Column>
|
|
|
|
<Column field="rating" header="Reviews">
|
|
|
|
<template #body="slotProps">
|
|
|
|
<Rating :modelValue="slotProps.data.rating" readonly :cancel="false" />
|
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<Column header="Status">
|
|
|
|
<template #body="slotProps">
|
|
|
|
<Tag :value="slotProps.data.inventoryStatus" :severity="getSeverity(slotProps.data)" />
|
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<template #footer> In total there are {{ products ? products.length : 0 }} products. </template>
|
|
|
|
</DataTable>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { ProductService } from '@/service/ProductService';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
products: null
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
ProductService.getProductsMini().then((data) => (this.products = data));
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
formatCurrency(value) {
|
|
|
|
return value.toLocaleString('en-US', { style: 'currency', currency: 'USD' });
|
|
|
|
},
|
|
|
|
getSeverity(product) {
|
|
|
|
switch (product.inventoryStatus) {
|
|
|
|
case 'INSTOCK':
|
|
|
|
return 'success';
|
|
|
|
|
|
|
|
case 'LOWSTOCK':
|
|
|
|
return 'warning';
|
|
|
|
|
|
|
|
case 'OUTOFSTOCK':
|
|
|
|
return 'danger';
|
|
|
|
|
|
|
|
default:
|
|
|
|
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="products" tableStyle="min-width: 50rem">
|
|
|
|
<template #header>
|
|
|
|
<div class="flex flex-wrap align-items-center justify-content-between gap-2">
|
|
|
|
<span class="text-xl text-900 font-bold">Products</span>
|
2023-03-03 12:15:20 +00:00
|
|
|
<Button icon="pi pi-refresh" rounded raised />
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<Column field="name" header="Name"></Column>
|
|
|
|
<Column header="Image">
|
|
|
|
<template #body="slotProps">
|
2024-01-24 10:57:05 +00:00
|
|
|
<img :src="\`https://primefaces.org/cdn/primevue/images/product/\${slotProps.data.image}\`" :alt="slotProps.data.image" class="w-6rem border-round" />
|
2023-02-28 08:29:30 +00:00
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<Column field="price" header="Price">
|
|
|
|
<template #body="slotProps">
|
|
|
|
{{ formatCurrency(slotProps.data.price) }}
|
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<Column field="category" header="Category"></Column>
|
|
|
|
<Column field="rating" header="Reviews">
|
|
|
|
<template #body="slotProps">
|
|
|
|
<Rating :modelValue="slotProps.data.rating" readonly :cancel="false" />
|
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<Column header="Status">
|
|
|
|
<template #body="slotProps">
|
|
|
|
<Tag :value="slotProps.data.inventoryStatus" :severity="getSeverity(slotProps.data)" />
|
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<template #footer> In total there are {{ products ? products.length : 0 }} products. </template>
|
|
|
|
</DataTable>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import { ref, onMounted } from 'vue';
|
|
|
|
import { ProductService } from '@/service/ProductService';
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
ProductService.getProductsMini().then((data) => (products.value = data));
|
|
|
|
});
|
|
|
|
|
|
|
|
const products = ref();
|
|
|
|
const formatCurrency = (value) => {
|
|
|
|
return value.toLocaleString('en-US', { style: 'currency', currency: 'USD' });
|
|
|
|
};
|
|
|
|
const getSeverity = (product) => {
|
|
|
|
switch (product.inventoryStatus) {
|
|
|
|
case 'INSTOCK':
|
|
|
|
return 'success';
|
|
|
|
|
|
|
|
case 'LOWSTOCK':
|
|
|
|
return 'warning';
|
|
|
|
|
|
|
|
case 'OUTOFSTOCK':
|
|
|
|
return 'danger';
|
|
|
|
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-10-15 09:38:39 +00:00
|
|
|
<\/script>
|
|
|
|
`,
|
2023-02-28 08:29:30 +00:00
|
|
|
data: `
|
|
|
|
{
|
|
|
|
id: '1000',
|
|
|
|
code: 'f230fh0g3',
|
|
|
|
name: 'Bamboo Watch',
|
|
|
|
description: 'Product Description',
|
|
|
|
image: 'bamboo-watch.jpg',
|
|
|
|
price: 65,
|
|
|
|
category: 'Accessories',
|
|
|
|
quantity: 24,
|
|
|
|
inventoryStatus: 'INSTOCK',
|
|
|
|
rating: 5
|
|
|
|
},
|
|
|
|
...
|
|
|
|
`
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
2023-12-31 14:08:33 +00:00
|
|
|
loadDemoData() {
|
|
|
|
ProductService.getProductsMini().then((data) => (this.products = data));
|
|
|
|
},
|
2023-02-28 08:29:30 +00:00
|
|
|
formatCurrency(value) {
|
|
|
|
return value.toLocaleString('en-US', { style: 'currency', currency: 'USD' });
|
|
|
|
},
|
|
|
|
getSeverity(product) {
|
|
|
|
switch (product.inventoryStatus) {
|
|
|
|
case 'INSTOCK':
|
|
|
|
return 'success';
|
|
|
|
|
|
|
|
case 'LOWSTOCK':
|
|
|
|
return 'warning';
|
|
|
|
|
|
|
|
case 'OUTOFSTOCK':
|
|
|
|
return 'danger';
|
|
|
|
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|