diff --git a/src/modules/10_registry/utils/exportPosition.ts b/src/modules/10_registry/utils/exportPosition.ts index 4c77019..7745306 100644 --- a/src/modules/10_registry/utils/exportPosition.ts +++ b/src/modules/10_registry/utils/exportPosition.ts @@ -62,7 +62,7 @@ export async function exportToExcelPosition(data: DataPosition[]) { // 3. Map ข้อมูล const newData = data.map((e, index) => ({ no: index + 1, - commandDateAffect: date2Thai(e.commandDateAffect), + commandDateAffect: e.commandDateAffect, positionName: e.positionName, positionType: e.positionType, positionLevel: e.positionLevel, @@ -86,7 +86,7 @@ export async function exportToExcelPosition(data: DataPosition[]) { posNumCodeSitAbb: e.posNumCodeSitAbb, commandNo: e.commandNo, commandYear: e.commandYear ? Number(e.commandYear) + 543 : "", - commandDateSign: date2Thai(e.commandDateSign), + commandDateSign: e.commandDateSign, commandCodeName: store.convertCommandCodeName(e.commandCode), remark: e.remark, commandId: e.commandId, @@ -99,6 +99,15 @@ export async function exportToExcelPosition(data: DataPosition[]) { newData.forEach((_, index) => { const rowIndex = index + 2; + const dateAffectCell = worksheet.getCell(`B${rowIndex}`); + const dateSignCell = worksheet.getCell(`Z${rowIndex}`); + + [dateAffectCell, dateSignCell].forEach((cell) => { + // ใช้ Custom Format: วัน/เดือน/ปี(4หลัก) + // โดยบังคับให้เลขวันและเดือนมี 2 หลักเสมอ (dd/mm) + cell.numFmt = "dd/mm/yyyy"; + }); + // --- ทำ Dropdown คอลัมน์ AA --- // อ้างอิงรายการจาก MasterData Sheet จะทำให้ Excel ทำงานได้เสถียรกว่า (กรณีรายการเยอะ) worksheet.getCell(`AA${rowIndex}`).dataValidation = {