sort แก้ไขทะเบียนประวัติ ตำแหน่ง/เงินเดือน
@Get: api/v1/org/profile/salaryTemp
This commit is contained in:
parent
c5b54d55de
commit
f2ea301d44
1 changed files with 70 additions and 10 deletions
|
|
@ -64,6 +64,8 @@ export class ProfileSalaryTempController extends Controller {
|
|||
@Query() searchKeyword: string = "",
|
||||
@Query() statusCheckEdit?: string | null,
|
||||
@Query() rootId?: string,
|
||||
@Query("sortBy") sortBy?: string,
|
||||
@Query("descending") descending?: boolean,
|
||||
) {
|
||||
if (type.trim().toUpperCase() == "OFFICER") {
|
||||
let _data = await new permission().PermissionOrgList(request, "SYS_REGISTRY_OFFICER");
|
||||
|
|
@ -78,7 +80,7 @@ export class ProfileSalaryTempController extends Controller {
|
|||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
const [record, total] = await this.profileRepo
|
||||
let query = await this.profileRepo
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profile.posType", "posType")
|
||||
|
|
@ -321,17 +323,49 @@ export class ProfileSalaryTempController extends Controller {
|
|||
rootId: rootId,
|
||||
})
|
||||
.addSelect("CASE WHEN current_holders.posMasterNo IS NULL THEN 1 ELSE 0 END", "sort_order")
|
||||
.orderBy("sort_order", "ASC")
|
||||
// .orderBy(`${sortBy}`, sort)
|
||||
|
||||
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 if(sortBy == "posNo"){
|
||||
query = query.orderBy(
|
||||
`orgRoot.orgRootShortName`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else{
|
||||
query = query.orderBy(
|
||||
`profile.${sortBy}`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
}else{
|
||||
query = query.orderBy("sort_order", "ASC")
|
||||
.addOrderBy("orgRoot.orgRootOrder", "ASC")
|
||||
.addOrderBy("orgChild1.orgChild1Order", "ASC")
|
||||
.addOrderBy("orgChild2.orgChild2Order", "ASC")
|
||||
.addOrderBy("orgChild3.orgChild3Order", "ASC")
|
||||
.addOrderBy("orgChild4.orgChild4Order", "ASC")
|
||||
.addOrderBy("current_holders.posMasterNo", "ASC")
|
||||
// .orderBy(`${sortBy}`, sort)
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
}
|
||||
|
||||
const [record, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const data = await Promise.all(
|
||||
record.map((_data) => {
|
||||
|
|
@ -465,7 +499,7 @@ export class ProfileSalaryTempController extends Controller {
|
|||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
const [record, total] = await this.profileEmployeeRepo
|
||||
let query = await this.profileEmployeeRepo
|
||||
.createQueryBuilder("profileEmployee")
|
||||
.leftJoinAndSelect("profileEmployee.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profileEmployee.posType", "posType")
|
||||
|
|
@ -721,9 +755,35 @@ export class ProfileSalaryTempController extends Controller {
|
|||
})
|
||||
.orderBy("current_holders.posMasterNo", "ASC")
|
||||
// .orderBy(`${sortBy}`, sort)
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
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 == "posNo"){
|
||||
query = query.orderBy(
|
||||
`orgRoot.orgRootShortName`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else{
|
||||
query = query.orderBy(
|
||||
`profileEmployee.${sortBy}`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
}
|
||||
const [record, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const data = await Promise.all(
|
||||
record.map((_data) => {
|
||||
const shortName =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue