From b0358de9cb08140da52a9acb8c18118e9aefb45a Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 17 Mar 2025 13:43:54 +0700 Subject: [PATCH] =?UTF-8?q?issue=20=E0=B9=81=E0=B8=9B=E0=B8=A5=E0=B8=87?= =?UTF-8?q?=E0=B9=80=E0=B8=AD=E0=B8=B2=E0=B9=80=E0=B8=A5=E0=B8=82=E0=B9=84?= =?UTF-8?q?=E0=B8=97=E0=B8=A2=20#1249=20&&=20=E0=B9=80=E0=B8=AD=E0=B8=B2?= =?UTF-8?q?=E0=B9=80=E0=B8=94=E0=B8=B7=E0=B8=AD=E0=B8=99=E0=B8=AD=E0=B8=AD?= =?UTF-8?q?=E0=B8=81=20#1248?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileController.ts | 24 +++++++++---------- src/controllers/ProfileEmployeeController.ts | 24 +++++++++---------- .../ProfileEmployeeTempController.ts | 24 +++++++++---------- src/interfaces/extension.ts | 7 ++++++ 4 files changed, 43 insertions(+), 36 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index cb2c07d9..ccb5617d 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -269,17 +269,17 @@ export class ProfileController extends Controller { : null, position: Extension.ToThaiNumber( Extension.ToThaiNumber( - `${item.positionName != null ? item.positionName : "-"} ${item.positionType == null ? item.positionCee : (item.positionType == "อำนวยการ" || item.positionType == "บริหาร" ? item.positionType : "") + item.positionLevel}`, + `${item.positionName != null ? item.positionName : "-"} ${item.positionType == null ? (item.positionCee??"") : (item.positionType == "อำนวยการ" || item.positionType == "บริหาร" ? item.positionType : "") + item.positionLevel}`, ), ), - posNo: item.posNo != null ? Extension.ToThaiNumber(item.posNo) : null, - orgRoot: item.orgRoot, - orgChild1: item.orgChild1, - orgChild2: item.orgChild2, - orgChild3: item.orgChild3, - orgChild4: item.orgChild4, - positionCee: item.positionCee, - positionExecutive: item.positionExecutive, + posNo: item.posNo != null ? Extension.ToThaiNumber(item.posNo) : "", + orgRoot: item.orgRoot != null ? Extension.ToThaiNumber( item.orgRoot) : "", + orgChild1: item.orgChild1 != null ? Extension.ToThaiNumber( item.orgChild1) : "", + orgChild2: item.orgChild2 != null ? Extension.ToThaiNumber( item.orgChild2) : "", + orgChild3: item.orgChild3 != null ? Extension.ToThaiNumber( item.orgChild3) : "", + orgChild4: item.orgChild4 != null ? Extension.ToThaiNumber( item.orgChild4) : "", + positionCee: item.positionCee != null ? Extension.ToThaiNumber( item.positionCee) : "", + positionExecutive: item.positionExecutive != null ? Extension.ToThaiNumber( item.positionExecutive) : "", })) : [ { @@ -328,11 +328,11 @@ export class ProfileController extends Controller { citizenId: profile.citizenId != null ? Extension.ToThaiNumber(profile.citizenId) : "", dateOfBirth: profile.birthDate != null - ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.birthDate)) + ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear2(profile.birthDate)) : "", dateRetire: profile.dateRetire != null - ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateRetire)) + ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear2(profile.dateRetire)) : "", salaryAmount: profile.amount != null ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "", @@ -356,7 +356,7 @@ export class ProfileController extends Controller { salary_raw.length > 0 && salary_raw[0].positionName != null ? Extension.ToThaiNumber( Extension.ToThaiNumber( - `${salary_raw[0].positionName != null ? salary_raw[0].positionName : "-"} ${salary_raw[0].positionType == null ? salary_raw[0].positionCee : (salary_raw[0].positionType == "อำนวยการ" || salary_raw[0].positionType == "บริหาร" ? salary_raw[0].positionType : "") + salary_raw[0].positionLevel}`, + `${salary_raw[0].positionName != null ? salary_raw[0].positionName : "-"} ${salary_raw[0].positionType == null ? (salary_raw[0].positionCee??"") : (salary_raw[0].positionType == "อำนวยการ" || salary_raw[0].positionType == "บริหาร" ? salary_raw[0].positionType : "") + salary_raw[0].positionLevel}`, ), ) : "", diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index d2f5cf71..94214956 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -261,17 +261,17 @@ export class ProfileEmployeeController extends Controller { : null, position: Extension.ToThaiNumber( Extension.ToThaiNumber( - `${item.positionName != null ? item.positionName : "-"} ${item.positionType == null ? item.positionCee : (item.positionType == "อำนวยการ" || item.positionType == "บริหาร" ? item.positionType : "") + item.positionLevel}`, + `${item.positionName != null ? item.positionName : "-"} ${item.positionType == null ? (item.positionCee??"") : (item.positionType == "อำนวยการ" || item.positionType == "บริหาร" ? item.positionType : "") + item.positionLevel}`, ), ), - posNo: item.posNo != null ? Extension.ToThaiNumber(item.posNo) : null, - orgRoot: item.orgRoot, - orgChild1: item.orgChild1, - orgChild2: item.orgChild2, - orgChild3: item.orgChild3, - orgChild4: item.orgChild4, - positionCee: item.positionCee, - positionExecutive: item.positionExecutive, + posNo: item.posNo != null ? Extension.ToThaiNumber(item.posNo) : "", + orgRoot: item.orgRoot != null ? Extension.ToThaiNumber( item.orgRoot) : "", + orgChild1: item.orgChild1 != null ? Extension.ToThaiNumber( item.orgChild1) : "", + orgChild2: item.orgChild2 != null ? Extension.ToThaiNumber( item.orgChild2) : "", + orgChild3: item.orgChild3 != null ? Extension.ToThaiNumber( item.orgChild3) : "", + orgChild4: item.orgChild4 != null ? Extension.ToThaiNumber( item.orgChild4) : "", + positionCee: item.positionCee != null ? Extension.ToThaiNumber( item.positionCee) : "", + positionExecutive: item.positionExecutive != null ? Extension.ToThaiNumber( item.positionExecutive) : "", })) : [ { @@ -320,11 +320,11 @@ export class ProfileEmployeeController extends Controller { citizenId: profile.citizenId != null ? Extension.ToThaiNumber(profile.citizenId) : "", dateOfBirth: profile.birthDate != null - ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.birthDate)) + ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear2(profile.birthDate)) : "", dateRetire: profile.dateRetire != null - ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateRetire)) + ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear2(profile.dateRetire)) : "", salaryAmount: profile.amount != null ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "", @@ -348,7 +348,7 @@ export class ProfileEmployeeController extends Controller { salary_raw.length > 0 && salary_raw[0].positionName != null ? Extension.ToThaiNumber( Extension.ToThaiNumber( - `${salary_raw[0].positionName != null ? salary_raw[0].positionName : "-"} ${salary_raw[0].positionType == null ? salary_raw[0].positionCee : (salary_raw[0].positionType == "อำนวยการ" || salary_raw[0].positionType == "บริหาร" ? salary_raw[0].positionType : "") + salary_raw[0].positionLevel}`, + `${salary_raw[0].positionName != null ? salary_raw[0].positionName : "-"} ${salary_raw[0].positionType == null ? (salary_raw[0].positionCee??"") : (salary_raw[0].positionType == "อำนวยการ" || salary_raw[0].positionType == "บริหาร" ? salary_raw[0].positionType : "") + salary_raw[0].positionLevel}`, ), ) : "", diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index 3fc25988..ff6f4a2b 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -256,17 +256,17 @@ export class ProfileEmployeeTempController extends Controller { : null, position: Extension.ToThaiNumber( Extension.ToThaiNumber( - `${item.positionName != null ? item.positionName : "-"} ${item.positionType == null ? item.positionCee : (item.positionType == "อำนวยการ" || item.positionType == "บริหาร" ? item.positionType : "") + item.positionLevel}`, + `${item.positionName != null ? item.positionName : "-"} ${item.positionType == null ? (item.positionCee??"") : (item.positionType == "อำนวยการ" || item.positionType == "บริหาร" ? item.positionType : "") + item.positionLevel}`, ), ), - posNo: item.posNo != null ? Extension.ToThaiNumber(item.posNo) : null, - orgRoot: item.orgRoot, - orgChild1: item.orgChild1, - orgChild2: item.orgChild2, - orgChild3: item.orgChild3, - orgChild4: item.orgChild4, - positionCee: item.positionCee, - positionExecutive: item.positionExecutive, + posNo: item.posNo != null ? Extension.ToThaiNumber(item.posNo) : "", + orgRoot: item.orgRoot != null ? Extension.ToThaiNumber( item.orgRoot) : "", + orgChild1: item.orgChild1 != null ? Extension.ToThaiNumber( item.orgChild1) : "", + orgChild2: item.orgChild2 != null ? Extension.ToThaiNumber( item.orgChild2) : "", + orgChild3: item.orgChild3 != null ? Extension.ToThaiNumber( item.orgChild3) : "", + orgChild4: item.orgChild4 != null ? Extension.ToThaiNumber( item.orgChild4) : "", + positionCee: item.positionCee != null ? Extension.ToThaiNumber( item.positionCee) : "", + positionExecutive: item.positionExecutive != null ? Extension.ToThaiNumber( item.positionExecutive) : "", })) : [ { @@ -314,11 +314,11 @@ export class ProfileEmployeeTempController extends Controller { citizenId: profile.citizenId != null ? Extension.ToThaiNumber(profile.citizenId) : "", dateOfBirth: profile.birthDate != null - ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.birthDate)) + ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear2(profile.birthDate)) : "", dateRetire: profile.dateRetire != null - ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateRetire)) + ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear2(profile.dateRetire)) : "", salaryAmount: profile.amount != null ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : "", @@ -342,7 +342,7 @@ export class ProfileEmployeeTempController extends Controller { salary_raw.length > 0 && salary_raw[0].positionName != null ? Extension.ToThaiNumber( Extension.ToThaiNumber( - `${salary_raw[0].positionName != null ? salary_raw[0].positionName : "-"} ${salary_raw[0].positionType == null ? salary_raw[0].positionCee : (salary_raw[0].positionType == "อำนวยการ" || salary_raw[0].positionType == "บริหาร" ? salary_raw[0].positionType : "") + salary_raw[0].positionLevel}`, + `${salary_raw[0].positionName != null ? salary_raw[0].positionName : "-"} ${salary_raw[0].positionType == null ? (salary_raw[0].positionCee??"") : (salary_raw[0].positionType == "อำนวยการ" || salary_raw[0].positionType == "บริหาร" ? salary_raw[0].positionType : "") + salary_raw[0].positionLevel}`, ), ) : "", diff --git a/src/interfaces/extension.ts b/src/interfaces/extension.ts index a2e766dc..15cbac88 100644 --- a/src/interfaces/extension.ts +++ b/src/interfaces/extension.ts @@ -228,6 +228,13 @@ class Extension { ); } + public static ToThaiShortDate_monthYear2(value: Date) { + let yy = value.getFullYear() < 2400 ? value.getFullYear() + 543 : value.getFullYear(); + return ( + value.getDate() + " " + Extension.ToThaiMonth(value.getMonth() + 1) + " พ.ศ. " + yy + ); + } + public static ToThaiShortYear(value: Date) { let yy = value.getFullYear() < 2400 ? value.getFullYear() + 543 : value.getFullYear(); return yy.toString();