diff --git a/src/pages/05_quotation/MainPage.vue b/src/pages/05_quotation/MainPage.vue index aee2385a..ad1904d9 100644 --- a/src/pages/05_quotation/MainPage.vue +++ b/src/pages/05_quotation/MainPage.vue @@ -8,26 +8,21 @@ import { storeToRefs } from 'pinia'; // NOTE: Import stores import useProductServiceStore from 'src/stores/product-service'; import { useQuotationStore } from 'src/stores/quotations'; -import { baseUrl, waitAll } from 'src/stores/utils'; -import useCustomerStore from 'stores/customer'; -import useEmployeeStore from 'stores/employee'; +import { isRoleInclude } from 'stores/utils'; import useFlowStore from 'src/stores/flow'; -import useOcrStore from 'stores/ocr'; import useMyBranch from 'stores/my-branch'; import { useQuotationForm } from './form'; +import useOcrStore from 'stores/ocr'; // NOTE Import Types import { CustomerBranchCreate } from 'stores/customer/types'; import { Employee } from 'src/stores/employee/types'; // NOTE: Import Components -import BasicInformation from 'components/03_customer-management/employee/BasicInformation.vue'; -import FormReferDocument from 'src/components/05_quotation/FormReferDocument.vue'; -import { UploadFileGroup, noticeJobEmployment } from 'components/upload-file'; -import FormPerson from 'components/02_personnel-management/FormPerson.vue'; import QuotationCard from 'src/components/05_quotation/QuotationCard.vue'; import PaginationComponent from 'src/components/PaginationComponent.vue'; import StatCardComponent from 'src/components/StatCardComponent.vue'; +import ButtonAddComponent from 'components/ButtonAddCompoent.vue'; import FormAbout from 'src/components/05_quotation/FormAbout.vue'; import SelectZone from 'src/components/shared/SelectZone.vue'; import PersonCard from 'src/components/shared/PersonCard.vue'; @@ -37,33 +32,20 @@ import ItemCard from 'src/components/ItemCard.vue'; import DialogForm from 'components/DialogForm.vue'; import { AddButton } from 'src/components/button'; import SideMenu from 'components/SideMenu.vue'; -import ButtonAddComponent from 'components/ButtonAddCompoent.vue'; -import { - uploadFileListEmployee, - columnsAttachment, - dialogCreateCustomerItem, -} from 'src/pages/03_customer-management/constant'; +import { dialogCreateCustomerItem } from 'src/pages/03_customer-management/constant'; import { ProductGroup, Product, Service, } from 'src/stores/product-service/types'; -import { EmployeeWorker } from 'src/stores/quotations/types'; - -import { - EditButton, - DeleteButton, - SaveButton, - UndoButton, -} from 'components/button'; +import { SaveButton } from 'components/button'; import ProfileBanner from 'components/ProfileBanner.vue'; import { AddressForm } from 'components/form'; import { EmployerFormBusiness, - EmployerFormContact, EmployerFormAbout, } from 'src/pages/03_customer-management/components'; @@ -76,8 +58,6 @@ import QuotationView from './QuotationView.vue'; const quotationFormStore = useQuotationForm(); const customerFormStore = useCustomerForm(); const employeeFormStore = useEmployeeForm(); -const employeeStore = useEmployeeStore(); -const customerStore = useCustomerStore(); const flowStore = useFlowStore(); const userBranch = useMyBranch(); const ocrStore = useOcrStore(); @@ -85,8 +65,6 @@ const ocrStore = useOcrStore(); const { currentFormData: quotationFormData } = storeToRefs(quotationFormStore); const { state: customerFormState, currentFormData: customerFormData } = storeToRefs(customerFormStore); -const { state: employeeFormState, currentFromDataEmployee } = - storeToRefs(employeeFormStore); const { currentMyBranch } = storeToRefs(userBranch); const special = ref(false); @@ -194,21 +172,6 @@ const statData = ref< }, ]); -const formDataEmployee = ref({ - alienReferencNumber: '', - documentExpireDate: new Date(), - lastNameEN: '', - lastName: '', - middleNameEN: '', - middleName: '', - firstNameEN: '', - firstName: '', - namePrefix: '', - nationality: '', - gender: '', - dateOfBirth: new Date(), -}); - const formDataCustomerBranch = ref< CustomerBranchCreate & { id?: string; @@ -266,77 +229,71 @@ const formDataCustomerBranch = ref< }); function setDefaultCustomerd() { - customerFormData.value.customerBranch = [ - { - customerCode: '', - customerId: '', - legalPersonNo: '', - citizenId: '', - namePrefix: '', - firstName: '', - lastName: '', - firstNameEN: '', - lastNameEN: '', - telephoneNo: '', - gender: '', - birthDate: new Date().toString(), - businessType: '', - jobPosition: '', - jobDescription: '', - payDate: '', - payDateEN: '', - wageRate: 0, - wageRateText: '', - homeCode: '', - employmentOffice: '', - employmentOfficeEN: '', - address: '', - addressEN: '', - street: '', - streetEN: '', - moo: '', - mooEN: '', - soi: '', - soiEN: '', - provinceId: '', - districtId: '', - subDistrictId: '', - contactName: '', - email: '', - contactTel: '', - officeTel: '', - agent: '', - status: 'CREATED', - customerName: '', - registerName: '', - registerNameEN: '', - registerDate: new Date(), - authorizedCapital: '', - authorizedName: '', - authorizedNameEN: '', - code: '', - }, - ]; + formDataCustomerBranch.value = { + customerCode: '', + customerId: '', + legalPersonNo: '', + citizenId: '', + namePrefix: '', + firstName: '', + lastName: '', + firstNameEN: '', + lastNameEN: '', + telephoneNo: '', + gender: '', + birthDate: new Date().toString(), + businessType: '', + jobPosition: '', + jobDescription: '', + payDate: '', + payDateEN: '', + wageRate: 0, + wageRateText: '', + homeCode: '', + employmentOffice: '', + employmentOfficeEN: '', + address: '', + addressEN: '', + street: '', + streetEN: '', + moo: '', + mooEN: '', + soi: '', + soiEN: '', + provinceId: '', + districtId: '', + subDistrictId: '', + contactName: '', + email: '', + contactTel: '', + officeTel: '', + agent: '', + status: 'CREATED', + customerName: '', + registerName: '', + registerNameEN: '', + registerDate: new Date(), + authorizedCapital: '', + authorizedName: '', + authorizedNameEN: '', + code: '', + }; } -function submitCustomer() { +async function submitCustomer() { if (currentMyBranch.value === undefined) return; const { code, customerCode, birthDate, ...payload } = formDataCustomerBranch.value; customerFormData.value.customerBranch = [{ ...payload }]; - customerFormData.value.registeredBranchId = currentMyBranch.value.id; - customerFormStore.submitFormCustomer(); - customerFormState.value.dialogType = 'info'; - customerFormState.value.editCustomerId = '218554'; -} + customerFormData.value.registeredBranchId = isRoleInclude(['system']) + ? branchId.value + : currentMyBranch.value.id; + await customerFormStore.submitFormCustomer(); -function triggerCreateEmployee() { - employeeFormStore.resetFormDataEmployee(true); - employeeFormState.value.dialogType = 'create'; - employeeFormState.value.dialogModal = true; - employeeFormState.value.isEmployeeEdit = true; + customerFormState.value.dialogModal = false; + // customerFormState.value.dialogType = 'info'; } function triggerCreateCustomerd(opts: { type: 'CORP' | 'PERS' }) { @@ -1011,6 +968,8 @@ watch(() => pageState.currentTab, fetchQuotationList); :close=" () => { customerFormState.dialogModal = false; + customerFormStore.resetForm(true); + setDefaultCustomerd(); } " > @@ -1080,15 +1039,6 @@ watch(() => pageState.currentTab, fetchQuotationList); v-if="customerFormData.status !== 'INACTIVE'" class="surface-1 row rounded" > - - - - -
pageState.currentTab, fetchQuotationList); show-title :index="(0).toString()" :customerType="customerFormData.customerType" + :readonly="customerFormState.dialogType === 'info'" v-model:citizen-id="formDataCustomerBranch.citizenId" v-model:prefix-name="formDataCustomerBranch.namePrefix" v-model:first-name="formDataCustomerBranch.firstName" @@ -1193,6 +1118,7 @@ watch(() => pageState.currentTab, fetchQuotationList); prefixId="dialog" dense outlined + :readonly="customerFormState.dialogType === 'info'" v-model:bussiness-type="formDataCustomerBranch.businessType" v-model:job-position="formDataCustomerBranch.jobPosition" v-model:job-description="formDataCustomerBranch.jobDescription" @@ -1210,6 +1136,8 @@ watch(() => pageState.currentTab, fetchQuotationList); :title="$t('form.address')" :addressTitle="$t('form.address')" :addressTitleEN="$t('form.address', { suffix: '(EN)' })" + :readonly="customerFormState.dialogType === 'info'" + v-model:bussiness-type="formDataCustomerBranch.businessType" v-model:address="formDataCustomerBranch.address" v-model:address-en="formDataCustomerBranch.addressEN" v-model:street="formDataCustomerBranch.street" @@ -1228,362 +1156,6 @@ watch(() => pageState.currentTab, fetchQuotationList);
- - - - - -
- -
-
-
-
-
- - - - -
-
-
- -
- -
- - - - - - - -
-
-
-
- - - >>({}); const serviceList = ref>>({}); const productGroup = ref([]); +const { state: employeeFormState, currentFromDataEmployee } = + storeToRefs(employeeFormStore); + const product = ref>({}); const service = ref>({}); @@ -114,6 +134,21 @@ const selectedGroupSub = ref<'product' | 'service' | null>(null); const selectedGroup = ref(null); const selectedProductServiceId = ref(''); +const formDataEmployee = ref({ + alienReferencNumber: '', + documentExpireDate: new Date(), + lastNameEN: '', + lastName: '', + middleNameEN: '', + middleName: '', + firstNameEN: '', + firstName: '', + namePrefix: '', + nationality: '', + gender: '', + dateOfBirth: new Date(), +}); + const productServiceList = ref< Required[] >([]); @@ -147,6 +182,13 @@ async function getAllService( if (ret) serviceList.value[groupId] = ret.result; } +function triggerCreateEmployee() { + employeeFormStore.resetFormDataEmployee(true); + employeeFormState.value.dialogType = 'create'; + employeeFormState.value.dialogModal = true; + employeeFormState.value.isEmployeeEdit = true; +} + async function triggerSelectEmployeeDialog() { pageState.employeeModal = true; await nextTick(); @@ -572,6 +614,351 @@ onMounted(async () => { " > + + + + +
+ +
+
+
+
+
+ + + + +
+
+
+ +
+ +
+ + + + + + + +
+
+
+
+ +