Merge branch 'adiDev' into develop
This commit is contained in:
commit
0ef11abe2b
1 changed files with 46 additions and 13 deletions
|
|
@ -6220,8 +6220,10 @@ export class ProfileController extends Controller {
|
||||||
@Query() nodeId?: string,
|
@Query() nodeId?: string,
|
||||||
@Query() isAll?: boolean,
|
@Query() isAll?: boolean,
|
||||||
@Query() retireType?: string,
|
@Query() retireType?: string,
|
||||||
@Query() sortBy: string = "current_holders.posMasterNo",
|
// @Query() sortBy: string = "current_holders.posMasterNo",
|
||||||
@Query() sort: "ASC" | "DESC" = "ASC",
|
@Query() sort: "ASC" | "DESC" = "ASC",
|
||||||
|
@Query("sortBy") sortBy?: string,
|
||||||
|
@Query("descending") descending?: boolean,
|
||||||
) {
|
) {
|
||||||
let _data = await new permission().PermissionOrgList(request, "SYS_REGISTRY_OFFICER");
|
let _data = await new permission().PermissionOrgList(request, "SYS_REGISTRY_OFFICER");
|
||||||
let queryLike =
|
let queryLike =
|
||||||
|
|
@ -6261,7 +6263,7 @@ export class ProfileController extends Controller {
|
||||||
nodeCondition = nodeCondition + nodeAll;
|
nodeCondition = nodeCondition + nodeAll;
|
||||||
|
|
||||||
// เลือกเฉพาะฟิลด์ที่จำเป็น
|
// เลือกเฉพาะฟิลด์ที่จำเป็น
|
||||||
const [record, total] = await this.profileRepo
|
let query = await this.profileRepo
|
||||||
.createQueryBuilder("profile")
|
.createQueryBuilder("profile")
|
||||||
.leftJoin("profile.posLevel", "posLevel")
|
.leftJoin("profile.posLevel", "posLevel")
|
||||||
.leftJoin("profile.posType", "posType")
|
.leftJoin("profile.posType", "posType")
|
||||||
|
|
@ -6307,6 +6309,9 @@ export class ProfileController extends Controller {
|
||||||
"orgChild4.orgChild4Name",
|
"orgChild4.orgChild4Name",
|
||||||
"orgChild4.orgChild4ShortName",
|
"orgChild4.orgChild4ShortName",
|
||||||
"orgChild4.orgChild4Order",
|
"orgChild4.orgChild4Order",
|
||||||
|
"positions.id",
|
||||||
|
"posExecutive.id",
|
||||||
|
"posExecutive.posExecutiveName"
|
||||||
])
|
])
|
||||||
// .where(node && nodeId ? "current_holders.orgRevisionId = :orgRevisionId" : "1=1", {
|
// .where(node && nodeId ? "current_holders.orgRevisionId = :orgRevisionId" : "1=1", {
|
||||||
// orgRevisionId:
|
// orgRevisionId:
|
||||||
|
|
@ -6384,13 +6389,40 @@ export class ProfileController extends Controller {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.addSelect("CASE WHEN current_holders.posMasterNo IS NULL THEN 1 ELSE 0 END", "sort_order")
|
.addSelect("CASE WHEN current_holders.posMasterNo IS NULL THEN 1 ELSE 0 END", "sort_order")
|
||||||
.orderBy("sort_order", "ASC")
|
|
||||||
|
if (sortBy) {
|
||||||
|
if(sortBy === "posLevel"){
|
||||||
|
query = query.orderBy(
|
||||||
|
`posLevel.posLevelName`,
|
||||||
|
descending ? "DESC" : "ASC"
|
||||||
|
);
|
||||||
|
}else if(sortBy === "posType"){
|
||||||
|
query = query.orderBy(
|
||||||
|
`posType.posTypeName`,
|
||||||
|
descending ? "DESC" : "ASC"
|
||||||
|
);
|
||||||
|
}else if(sortBy === "posExecutive"){
|
||||||
|
query = query.orderBy(
|
||||||
|
`posExecutive.posExecutiveName`,
|
||||||
|
descending ? "DESC" : "ASC"
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
query = query.orderBy(
|
||||||
|
`profile.${sortBy}`,
|
||||||
|
descending ? "DESC" : "ASC"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
query = query.orderBy("sort_order", "ASC")
|
||||||
.addOrderBy("orgRoot.orgRootOrder", sort)
|
.addOrderBy("orgRoot.orgRootOrder", sort)
|
||||||
.addOrderBy("orgChild1.orgChild1Order", sort)
|
.addOrderBy("orgChild1.orgChild1Order", sort)
|
||||||
.addOrderBy("orgChild2.orgChild2Order", sort)
|
.addOrderBy("orgChild2.orgChild2Order", sort)
|
||||||
.addOrderBy("orgChild3.orgChild3Order", sort)
|
.addOrderBy("orgChild3.orgChild3Order", sort)
|
||||||
.addOrderBy("orgChild4.orgChild4Order", sort)
|
.addOrderBy("orgChild4.orgChild4Order", sort)
|
||||||
.addOrderBy("current_holders.posMasterNo", sort)
|
.addOrderBy("current_holders.posMasterNo", sort)
|
||||||
|
}
|
||||||
|
|
||||||
|
const [record, total] = await query
|
||||||
.skip((page - 1) * pageSize)
|
.skip((page - 1) * pageSize)
|
||||||
.take(pageSize)
|
.take(pageSize)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
@ -6437,6 +6469,7 @@ export class ProfileController extends Controller {
|
||||||
posLevelId: _data.posLevel?.id ?? null,
|
posLevelId: _data.posLevel?.id ?? null,
|
||||||
posTypeId: _data.posType?.id ?? null,
|
posTypeId: _data.posType?.id ?? null,
|
||||||
position: _data.position,
|
position: _data.position,
|
||||||
|
posExecutive: _data.current_holders[0].positions[0].posExecutive?.posExecutiveName ?? null,
|
||||||
posNo: shortName ?? null,
|
posNo: shortName ?? null,
|
||||||
rootId: holder?.orgRoot?.id ?? null,
|
rootId: holder?.orgRoot?.id ?? null,
|
||||||
root: holder?.orgRoot?.orgRootName ?? null,
|
root: holder?.orgRoot?.orgRootName ?? null,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue