Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 46s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 46s
* develop: sort ข้อมูลการประเมิน
This commit is contained in:
commit
4f64efd2c6
6 changed files with 80 additions and 8 deletions
|
|
@ -348,18 +348,29 @@ export class kpiCapacityController extends Controller {
|
|||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("type") type?: string,
|
||||
@Query("keyword") keyword?: string,
|
||||
@Query("sortBy") sortBy?: string,
|
||||
@Query("descending") descending?: boolean,
|
||||
) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_COMPETENCY");
|
||||
const [kpiCapacity, total] = await AppDataSource.getRepository(KpiCapacity)
|
||||
let query = await AppDataSource.getRepository(KpiCapacity)
|
||||
.createQueryBuilder("kpiCapacity")
|
||||
.leftJoinAndSelect("kpiCapacity.kpiCapacityDetails", "kpiCapacityDetail")
|
||||
.andWhere(keyword == undefined ? "1=1" : [{ name: Like(`%${keyword}%`) }])
|
||||
.andWhere(type == undefined ? "1=1" : { type: type })
|
||||
.orderBy("kpiCapacity.createdAt", "ASC")
|
||||
|
||||
if (sortBy) {
|
||||
query = query.orderBy(
|
||||
`kpiCapacity.${sortBy}`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
|
||||
const [kpiCapacity, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
|
||||
const mapFormula = kpiCapacity.map((item) => ({
|
||||
id: item.id,
|
||||
type: item.type,
|
||||
|
|
|
|||
|
|
@ -145,9 +145,12 @@ export class kpiGroupController extends Controller {
|
|||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("keyword") keyword?: string,
|
||||
@Query("sortBy") sortBy?: string,
|
||||
@Query("descending") descending?: boolean,
|
||||
) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_COMPETENCY");
|
||||
let whereClause: any = {};
|
||||
let sort: any = {};
|
||||
|
||||
if (keyword !== undefined && keyword !== "") {
|
||||
whereClause = {
|
||||
|
|
@ -155,12 +158,23 @@ export class kpiGroupController extends Controller {
|
|||
};
|
||||
}
|
||||
|
||||
if(sortBy){
|
||||
sort = {
|
||||
order: {[sortBy]: descending ? "DESC" : "ASC"}
|
||||
}
|
||||
}else{
|
||||
sort = {
|
||||
order: { createdAt: "ASC" },
|
||||
}
|
||||
}
|
||||
|
||||
const [kpiGroup, total] = await this.kpiGroupRepository.findAndCount({
|
||||
...whereClause,
|
||||
...(keyword ? {} : { skip: (page - 1) * pageSize, take: pageSize }),
|
||||
order: { createdAt: "ASC" },
|
||||
...sort
|
||||
});
|
||||
|
||||
|
||||
return new HttpSuccess({ data: kpiGroup, total });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -230,6 +230,8 @@ export class kpiLinkController extends Controller {
|
|||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("keyword") keyword?: string,
|
||||
@Query("sortBy") sortBy?: string,
|
||||
@Query("descending") descending?: boolean,
|
||||
) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_COMPETENCY");
|
||||
const [_kpiLink, _total] = await AppDataSource.getRepository(KpiLink)
|
||||
|
|
@ -253,7 +255,7 @@ export class kpiLinkController extends Controller {
|
|||
});
|
||||
}
|
||||
|
||||
const [kpiLink, total] = await AppDataSource.getRepository(KpiLink)
|
||||
let query = await AppDataSource.getRepository(KpiLink)
|
||||
.createQueryBuilder("kpiLink")
|
||||
.leftJoinAndSelect("kpiLink.kpiGroup", "kpiGroup")
|
||||
.leftJoinAndSelect("kpiLink.positions", "positions")
|
||||
|
|
@ -261,9 +263,20 @@ export class kpiLinkController extends Controller {
|
|||
.andWhere("kpiLink.id In (:id)", {
|
||||
id: _kpiLink.map((x) => x.id),
|
||||
})
|
||||
.orderBy("kpiLink.createdAt", "ASC")
|
||||
|
||||
if (sortBy) {
|
||||
if(sortBy == 'groupName'){
|
||||
query = query.orderBy(
|
||||
`kpiGroup.nameGroupKPI`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const [kpiLink, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.orderBy("kpiLink.createdAt", "ASC")
|
||||
.getManyAndCount();
|
||||
|
||||
if (_total === 0) {
|
||||
|
|
|
|||
|
|
@ -792,6 +792,8 @@ export class kpiPlanController extends Controller {
|
|||
keyword?: string | null;
|
||||
isAll?: boolean | false;
|
||||
// isNull?: boolean | false;
|
||||
sortBy?: string,
|
||||
descending?: boolean,
|
||||
},
|
||||
) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR");
|
||||
|
|
@ -842,7 +844,7 @@ export class kpiPlanController extends Controller {
|
|||
}
|
||||
parameters.nodeId = `%${requestBody.nodeId}%`;
|
||||
}
|
||||
const [kpiPlan, total] = await AppDataSource.getRepository(KpiPlan)
|
||||
let query = await AppDataSource.getRepository(KpiPlan)
|
||||
.createQueryBuilder("kpiPlan")
|
||||
.leftJoinAndSelect("kpiPlan.kpiPeriod", "kpiPeriod")
|
||||
.andWhere(condition, parameters)
|
||||
|
|
@ -877,6 +879,15 @@ export class kpiPlanController extends Controller {
|
|||
"kpiPlan.createdAt",
|
||||
])
|
||||
.orderBy("kpiPlan.createdAt", "DESC")
|
||||
|
||||
if (requestBody.sortBy) {
|
||||
query = query.orderBy(
|
||||
`kpiPlan.${requestBody.sortBy}`,
|
||||
requestBody.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
|
||||
const [kpiPlan, total] = await query
|
||||
.skip((requestBody.page - 1) * requestBody.pageSize)
|
||||
.take(requestBody.pageSize)
|
||||
.getManyAndCount();
|
||||
|
|
|
|||
|
|
@ -728,6 +728,8 @@ export class kpiRoleController extends Controller {
|
|||
keyword?: string | null;
|
||||
isAll?: boolean | false;
|
||||
// isNull?: boolean | false;
|
||||
sortBy?: string,
|
||||
descending?: boolean,
|
||||
},
|
||||
) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR");
|
||||
|
|
@ -783,7 +785,7 @@ export class kpiRoleController extends Controller {
|
|||
// parameters.year = `%${requestBody.year}%`;
|
||||
// parameters.period = `%${requestBody.period}%`;
|
||||
// }
|
||||
const [kpiRole, total] = await AppDataSource.getRepository(KpiRole)
|
||||
let query = await AppDataSource.getRepository(KpiRole)
|
||||
.createQueryBuilder("kpiRole")
|
||||
.leftJoinAndSelect("kpiRole.kpiPeriod", "kpiPeriod")
|
||||
.andWhere(condition, parameters)
|
||||
|
|
@ -830,10 +832,20 @@ export class kpiRoleController extends Controller {
|
|||
"kpiRole.createdAt",
|
||||
])
|
||||
.orderBy("kpiRole.createdAt", "DESC")
|
||||
|
||||
if (requestBody.sortBy) {
|
||||
query = query.orderBy(
|
||||
`kpiRole.${requestBody.sortBy}`,
|
||||
requestBody.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
|
||||
const [kpiRole, total] = await query
|
||||
.skip((requestBody.page - 1) * requestBody.pageSize)
|
||||
.take(requestBody.pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
|
||||
return new HttpSuccess({ data: kpiRole, total });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -330,6 +330,8 @@ export class kpiSpecialController extends Controller {
|
|||
year?: string | null;
|
||||
period?: string | null;
|
||||
keyword?: string | null;
|
||||
sortBy?: string,
|
||||
descending?: boolean,
|
||||
},
|
||||
) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR");
|
||||
|
|
@ -345,7 +347,7 @@ export class kpiSpecialController extends Controller {
|
|||
// };
|
||||
// }
|
||||
|
||||
const [kpiSpecial, total] = await AppDataSource.getRepository(KpiSpecial)
|
||||
let query = await AppDataSource.getRepository(KpiSpecial)
|
||||
.createQueryBuilder("kpiSpecial")
|
||||
// .andWhere(condition)
|
||||
.andWhere(requestBody.year ? "kpiSpecial.year LIKE :year" : "1=1", {
|
||||
|
|
@ -372,6 +374,15 @@ export class kpiSpecialController extends Controller {
|
|||
"kpiSpecial.createdAt",
|
||||
])
|
||||
.orderBy("kpiSpecial.createdAt", "DESC")
|
||||
|
||||
if (requestBody.sortBy) {
|
||||
query = query.orderBy(
|
||||
`kpiSpecial.${requestBody.sortBy}`,
|
||||
requestBody.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
|
||||
const [kpiSpecial, total] = await query
|
||||
.skip((requestBody.page - 1) * requestBody.pageSize)
|
||||
.take(requestBody.pageSize)
|
||||
.getManyAndCount();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue