fix: ไฟล์แนบท้ายดาวน์โหลดไม่ได้
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m20s

This commit is contained in:
Adisak 2026-02-13 12:50:35 +07:00
parent 74b2694aef
commit a16ae79c7e

View file

@ -601,7 +601,7 @@ export async function PayloadSendNoti(commandId: string) {
where: { where: {
id: commandId, id: commandId,
}, },
relations: ["commandType"], relations: ["commandType", "commandRecives"],
}); });
if (!_command || !_command.commandType) if (!_command || !_command.commandType)
return ""; return "";
@ -615,19 +615,18 @@ export async function PayloadSendNoti(commandId: string) {
} }
let attachments = {} let attachments = {}
if (_command.commandType.isUploadAttachment === true) { if (_command.commandType.isUploadAttachment === true) {
const _payloadAtt = {
name: _command && _command.commandType const attachmentPayloads = _command.commandRecives.map((recive: any) => ({
? `เอกสารแนบท้ายคำสั่ง${_command.commandType.name}` name: `เอกสารแนบท้ายคำสั่ง${_command.commandType.name} (${recive.prefix}${recive.firstName} ${recive.lastName})`,
: "", url: `${process.env.API_URL}/salary/file/ระบบออกคำสั่ง/แนบท้าย/${commandId}/${recive.citizenId}/แนบท้าย`,
url: `${process.env.API_URL}/salary/file/ระบบออกคำสั่ง/แนบท้าย/${commandId}/แนบท้าย`,
isReport: true, isReport: true,
isTemplate: false, isTemplate: false,
} }));
attachments = { attachments = {
attachments: [_payload, _payloadAtt] attachments: [_payload, ...attachmentPayloads]
}; };
} } else {
else {
attachments = { attachments = {
attachments: [_payload] attachments: [_payload]
}; };