2022-09-09 20:41:18 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="flex justify-end mt-1 mb-4">
|
2023-03-03 12:15:20 +00:00
|
|
|
<Button icon="pi pi-external-link" label="Nested Dialog" outlined severity="success" @click="showInfo" />
|
2022-09-09 20:41:18 +00:00
|
|
|
</div>
|
2023-02-28 08:29:30 +00:00
|
|
|
<DataTable :value="products">
|
2022-09-09 20:41:18 +00:00
|
|
|
<Column field="code" header="Code"></Column>
|
|
|
|
<Column field="name" header="Name"></Column>
|
|
|
|
<Column header="Image">
|
|
|
|
<template #body="slotProps">
|
2024-05-20 12:14:38 +00:00
|
|
|
<img :src="'https://primefaces.org/cdn/primevue/images/product/' + slotProps.data.image" :alt="slotProps.data.name" class="w-16" />
|
2022-09-09 20:41:18 +00:00
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
<Column field="category" header="Category"></Column>
|
|
|
|
<Column field="quantity" header="Quantity"></Column>
|
|
|
|
<Column style="width: 5rem">
|
|
|
|
<template #body="slotProps">
|
2023-03-03 12:15:20 +00:00
|
|
|
<Button type="button" icon="pi pi-plus" text rounded @click="selectProduct(slotProps.data)"></Button>
|
2022-09-09 20:41:18 +00:00
|
|
|
</template>
|
|
|
|
</Column>
|
|
|
|
</DataTable>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-02-28 08:29:30 +00:00
|
|
|
import { ProductService } from '@/service/ProductService';
|
2022-09-09 20:41:18 +00:00
|
|
|
import InfoDemo from './InfoDemo.vue';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
inject: ['dialogRef'],
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
products: null
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
2023-02-28 08:29:30 +00:00
|
|
|
ProductService.getProductsSmall().then((data) => (this.products = data.slice(0, 5)));
|
2022-09-09 20:41:18 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
selectProduct(data) {
|
|
|
|
this.dialogRef.close(data);
|
|
|
|
},
|
|
|
|
showInfo() {
|
|
|
|
this.$dialog.open(InfoDemo, {
|
|
|
|
props: {
|
|
|
|
header: 'Information',
|
|
|
|
modal: true,
|
|
|
|
dismissableMask: true
|
|
|
|
},
|
|
|
|
data: {
|
|
|
|
totalProducts: this.products ? this.products.length : 0
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|