list ปลัด และรองปลัดใน popup ผู้บังคับบัญชา และผู้มีอำนาจเพิ่ม
This commit is contained in:
parent
f8bb9e7cab
commit
2f6d230e4e
2 changed files with 49 additions and 9 deletions
|
|
@ -2998,12 +2998,35 @@ export class ProfileController extends Controller {
|
|||
// console.log(condition);
|
||||
// console.log("------------------");
|
||||
// console.log(conditionNow);
|
||||
|
||||
// Task #2342 list ปลัด และรองปลัดใน popup ผู้บังคับบัญชา และผู้มีอำนาจเพิ่ม
|
||||
let conditionisDeputy: any = {
|
||||
isDeputy: true,
|
||||
isDirector: true,
|
||||
orgChild1Id: IsNull(),
|
||||
orgChild2Id: IsNull(),
|
||||
orgChild3Id: IsNull(),
|
||||
orgChild4Id: IsNull(),
|
||||
id: Not(posMaster.current_holderId),
|
||||
};
|
||||
const orgRoot = await this.orgRootRepo.findOne({
|
||||
select: { id: true, isDeputy: true },
|
||||
where: {
|
||||
id: Not(posMaster.orgRootId ?? ""),
|
||||
isDeputy: true,
|
||||
orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||
},
|
||||
});
|
||||
|
||||
if (body.isAct == true) {
|
||||
const [lists, total] = await AppDataSource.getRepository(viewDirectorActing)
|
||||
.createQueryBuilder("viewDirectorActing")
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.orWhere(condition).orWhere(conditionNow);
|
||||
if (orgRoot && orgRoot.isDeputy) {
|
||||
qb.orWhere(conditionisDeputy);
|
||||
}
|
||||
}),
|
||||
)
|
||||
.andWhere("viewDirectorActing.isProbation = :isProbation", { isProbation: false })
|
||||
|
|
@ -3069,6 +3092,9 @@ export class ProfileController extends Controller {
|
|||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.orWhere(condition).orWhere(conditionNow);
|
||||
if (orgRoot && orgRoot.isDeputy) {
|
||||
qb.orWhere(conditionisDeputy);
|
||||
}
|
||||
}),
|
||||
)
|
||||
.andWhere("viewDirector.isProbation = :isProbation", { isProbation: false })
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import { viewDirectorActing } from "../entities/view/viewDirectorActing";
|
|||
import { viewDirector } from "../entities/view/viewDirector";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||
|
||||
import { OrgRoot } from "../entities/OrgRoot";
|
||||
@Route("api/v1/org/workflow")
|
||||
@Tags("Workflow")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -34,7 +34,7 @@ export class WorkflowController extends Controller {
|
|||
private stateUserCommentRepo = AppDataSource.getRepository(StateUserComment);
|
||||
private profileRepo = AppDataSource.getRepository(Profile);
|
||||
private profileEmployeeRepo = AppDataSource.getRepository(ProfileEmployee);
|
||||
|
||||
private orgRootRepo = AppDataSource.getRepository(OrgRoot);
|
||||
private metaWorkflowRepo = AppDataSource.getRepository(MetaWorkflow);
|
||||
private metaStateRepo = AppDataSource.getRepository(MetaState);
|
||||
private metaStateOperatorRepo = AppDataSource.getRepository(MetaStateOperator);
|
||||
|
|
@ -898,6 +898,20 @@ export class WorkflowController extends Controller {
|
|||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบตำแหน่งผู้ใช้งาน");
|
||||
}
|
||||
|
||||
// Task #2342 list ปลัด และรองปลัดใน popup ผู้บังคับบัญชา และผู้มีอำนาจเพิ่ม
|
||||
const roodIds = [posMasterUser.orgRootId];
|
||||
const orgRoot = await this.orgRootRepo.findOne({
|
||||
select: { id: true, isDeputy: true },
|
||||
where: {
|
||||
id: Not(posMasterUser.orgRootId),
|
||||
isDeputy: true,
|
||||
orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||
},
|
||||
});
|
||||
if (orgRoot && orgRoot.isDeputy) {
|
||||
roodIds.push(orgRoot.id)
|
||||
}
|
||||
|
||||
// 2. Pre-calculate conditions - ย้ายออกมาข้างนอก
|
||||
const posType = posMasterUser.current_holder?.posType?.posTypeName;
|
||||
const posLevel = posMasterUser.current_holder?.posLevel?.posLevelName;
|
||||
|
|
@ -927,23 +941,23 @@ export class WorkflowController extends Controller {
|
|||
|
||||
if (type.trim().toUpperCase() === "OPERATE" || body.type === "employee") {
|
||||
mainConditions = [
|
||||
{ ...baseCondition, orgRootId: posMasterUser.orgRootId, orgChild1Id: IsNull() },
|
||||
{ ...baseCondition, orgRootId: In(roodIds), orgChild1Id: IsNull() },
|
||||
{
|
||||
...baseCondition,
|
||||
orgRootId: posMasterUser.orgRootId,
|
||||
orgRootId: In(roodIds),
|
||||
orgChild1Id: posMasterUser.orgChild1Id,
|
||||
orgChild2Id: IsNull(),
|
||||
},
|
||||
{
|
||||
...baseCondition,
|
||||
orgRootId: posMasterUser.orgRootId,
|
||||
orgRootId: In(roodIds),
|
||||
orgChild1Id: posMasterUser.orgChild1Id,
|
||||
orgChild2Id: posMasterUser.orgChild2Id,
|
||||
orgChild3Id: IsNull(),
|
||||
},
|
||||
{
|
||||
...baseCondition,
|
||||
orgRootId: posMasterUser.orgRootId,
|
||||
orgRootId: In(roodIds),
|
||||
orgChild1Id: posMasterUser.orgChild1Id,
|
||||
orgChild2Id: posMasterUser.orgChild2Id,
|
||||
orgChild3Id: posMasterUser.orgChild3Id,
|
||||
|
|
@ -951,7 +965,7 @@ export class WorkflowController extends Controller {
|
|||
},
|
||||
{
|
||||
...baseCondition,
|
||||
orgRootId: posMasterUser.orgRootId,
|
||||
orgRootId: In(roodIds),
|
||||
orgChild1Id: posMasterUser.orgChild1Id,
|
||||
orgChild2Id: posMasterUser.orgChild2Id,
|
||||
orgChild3Id: posMasterUser.orgChild3Id,
|
||||
|
|
@ -962,7 +976,7 @@ export class WorkflowController extends Controller {
|
|||
mainConditions = [
|
||||
{
|
||||
...baseCondition,
|
||||
orgRootId: posMasterUser.orgRootId,
|
||||
orgRootId: In(roodIds),
|
||||
orgChild1Id: IsNull(),
|
||||
orgChild2Id: IsNull(),
|
||||
orgChild3Id: IsNull(),
|
||||
|
|
@ -981,7 +995,7 @@ export class WorkflowController extends Controller {
|
|||
},
|
||||
];
|
||||
} else {
|
||||
mainConditions = [{ ...baseCondition, orgRootId: posMasterUser.orgRootId }];
|
||||
mainConditions = [{ ...baseCondition, orgRootId: In(roodIds) }];
|
||||
}
|
||||
|
||||
// 4. สร้าง optimized query builder
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue