diff --git a/src/pages/03_customer-management/BranchPage.vue b/src/pages/03_customer-management/BranchPage.vue index c42f28c9..5451fdbc 100644 --- a/src/pages/03_customer-management/BranchPage.vue +++ b/src/pages/03_customer-management/BranchPage.vue @@ -3,6 +3,7 @@ import { ref, onMounted, watch } from 'vue'; import { storeToRefs } from 'pinia'; import { useI18n } from 'vue-i18n'; import { QTableProps } from 'quasar'; +import { useRoute } from 'vue-router'; import { baseUrl } from 'src/stores/utils'; import useCustomerStore from 'stores/customer'; @@ -42,6 +43,7 @@ import { formatAddress } from 'src/utils/address'; import PaginationPageSize from 'src/components/PaginationPageSize.vue'; import { nextTick } from 'vue'; +const route = useRoute(); const flowStore = useFlowStore(); const customerStore = useCustomerStore(); const employeeFormStore = useEmployeeForm(); @@ -74,6 +76,7 @@ const maxPageBranch = ref(1); const pageSizeBranch = ref(30); const statusEmployeeCreate = defineModel('statusEmployeeCreate'); +const statusEmployeeEdit = defineModel('statusEmployeeEdit'); const prop = withDefaults( defineProps<{ @@ -103,11 +106,8 @@ defineEmits<{ }>(); onMounted(async () => { - const url = window.location.href; - const parts = url.split('/'); - - customerBranchFormState.value.currentCustomerId = parts[4]; - + customerBranchFormState.value.currentCustomerId = route.params + .customerId as string; await fetchList(); branch.value?.forEach((v) => { @@ -244,9 +244,9 @@ watch([customerId, inputSearch, currentStatus, pageSizeBranch], async () => { await fetchList(); }); watch( - () => statusEmployeeCreate.value, + () => [statusEmployeeCreate.value, statusEmployeeEdit.value], async () => { - if (statusEmployeeCreate.value) { + if (!statusEmployeeCreate.value || !statusEmployeeEdit.value) { await fetchEmployee({ branchId: currentBranchEmployee.value, pageSize: 999, @@ -255,7 +255,7 @@ watch( const br = branch.value?.find( (v) => v.id === currentBranchEmployee.value, ); - if (br) br._count.employee += 1; + if (br) br._count.employee = listEmployee.value.length; } }, ); @@ -407,6 +407,7 @@ watch(
+ {{ console.log(branch) }} {}, }); } @@ -1344,25 +1364,24 @@ const emptyCreateDialog = ref(false); flat @click.stop=" async () => { - const res = await employeeStore.fetchList({ - customerId: props.row.id, - pageSize: 999, - passport: true, - visa: true, - }); + if (!currentBtnOpen[props.rowIndex]) { + customerFormState.currentCustomerId = + props.row.id; - if (res) { - listEmployee = res.result; + await fetchListEmployee({ + customerId: props.row.id, + page: 1, + pageSize: 9999, + }); currentBtnOpen.map((v, i) => { if (i !== props.rowIndex) { currentBtnOpen[i] = false; } }); - - currentBtnOpen[props.rowIndex] = - !currentBtnOpen[props.rowIndex]; } + currentBtnOpen[props.rowIndex] = + !currentBtnOpen[props.rowIndex]; } " > @@ -1814,6 +1833,7 @@ const emptyCreateDialog = ref(false); >
{ treeFile: { label: string; file: { label: string }[] }[]; formDataOcr: Record; isImageEdit: boolean; + currentCustomerId?: string; }>({ dialogType: 'info', dialogOpen: false,