diff --git a/src/components/04_product-service/BasicInfoProduct.vue b/src/components/04_product-service/BasicInfoProduct.vue index 56753658..948e6dc6 100644 --- a/src/components/04_product-service/BasicInfoProduct.vue +++ b/src/components/04_product-service/BasicInfoProduct.vue @@ -1,6 +1,5 @@ @@ -60,6 +63,51 @@ const serviceCodeFilter = selectFilterOptionRefMod( {{ $t(`form.field.basicInformation`) }}
+ + +
- ({ detail: '', name: '', code: '', + registeredBranchId: '', }); const formDataProduct = ref({ @@ -719,7 +720,7 @@ async function triggerChangeStatus( : t('dialog.message.confirmChangeStatusOn'), action: async () => { if (type === 'group' || productMode.value === 'group') { - const res = await toggleStatusGroup(id, status as Status) + await toggleStatusGroup(id, status as Status) .then(resolve) .catch(reject); } else if (type === 'service') { @@ -847,21 +848,24 @@ function undoProductGroup() { detail: previousValue.value.detail, name: previousValue.value.name, code: previousValue.value.code, + registeredBranchId: previousValue.value.registeredBranchId, }; isEdit.value = false; flowStore.rotate(); } -function assignFormDataGroup(data: ProductGroup) { +async function assignFormDataGroup(data: ProductGroup) { previousValue.value = data; currentStatusGroupType.value = data.status; currentIdGroupType.value = data.id; + await fetchListOfOptionBranch(); formDataGroup.value = { remark: data.remark, detail: data.detail, name: data.name, code: data.code, + registeredBranchId: data.registeredBranchId, }; } @@ -981,6 +985,7 @@ function clearFormGroup() { detail: '', name: '', code: '', + registeredBranchId: '', }; currentStatusGroupType.value = 'CREATED'; dialogInputForm.value = false; @@ -1481,8 +1486,9 @@ watch(productMode, async () => { external-label label-position="left" @click=" - () => { + async () => { clearFormGroup(); + await fetchListOfOptionBranch(); dialogInputForm = true; } " @@ -1640,12 +1646,12 @@ watch(productMode, async () => { } " @view=" - (v: (typeof treeProductTypeAndGroup)[number]) => { + async (v: (typeof treeProductTypeAndGroup)[number]) => { if (v.type === 'group') { editByTree = 'group'; currentStatusProduct = v.status === 'INACTIVE'; clearFormGroup(); - assignFormDataGroup(v); + await assignFormDataGroup(v); isEdit = false; currentIdGropTree = v.id; drawerInfo = true; @@ -1653,11 +1659,11 @@ watch(productMode, async () => { } " @edit=" - (v: (typeof treeProductTypeAndGroup)[number]) => { + async (v: (typeof treeProductTypeAndGroup)[number]) => { editByTree = v.type as typeof editByTree; if (v.type === 'group') { clearFormGroup(); - assignFormDataGroup(v); + await assignFormDataGroup(v); isEdit = true; currentIdGropTree = v.id; drawerInfo = true; @@ -1980,13 +1986,13 @@ watch(productMode, async () => { round flat @click.stop=" - () => { + async () => { if (productMode === 'group') { editByTree = 'group'; currentStatusProduct = props.row.status === 'INACTIVE'; clearFormGroup(); - assignFormDataGroup(props.row); + await assignFormDataGroup(props.row); isEdit = false; currentIdGrop = props.row.id; drawerInfo = true; @@ -2000,13 +2006,13 @@ watch(productMode, async () => { :status="props.row.status" :idName="props.row.name" @view=" - () => { + async () => { if (productMode === 'group') { editByTree = 'group'; currentStatusProduct = props.row.status === 'INACTIVE'; clearFormGroup(); - assignFormDataGroup(props.row); + await assignFormDataGroup(props.row); isEdit = false; currentIdGrop = props.row.id; drawerInfo = true; @@ -2014,11 +2020,11 @@ watch(productMode, async () => { } " @edit=" - () => { + async () => { if (productMode === 'group') { editByTree = 'group'; clearFormGroup(); - assignFormDataGroup(props.row); + await assignFormDataGroup(props.row); isEdit = true; currentIdGrop = props.row.id; @@ -2072,13 +2078,13 @@ watch(productMode, async () => { triggerChangeStatus(props.row.id, props.row.status) " @viewCard=" - () => { + async () => { if (productMode === 'group') { editByTree = 'group'; currentStatusProduct = props.row.status === 'INACTIVE'; clearFormGroup(); - assignFormDataGroup(props.row); + await assignFormDataGroup(props.row); isEdit = false; currentIdGrop = props.row.id; drawerInfo = true; @@ -2086,10 +2092,10 @@ watch(productMode, async () => { } " @updateCard=" - () => { + async () => { if (productMode === 'group') { clearFormGroup(); - assignFormDataGroup(props.row); + await assignFormDataGroup(props.row); isEdit = true; currentIdGrop = props.row.id; @@ -2971,9 +2977,11 @@ watch(productMode, async () => {
@@ -3140,6 +3148,8 @@ watch(productMode, async () => { id="info-group" dense :readonly="!isEdit" + v-model:options-branch="branchOption" + v-model:registered-branch-id="formDataGroup.registeredBranchId" v-model:remark="formDataGroup.remark" v-model:name="formDataGroup.name" v-model:code="formDataGroup.code" @@ -3755,10 +3765,6 @@ watch(productMode, async () => { v-if="serviceTab === 1" dense service - v-model:options-branch="branchOption" - v-model:registered-branch-id=" - formDataProductService.registeredBranchId - " v-model:service-code="formDataProductService.code" v-model:service-description="formDataProductService.detail" v-model:service-name-th="formDataProductService.name" @@ -4057,10 +4063,6 @@ watch(productMode, async () => { dense service disableCode - v-model:options-branch="branchOption" - v-model:registered-branch-id=" - formDataProductService.registeredBranchId - " v-model:service-code="formDataProductService.code" v-model:service-description="formDataProductService.detail" v-model:service-name-th="formDataProductService.name" @@ -4141,12 +4143,11 @@ watch(productMode, async () => { async () => { if (!currentNode) return; - await fetchListOfOptionBranch(); if (currentNode.type === 'group') { editByTree = 'group'; currentStatusProduct = currentNode.status === 'INACTIVE'; clearFormGroup(); - assignFormDataGroup(currentNode); + await assignFormDataGroup(currentNode); isEdit = false; currentIdGrop = currentNode.id; drawerInfo = true; @@ -4168,12 +4169,12 @@ watch(productMode, async () => { v-ripple v-close-popup @click.stop=" - () => { + async () => { if (!currentNode) return; editByTree = currentNode.type as 'type' | 'group'; if (currentNode.type === 'group') { clearFormGroup(); - assignFormDataGroup(currentNode); + await assignFormDataGroup(currentNode); isEdit = true; currentIdGrop = currentNode.id; diff --git a/src/stores/my-branch/index.ts b/src/stores/my-branch/index.ts index 20fae24a..8b2cd671 100644 --- a/src/stores/my-branch/index.ts +++ b/src/stores/my-branch/index.ts @@ -45,7 +45,7 @@ const useMyBranch = defineStore('useMyBranchStore', () => { } async function fetchListMyBranch(userId: string) { - const res = await api.get>(`/user/${userId}/branch`, { + const res = await api.get>(`/branch`, { headers: { 'X-Rtid': flowStore.rtid, }, diff --git a/src/stores/product-service/types.ts b/src/stores/product-service/types.ts index 1d2bb8f5..9c57677d 100644 --- a/src/stores/product-service/types.ts +++ b/src/stores/product-service/types.ts @@ -195,11 +195,12 @@ export type ProductGroup = { detail: string; remark: string; status: Status; + registeredBranchId: string; createdBy: CreatedBy; createdAt: string; updatedBy: UpdatedBy; updatedAt: string; - _count: { product: number; type: number; service: number }; + _count: { product: number; service: number }; }; export interface ProductGroupCreate { @@ -207,6 +208,7 @@ export interface ProductGroupCreate { detail: string; name: string; code: string; + registeredBranchId: string; } export interface ProductGroupUpdate { @@ -215,4 +217,5 @@ export interface ProductGroupUpdate { name: string; code: string; status: Status; + registeredBranchId?: string; }