diff --git a/src/components/shared/select/SelectBusinessType.vue b/src/components/shared/select/SelectBusinessType.vue index 211ed07e..12b6172e 100644 --- a/src/components/shared/select/SelectBusinessType.vue +++ b/src/components/shared/select/SelectBusinessType.vue @@ -158,6 +158,39 @@ function setDefaultValue() { + + + + diff --git a/src/pages/03_customer-management/MainPage.vue b/src/pages/03_customer-management/MainPage.vue index e02a381e..539a4a01 100644 --- a/src/pages/03_customer-management/MainPage.vue +++ b/src/pages/03_customer-management/MainPage.vue @@ -2263,7 +2263,7 @@ const emptyCreateDialog = ref(false); customerFormData.customerBranch[0].legalPersonNo " v-model:business-type=" - customerFormData.customerBranch[0].businessType + customerFormData.customerBranch[0].businessTypeId " v-model:job-position=" customerFormData.customerBranch[0].jobPosition diff --git a/src/pages/03_customer-management/components/employer/EmployerFormBusiness.vue b/src/pages/03_customer-management/components/employer/EmployerFormBusiness.vue index 0717d54f..26b0d659 100644 --- a/src/pages/03_customer-management/components/employer/EmployerFormBusiness.vue +++ b/src/pages/03_customer-management/components/employer/EmployerFormBusiness.vue @@ -10,10 +10,25 @@ import { useI18n } from 'vue-i18n'; import ThaiBahtText from 'thai-baht-text'; import SelectBusinessType from 'src/components/shared/select/SelectBusinessType.vue'; +import BusinessTypeDialog from 'src/pages/16_business-type-management/BusinessTypeDialog.vue'; + +import useBusinessTypeStore from 'src/stores/business-type'; + const { locale } = useI18n({ useScope: 'global' }); const rawOption = ref(); +const businessTypeDialog = ref(false); +const formDataBusinessType = ref<{ + name: string; + nameEN: string; +}>({ + name: '', + nameEN: '', +}); + +const useBusinessType = useBusinessTypeStore(); + const businessTypeId = defineModel('businessTypeId'); const jobPosition = defineModel('jobPosition'); const jobDescription = defineModel('jobDescription'); @@ -29,6 +44,8 @@ const typeBusinessENOption = ref([]); const jobPositionOption = ref([]); const jobPositionENOption = ref([]); +const keySelect = ref(0); + defineProps<{ title?: string; dense?: boolean; @@ -38,6 +55,20 @@ defineProps<{ showTitle?: boolean; }>(); +function resetFormBusinessType() { + businessTypeDialog.value = false; + formDataBusinessType.value = { name: '', nameEN: '' }; +} + +async function submitBusinessType() { + const res = await useBusinessType.create(formDataBusinessType.value); + if (res) { + businessTypeId.value = res.id; + resetFormBusinessType(); + keySelect.value++; + } +} + onMounted(async () => { const resultOption = await fetch('/option/option.json'); rawOption.value = await resultOption.json(); @@ -121,16 +152,24 @@ let jobPositionENFilter = selectFilterOptionRefMod( + + diff --git a/src/pages/03_customer-management/form.ts b/src/pages/03_customer-management/form.ts index 3abefdaa..fe875a3c 100644 --- a/src/pages/03_customer-management/form.ts +++ b/src/pages/03_customer-management/form.ts @@ -30,6 +30,8 @@ export const useCustomerForm = defineStore('form-customer', () => { const registerAbleBranchOption = ref<{ id: string; name: string }[]>(); + const currentBranchRootId = ref(''); + const tabFieldRequired = ref<{ [key: string]: (keyof CustomerBranchCreate)[]; }>({ @@ -160,6 +162,7 @@ export const useCustomerForm = defineStore('form-customer', () => { state.value.editCustomerCode = data.code; state.value.customerImageUrl = `${baseUrl}/customer/${id}/image/${data.selectedImage}`; state.value.defaultCustomerImageUrl = `${baseUrl}/customer/${id}/image/${data.selectedImage}`; + currentBranchRootId.value = data.branch[0].id || ''; resetFormData.registeredBranchId = data.registeredBranchId; resetFormData.status = data.status; @@ -500,6 +503,8 @@ export const useCustomerForm = defineStore('form-customer', () => { state, resetFormData, currentFormData, + currentBranchRootId, + isFormDataDifferent, resetForm, assignFormData, @@ -1663,6 +1668,7 @@ export const useEmployeeForm = defineStore('form-employee', () => { state, currentFromDataEmployee, resetEmployeeData, + addPassport, addVisa, addCheckup, diff --git a/src/pages/05_quotation/MainPage.vue b/src/pages/05_quotation/MainPage.vue index b9b57354..3551a047 100644 --- a/src/pages/05_quotation/MainPage.vue +++ b/src/pages/05_quotation/MainPage.vue @@ -60,7 +60,6 @@ const flowStore = useFlowStore(); const userBranch = useMyBranch(); const navigatorStore = useNavigator(); const customerStore = useCustomerStore(); - const { fetchListOfOptionBranch, customerFormUndo, @@ -76,6 +75,7 @@ const { const { state: customerFormState, currentFormData: customerFormData, + currentBranchRootId, registerAbleBranchOption, tabFieldRequired, } = storeToRefs(customerFormStore); @@ -89,6 +89,8 @@ const fieldSelectedOption = computed(() => { value: v.name, })); }); + +const keyAddDialog = ref(0); const special = ref(false); const branchId = ref(''); const agentPrice = ref(false); @@ -865,6 +867,7 @@ async function filterBySellerId() { @@ -999,6 +1002,7 @@ async function filterBySellerId() { () => { customerFormState.dialogModal = false; onCreateImageList = { selectedImage: '', list: [] }; + keyAddDialog++; } " > @@ -1190,7 +1194,7 @@ async function filterBySellerId() { customerFormData.customerBranch[0].legalPersonNo " v-model:business-type=" - customerFormData.customerBranch[0].businessType + customerFormData.customerBranch[0].businessTypeId " v-model:job-position=" customerFormData.customerBranch[0].jobPosition @@ -1271,7 +1275,6 @@ async function filterBySellerId() { res = await customerStore.createBranch({ ...customerFormData.customerBranch[idx], customerId: customerFormState.editCustomerId || '', - id: undefined, }); } if (res) {