From 42598b0653ff12f8b5e48131ba6dc3b5c5acad4c Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Mon, 19 Aug 2024 15:15:39 +0700 Subject: [PATCH] refactor: move button product --- src/pages/04_product-service/MainPage.vue | 123 +++++++++------------- 1 file changed, 49 insertions(+), 74 deletions(-) diff --git a/src/pages/04_product-service/MainPage.vue b/src/pages/04_product-service/MainPage.vue index e4e3217a..4748c2df 100644 --- a/src/pages/04_product-service/MainPage.vue +++ b/src/pages/04_product-service/MainPage.vue @@ -214,7 +214,6 @@ const profileUrl = ref(''); const pathGroupName = ref(''); const pathTypeName = ref(''); -const dialogProductServiceType = ref(false); const dialogTotalProduct = ref(false); const productMode = ref<'group' | 'type' | 'service' | 'product'>('group'); @@ -225,7 +224,6 @@ const product = ref<(ProductList & { type: 'product' })[]>(); const productIsAdd = ref<(ProductList & { type: 'product' })[]>(); const service = ref<(Service & { type: 'service' })[]>(); const resultSearchProduct = ref(); -const productAndService = ref([]); const productAndServiceTab = ref<'product' | 'service'>('service'); const manageWorkNameDialog = ref(false); @@ -477,13 +475,6 @@ async function searchProduct(isAdd: boolean = true) { flowStore.rotate(); } -async function featchStatsService() { - const resStatsService = await fetchStatsService(); - - totalService.value = resStatsService; - flowStore.rotate(); -} - async function fetchListOfOptionBranch() { const uid = getUserId(); const role = getRole(); @@ -503,15 +494,6 @@ async function fetchListOfOptionBranch() { currentMyBranch.value?.id || ''; } -async function featchStatsProduct() { - const resStatsProduct = await fetchStatsProduct({ - productTypeId: currentIdType.value, - }); - - totalProduct.value = resStatsProduct; - flowStore.rotate(); -} - async function fetchListType() { const res = await fetchListProductServiceType({ page: currentPageType.value, @@ -663,19 +645,6 @@ async function submitType() { await fetchListType(); } -const itemCard = [ - { - icon: 'mdi:server-network', - text: 'บริการ', - color: 'var(--orange-5)', - }, - { - icon: 'mdi:shopping', - text: 'สินค้า', - color: 'var(--green-9)', - }, -]; - async function toggleStatusProduct(id: string, status: Status) { const res = await editProduct(id, { status: status === 'INACTIVE' ? 'ACTIVE' : 'INACTIVE', @@ -783,7 +752,7 @@ async function deleteServiceById(serviceId?: string) { }); } -async function deleteTypeOfProduct(id?: string) { +async function deleteProductConfirm(id?: string) { dialog({ color: 'negative', icon: 'mdi-alert', @@ -794,6 +763,11 @@ async function deleteTypeOfProduct(id?: string) { action: async () => { const res = await deleteProduct(id ?? currentIdProduct.value); + if (!res) { + flowStore.rotate(); + return; + } + if (productAndServiceTab.value === 'product') { await fetchListOfProduct(); } @@ -2734,7 +2708,8 @@ watch( }[productAndServiceTab] " @update:model-value=" - (v) => (tbControl[productAndServiceTab].fieldSelected = v) + (v: string[]) => + (tbControl[productAndServiceTab].fieldSelected = v) " option-label="label" option-value="value" @@ -3258,7 +3233,7 @@ watch( @click=" () => { if (props.row.type === 'product') { - deleteTypeOfProduct(props.row.id); + deleteProductConfirm(props.row.id); } if (props.row.type === 'service') { deleteServiceById(props.row.id); @@ -3710,34 +3685,6 @@ watch( - - - -
+
+ + + + +