From 1f0ae6cc5adf28f1092fafa0a4c3e12d0533d099 Mon Sep 17 00:00:00 2001 From: mamoss <> Date: Fri, 21 Mar 2025 16:36:11 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=84=E0=B9=89=E0=B8=99=E0=B8=AB=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/WorkflowController.ts | 65 ++++++++++++++++++--------- 1 file changed, 45 insertions(+), 20 deletions(-) diff --git a/src/controllers/WorkflowController.ts b/src/controllers/WorkflowController.ts index ccdf3bfe..a8dac61d 100644 --- a/src/controllers/WorkflowController.ts +++ b/src/controllers/WorkflowController.ts @@ -827,38 +827,63 @@ export class WorkflowController extends Controller { if (!posMasterUser || !posMasterUser.orgRootId) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบตำแหน่งผู้ใช้งาน"); - let condition: any = { - isDirector: true, - orgRootId: posMasterUser.orgRootId, - orgRevisionId: posMasterUser.orgRevisionId, - }; + let condition: any = []; let conditionOfficer: any = { isDirector: true, isOfficer: true, orgRevisionId: posMasterUser.orgRevisionId, + orgChild1Id: IsNull(), }; if (type.trim().toUpperCase() == "OPERATE") { - condition = { + condition.push({ isDirector: true, orgRootId: posMasterUser.orgRootId, orgRevisionId: posMasterUser.orgRevisionId, - // orgChild1Id: IsNull(), - // orgChild2Id: IsNull(), - // orgChild3Id: IsNull(), - // orgChild4Id: IsNull(), - }; - if (posMasterUser.orgChild4Id == null) { - condition.orgChild4Id = IsNull(); - } else if (posMasterUser.orgChild3Id == null) { - condition.orgChild3Id = IsNull(); - } else if (posMasterUser.orgChild2Id == null) { - condition.orgChild2Id = IsNull(); - } else if (posMasterUser.orgChild1Id == null) { - condition.orgChild1Id = IsNull(); - } + orgChild1Id: IsNull(), + }); + condition.push({ + isDirector: true, + orgRootId: posMasterUser.orgRootId, + orgRevisionId: posMasterUser.orgRevisionId, + orgChild1Id: posMasterUser.orgChild1Id, + orgChild2Id: IsNull(), + }); + condition.push({ + isDirector: true, + orgRootId: posMasterUser.orgRootId, + orgRevisionId: posMasterUser.orgRevisionId, + orgChild1Id: posMasterUser.orgChild1Id, + orgChild2Id: posMasterUser.orgChild2Id, + orgChild3Id: IsNull(), + }); + condition.push({ + isDirector: true, + orgRootId: posMasterUser.orgRootId, + orgRevisionId: posMasterUser.orgRevisionId, + orgChild1Id: posMasterUser.orgChild1Id, + orgChild2Id: posMasterUser.orgChild2Id, + orgChild3Id: posMasterUser.orgChild3Id, + orgChild4Id: IsNull(), + }); + condition.push({ + isDirector: true, + orgRootId: posMasterUser.orgRootId, + orgRevisionId: posMasterUser.orgRevisionId, + orgChild1Id: posMasterUser.orgChild1Id, + orgChild2Id: posMasterUser.orgChild2Id, + orgChild3Id: posMasterUser.orgChild3Id, + orgChild4Id: posMasterUser.orgChild4Id, + }); } else { + condition = [ + { + isDirector: true, + orgRootId: posMasterUser.orgRootId, + orgRevisionId: posMasterUser.orgRevisionId, + }, + ]; if ( (posMasterUser.current_holder.posType.posTypeName == "ทั่วไป" && posMasterUser.current_holder.posLevel.posLevelName == "ชำนาญงาน") ||