primevue-mirror/doc/dynamicdialog/demo/ProductListDemo.vue

58 lines
1.9 KiB
Vue
Raw Normal View History

2022-09-09 20:41:18 +00:00
<template>
<div>
<div class="flex justify-content-end mt-1 mb-3">
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-01-24 10:57:05 +00:00
<img :src="'https://primefaces.org/cdn/primevue/images/product/' + slotProps.data.image" :alt="slotProps.data.name" class="w-4rem" />
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>