From 185a713ad17887eb80162c3496d1d994379df7bb Mon Sep 17 00:00:00 2001 From: puriphatt Date: Wed, 28 Aug 2024 18:05:01 +0700 Subject: [PATCH] fix: i18n & work name before close --- .../02_personnel-management/FormByType.vue | 12 ++++--- src/i18n/eng/index.ts | 16 +++++++-- src/i18n/tha/index.ts | 17 ++++++++-- src/layouts/MainLayout.vue | 5 +-- .../02_personnel-management/MainPage.vue | 6 ++-- src/pages/04_product-service/MainPage.vue | 33 +++++++++++-------- src/stores/utils/index.ts | 6 ++-- 7 files changed, 64 insertions(+), 31 deletions(-) diff --git a/src/components/02_personnel-management/FormByType.vue b/src/components/02_personnel-management/FormByType.vue index b207369b..34b3f92a 100644 --- a/src/components/02_personnel-management/FormByType.vue +++ b/src/components/02_personnel-management/FormByType.vue @@ -3,14 +3,13 @@ import useUserStore from 'stores/user'; import useOptionStore from 'stores/options'; import { UserAttachmentDelete } from 'stores/user/types'; import { dialog, selectFilterOptionRefMod } from 'stores/utils'; -import { dateFormat, parseAndFormatDate } from 'src/utils/datetime'; import { onMounted, ref, watch } from 'vue'; import { useI18n } from 'vue-i18n'; import { Icon } from '@iconify/vue'; import { QSelect } from 'quasar'; import DatePicker from '../shared/DatePicker.vue'; -const { locale } = useI18n(); +const { t } = useI18n(); const userStore = useUserStore(); const optionStore = useOptionStore(); @@ -54,10 +53,12 @@ function deleteFile(name: string) { dialog({ color: 'negative', icon: 'mdi-trash-can-outline', - title: 'ยืนยันการลบเอกสารประจำตัว', - actionText: 'ตกลง', + title: t('dialog.title.confirmDelete', { + msg: t('personnel.form.attachment'), + }), + actionText: t('general.delete'), persistent: true, - message: 'คุณต้องการลบเอกสารประจำตัว ใช่หรือไม่', + message: t('dialog.message.confirmDelete'), action: async () => { if (!userId.value) return; const payload: UserAttachmentDelete = { @@ -69,6 +70,7 @@ function deleteFile(name: string) { agencyFileList.value = result; } }, + cancel: () => {}, }); } diff --git a/src/i18n/eng/index.ts b/src/i18n/eng/index.ts index 46459a67..c57408d7 100644 --- a/src/i18n/eng/index.ts +++ b/src/i18n/eng/index.ts @@ -56,6 +56,7 @@ export default { times: 'No. {number}', uploadFile: 'Upload File', }, + menu: { dashboard: 'Dashboard', dashboardCaption: 'Statistical information.', @@ -99,6 +100,7 @@ export default { addSignature: 'Add Signature', }, }, + form: { title: { info: '{name}', @@ -126,6 +128,7 @@ export default { middleName: 'Middle Name', middleNameEN: 'Middle Name (EN)', error: { + title: 'Error Occurred {msg}', required: 'This field is required.', select: 'Please select.', selectField: 'Please select {field}.', @@ -148,12 +151,14 @@ export default { decimalPlace: 'Decimal Place', selection: 'Selection', }, + status: { title: 'Status', CREATED: 'Active', // NOTE: Treated as active ACTIVE: 'Active', INACTIVE: 'Inactive', }, + branch: { office: 'Office', card: { @@ -199,6 +204,7 @@ export default { bankAccountType: 'Bank Account Type', }, }, + personnel: { title: 'Personnel Management', caption: 'Manage All Personnel', @@ -308,7 +314,6 @@ export default { headQuarters: { title: 'Headoffice', }, - businessType: 'Business Type', businessTypeEN: 'Business Type (EN)', jobPosition: 'Job Position', @@ -329,6 +334,7 @@ export default { contactPhone: 'Contact Phone', }, }, + customerEmployee: { branch: 'Branch', form: { @@ -417,6 +423,7 @@ export default { other: 'Other', }, }, + customerBranch: { tab: { main: 'About', @@ -439,6 +446,7 @@ export default { attachment: 'Attachment', }, }, + productService: { title: 'Products and Services', caption: 'Manage All Products and Services', @@ -499,8 +507,9 @@ export default { title: { incompleteDataEntry: 'Incomplete Data Entry', confirmChangeStatus: 'Confirm Status Change', - confirmDelete: 'Confirm Deletion', + confirmDelete: 'Confirm Deletion {msg}', youngWorker: 'Employee under 18', + confirmLogout: 'Confirm Logout', }, message: { incompleteDataEntry: 'Incomplete data entry on {tap} page', @@ -508,6 +517,9 @@ export default { confirmChangeStatusOff: 'Do you want to close?', confirmDelete: 'Do you want to delete this item?', youngWorker: 'Employee is under 18 years old, do you want to confirm?', + confirmLogout: 'Do you want to Logout?', + headquartersNotEstablished: 'Headoffice not established', + warningClose: 'Incomplte edit data, Do you want to close?', }, action: { ok: 'OK', diff --git a/src/i18n/tha/index.ts b/src/i18n/tha/index.ts index 8a7409a8..f3b76f29 100644 --- a/src/i18n/tha/index.ts +++ b/src/i18n/tha/index.ts @@ -56,6 +56,7 @@ export default { times: 'ครั้งที่ {number}', uploadFile: 'อัปโหลดไฟล์', }, + menu: { dashboard: 'แดชบอร์ด', dashboardCaption: 'แสดงข้อมูลสถิติ', @@ -99,6 +100,7 @@ export default { addSignature: 'เพิ่มลายเซ็น', }, }, + form: { title: { info: '{name}', @@ -149,12 +151,14 @@ export default { decimalPlace: 'ตำแหน่ง', selection: 'ตัวเลือก', }, + status: { title: 'สถานะการใช้งาน', CREATED: 'ใช้งานอยู่', // NOTE: Treated as active ACTIVE: 'ใช้งานอยู่', INACTIVE: 'ไม่ใช้งาน', }, + branch: { office: 'สำนักงาน', card: { @@ -200,6 +204,7 @@ export default { bankAccountType: 'ประเภทบัญชี', }, }, + personnel: { title: 'จัดการบุคลากร', caption: 'จัดการบุคลากรทั้งหมด', @@ -236,7 +241,7 @@ export default { trainingPlace: 'สถานที่อบรม', checkpoint: 'ด่าน', checkpointEN: 'ด่าน ภาษาอังกฤษ', - attachment: 'แบบเอกสารประจำตัว', + attachment: 'เอกสารประจำตัว', }, }, customer: { @@ -250,6 +255,7 @@ export default { powerOfAttorney: 'หนังสือมอบอำนาจ', others: 'อื่นๆ', }, + employer: 'นายจ้าง', employee: 'ลูกจ้าง', employerLegalEntity: 'นิติบุคคล', @@ -328,6 +334,7 @@ export default { contactPhone: 'โทรศัพท์ผู้ติดต่อ', }, }, + customerEmployee: { branch: 'สาขา', form: { @@ -414,6 +421,7 @@ export default { other: 'อื่นๆ', }, }, + customerBranch: { tab: { main: 'เกี่ยวกับ', @@ -436,6 +444,7 @@ export default { attachment: 'เอกสารเพิ่มเติม', }, }, + productService: { title: 'สินค้าและบริการ', caption: 'จัดการสินค้าและบริการทั้งหมด', @@ -496,8 +505,9 @@ export default { title: { incompleteDataEntry: 'กรอกข้อมูลไม่ครบ', confirmChangeStatus: 'ยืนยันการเปลี่ยนสถานะ', - confirmDelete: 'ยืนยันการลบ', + confirmDelete: 'ยืนยันการลบ {msg}', youngWorker: 'ลูกจ้างอายุต่ำกว่า 18 ปี', + confirmLogout: 'ยืนยันการออกจากระบบ', }, message: { incompleteDataEntry: 'กรอกข้อมูลไม่ครบในหน้า {tap}', @@ -505,6 +515,9 @@ export default { confirmChangeStatusOff: 'คุณต้องการปิดใช่หรือไม่', confirmDelete: 'คุณต้องการลบรายการนี้ใช่หรือไม่', youngWorker: 'ลูกจ้างอายุต่ำกว่า 18 ปี ต้องการยืนยันหรือไม่', + confirmLogout: 'คุณต้องการออกจากระบบใช่หรือไม่', + headquartersNotEstablished: 'ยังไม่ได้สร้างสำนักงานใหญ่', + warningClose: 'มีการแก้ไขที่ยังไม่ได้บันทึก คุณต้องการปิดใช่หรือไม่', }, action: { ok: 'ยืนยัน', diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index 21823ee3..1090a280 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -118,10 +118,11 @@ function setActive(button: NotificationButton) { function doLogout() { dialog({ icon: 'mdi-logout-variant', - title: t('confirmLogoutTitle'), + title: t('dialog.title.confirmLogout'), persistent: true, color: 'negative', - message: t('confirmLogoutMessage'), + message: t('dialog.message.confirmLogout'), + actionText: t('general.logout'), action: async () => { logout(); }, diff --git a/src/pages/02_personnel-management/MainPage.vue b/src/pages/02_personnel-management/MainPage.vue index 822281a4..b6c4e6d8 100644 --- a/src/pages/02_personnel-management/MainPage.vue +++ b/src/pages/02_personnel-management/MainPage.vue @@ -325,10 +325,10 @@ async function openDialog( dialog({ color: 'warning', icon: 'mdi-alert', - title: t('warning'), - actionText: t('agree'), + title: t('form.warning.title'), + actionText: t('ok'), persistent: true, - message: t('headquartersNotEstablished'), + message: t('dialog.message.headquartersNotEstablished'), action: async () => {}, }); diff --git a/src/pages/04_product-service/MainPage.vue b/src/pages/04_product-service/MainPage.vue index f0dc18b3..24ea1f4b 100644 --- a/src/pages/04_product-service/MainPage.vue +++ b/src/pages/04_product-service/MainPage.vue @@ -1209,19 +1209,12 @@ function confirmDeleteWork(id: string) { } function triggerConfirmCloseWork() { - const isWorkNameEdit = - workNameRef.value && workNameRef.value.isWorkNameEdit - ? workNameRef.value.isWorkNameEdit() - : false; - if (isWorkNameEdit) { - dialogWarningClose(t, { - action: () => { - manageWorkNameDialog.value = false; - }, - }); - } else { - manageWorkNameDialog.value = false; - } + dialogWarningClose(t, { + action: () => { + manageWorkNameDialog.value = false; + }, + cancel: () => {}, + }); } const tempValueProperties = ref({ @@ -4066,7 +4059,19 @@ watch([currentStatusList, productMode], () => { width="65%" v-model:modal="manageWorkNameDialog" :title="$t('general.manage')" - :close="triggerConfirmCloseWork" + :before-close=" + () => { + const isWorkNameEdit = + workNameRef && workNameRef.isWorkNameEdit + ? workNameRef.isWorkNameEdit() + : false; + if (isWorkNameEdit) { + triggerConfirmCloseWork(); + return true; + } + return false; + } + " >
{ if (opts.action) opts.action(); },