diff --git a/src/boot/axios.ts b/src/boot/axios.ts index b6a869ff..946723e8 100644 --- a/src/boot/axios.ts +++ b/src/boot/axios.ts @@ -50,7 +50,7 @@ api.interceptors.response.use( icon: 'mdi-alert', title: err.response.status >= 400 && err.response.status < 500 - ? 'warning' + ? 'form.warning.title' : 'errorOccurred', persistent: true, enablei18n: true, diff --git a/src/i18n/en-US/alert-dialog.ts b/src/i18n/en-US/alert-dialog.ts index 6a9dc35f..843c4216 100644 --- a/src/i18n/en-US/alert-dialog.ts +++ b/src/i18n/en-US/alert-dialog.ts @@ -82,4 +82,6 @@ export default { relationCustomerNotFound: 'Customer cannot be found.', relationCustomerBranchNotFound: 'Customer Branch cannot be found.', + + sameBranchCodeExists: 'This Head Office Abbreviation is already in use.', }; diff --git a/src/i18n/en-US/index.ts b/src/i18n/en-US/index.ts index 01328aba..3919920f 100644 --- a/src/i18n/en-US/index.ts +++ b/src/i18n/en-US/index.ts @@ -110,6 +110,10 @@ export default { unsave: 'You have unsaved changes. Are you sure you want to close this window?', }, + info: { + cantChange: + 'The {field} cannot be changed later. Do you want to use "{name}"', + }, }, customer: { employer: 'Employer', @@ -147,4 +151,7 @@ export default { attachment: 'Attachment', }, }, + backend: { + sameBranchCodeExists: 'This Head Office Abbreviation is already in use.', + }, }; diff --git a/src/i18n/th-th/alert-dialog.ts b/src/i18n/th-th/alert-dialog.ts index 5f363d50..1f65b43e 100644 --- a/src/i18n/th-th/alert-dialog.ts +++ b/src/i18n/th-th/alert-dialog.ts @@ -81,4 +81,6 @@ export default { relationCustomerNotFound: 'ไม่พบลูกค้า', relationCustomerBranchNotFound: 'ไม่พบสาขาลูกค้า', + + sameBranchCodeExists: 'ตัวย่อสำนักงานใหญ่นี้ถูกใช้แล้ว', }; diff --git a/src/i18n/th-th/index.ts b/src/i18n/th-th/index.ts index 5bda5a9e..5a1ec4d0 100644 --- a/src/i18n/th-th/index.ts +++ b/src/i18n/th-th/index.ts @@ -111,6 +111,10 @@ export default { unsave: 'คุณมีการเปลี่ยนแปลงที่ยังไม่ได้บันทึก คุณต้องการปิดหน้าต่างนี้หรือไม่', }, + info: { + cantChange: + '{field} ไม่สามารถแก้ไขภายหลังได้ คุณต้องการใช้ "{name}" ใช่หรือไม่', + }, }, customer: { employer: 'นายจ้าง', @@ -150,4 +154,7 @@ export default { attachment: 'เอกสารเพิ่มเติม', }, }, + backend: { + sameBranchCodeExists: 'ตัวย่อสำนักงานใหญ่นี้ถูกใช้แล้ว', + }, }; diff --git a/src/pages/01_branch-management/MainPage.vue b/src/pages/01_branch-management/MainPage.vue index dba35268..2639c554 100644 --- a/src/pages/01_branch-management/MainPage.vue +++ b/src/pages/01_branch-management/MainPage.vue @@ -491,7 +491,8 @@ async function triggerChangeStatus( return await new Promise((resolve) => { dialog({ color: status !== 'INACTIVE' ? 'warning' : 'info', - icon: status !== 'INACTIVE' ? 'mdi-alert' : 'mdi-comment-alert', + icon: + status !== 'INACTIVE' ? 'mdi-alert' : 'mdi-message-processing-outline', title: t('confirmChangeStatusTitle'), actionText: status !== 'INACTIVE' ? t('switchOffLabel') : t('switchOnLabel'), @@ -532,27 +533,41 @@ async function onSubmit() { } if (formType.value === 'create') { - if (formTypeBranch.value === 'subBranch') { - const currentRecord = branchData.value.result.find( - (x) => x.id === formData.value.headOfficeId, - ); + dialog({ + color: 'info', + icon: 'mdi-message-processing-outline', + message: t('form.info.cantChange', { + field: t('formDialogHqAbbreviation'), + name: formData.value.code, + }), + actionText: t('agree'), + persistent: true, + title: t('form.warning.title'), + cancel: () => {}, + action: async () => { + if (formTypeBranch.value === 'subBranch') { + const currentRecord = branchData.value.result.find( + (x) => x.id === formData.value.headOfficeId, + ); - formData.value.headOfficeId = currentRecord?.id; - formData.value.code = formData.value.code?.slice(0, -6); - delete formData.value['codeHeadOffice']; - } + formData.value.headOfficeId = currentRecord?.id; + formData.value.code = formData.value.code?.slice(0, -6); + delete formData.value['codeHeadOffice']; + } - await branchStore.create( - { - ...formData.value, - qrCodeImage: profileFile.value, - imageUrl: profileFileImg.value, + await branchStore.create( + { + ...formData.value, + qrCodeImage: profileFile.value, + imageUrl: profileFileImg.value, + }, + formBankBook.value, + ); + + await branchStore.fetchList({ pageSize: 99999 }); + modal.value = false; }, - formBankBook.value, - ); - - await branchStore.fetchList({ pageSize: 99999 }); - modal.value = false; + }); } const _stats = await branchStore.stats();