diff --git a/src/components/03_customer-management/TableEmpoloyee.vue b/src/components/03_customer-management/TableEmpoloyee.vue index f887fd1f..31cee457 100644 --- a/src/components/03_customer-management/TableEmpoloyee.vue +++ b/src/components/03_customer-management/TableEmpoloyee.vue @@ -7,6 +7,8 @@ import PersonCard from 'components/shared/PersonCard.vue'; import KebabAction from '../shared/KebabAction.vue'; import useOptionStore from 'stores/options'; +import { AddButton } from 'components/button'; + const optionStore = useOptionStore(); const pageSize = defineModel('pageSize', { default: 30 }); const currentPage = defineModel('currentPage', { default: 1 }); @@ -18,6 +20,7 @@ const prop = withDefaults( columnsEmployee: any[]; fieldSelected?: string[]; inTable?: boolean; + addButton?: boolean; }>(), { gridView: false, @@ -37,6 +40,7 @@ const prop = withDefaults( ); defineEmits<{ + (e: 'add'): void; (e: 'view', data: any): void; (e: 'edit', data: any): void; (e: 'delete', data: any): void; @@ -68,7 +72,9 @@ defineEmits<{ {{ $t('fullname') }} - + + + {{ $t(col.label) }} diff --git a/src/pages/03_customer-management/BranchPage.vue b/src/pages/03_customer-management/BranchPage.vue index e6c4defb..1c786142 100644 --- a/src/pages/03_customer-management/BranchPage.vue +++ b/src/pages/03_customer-management/BranchPage.vue @@ -70,6 +70,8 @@ const currentPageBranch = ref(1); const maxPageBranch = ref(1); const pageSizeBranch = ref(30); +const statusEmployeeCreate = defineModel('statusEmployeeCreate'); + const prop = withDefaults( defineProps<{ index?: string | number; @@ -84,12 +86,13 @@ const prop = withDefaults( color: 'green', }, ); - +const currentBranchEmployee = ref(''); const listEmployee = ref([]); const customerId = defineModel('customerId', { required: true }); defineEmits<{ + (e: 'addEmployee', currentBranch: CustomerBranch): void; (e: 'back'): void; (e: 'viewDetail', branch: CustomerBranch, index: number): void; (e: 'dialog'): void; @@ -210,6 +213,14 @@ function openEmployerBranchForm(formType: 'create' | 'edit' | 'info') { customerBranchFormState.value.dialogModal = true; } +async function fetchEmployee(branchId: string) { + const res = await fetchBranchEmployee(branchId); + + if (res) { + listEmployee.value = res.data.result; + } +} + onMounted(async () => { await fetchList(); }); @@ -217,6 +228,19 @@ onMounted(async () => { watch([customerId, inputSearch, currentStatus], async () => { await fetchList(); }); +watch( + () => statusEmployeeCreate.value, + async () => { + if (statusEmployeeCreate.value) { + await fetchEmployee(currentBranchEmployee.value); + + const br = branch.value?.find( + (v) => v.id === currentBranchEmployee.value, + ); + if (br) br._count.employee += 1; + } + }, +);