ค้นหาทะเบียนประวัติ
This commit is contained in:
parent
a01c657512
commit
124e6ea1d7
1 changed files with 47 additions and 21 deletions
|
|
@ -333,31 +333,13 @@ export class ProfileController extends Controller {
|
||||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||||
.leftJoinAndSelect("profile.posType", "posType")
|
.leftJoinAndSelect("profile.posType", "posType")
|
||||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||||
|
.leftJoinAndSelect("current_holders.positions", "positions")
|
||||||
|
.leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
||||||
.leftJoinAndSelect("current_holders.orgRoot", "orgRoot")
|
.leftJoinAndSelect("current_holders.orgRoot", "orgRoot")
|
||||||
.leftJoinAndSelect("current_holders.orgChild1", "orgChild1")
|
.leftJoinAndSelect("current_holders.orgChild1", "orgChild1")
|
||||||
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
|
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
|
||||||
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
||||||
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||||
.select([
|
|
||||||
"profile.id",
|
|
||||||
"profile.rank",
|
|
||||||
"profile.prefix",
|
|
||||||
"profile.firstName",
|
|
||||||
"profile.lastName",
|
|
||||||
"profile.citizenId",
|
|
||||||
"profile.birthDate",
|
|
||||||
"profile.isProbation",
|
|
||||||
"profile.dateRetire",
|
|
||||||
"profile.position",
|
|
||||||
"posType.posTypeName",
|
|
||||||
"posLevel.posLevelName",
|
|
||||||
"current_holders.posMasterNo",
|
|
||||||
// "orgRoot?.orgRootShortName",
|
|
||||||
// "orgChild1?.orgRootShortName",
|
|
||||||
// "orgChild2?.orgRootShortName",
|
|
||||||
// "orgChild3?.orgRootShortName",
|
|
||||||
// "orgChild4?.orgRootShortName",
|
|
||||||
])
|
|
||||||
.andWhere(
|
.andWhere(
|
||||||
searchKeyword != undefined && searchKeyword != null && searchKeyword != ""
|
searchKeyword != undefined && searchKeyword != null && searchKeyword != ""
|
||||||
? queryLike
|
? queryLike
|
||||||
|
|
@ -397,8 +379,52 @@ export class ProfileController extends Controller {
|
||||||
.skip((page - 1) * pageSize)
|
.skip((page - 1) * pageSize)
|
||||||
.take(pageSize)
|
.take(pageSize)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
const data = await Promise.all(
|
||||||
|
record.map((_data) => {
|
||||||
|
const posExecutive =
|
||||||
|
_data.current_holders.length == 0 ||
|
||||||
|
_data.current_holders[0].positions.length == 0 ||
|
||||||
|
_data.current_holders[0].positions.find((x: any) => x.positionIsSelected == true) ==
|
||||||
|
null ||
|
||||||
|
_data.current_holders[0].positions.find((x: any) => x.positionIsSelected == true)
|
||||||
|
?.posExecutive == null
|
||||||
|
? null
|
||||||
|
: _data.current_holders[0].positions.find((x: any) => x.positionIsSelected == true)
|
||||||
|
?.posExecutive?.posExecutiveName;
|
||||||
|
|
||||||
return new HttpSuccess({ data: record, total });
|
const shortName =
|
||||||
|
_data.current_holders.length == 0
|
||||||
|
? null
|
||||||
|
: _data.current_holders[0].orgChild4 != null
|
||||||
|
? `${_data.current_holders[0].orgChild4.orgChild4ShortName}${_data.current_holders[0].posMasterNo}`
|
||||||
|
: _data.current_holders[0].orgChild3 != null
|
||||||
|
? `${_data.current_holders[0].orgChild3.orgChild3ShortName}${_data.current_holders[0].posMasterNo}`
|
||||||
|
: _data.current_holders[0].orgChild2 != null
|
||||||
|
? `${_data.current_holders[0].orgChild2.orgChild2ShortName}${_data.current_holders[0].posMasterNo}`
|
||||||
|
: _data.current_holders[0].orgChild1 != null
|
||||||
|
? `${_data.current_holders[0].orgChild1.orgChild1ShortName}${_data.current_holders[0].posMasterNo}`
|
||||||
|
: _data.current_holders[0].orgRoot != null
|
||||||
|
? `${_data.current_holders[0].orgRoot.orgRootShortName}${_data.current_holders[0].posMasterNo}`
|
||||||
|
: null;
|
||||||
|
return {
|
||||||
|
id: _data.id,
|
||||||
|
prefix: _data.prefix,
|
||||||
|
rank: _data.rank,
|
||||||
|
firstName: _data.firstName,
|
||||||
|
lastName: _data.lastName,
|
||||||
|
citizenId: _data.citizenId,
|
||||||
|
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
|
||||||
|
posType: _data.posType == null ? null : _data.posType.posTypeName,
|
||||||
|
posLevelId: _data.posLevel == null ? null : _data.posLevel.id,
|
||||||
|
posTypeId: _data.posType == null ? null : _data.posType.id,
|
||||||
|
position: _data.position,
|
||||||
|
posExecutive: posExecutive,
|
||||||
|
posNo: shortName,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
return new HttpSuccess({ data: data, total });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue