From cae5bf6da0845b983d9f0d2c6ac30c609868fc65 Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Mon, 24 Jun 2024 09:44:38 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20by=E0=B8=84=E0=B9=88=E0=B8=B2=20?= =?UTF-8?q?=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B9=81=E0=B8=AA=E0=B8=94=E0=B8=87?= =?UTF-8?q?=20=E0=B8=AA=E0=B8=B4=E0=B8=99=E0=B8=84=E0=B9=89=E0=B8=B2=20?= =?UTF-8?q?=E0=B9=81=E0=B8=A5=E0=B8=B0=20=E0=B8=9A=E0=B8=A3=E0=B8=B4?= =?UTF-8?q?=E0=B8=81=E0=B8=B2=E0=B8=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/04_product-service/MainPage.vue | 55 ++++++++++++++++++----- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/src/pages/04_product-service/MainPage.vue b/src/pages/04_product-service/MainPage.vue index 40eb848b..a8a4ff79 100644 --- a/src/pages/04_product-service/MainPage.vue +++ b/src/pages/04_product-service/MainPage.vue @@ -59,6 +59,7 @@ const { editProduct, deleteProduct, + fetchStatsService, fetchListService, fetchListServiceById, createService, @@ -103,6 +104,7 @@ const { t } = useI18n(); const inputSearch = ref(''); const searchTotalProduct = ref(''); +const currentStatusProduct = ref(false); const drawerInfo = ref(false); const isEdit = ref(false); @@ -352,6 +354,7 @@ async function deleteServiceById(serviceId?: string) { await fetchListOfService(); dialogServiceEdit.value = false; + calculateStats(); }, cancel: () => {}, }); @@ -371,7 +374,7 @@ async function deleteTypeOfProduct(id?: string) { dialogProductEdit.value = false; - stat.value[3].count = stat.value[3].count - 1; + calculateStats(); }, cancel: () => {}, }); @@ -391,17 +394,15 @@ async function deleteProductById(productId?: string) { // Product Type await deleteProductServiceType(productId ?? currentIdType.value); await fetchListType(); - - stat.value[1].count = stat.value[1].count - 1; } if (productMode.value === 'group') { // Product Group const res = await deleteProductService(productId ?? currentId.value); if (res) { - stat.value[0].count = stat.value[0].count - 1; } await fetchListGroups(); } + calculateStats(); drawerInfo.value = false; }, cancel: () => {}, @@ -651,15 +652,20 @@ function openPropertiesDialog(type: 'service' | 'work') { propertiesDialog.value = true; } -onMounted(async () => { +async function calculateStats() { const resStatsGroup = await fetchStatsProductGroup(); const resStatsType = await fetchStatsProductType(); + const resStatsService = await fetchStatsService(); const resStatsProduct = await fetchStatsProduct(); stat.value[0].count = resStatsGroup ?? 0; stat.value[1].count = resStatsType ?? 0; + stat.value[2].count = resStatsService ?? 0; stat.value[3].count = resStatsProduct ?? 0; +} +onMounted(async () => { + calculateStats(); await fetchListGroups(); }); @@ -922,11 +928,12 @@ watch(currentStatus, async () => { :date="new Date(v.updatedAt)" :status="v.status" :id="v.id" - :isDisabled="v.status === 'ACTIVE' || v.status === 'CREATED'" + :isDisabled="v.status === 'INACTIVE'" color="var(--purple-11-hsl)" @toggleStatus="toggleStatusType(v.id, v.status)" @viewCard=" () => { + currentStatusProduct = v.status === 'INACTIVE'; clearFormGroup(); currentIdType = v.id; assignFormDataGroup(v); @@ -966,10 +973,11 @@ watch(currentStatus, async () => { :status="v.status" color="var(--pink-6-hsl)" :id="v.id" - :isDisabled="v.status === 'ACTIVE' || v.status === 'CREATED'" + :isDisabled="v.status === 'INACTIVE'" @toggleStatus="toggleStatusGroup(v.id, v.status)" @viewCard=" () => { + currentStatusProduct = v.status === 'INACTIVE'; clearFormGroup(); assignFormDataGroup(v); isEdit = false; @@ -1035,7 +1043,7 @@ watch(currentStatus, async () => { " :color="productAndServiceTab === 'all' ? 'primary' : ''" style="background-color: var(--surface-3)" - label="2" + :label="(service?.length ?? 0) + (product?.length ?? 0)" /> @@ -1057,7 +1065,7 @@ watch(currentStatus, async () => { " :color="productAndServiceTab === 'product' ? 'primary' : ''" style="background-color: var(--surface-3)" - label="2" + :label="service?.length" /> @@ -1156,7 +1164,14 @@ watch(currentStatus, async () => { gap: var(--size-3); " > -
+
{ />
-
+
{ { gap: var(--size-3); " > -
+