search list kpi plan

This commit is contained in:
Kittapath 2024-04-20 12:51:44 +07:00
parent cfe9b4b105
commit 0d8d5c28aa
2 changed files with 14 additions and 12 deletions

View file

@ -265,13 +265,14 @@ export class kpiPlanController extends Controller {
async listKpiPlan(
@Query("page") page: number = 1,
@Query("pageSize") pageSize: number = 10,
@Query("round") round?: string,
@Query("kpiPeriodId") kpiPeriodId?: string,
@Query("nodeId") nodeId?: string | null,
@Query("node") node?: number | null,
@Query("keyword") keyword?: string,
) {
const [kpiPlan, total] = await AppDataSource.getRepository(KpiPlan)
.createQueryBuilder("kpiPlan")
.leftJoinAndSelect("kpiPlan.kpiPeriod", "kpiPeriod")
.andWhere(
node != undefined && node != null
? node == 4
@ -289,17 +290,17 @@ export class kpiPlanController extends Controller {
},
)
.andWhere(
round != undefined && round != null && round != ""
? "kpiPlan.kpiPeriodId LIKE :round"
kpiPeriodId != undefined && kpiPeriodId != null && kpiPeriodId != ""
? "kpiPlan.kpiPeriodId LIKE :kpiPeriodId"
: "1=1",
{
round: `${round}`,
kpiPeriodId: `${kpiPeriodId}`,
},
)
.select([
"kpiPlan.id",
"kpiPlan.year",
"kpiPlan.round",
"kpiPeriod.year",
"kpiPeriod.durationKPI",
"kpiPlan.including",
"kpiPlan.includingName",
])

View file

@ -209,7 +209,7 @@ export class kpiRoleController extends Controller {
async listKpiRole(
@Query("page") page: number = 1,
@Query("pageSize") pageSize: number = 10,
@Query("round") round?: string,
@Query("kpiPeriodId") kpiPeriodId?: string,
@Query("nodeId") nodeId?: string | null,
@Query("node") node?: number | null,
@Query("keyword") keyword?: string,
@ -217,6 +217,7 @@ export class kpiRoleController extends Controller {
) {
const [kpiRole, total] = await AppDataSource.getRepository(KpiRole)
.createQueryBuilder("kpiRole")
.leftJoinAndSelect("kpiRole.kpiPeriod", "kpiPeriod")
.andWhere(
node != undefined && node != null
? node == 4
@ -234,11 +235,11 @@ export class kpiRoleController extends Controller {
},
)
.andWhere(
round != undefined && round != null && round != ""
? "kpiRole.kpiPeriod LIKE :round"
kpiPeriodId != undefined && kpiPeriodId != null && kpiPeriodId != ""
? "kpiRole.kpiPeriod LIKE :kpiPeriodId"
: "1=1",
{
round: `${round}`,
kpiPeriodId: `${kpiPeriodId}`,
},
)
.andWhere(position != undefined ? "kpiRole.position LIKE :position" : "1=1", {
@ -246,8 +247,8 @@ export class kpiRoleController extends Controller {
})
.select([
"kpiRole.id",
"kpiRole.year",
"kpiRole.round",
"kpiPeriod.year",
"kpiPeriod.durationKPI",
"kpiRole.including",
"kpiRole.includingName",
])