From a16ae79c7e0a6405037558e7782ddf71dff83db4 Mon Sep 17 00:00:00 2001 From: Adisak Date: Fri, 13 Feb 2026 12:50:35 +0700 Subject: [PATCH] =?UTF-8?q?fix:=20=E0=B9=84=E0=B8=9F=E0=B8=A5=E0=B9=8C?= =?UTF-8?q?=E0=B9=81=E0=B8=99=E0=B8=9A=E0=B8=97=E0=B9=89=E0=B8=B2=E0=B8=A2?= =?UTF-8?q?=E0=B8=94=E0=B8=B2=E0=B8=A7=E0=B8=99=E0=B9=8C=E0=B9=82=E0=B8=AB?= =?UTF-8?q?=E0=B8=A5=E0=B8=94=E0=B9=84=E0=B8=A1=E0=B9=88=E0=B9=84=E0=B8=94?= =?UTF-8?q?=E0=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/interfaces/utils.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/interfaces/utils.ts b/src/interfaces/utils.ts index d3409187..128499ea 100644 --- a/src/interfaces/utils.ts +++ b/src/interfaces/utils.ts @@ -601,7 +601,7 @@ export async function PayloadSendNoti(commandId: string) { where: { id: commandId, }, - relations: ["commandType"], + relations: ["commandType", "commandRecives"], }); if (!_command || !_command.commandType) return ""; @@ -615,19 +615,18 @@ export async function PayloadSendNoti(commandId: string) { } let attachments = {} if (_command.commandType.isUploadAttachment === true) { - const _payloadAtt = { - name: _command && _command.commandType - ? `เอกสารแนบท้ายคำสั่ง${_command.commandType.name}` - : "", - url: `${process.env.API_URL}/salary/file/ระบบออกคำสั่ง/แนบท้าย/${commandId}/แนบท้าย`, + + const attachmentPayloads = _command.commandRecives.map((recive: any) => ({ + name: `เอกสารแนบท้ายคำสั่ง${_command.commandType.name} (${recive.prefix}${recive.firstName} ${recive.lastName})`, + url: `${process.env.API_URL}/salary/file/ระบบออกคำสั่ง/แนบท้าย/${commandId}/${recive.citizenId}/แนบท้าย`, isReport: true, isTemplate: false, - } + })); + attachments = { - attachments: [_payload, _payloadAtt] + attachments: [_payload, ...attachmentPayloads] }; - } - else { + } else { attachments = { attachments: [_payload] };