feat: ต่อ api จำนวน ของ Product
This commit is contained in:
parent
2ffc252a8b
commit
372d63f99e
2 changed files with 21 additions and 1 deletions
|
|
@ -47,6 +47,7 @@ const {
|
||||||
editProductService,
|
editProductService,
|
||||||
deleteProductService,
|
deleteProductService,
|
||||||
|
|
||||||
|
fetchStatsProduct,
|
||||||
fetchListProduct,
|
fetchListProduct,
|
||||||
createProduct,
|
createProduct,
|
||||||
|
|
||||||
|
|
@ -438,7 +439,11 @@ async function submitProduct() {
|
||||||
formDataProduct.value.image = imageProduct.value;
|
formDataProduct.value.image = imageProduct.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
await createProduct(formDataProduct.value);
|
const res = await createProduct(formDataProduct.value);
|
||||||
|
|
||||||
|
if (res) {
|
||||||
|
stat.value[3].count = stat.value[3].count + 1;
|
||||||
|
}
|
||||||
|
|
||||||
dialogProduct.value = false;
|
dialogProduct.value = false;
|
||||||
await fetchListOfProduct(currentIdType.value);
|
await fetchListOfProduct(currentIdType.value);
|
||||||
|
|
@ -463,8 +468,11 @@ async function submitGroup() {
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const resStatsGroup = await fetchStatsProductGroup();
|
const resStatsGroup = await fetchStatsProductGroup();
|
||||||
const resStatsType = await fetchStatsProductType();
|
const resStatsType = await fetchStatsProductType();
|
||||||
|
const resStatsProduct = await fetchStatsProduct();
|
||||||
|
|
||||||
stat.value[0].count = resStatsGroup ?? 0;
|
stat.value[0].count = resStatsGroup ?? 0;
|
||||||
stat.value[1].count = resStatsType ?? 0;
|
stat.value[1].count = resStatsType ?? 0;
|
||||||
|
stat.value[3].count = resStatsProduct ?? 0;
|
||||||
|
|
||||||
await fetchListGroups();
|
await fetchListGroups();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -239,6 +239,17 @@ const useProductServiceStore = defineStore('api-product-service', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Product
|
// Product
|
||||||
|
|
||||||
|
async function fetchStatsProduct() {
|
||||||
|
const res = await api.get('/product/stats');
|
||||||
|
|
||||||
|
if (!res) return false;
|
||||||
|
|
||||||
|
if (res.status === 200) {
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchListProduct(
|
async function fetchListProduct(
|
||||||
opts?: {
|
opts?: {
|
||||||
query?: string;
|
query?: string;
|
||||||
|
|
@ -500,6 +511,7 @@ const useProductServiceStore = defineStore('api-product-service', () => {
|
||||||
editProductService,
|
editProductService,
|
||||||
deleteProductService,
|
deleteProductService,
|
||||||
|
|
||||||
|
fetchStatsProduct,
|
||||||
fetchListProduct,
|
fetchListProduct,
|
||||||
createProduct,
|
createProduct,
|
||||||
fetchListProductById,
|
fetchListProductById,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue