sort ประเมินผลการปฏิบัติราชการระดับบุคคล
This commit is contained in:
parent
50da2b4e70
commit
254d6ae810
3 changed files with 135 additions and 17 deletions
|
|
@ -235,20 +235,32 @@ export class kpiPeriodController extends Controller {
|
|||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("year") year?: number,
|
||||
@Query("keyword") keyword?: string,
|
||||
@Query("sortBy") sortBy?: string,
|
||||
@Query("descending") descending?: boolean,
|
||||
) {
|
||||
await new permission().PermissionList(request, "SYS_KPI_ROUND");
|
||||
const [kpiPeriod, total] = await AppDataSource.getRepository(KpiPeriod)
|
||||
let query = await AppDataSource.getRepository(KpiPeriod)
|
||||
.createQueryBuilder("kpiPeriod")
|
||||
.andWhere(
|
||||
year !== 0 && year != null && year != undefined ? "kpiPeriod.year = :year" : "1=1",
|
||||
{ year: year },
|
||||
)
|
||||
.orderBy("kpiPeriod.year", "DESC")
|
||||
.addOrderBy("kpiPeriod.durationKPI", "DESC")
|
||||
.addOrderBy("kpiPeriod.startDate", "DESC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
if (sortBy) {
|
||||
query = query.orderBy(
|
||||
`kpiPeriod.${sortBy}`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else{
|
||||
query = query.orderBy("kpiPeriod.year", "DESC")
|
||||
.addOrderBy("kpiPeriod.durationKPI", "DESC")
|
||||
.addOrderBy("kpiPeriod.startDate", "DESC")
|
||||
}
|
||||
|
||||
const [kpiPeriod, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
return new HttpSuccess({ data: kpiPeriod, total });
|
||||
}
|
||||
|
|
@ -290,15 +302,27 @@ export class kpiPeriodController extends Controller {
|
|||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("year") year?: number,
|
||||
@Query("keyword") keyword?: string,
|
||||
@Query("sortBy") sortBy?: string,
|
||||
@Query("descending") descending?: boolean,
|
||||
) {
|
||||
const [kpiPeriod, total] = await AppDataSource.getRepository(KpiPeriod)
|
||||
let query = await AppDataSource.getRepository(KpiPeriod)
|
||||
.createQueryBuilder("kpiPeriod")
|
||||
.andWhere(
|
||||
year !== 0 && year != null && year != undefined ? "kpiPeriod.year = :year" : "1=1",
|
||||
{ year: year },
|
||||
)
|
||||
.orderBy("kpiPeriod.year", "DESC")
|
||||
.addOrderBy("kpiPeriod.createdAt", "DESC")
|
||||
|
||||
if (sortBy) {
|
||||
query = query.orderBy(
|
||||
`developmentRequest.${sortBy}`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else{
|
||||
query = query.orderBy("kpiPeriod.year", "DESC")
|
||||
.addOrderBy("kpiPeriod.createdAt", "DESC")
|
||||
}
|
||||
|
||||
const [kpiPeriod, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
|
|
|||
|
|
@ -360,6 +360,8 @@ export class KpiUserDevelopmentController extends Controller {
|
|||
// results?: string | null;
|
||||
// reqedit?: string | null;
|
||||
// evaluating?: boolean | null;
|
||||
sortBy?: string;
|
||||
descending?: boolean;
|
||||
},
|
||||
) {
|
||||
// await new permission().PermissionList(request, "SYS_RESULT");
|
||||
|
|
@ -372,7 +374,7 @@ export class KpiUserDevelopmentController extends Controller {
|
|||
_data = x;
|
||||
})
|
||||
.catch((x) => {});
|
||||
const [kpiUserDevelopment, total] = await AppDataSource.getRepository(KpiUserDevelopment)
|
||||
let query = await AppDataSource.getRepository(KpiUserDevelopment)
|
||||
.createQueryBuilder("kpiUserDevelopment")
|
||||
.leftJoinAndSelect("kpiUserDevelopment.kpiUserEvaluation", "kpiUserEvaluation")
|
||||
.leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod")
|
||||
|
|
@ -476,7 +478,46 @@ export class KpiUserDevelopmentController extends Controller {
|
|||
});
|
||||
}),
|
||||
)
|
||||
.orderBy("kpiUserDevelopment.createdAt", "ASC")
|
||||
|
||||
if (requestBody.sortBy) {
|
||||
if(requestBody.sortBy === "developmentName"){
|
||||
query = query.orderBy(
|
||||
`kpiUserDevelopment.name`,
|
||||
requestBody.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else if (requestBody.sortBy === "organization"){
|
||||
query = query
|
||||
.orderBy(`kpiUserEvaluation.child4`, requestBody.descending ? "DESC" : "ASC")
|
||||
.addOrderBy(`kpiUserEvaluation.child3`, requestBody.descending ? "DESC" : "ASC")
|
||||
.addOrderBy(`kpiUserEvaluation.child2`, requestBody.descending ? "DESC" : "ASC")
|
||||
.addOrderBy(`kpiUserEvaluation.child1`, requestBody.descending ? "DESC" : "ASC")
|
||||
.addOrderBy(`kpiUserEvaluation.org`, requestBody.descending ? "DESC" : "ASC");
|
||||
}else if(requestBody.sortBy === "firstname"){
|
||||
query = query.orderBy(
|
||||
`kpiUserEvaluation.firstName`,
|
||||
requestBody.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else if(requestBody.sortBy === "lastname"){
|
||||
query = query.orderBy(
|
||||
`kpiUserEvaluation.lastName`,
|
||||
requestBody.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else if(requestBody.sortBy === "root"){
|
||||
query = query.orderBy(
|
||||
`kpiUserEvaluation.org`,
|
||||
requestBody.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else{
|
||||
query = query.orderBy(
|
||||
`kpiUserEvaluation.${requestBody.sortBy}`,
|
||||
requestBody.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
}else{
|
||||
query = query.orderBy("kpiUserDevelopment.createdAt", "ASC")
|
||||
}
|
||||
|
||||
const [kpiUserDevelopment, total] = await query
|
||||
.skip((requestBody.page - 1) * requestBody.pageSize)
|
||||
.take(requestBody.pageSize)
|
||||
.getManyAndCount();
|
||||
|
|
|
|||
|
|
@ -241,6 +241,8 @@ export class KpiUserEvaluationController extends Controller {
|
|||
results?: string | null;
|
||||
reqedit?: string | null;
|
||||
evaluating?: boolean | null;
|
||||
sortBy?: string;
|
||||
descending?: boolean;
|
||||
},
|
||||
) {
|
||||
// await new permission().PermissionList(request, "SYS_RESULT");
|
||||
|
|
@ -253,7 +255,7 @@ export class KpiUserEvaluationController extends Controller {
|
|||
_data = x;
|
||||
})
|
||||
.catch((x) => {});
|
||||
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||
let query = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||
.createQueryBuilder("kpiUserEvaluation")
|
||||
.andWhere(
|
||||
_data.root != undefined && _data.root != null
|
||||
|
|
@ -385,7 +387,32 @@ export class KpiUserEvaluationController extends Controller {
|
|||
});
|
||||
}),
|
||||
)
|
||||
.orderBy("kpiUserEvaluation.createdAt", "DESC")
|
||||
|
||||
if (requestBody.sortBy) {
|
||||
if(requestBody.sortBy === "root"){
|
||||
query = query.orderBy(
|
||||
`kpiUserEvaluation.org`,
|
||||
requestBody.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else if(requestBody.sortBy === "organization"){
|
||||
query = query
|
||||
.orderBy(`kpiUserEvaluation.child4`, requestBody.descending ? "DESC" : "ASC")
|
||||
.addOrderBy(`kpiUserEvaluation.child3`, requestBody.descending ? "DESC" : "ASC")
|
||||
.addOrderBy(`kpiUserEvaluation.child2`, requestBody.descending ? "DESC" : "ASC")
|
||||
.addOrderBy(`kpiUserEvaluation.child1`, requestBody.descending ? "DESC" : "ASC")
|
||||
.addOrderBy(`kpiUserEvaluation.org`, requestBody.descending ? "DESC" : "ASC");
|
||||
}else{
|
||||
query = query.orderBy(
|
||||
`kpiUserEvaluation.${requestBody.sortBy}`,
|
||||
requestBody.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
}else{
|
||||
query = query.orderBy("kpiPeriod.year", "DESC")
|
||||
.addOrderBy("kpiUserEvaluation.createdAt", "DESC")
|
||||
}
|
||||
|
||||
const [kpiUserEvaluation, total] = await query
|
||||
.skip((requestBody.page - 1) * requestBody.pageSize)
|
||||
.take(requestBody.pageSize)
|
||||
.getManyAndCount();
|
||||
|
|
@ -441,6 +468,8 @@ export class KpiUserEvaluationController extends Controller {
|
|||
keyword?: string;
|
||||
status?: string | null;
|
||||
results?: string | null;
|
||||
sortBy?: string;
|
||||
descending?: boolean;
|
||||
},
|
||||
) {
|
||||
let _data = await new permission().PermissionOrgList(request, "SYS_KPI_LIST");
|
||||
|
|
@ -452,7 +481,7 @@ export class KpiUserEvaluationController extends Controller {
|
|||
.catch((x) => {});
|
||||
let conditionFullName =
|
||||
"CONCAT(kpiUserEvaluation.prefix, kpiUserEvaluation.firstName, ' ', kpiUserEvaluation.lastName) LIKE :keyword";
|
||||
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||
let query = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||
.createQueryBuilder("kpiUserEvaluation")
|
||||
.leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod")
|
||||
.andWhere(
|
||||
|
|
@ -564,8 +593,32 @@ export class KpiUserEvaluationController extends Controller {
|
|||
child4: _data.child4,
|
||||
},
|
||||
)
|
||||
.orderBy("kpiPeriod.year", "DESC")
|
||||
.addOrderBy("kpiUserEvaluation.createdAt", "DESC")
|
||||
|
||||
if (requestBody.sortBy) {
|
||||
if(requestBody.sortBy === "root"){
|
||||
query = query.orderBy(
|
||||
`kpiUserEvaluation.org`,
|
||||
requestBody.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else if(requestBody.sortBy === "organization"){
|
||||
query = query
|
||||
.orderBy(`kpiUserEvaluation.child4`, requestBody.descending ? "DESC" : "ASC")
|
||||
.addOrderBy(`kpiUserEvaluation.child3`, requestBody.descending ? "DESC" : "ASC")
|
||||
.addOrderBy(`kpiUserEvaluation.child2`, requestBody.descending ? "DESC" : "ASC")
|
||||
.addOrderBy(`kpiUserEvaluation.child1`, requestBody.descending ? "DESC" : "ASC")
|
||||
.addOrderBy(`kpiUserEvaluation.org`, requestBody.descending ? "DESC" : "ASC");
|
||||
}else{
|
||||
query = query.orderBy(
|
||||
`kpiUserEvaluation.${requestBody.sortBy}`,
|
||||
requestBody.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
}else{
|
||||
query = query.orderBy("kpiPeriod.year", "DESC")
|
||||
.addOrderBy("kpiUserEvaluation.createdAt", "DESC")
|
||||
}
|
||||
|
||||
const [kpiUserEvaluation, total] = await query
|
||||
.skip((requestBody.page - 1) * requestBody.pageSize)
|
||||
.take(requestBody.pageSize)
|
||||
.getManyAndCount();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue