From 5e9189a4892cae8e49d39ff56c1cc29e882ff841 Mon Sep 17 00:00:00 2001 From: harid Date: Fri, 12 Dec 2025 18:27:32 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=E0=B8=9F=E0=B8=B4=E0=B8=A5=E0=B8=94=E0=B9=8C=20isSalary=20+=20?= =?UTF-8?q?api=20=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82=E0=B9=80?= =?UTF-8?q?=E0=B8=87=E0=B8=B4=E0=B8=99=E0=B9=80=E0=B8=94=E0=B8=B7=E0=B8=AD?= =?UTF-8?q?=E0=B8=99=E0=B8=97=E0=B8=B1=E0=B9=89=E0=B8=87=E0=B8=81=E0=B8=A5?= =?UTF-8?q?=E0=B8=B8=E0=B9=88=E0=B8=A1=20=20#2102?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 48 ++++++++++++++++++++++++ src/controllers/CommandTypeController.ts | 1 + src/controllers/WorkflowController.ts | 4 +- 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index cad8dc18..a682932d 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -649,6 +649,54 @@ export class CommandController extends Controller { return new HttpSuccess(); } + /** + * API แก้ไขเงินเดือนทั้งกลุ่ม + * + * @summary API แก้ไขเงินเดือนทั้งกลุ่ม + * + * @param {string} id Id คำสั่ง + */ + @Post("tab2/edit-salary") + async EditSalary( + @Body() + requestBody: { + id: string; + mouthSalaryAmount?: Double | null; + positionSalaryAmount?: Double | null; + amount?: Double | null; + amountSpecial?: Double | null; + remarkVertical?: string | null; + remarkHorizontal?: string | null; + }[], + @Request() request: RequestWithUser, + ) { + await new permission().PermissionUpdate(request, "COMMAND"); + + if (!Array.isArray(requestBody)) { + throw new HttpError(HttpStatusCode.BAD_REQUEST, "รูปแบบข้อมูลไม่ถูกต้อง"); + } + + for (const item of requestBody) { + if (!item.id) continue; + + const rec = await this.commandReciveRepository.findOne({ + where: { id: item.id }, + }); + + if (!rec) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ได้รับคำสั่ง"); + } + + const updated = Object.assign(rec, item); + updated.lastUpdateUserId = request.user.sub; + updated.lastUpdateFullName = request.user.name; + updated.lastUpdatedAt = new Date(); + + await this.commandReciveRepository.save(updated); + } + return new HttpSuccess(); + } + /** * API ลบรายการผู้ได้รับคำสั่ง * diff --git a/src/controllers/CommandTypeController.ts b/src/controllers/CommandTypeController.ts index 4d12f478..6c5cc2a2 100644 --- a/src/controllers/CommandTypeController.ts +++ b/src/controllers/CommandTypeController.ts @@ -53,6 +53,7 @@ export class CommandTypeController extends Controller { "detailBody", "detailFooter", "subtitle", + "isSalary", "isAttachment", "isUploadAttachment", "createdAt", diff --git a/src/controllers/WorkflowController.ts b/src/controllers/WorkflowController.ts index e12cdd0a..884629e7 100644 --- a/src/controllers/WorkflowController.ts +++ b/src/controllers/WorkflowController.ts @@ -1030,7 +1030,7 @@ export class WorkflowController extends Controller { : data.map((x: any) => ({ ...x, posExecutiveNameOrg: - x.posExecutiveName + + x.posExecutiveName ?? "" + (x.orgChild4 ?? x.orgChild3 ?? x.orgChild2 ?? x.orgChild1 ?? x.orgRoot ?? ""), })); @@ -1227,7 +1227,7 @@ export class WorkflowController extends Controller { const processedData = data.map((x: any) => ({ ...x, posExecutiveNameOrg: - x.posExecutiveName + + x.posExecutiveName ?? "" + (x.orgChild4 ?? x.orgChild3 ?? x.orgChild2 ?? x.orgChild1 ?? x.orgRoot ?? ""), }));