filter รักษาการ

This commit is contained in:
mamoss 2025-07-18 16:33:09 +07:00
parent d9a92eda9d
commit 3ae17c23e2
3 changed files with 52 additions and 80 deletions

View file

@ -4554,7 +4554,7 @@ export class PositionController extends Controller {
) {
await new permission().PermissionGet(request, "SYS_ACTING");
const posMasterMain = await this.posMasterRepository.findOne({
where: { id: body.posmasterId },
where: { id: body.posmasterId, posMasterActs: { statusReport: "DONE" } },
relations: ["posMasterActs"],
});
if (posMasterMain == null) {
@ -5050,19 +5050,21 @@ export class PositionController extends Controller {
: `CASE WHEN posMaster.orgChild1 is null THEN ${searchShortName0} WHEN posMaster.orgChild2 is null THEN ${searchShortName1} WHEN posMaster.orgChild3 is null THEN ${searchShortName2} WHEN posMaster.orgChild4 is null THEN ${searchShortName3} ELSE ${searchShortName4} END LIKE '%${body.keyword}%'`
: "1=1",
)
.andWhere(checkChildConditions)
.andWhere(typeCondition)
.andWhere(revisionCondition)
.andWhere({ current_holderId: IsNull() });
.andWhere(checkChildConditions)
.andWhere(typeCondition)
.andWhere(revisionCondition)
.andWhere({ current_holderId: IsNull() });
}),
)
.orWhere(
new Brackets((qb) => {
qb.andWhere(`posMaster.conditionReason LIKE '%${body.keyword}%' AND posMaster.conditionReason IS NOT NULL`)
.andWhere(checkChildConditions)
.andWhere(typeCondition)
.andWhere(revisionCondition)
.andWhere({ current_holderId: IsNull() });
qb.andWhere(
`posMaster.conditionReason LIKE '%${body.keyword}%' AND posMaster.conditionReason IS NOT NULL`,
)
.andWhere(checkChildConditions)
.andWhere(typeCondition)
.andWhere(revisionCondition)
.andWhere({ current_holderId: IsNull() });
}),
)
.orderBy("orgRoot.orgRootOrder", "ASC")