diff --git a/src/components/shared/DatePicker.vue b/src/components/shared/DatePicker.vue index 7f0cd9ad..3c3d6dfd 100644 --- a/src/components/shared/DatePicker.vue +++ b/src/components/shared/DatePicker.vue @@ -16,7 +16,11 @@ const props = defineProps<{ }>(); function valueUpdate(value: string) { - if (typeof model.value === 'string') model.value = new Date(model.value); + if (props.readonly) return; + + if (model.value && !(model.value instanceof Date)) { + model.value = new Date(model.value); + } if (value.length === 10) { const _date = parseAndFormatDate(value, i18n.locale.value); @@ -43,8 +47,6 @@ function valueUpdate(value: string) { } else { model.value = _date; } - } else { - model.value = model.value; } } } diff --git a/src/pages/03_customer-management/form.ts b/src/pages/03_customer-management/form.ts index 78fae25a..60d2f0f9 100644 --- a/src/pages/03_customer-management/form.ts +++ b/src/pages/03_customer-management/form.ts @@ -828,7 +828,6 @@ export const useEmployeeForm = defineStore('form-employee', () => { }; currentFromDataEmployee.value = structuredClone(resetEmployeeData); - const foundBranch = await customerStore.fetchListCustomeBranchById( playlond.customerBranchId, ); @@ -843,7 +842,10 @@ export const useEmployeeForm = defineStore('form-employee', () => { state.value.formDataEmployeeOwner = { ...foundBranch }; - if (foundBranch.address === playlond.address) { + if ( + foundBranch.address === playlond.address && + foundBranch.zipCode === playlond.zipCode + ) { state.value.formDataEmployeeSameAddr = true; } else { state.value.formDataEmployeeSameAddr = false; diff --git a/src/utils/datetime.ts b/src/utils/datetime.ts index 8ccacf0a..6190abcb 100644 --- a/src/utils/datetime.ts +++ b/src/utils/datetime.ts @@ -115,9 +115,9 @@ export function parseAndFormatDate( if (locale === 'th-th') { const adjustedYear = Number(year) - 543; - return new Date(`${month}/${date}/${adjustedYear}`); + return new Date(`${month}/${date}/${adjustedYear}T00:00.000Z`); } else { - return new Date(`${month}/${date}/${year}`); + return new Date(`${month}/${date}/${year}T00:00.000Z`); } } return null;