From e58035a30307cee13acb4563bf3f581458744c5c Mon Sep 17 00:00:00 2001 From: puriphatt Date: Fri, 12 Sep 2025 17:59:03 +0700 Subject: [PATCH] refactor: customer & employee --- .../03_customer-management/TableEmpoloyee.vue | 11 +- src/pages/03_customer-management/MainPage.vue | 5968 ++--------------- .../03_customer-management/TabCustomer.vue | 2001 ++++++ .../03_customer-management/TabEmployee.vue | 3704 ++++++++++ src/pages/03_customer-management/form.ts | 5 + 5 files changed, 6154 insertions(+), 5535 deletions(-) create mode 100644 src/pages/03_customer-management/TabCustomer.vue create mode 100644 src/pages/03_customer-management/TabEmployee.vue diff --git a/src/components/03_customer-management/TableEmpoloyee.vue b/src/components/03_customer-management/TableEmpoloyee.vue index d93c6085..000c701a 100644 --- a/src/components/03_customer-management/TableEmpoloyee.vue +++ b/src/components/03_customer-management/TableEmpoloyee.vue @@ -141,8 +141,9 @@ defineEmits<{ router.push('/customer-management'), - }, - ]; - - gridView.value = $q.screen.lt.md ? true : false; - - if (route.query.tab === 'customer') { - currentTab.value = 'employer'; - if (route.query.id) openSpecificCustomer(route.query.id as string); - } else if (route.query.tab === 'employee') { - currentTab.value = 'employee'; - if (route.query.id) openSpecificEmployee(route.query.id as string); - } - - if (route.name === 'CustomerManagement') await fetchListCustomer(true); - - if ( - route.name === 'CustomerBranchManagement' && - typeof route.params.customerId === 'string' - ) { - const _data = await customerStore.fetchById(route.params.customerId); - - if (_data) { - currentCustomer.value = _data; - navigatorStore.current.path.push({ - text: `${ - _data.customerType === 'CORP' - ? _data.branch[0].registerName - : locale.value === 'eng' - ? _data.branch[0].firstNameEN + ' ' + _data.branch[0].lastNameEN - : _data.branch[0].firstName + ' ' + _data.branch[0].lastName - }`, - i18n: false, - }); - } else { - router.push('/customer-management'); - } - } - flowStore.rotate(); -} -onMounted(init); +const refTabCustomer = ref>(); +const refTabEmployee = ref>(); // NOTE: Page Data const currentCustomer = ref(); -const listCustomer = ref<(Customer & { branch: CustomerBranch[] })[]>([]); -const listEmployee = ref([]); +// const listCustomer = ref<(Customer & { branch: CustomerBranch[] })[]>([]); +// const listEmployee = ref([]); const hideStats = ref(false); const statsCustomerType = ref({ CORP: 0, @@ -201,68 +158,31 @@ const customerTypeSelected = ref<{ value: 'all', }); -const customerNameInfo = computed(() => { - if (customerFormData.value.customerBranch === undefined) return; +// const customerNameInfo = computed(() => { +// if (customerFormData.value.customerBranch === undefined) return; - const name = - locale.value === 'eng' - ? `${customerFormData.value.customerBranch[0]?.firstNameEN} ${customerFormData.value.customerBranch[0]?.lastNameEN}` - : `${customerFormData.value.customerBranch[0]?.firstName} ${customerFormData.value.customerBranch[0]?.lastName}`; - return name || '-'; -}); -const currentBtnOpen = ref([]); +// const name = +// locale.value === 'eng' +// ? `${customerFormData.value.customerBranch[0]?.firstNameEN} ${customerFormData.value.customerBranch[0]?.lastNameEN}` +// : `${customerFormData.value.customerBranch[0]?.firstName} ${customerFormData.value.customerBranch[0]?.lastName}`; +// return name || '-'; +// }); +// const currentBtnOpen = ref([]); const employeeStats = ref(0); const gridView = ref(false); -const splitPercent = computed(() => ($q.screen.lt.md ? 0 : 15)); +// const splitPercent = computed(() => ($q.screen.lt.md ? 0 : 15)); -const currentPageCustomer = ref(1); -const maxPageCustomer = ref(1); -const currentPageEmployee = ref(1); -const maxPageEmployee = ref(1); -const pageSize = ref(30); -const dialogCustomerImageUpload = ref>(); -const dialogEmployeeImageUpload = ref>(); +// const currentPageCustomer = ref(1); +// const maxPageCustomer = ref(1); +// const currentPageEmployee = ref(1); +// const maxPageEmployee = ref(1); +// const pageSize = ref(30); +// const dialogCustomerImageUpload = ref>(); +// const dialogEmployeeImageUpload = ref>(); // image const imageList = ref<{ selectedImage: string; list: string[] }>(); -watch(() => route.name, init); -watch( - [ - currentTab, - currentStatus, - inputSearch, - customerTypeSelected, - pageSize, - searchDate, - ], - async ([tabName], [oldTabName]) => { - // if (tabName !== oldTabName) searchDate.value = []; - if (tabName === 'employer') { - currentPageCustomer.value = 1; - currentBtnOpen.value = []; - listCustomer.value = []; - await fetchListCustomer(true); - } - if (tabName === 'employee') { - currentPageEmployee.value = 1; - listEmployee.value = []; - await fetchListEmployee({ fetchStats: true }); - } - - customerFormState.value.currentCustomerId = undefined; - flowStore.rotate(); - }, -); -watch(locale, () => { - customerTypeSelected.value = { - label: `${customerTypeSelected.value.label}`, - value: customerTypeSelected.value?.value, - }; -}); -watch( - () => $q.screen.lt.md, - () => $q.screen.lt.md && (gridView.value = true), -); +const branch = ref(); const fieldDisplayCustomer = ref< { @@ -274,7 +194,6 @@ const fieldDisplayCustomer = ref< .filter((v) => v.name !== 'action') .map((v) => ({ label: v.label, value: v.name })), ); - const fieldDisplayEmployee = ref< { label: string; @@ -285,7 +204,6 @@ const fieldDisplayEmployee = ref< .filter((v) => v.name !== 'action') .map((v) => ({ label: v.label, value: v.name })), ); - const fieldSelected = ref( [ ...columnsEmployee.map((v) => v.name), @@ -293,110 +211,16 @@ const fieldSelected = ref( ].filter((v, index, self) => self.indexOf(v) === index), ); -const branch = ref(); - const customerStats = [ { id: 1, count: 2, name: 'CORP' }, { id: 2, count: 3, name: 'PERS' }, ]; - const fieldCustomer = [ 'all', 'customerLegalEntity', 'customerNaturalPerson', ] as const; -const employeeHistoryDialog = ref(false); -const employeeHistory = ref(); - -async function fetchListCustomer(fetchStats = false, mobileFetch?: boolean) { - const total = statsCustomerType.value.PERS + statsCustomerType.value.CORP; - - const resultList = await customerStore.fetchList({ - includeBranch: true, - page: mobileFetch ? 1 : currentPageCustomer.value, - pageSize: mobileFetch - ? listCustomer.value.length + - (total === listCustomer.value.length ? 1 : 0) - : pageSize.value, - status: - currentStatus.value === 'All' - ? undefined - : currentStatus.value === 'ACTIVE' - ? 'ACTIVE' - : 'INACTIVE', - query: inputSearch.value, - startDate: searchDate.value[0], - endDate: searchDate.value[1], - customerType: ( - { - all: undefined, - customerLegalEntity: CustomerType.Corporate, - customerNaturalPerson: CustomerType.Person, - } as const - )[customerTypeSelected.value.value], - }); - - if (resultList) { - // currentPageCustomer.value = resultList.page; - maxPageCustomer.value = Math.ceil(resultList.total / pageSize.value); - $q.screen.xs && !mobileFetch - ? listCustomer.value.push(...resultList.result) - : (listCustomer.value = resultList.result); - } - - if (fetchStats) { - statsCustomerType.value = await customerStore - .getStatsCustomer() - .then((value) => (value ? value : { CORP: 0, PERS: 0 })); - } -} - -async function fetchListEmployee(opt?: { - fetchStats?: boolean; - page?: number; - pageSize?: number; - customerId?: string; - mobileFetch?: boolean; -}) { - const resultListEmployee = await employeeStore.fetchList({ - customerId: opt?.customerId, - page: opt - ? opt.mobileFetch - ? 1 - : opt.page || currentPageEmployee.value - : currentPageEmployee.value, - pageSize: opt - ? opt.mobileFetch - ? listEmployee.value.length + - (employeeStats.value === listEmployee.value.length ? 1 : 0) - : opt.pageSize || pageSize.value - : pageSize.value, - status: - currentStatus.value === 'All' - ? undefined - : currentStatus.value === 'ACTIVE' - ? 'ACTIVE' - : 'INACTIVE', - query: inputSearch.value, - passport: true, - visa: true, - startDate: searchDate.value[0], - endDate: searchDate.value[1], - }); - if (resultListEmployee) { - maxPageEmployee.value = Math.ceil( - resultListEmployee.total / pageSize.value, - ); - $q.screen.xs && !(opt && opt.mobileFetch) - ? listEmployee.value.push(...resultListEmployee.result) - : (listEmployee.value = resultListEmployee.result); - } - - if (opt && opt.fetchStats) - employeeStats.value = await employeeStore.getStatsEmployee(); -} - async function triggerChangeStatus( id: string, status: string, @@ -416,15 +240,17 @@ async function triggerChangeStatus( : t('dialog.message.confirmChangeStatusOn'), action: async () => { if (currentTab.value === 'employee') { - await toggleStatusEmployee( - id, - status === 'INACTIVE' ? false : true, - employeeName, - ) + await refTabEmployee.value + ?.toggleStatusEmployee( + id, + status === 'INACTIVE' ? false : true, + employeeName, + ) .then(resolve) .catch(reject); } else { - await toggleStatusCustomer(id, status === 'INACTIVE' ? false : true) + await refTabCustomer.value + ?.toggleStatusCustomer(id, status === 'INACTIVE' ? false : true) .then(resolve) .catch(reject); } @@ -434,65 +260,6 @@ async function triggerChangeStatus( }); } -async function toggleStatusEmployee( - id: string, - status: boolean, - employeeName: string, -) { - const res = await employeeStore.editById(id, { - status: !status ? 'ACTIVE' : 'INACTIVE', - firstNameEN: employeeName, - }); - if (res && employeeFormState.value.drawerModal) - currentFromDataEmployee.value.status = res.status; - - await fetchListEmployee({ mobileFetch: $q.screen.xs }); - flowStore.rotate(); -} - -async function toggleStatusCustomer(id: string, status: boolean) { - const res = await customerStore.editById(id, { - status: !status ? 'ACTIVE' : 'INACTIVE', - }); - if (res && customerFormState.value.drawerModal) - customerFormData.value.status = res.status; - - await fetchListCustomer(false, $q.screen.xs); - flowStore.rotate(); -} -async function openHistory(id: string) { - const res = await employeeStore.getEditHistory(id); - employeeHistory.value = res.reverse(); - employeeHistoryDialog.value = true; -} - -async function editCustomerForm(id: string) { - await customerFormStore.assignFormData(id); - await fetchListOfOptionBranch(); - await fetchImageList( - id, - customerFormData.value.selectedImage || '', - 'customer', - ); - customerFormState.value.branchIndex = -1; - customerFormState.value.dialogType = 'edit'; - customerFormState.value.drawerModal = true; - customerFormState.value.editCustomerId = id; -} - -async function editEmployeeFormPersonal(id: string) { - await employeeFormStore.assignFormDataEmployee(id); - await fetchImageList( - id, - currentFromDataEmployee.value.selectedImage || '', - 'employee', - ); - - employeeFormState.value.isEmployeeEdit = true; - employeeFormState.value.dialogType = 'edit'; - employeeFormState.value.drawerModal = true; -} - async function createCustomerForm(customerType: 'CORP' | 'PERS') { customerFormState.value.dialogModal = true; customerFormState.value.dialogType = 'create'; @@ -524,30 +291,6 @@ async function fetchImageList( return res; } -async function openSpecificCustomer(id: string) { - await customerFormStore.assignFormData(id); - await fetchImageList( - id, - customerFormData.value.selectedImage || '', - 'customer', - ); - customerFormState.value.branchIndex = -1; - customerFormState.value.drawerModal = true; - customerFormState.value.editCustomerId = id; - customerFormState.value.dialogType = 'info'; -} - -async function openSpecificEmployee(id: string) { - await employeeFormStore.assignFormDataEmployee(id); - await fetchImageList( - id, - currentFromDataEmployee.value.selectedImage || '', - 'employee', - ); - employeeFormState.value.dialogType = 'info'; - employeeFormState.value.drawerModal = true; -} - async function triggerExport() { switch (currentTab.value) { case 'employer': @@ -561,131 +304,388 @@ async function triggerExport() { } } +async function init() { + navigatorStore.current.title = 'menu.customer'; + navigatorStore.current.path = [ + { + text: 'menu.customerCaption', + i18n: true, + handler: () => router.push('/customer-management'), + }, + ]; + + gridView.value = $q.screen.lt.md ? true : false; + + if (route.query.tab === 'customer') { + currentTab.value = 'employer'; + if (route.query.id) + refTabCustomer.value?.openSpecificCustomer(route.query.id as string); + } else if (route.query.tab === 'employee') { + currentTab.value = 'employee'; + if (route.query.id) + refTabEmployee.value?.openSpecificEmployee(route.query.id as string); + } + + if ( + route.name === 'CustomerBranchManagement' && + typeof route.params.customerId === 'string' + ) { + const _data = await customerStore.fetchById(route.params.customerId); + + if (_data) { + currentCustomer.value = _data; + navigatorStore.current.path.push({ + text: `${ + _data.customerType === 'CORP' + ? _data.branch[0].registerName + : locale.value === 'eng' + ? _data.branch[0].firstNameEN + ' ' + _data.branch[0].lastNameEN + : _data.branch[0].firstName + ' ' + _data.branch[0].lastName + }`, + i18n: false, + }); + } else { + router.push('/customer-management'); + } + } + + flowStore.rotate(); +} + +watch(() => route.name, init); + +// watch( +// [currentTab, currentStatus, inputSearch, searchDate], +// async ([tabName], [oldTabName]) => { +// if (tabName !== oldTabName) searchDate.value = []; +// if (tabName === 'employer') { +// currentPageCustomer.value = 1; +// currentBtnOpen.value = []; +// listCustomer.value = []; +// await fetchListCustomer(true); +// } +// if (tabName === 'employee') { +// currentPageEmployee.value = 1; +// listEmployee.value = []; +// await fetchListEmployee({ fetchStats: true }); +// } + +// customerFormState.value.currentCustomerId = undefined; +// flowStore.rotate(); +// }, +// ); + +watch(locale, () => { + customerTypeSelected.value = { + label: `${customerTypeSelected.value.label}`, + value: customerTypeSelected.value?.value, + }; +}); + +watch( + () => $q.screen.lt.md, + () => $q.screen.lt.md && (gridView.value = true), +); + +onMounted(async () => await init()); +// const employeeHistoryDialog = ref(false); +// const employeeHistory = ref(); + +// async function fetchListCustomer(fetchStats = false, mobileFetch?: boolean) { +// const total = statsCustomerType.value.PERS + statsCustomerType.value.CORP; + +// const resultList = await customerStore.fetchList({ +// includeBranch: true, +// page: mobileFetch ? 1 : currentPageCustomer.value, +// pageSize: mobileFetch +// ? listCustomer.value.length + +// (total === listCustomer.value.length ? 1 : 0) +// : pageSize.value, +// status: +// currentStatus.value === 'All' +// ? undefined +// : currentStatus.value === 'ACTIVE' +// ? 'ACTIVE' +// : 'INACTIVE', +// query: inputSearch.value, +// startDate: searchDate.value[0], +// endDate: searchDate.value[1], +// customerType: ( +// { +// all: undefined, +// customerLegalEntity: CustomerType.Corporate, +// customerNaturalPerson: CustomerType.Person, +// } as const +// )[customerTypeSelected.value.value], +// }); + +// if (resultList) { +// maxPageCustomer.value = Math.ceil(resultList.total / pageSize.value); +// $q.screen.xs && !mobileFetch +// ? listCustomer.value.push(...resultList.result) +// : (listCustomer.value = resultList.result); +// } + +// if (fetchStats) { +// statsCustomerType.value = await customerStore +// .getStatsCustomer() +// .then((value) => (value ? value : { CORP: 0, PERS: 0 })); +// } +// } + +// async function fetchListEmployee(opt?: { +// fetchStats?: boolean; +// page?: number; +// pageSize?: number; +// customerId?: string; +// mobileFetch?: boolean; +// }) { +// const resultListEmployee = await employeeStore.fetchList({ +// customerId: opt?.customerId, +// page: opt +// ? opt.mobileFetch +// ? 1 +// : opt.page || currentPageEmployee.value +// : currentPageEmployee.value, +// pageSize: opt +// ? opt.mobileFetch +// ? listEmployee.value.length + +// (employeeStats.value === listEmployee.value.length ? 1 : 0) +// : opt.pageSize || pageSize.value +// : pageSize.value, +// status: +// currentStatus.value === 'All' +// ? undefined +// : currentStatus.value === 'ACTIVE' +// ? 'ACTIVE' +// : 'INACTIVE', +// query: inputSearch.value, +// passport: true, +// visa: true, +// startDate: searchDate.value[0], +// endDate: searchDate.value[1], +// }); +// if (resultListEmployee) { +// maxPageEmployee.value = Math.ceil( +// resultListEmployee.total / pageSize.value, +// ); +// $q.screen.xs && !(opt && opt.mobileFetch) +// ? listEmployee.value.push(...resultListEmployee.result) +// : (listEmployee.value = resultListEmployee.result); +// } + +// if (opt && opt.fetchStats) +// employeeStats.value = await employeeStore.getStatsEmployee(); +// } + +// async function toggleStatusEmployee( +// id: string, +// status: boolean, +// employeeName: string, +// ) { +// const res = await employeeStore.editById(id, { +// status: !status ? 'ACTIVE' : 'INACTIVE', +// firstNameEN: employeeName, +// }); +// if (res && employeeFormState.value.drawerModal) +// currentFromDataEmployee.value.status = res.status; + +// await fetchListEmployee({ mobileFetch: $q.screen.xs }); +// flowStore.rotate(); +// } + +// async function toggleStatusCustomer(id: string, status: boolean) { +// const res = await customerStore.editById(id, { +// status: !status ? 'ACTIVE' : 'INACTIVE', +// }); +// if (res && customerFormState.value.drawerModal) +// customerFormData.value.status = res.status; + +// await fetchListCustomer(false, $q.screen.xs); +// flowStore.rotate(); +// } +// async function openHistory(id: string) { +// const res = await employeeStore.getEditHistory(id); +// employeeHistory.value = res.reverse(); +// employeeHistoryDialog.value = true; +// } + +// async function editCustomerForm(id: string) { +// await customerFormStore.assignFormData(id); +// await fetchListOfOptionBranch(); +// await fetchImageList( +// id, +// customerFormData.value.selectedImage || '', +// 'customer', +// ); +// customerFormState.value.branchIndex = -1; +// customerFormState.value.dialogType = 'edit'; +// customerFormState.value.drawerModal = true; +// customerFormState.value.editCustomerId = id; +// } + +// async function editEmployeeFormPersonal(id: string) { +// await employeeFormStore.assignFormDataEmployee(id); +// await fetchImageList( +// id, +// currentFromDataEmployee.value.selectedImage || '', +// 'employee', +// ); + +// employeeFormState.value.isEmployeeEdit = true; +// employeeFormState.value.dialogType = 'edit'; +// employeeFormState.value.drawerModal = true; +// } + +// async function openSpecificCustomer(id: string) { +// await customerFormStore.assignFormData(id); +// await fetchImageList( +// id, +// customerFormData.value.selectedImage || '', +// 'customer', +// ); +// customerFormState.value.branchIndex = -1; +// customerFormState.value.drawerModal = true; +// customerFormState.value.editCustomerId = id; +// customerFormState.value.dialogType = 'info'; +// } + +// async function openSpecificEmployee(id: string) { +// await employeeFormStore.assignFormDataEmployee(id); +// await fetchImageList( +// id, +// currentFromDataEmployee.value.selectedImage || '', +// 'employee', +// ); +// employeeFormState.value.dialogType = 'info'; +// employeeFormState.value.drawerModal = true; +// } + // TODO: When in employee form, if select address same as customer then auto fill -watch( - () => employeeFormState.value.currentCustomerBranch, - (e) => { - if (!e) return; - if (employeeFormState.value.formDataEmployeeSameAddr) { - currentFromDataEmployee.value.address = e.address; - currentFromDataEmployee.value.addressEN = e.addressEN; - currentFromDataEmployee.value.provinceId = e.provinceId; - currentFromDataEmployee.value.districtId = e.districtId; - currentFromDataEmployee.value.subDistrictId = e.subDistrictId; - } - currentFromDataEmployee.value.customerBranchId = e.id; - }, -); +// watch( +// () => employeeFormState.value.currentCustomerBranch, +// (e) => { +// if (!e) return; +// if (employeeFormState.value.formDataEmployeeSameAddr) { +// currentFromDataEmployee.value.address = e.address; +// currentFromDataEmployee.value.addressEN = e.addressEN; +// currentFromDataEmployee.value.provinceId = e.provinceId; +// currentFromDataEmployee.value.districtId = e.districtId; +// currentFromDataEmployee.value.subDistrictId = e.subDistrictId; +// } +// currentFromDataEmployee.value.customerBranchId = e.id; +// }, +// ); -watch( - () => employeeFormState.value.formDataEmployeeSameAddr, - (isSame) => { - if (!employeeFormState.value.currentCustomerBranch) return; - if (isSame) { - currentFromDataEmployee.value.address = - employeeFormState.value.currentCustomerBranch.address; - currentFromDataEmployee.value.addressEN = - employeeFormState.value.currentCustomerBranch.addressEN; - currentFromDataEmployee.value.provinceId = - employeeFormState.value.currentCustomerBranch.provinceId; - currentFromDataEmployee.value.districtId = - employeeFormState.value.currentCustomerBranch.districtId; - currentFromDataEmployee.value.subDistrictId = - employeeFormState.value.currentCustomerBranch.subDistrictId; - } - currentFromDataEmployee.value.customerBranchId = - employeeFormState.value.currentCustomerBranch.id; - }, -); +// watch( +// () => employeeFormState.value.formDataEmployeeSameAddr, +// (isSame) => { +// if (!employeeFormState.value.currentCustomerBranch) return; +// if (isSame) { +// currentFromDataEmployee.value.address = +// employeeFormState.value.currentCustomerBranch.address; +// currentFromDataEmployee.value.addressEN = +// employeeFormState.value.currentCustomerBranch.addressEN; +// currentFromDataEmployee.value.provinceId = +// employeeFormState.value.currentCustomerBranch.provinceId; +// currentFromDataEmployee.value.districtId = +// employeeFormState.value.currentCustomerBranch.districtId; +// currentFromDataEmployee.value.subDistrictId = +// employeeFormState.value.currentCustomerBranch.subDistrictId; +// } +// currentFromDataEmployee.value.customerBranchId = +// employeeFormState.value.currentCustomerBranch.id; +// }, +// ); -watch( - () => employeeFormState.value.currentTab, - () => { - employeeFormState.value.isEmployeeEdit = false; - }, -); +// watch( +// () => employeeFormState.value.currentTab, +// () => { +// employeeFormState.value.isEmployeeEdit = false; +// }, +// ); -watch( - () => currentFromDataEmployee.value.dateOfBirth, - (v) => { - const isEdit = - employeeFormState.value.drawerModal && - employeeFormState.value.isEmployeeEdit; - let currentFormDate = v && toISOStringWithTimezone(new Date(v)); - let currentDate: string = ''; +// watch( +// () => currentFromDataEmployee.value.dateOfBirth, +// (v) => { +// const isEdit = +// employeeFormState.value.drawerModal && +// employeeFormState.value.isEmployeeEdit; +// let currentFormDate = v && toISOStringWithTimezone(new Date(v)); +// let currentDate: string = ''; - if (isEdit && employeeFormState.value.currentEmployee) { - currentDate = toISOStringWithTimezone( - new Date(employeeFormState.value.currentEmployee.dateOfBirth), - ); - } +// if (isEdit && employeeFormState.value.currentEmployee) { +// currentDate = toISOStringWithTimezone( +// new Date(employeeFormState.value.currentEmployee.dateOfBirth), +// ); +// } - if ( - employeeFormState.value.dialogModal || - (isEdit && currentFormDate !== currentDate) - ) { - const age = calculateAge( - currentFromDataEmployee.value.dateOfBirth, - 'year', - ); - if (currentFromDataEmployee.value.dateOfBirth && Number(age) < 15) { - dialog({ - color: 'warning', - icon: 'mdi-alert', - title: t('dialog.title.youngWorker15'), - cancelText: t('general.edit'), - persistent: true, - message: t('dialog.message.youngWorker15'), +// if ( +// employeeFormState.value.dialogModal || +// (isEdit && currentFormDate !== currentDate) +// ) { +// const age = calculateAge( +// currentFromDataEmployee.value.dateOfBirth, +// 'year', +// ); +// if (currentFromDataEmployee.value.dateOfBirth && Number(age) < 15) { +// dialog({ +// color: 'warning', +// icon: 'mdi-alert', +// title: t('dialog.title.youngWorker15'), +// cancelText: t('general.edit'), +// persistent: true, +// message: t('dialog.message.youngWorker15'), - cancel: async () => { - currentFromDataEmployee.value.dateOfBirth = null; - return; - }, - }); - } +// cancel: async () => { +// currentFromDataEmployee.value.dateOfBirth = null; +// return; +// }, +// }); +// } - if ( - currentFromDataEmployee.value.dateOfBirth && - Number(age) > 15 && - Number(age) <= 18 - ) { - dialog({ - color: 'warning', - icon: 'mdi-alert', - title: t('dialog.title.youngWorker18'), - cancelText: t('general.cancel'), - actionText: t('general.confirm'), - persistent: true, - message: t('dialog.message.youngWorker18'), - action: () => {}, - cancel: async () => { - currentFromDataEmployee.value.dateOfBirth = null; - return; - }, - }); - } - } - }, -); +// if ( +// currentFromDataEmployee.value.dateOfBirth && +// Number(age) > 15 && +// Number(age) <= 18 +// ) { +// dialog({ +// color: 'warning', +// icon: 'mdi-alert', +// title: t('dialog.title.youngWorker18'), +// cancelText: t('general.cancel'), +// actionText: t('general.confirm'), +// persistent: true, +// message: t('dialog.message.youngWorker18'), +// action: () => {}, +// cancel: async () => { +// currentFromDataEmployee.value.dateOfBirth = null; +// return; +// }, +// }); +// } +// } +// }, +// ); -watch( - () => customerFormData.value.image, - () => { - if (customerFormData.value.image !== null) - customerFormState.value.isImageEdit = true; - }, -); +// watch( +// () => customerFormData.value.image, +// () => { +// if (customerFormData.value.image !== null) +// customerFormState.value.isImageEdit = true; +// }, +// ); -watch( - () => currentFromDataEmployee.value.image, - () => { - if (currentFromDataEmployee.value.image !== null) - employeeFormState.value.isImageEdit = true; - }, -); +// watch( +// () => currentFromDataEmployee.value.image, +// () => { +// if (currentFromDataEmployee.value.image !== null) +// employeeFormState.value.isImageEdit = true; +// }, +// ); -const emptyCreateDialog = ref(false); +// const emptyCreateDialog = ref(false); diff --git a/src/pages/03_customer-management/TabEmployee.vue b/src/pages/03_customer-management/TabEmployee.vue new file mode 100644 index 00000000..c7fcc8d9 --- /dev/null +++ b/src/pages/03_customer-management/TabEmployee.vue @@ -0,0 +1,3704 @@ + + + + diff --git a/src/pages/03_customer-management/form.ts b/src/pages/03_customer-management/form.ts index fe875a3c..2de3415d 100644 --- a/src/pages/03_customer-management/form.ts +++ b/src/pages/03_customer-management/form.ts @@ -22,6 +22,10 @@ import { useRoute } from 'vue-router'; export const useCustomerForm = defineStore('form-customer', () => { const customerStore = useCustomerStore(); + const onCreateImageList = ref<{ + selectedImage: string; + list: { url: string; imgFile: File | null; name: string }[]; + }>({ selectedImage: '', list: [] }); const { t } = useI18n(); const flowStore = useFlowStore(); @@ -498,6 +502,7 @@ export const useCustomerForm = defineStore('form-customer', () => { } return { + onCreateImageList, tabFieldRequired, registerAbleBranchOption, state,