From 0a874798bd8191b32c43c6d0df5845d5d3f88071 Mon Sep 17 00:00:00 2001 From: harid Date: Mon, 8 Jun 2026 18:09:44 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=95=E0=B9=88=E0=B8=87=E0=B8=95?= =?UTF-8?q?=E0=B8=B1=E0=B9=89=E0=B8=87=20=E0=B8=A2=E0=B9=89=E0=B8=B2?= =?UTF-8?q?=E0=B8=A2=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=B7=E0=B9=88=E0=B8=AD=E0=B8=99=E0=B9=84=E0=B8=82?= =?UTF-8?q?=E0=B8=81=E0=B8=B2=E0=B8=A3=20search=20=E0=B8=95=E0=B8=B3?= =?UTF-8?q?=E0=B9=81=E0=B8=AB=E0=B8=99=E0=B9=88=E0=B8=87=20#2554?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/PositionController.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index cd919c19..96fa3db6 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -4434,6 +4434,7 @@ export class PositionController extends Controller { typeCommand: string | null; posType?: string | null; posLevel?: string | null; + profileId?: string | null; isAll: boolean; isBlank: boolean; }, @@ -4475,9 +4476,13 @@ export class PositionController extends Controller { posLevel: posLevel?.id, }; } else if (body.typeCommand == "APPOINT") { - conditionA = "posType.posTypeRank > :posTypeRank"; + // เดิม : กรองเฉพาะ posTypeRank ที่สูงกว่า + // conditionA = "posType.posTypeRank > :posTypeRank"; + // ใหม่ : กรองเฉพาะ posType ที่สูงหรือต่ำกว่าก็ได้ + conditionA = "positions.posTypeId != :currentPosType"; params = { - posTypeRank: posType?.posTypeRank ?? 0, + // posTypeRank: posType?.posTypeRank ?? 0, + currentPosType: posType?.id, }; } else if (body.typeCommand == "SLIP") { conditionA = "positions.posTypeId LIKE :posType AND posLevel.posLevelRank > :posLevelRank"; @@ -4541,6 +4546,10 @@ export class PositionController extends Controller { typeCondition.current_holderId = IsNull(); } + if (body.typeCommand === "MOVE" && body.profileId && !body.isBlank) { + typeCondition.current_holderId = Not(body.profileId); + } + const [posMaster, total] = await AppDataSource.getRepository(PosMaster) .createQueryBuilder("posMaster") .leftJoinAndSelect("posMaster.orgRevision", "orgRevision")