refactor(01): dialog before submit (abbreviation alert) & i18n

This commit is contained in:
puriphatt 2024-08-09 06:17:57 +00:00
parent 10a54647af
commit e38c76e7d3
6 changed files with 53 additions and 20 deletions

View file

@ -50,7 +50,7 @@ api.interceptors.response.use(
icon: 'mdi-alert', icon: 'mdi-alert',
title: title:
err.response.status >= 400 && err.response.status < 500 err.response.status >= 400 && err.response.status < 500
? 'warning' ? 'form.warning.title'
: 'errorOccurred', : 'errorOccurred',
persistent: true, persistent: true,
enablei18n: true, enablei18n: true,

View file

@ -82,4 +82,6 @@ export default {
relationCustomerNotFound: 'Customer cannot be found.', relationCustomerNotFound: 'Customer cannot be found.',
relationCustomerBranchNotFound: 'Customer Branch cannot be found.', relationCustomerBranchNotFound: 'Customer Branch cannot be found.',
sameBranchCodeExists: 'This Head Office Abbreviation is already in use.',
}; };

View file

@ -110,6 +110,10 @@ export default {
unsave: unsave:
'You have unsaved changes. Are you sure you want to close this window?', '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: { customer: {
employer: 'Employer', employer: 'Employer',
@ -147,4 +151,7 @@ export default {
attachment: 'Attachment', attachment: 'Attachment',
}, },
}, },
backend: {
sameBranchCodeExists: 'This Head Office Abbreviation is already in use.',
},
}; };

View file

@ -81,4 +81,6 @@ export default {
relationCustomerNotFound: 'ไม่พบลูกค้า', relationCustomerNotFound: 'ไม่พบลูกค้า',
relationCustomerBranchNotFound: 'ไม่พบสาขาลูกค้า', relationCustomerBranchNotFound: 'ไม่พบสาขาลูกค้า',
sameBranchCodeExists: 'ตัวย่อสำนักงานใหญ่นี้ถูกใช้แล้ว',
}; };

View file

@ -111,6 +111,10 @@ export default {
unsave: unsave:
'คุณมีการเปลี่ยนแปลงที่ยังไม่ได้บันทึก คุณต้องการปิดหน้าต่างนี้หรือไม่', 'คุณมีการเปลี่ยนแปลงที่ยังไม่ได้บันทึก คุณต้องการปิดหน้าต่างนี้หรือไม่',
}, },
info: {
cantChange:
'{field} ไม่สามารถแก้ไขภายหลังได้ คุณต้องการใช้ "{name}" ใช่หรือไม่',
},
}, },
customer: { customer: {
employer: 'นายจ้าง', employer: 'นายจ้าง',
@ -150,4 +154,7 @@ export default {
attachment: 'เอกสารเพิ่มเติม', attachment: 'เอกสารเพิ่มเติม',
}, },
}, },
backend: {
sameBranchCodeExists: 'ตัวย่อสำนักงานใหญ่นี้ถูกใช้แล้ว',
},
}; };

View file

@ -491,7 +491,8 @@ async function triggerChangeStatus(
return await new Promise((resolve) => { return await new Promise((resolve) => {
dialog({ dialog({
color: status !== 'INACTIVE' ? 'warning' : 'info', 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'), title: t('confirmChangeStatusTitle'),
actionText: actionText:
status !== 'INACTIVE' ? t('switchOffLabel') : t('switchOnLabel'), status !== 'INACTIVE' ? t('switchOffLabel') : t('switchOnLabel'),
@ -532,27 +533,41 @@ async function onSubmit() {
} }
if (formType.value === 'create') { if (formType.value === 'create') {
if (formTypeBranch.value === 'subBranch') { dialog({
const currentRecord = branchData.value.result.find( color: 'info',
(x) => x.id === formData.value.headOfficeId, 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.headOfficeId = currentRecord?.id;
formData.value.code = formData.value.code?.slice(0, -6); formData.value.code = formData.value.code?.slice(0, -6);
delete formData.value['codeHeadOffice']; delete formData.value['codeHeadOffice'];
} }
await branchStore.create( await branchStore.create(
{ {
...formData.value, ...formData.value,
qrCodeImage: profileFile.value, qrCodeImage: profileFile.value,
imageUrl: profileFileImg.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(); const _stats = await branchStore.stats();