ค้นหารักษาการ

This commit is contained in:
mamoss 2025-07-26 12:40:02 +07:00
parent de65c06b71
commit 17c76ee1cc

View file

@ -433,6 +433,11 @@ export class PosMasterActController extends Controller {
.leftJoinAndSelect("positions.posLevel", "posLevel") .leftJoinAndSelect("positions.posLevel", "posLevel")
.leftJoinAndSelect("posMasterAct.posMaster", "posMaster") .leftJoinAndSelect("posMasterAct.posMaster", "posMaster")
.leftJoinAndSelect("posMaster.positions", "positionActs") .leftJoinAndSelect("posMaster.positions", "positionActs")
.leftJoinAndSelect("posMaster.orgRoot", "orgRootAct")
.leftJoinAndSelect("posMaster.orgChild1", "orgChild1Act")
.leftJoinAndSelect("posMaster.orgChild2", "orgChild2Act")
.leftJoinAndSelect("posMaster.orgChild3", "orgChild3Act")
.leftJoinAndSelect("posMaster.orgChild4", "orgChild4Act")
.leftJoinAndSelect("positionActs.posType", "posTypeAct") .leftJoinAndSelect("positionActs.posType", "posTypeAct")
.leftJoinAndSelect("positionActs.posLevel", "posLevelAct") .leftJoinAndSelect("positionActs.posLevel", "posLevelAct")
.leftJoinAndSelect("posMasterChild.orgRevision", "orgRevision") .leftJoinAndSelect("posMasterChild.orgRevision", "orgRevision")
@ -447,8 +452,8 @@ export class PosMasterActController extends Controller {
.andWhere("orgRevision.orgRevisionIsDraft = :orgRevisionIsDraft", { .andWhere("orgRevision.orgRevisionIsDraft = :orgRevisionIsDraft", {
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
}) })
// .andWhere("positions.positionIsSelected = :isSelected", { isSelected: true }) .andWhere("positions.positionIsSelected = :isSelected", { isSelected: true })
.andWhere("positionActs.positionIsSelected = :isSelected", { isSelected: true }) // .andWhere("positionActs.positionIsSelected = :isSelected", { isSelected: true })
.andWhere( .andWhere(
new Brackets((qb) => { new Brackets((qb) => {
qb.andWhere(conditionGroup); qb.andWhere(conditionGroup);
@ -467,6 +472,12 @@ export class PosMasterActController extends Controller {
"orgChild2.orgChild2ShortName", "orgChild2.orgChild2ShortName",
"orgChild3.orgChild3ShortName", "orgChild3.orgChild3ShortName",
"orgChild4.orgChild4ShortName", "orgChild4.orgChild4ShortName",
"posMaster.posMasterNo",
"orgRootAct.orgRootShortName",
"orgChild1Act.orgChild1ShortName",
"orgChild2Act.orgChild2ShortName",
"orgChild3Act.orgChild3ShortName",
"orgChild4Act.orgChild4ShortName",
"current_holder.prefix", "current_holder.prefix",
"current_holder.firstName", "current_holder.firstName",
"current_holder.lastName", "current_holder.lastName",
@ -476,17 +487,33 @@ export class PosMasterActController extends Controller {
.getMany(); .getMany();
const _posMaster = posMaster.map((x) => { const _posMaster = posMaster.map((x) => {
const posMasterNo = const posMasterNo =
x.posMasterChild.orgChild4 != null [
? `${x.posMasterChild.orgChild4.orgChild4ShortName} ${x.posMasterChild.posMasterNo}` x.posMasterChild?.orgChild4?.orgChild4ShortName,
: x.posMasterChild != null && x?.posMasterChild?.orgChild3 != null x.posMasterChild?.orgChild3?.orgChild3ShortName,
? `${x.posMasterChild.orgChild3.orgChild3ShortName} ${x.posMasterChild.posMasterNo}` x.posMasterChild?.orgChild2?.orgChild2ShortName,
: x.posMasterChild != null && x?.posMasterChild?.orgChild2 != null x.posMasterChild?.orgChild1?.orgChild1ShortName,
? `${x.posMasterChild.orgChild2.orgChild2ShortName} ${x.posMasterChild.posMasterNo}` x.posMasterChild?.orgRoot?.orgRootShortName,
: x.posMasterChild != null && x?.posMasterChild?.orgChild1 != null ].find((name) => !!name) && x.posMasterChild?.posMasterNo
? `${x.posMasterChild.orgChild1.orgChild1ShortName} ${x.posMasterChild.posMasterNo}` ? `${[
: x.posMasterChild != null && x?.posMasterChild?.orgRoot != null x.posMasterChild?.orgChild4?.orgChild4ShortName,
? `${x.posMasterChild.orgRoot.orgRootShortName} ${x.posMasterChild.posMasterNo}` x.posMasterChild?.orgChild3?.orgChild3ShortName,
: null; x.posMasterChild?.orgChild2?.orgChild2ShortName,
x.posMasterChild?.orgChild1?.orgChild1ShortName,
x.posMasterChild?.orgRoot?.orgRootShortName,
].find((name) => !!name)} ${x.posMasterChild.posMasterNo}`
: x.posMasterChild?.posMasterNo || null;
const orgShortNameAct =
[
x.posMaster?.orgChild4?.orgChild4ShortName,
x.posMaster?.orgChild3?.orgChild3ShortName,
x.posMaster?.orgChild2?.orgChild2ShortName,
x.posMaster?.orgChild1?.orgChild1ShortName,
x.posMaster?.orgRoot?.orgRootShortName,
].find((name) => !!name) || "";
const posMasterNoAct =
orgShortNameAct && x.posMaster?.posMasterNo
? `${orgShortNameAct} ${x.posMaster.posMasterNo}`
: x.posMaster?.posMasterNo || null;
const position = const position =
x.posMasterChild.positions.filter((x) => x.positionIsSelected == true).length > 0 x.posMasterChild.positions.filter((x) => x.positionIsSelected == true).length > 0
? x.posMasterChild.positions.filter((x) => x.positionIsSelected == true)[0] ? x.posMasterChild.positions.filter((x) => x.positionIsSelected == true)[0]
@ -494,6 +521,7 @@ export class PosMasterActController extends Controller {
return { return {
id: x.id, id: x.id,
posMasterNo: posMasterNo, posMasterNo: posMasterNo,
posMasterNoAct: posMasterNoAct,
positionName: position?.positionName || null, positionName: position?.positionName || null,
posType: position?.posType?.posTypeName || null, posType: position?.posType?.posTypeName || null,
posLevel: position?.posLevel?.posLevelName || null, posLevel: position?.posLevel?.posLevelName || null,