fix: formatDate

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2026-04-23 10:11:14 +07:00
parent 803ba41a79
commit 87f091f15b

View file

@ -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 = {