เพิ่ม parth api ใช่ซ้ำกันในหลายเมนู (ข้อมูลแบบปนะเมิน>>>ตัวชี้วัด)
This commit is contained in:
parent
b95cda9512
commit
62d3824b4a
3 changed files with 279 additions and 0 deletions
|
|
@ -618,6 +618,118 @@ export class kpiPlanController extends Controller {
|
|||
return new HttpSuccess({ data: kpiPlan, total });
|
||||
}
|
||||
|
||||
/**
|
||||
* API list ตัวชี้วัดตามแผนฯ
|
||||
* @param page
|
||||
* @param pageSize
|
||||
* @param keyword
|
||||
*/
|
||||
@Post("search-kpi-plan")
|
||||
async searchKpiPlan(
|
||||
@Request() request: RequestWithUser,
|
||||
@Body()
|
||||
requestBody: {
|
||||
page: number;
|
||||
pageSize: number;
|
||||
year?: string | null;
|
||||
period?: string | null;
|
||||
nodeId?: string | null;
|
||||
node?: number | null;
|
||||
keyword?: string | null;
|
||||
isAll?: boolean | false;
|
||||
// isNull?: boolean | false;
|
||||
},
|
||||
) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_KPI_LIST");
|
||||
let condition = "";
|
||||
let parameters: any = {};
|
||||
if (requestBody.isAll === false) {
|
||||
switch (requestBody.node) {
|
||||
case 0:
|
||||
condition = "kpiPlan.rootId LIKE :nodeId AND kpiPlan.child1Id IS NULL";
|
||||
break;
|
||||
case 1:
|
||||
condition = "kpiPlan.child1Id LIKE :nodeId AND kpiPlan.child2Id IS NULL";
|
||||
break;
|
||||
case 2:
|
||||
condition = "kpiPlan.child2Id LIKE :nodeId AND kpiPlan.child3Id IS NULL";
|
||||
break;
|
||||
case 3:
|
||||
condition = "kpiPlan.child3Id LIKE :nodeId AND kpiPlan.child4Id IS NULL";
|
||||
break;
|
||||
case 4:
|
||||
condition = "kpiPlan.child4Id LIKE :nodeId";
|
||||
break;
|
||||
default:
|
||||
condition = "1=1";
|
||||
break;
|
||||
}
|
||||
parameters.nodeId = `%${requestBody.nodeId}%`;
|
||||
} else {
|
||||
switch (requestBody.node) {
|
||||
case 0:
|
||||
condition = "kpiPlan.rootId LIKE :nodeId";
|
||||
break;
|
||||
case 1:
|
||||
condition = "kpiPlan.child1Id LIKE :nodeId";
|
||||
break;
|
||||
case 2:
|
||||
condition = "kpiPlan.child2Id LIKE :nodeId";
|
||||
break;
|
||||
case 3:
|
||||
condition = "kpiPlan.child3Id LIKE :nodeId";
|
||||
break;
|
||||
case 4:
|
||||
condition = "kpiPlan.child4Id LIKE :nodeId";
|
||||
break;
|
||||
default:
|
||||
condition = "1=1";
|
||||
break;
|
||||
}
|
||||
parameters.nodeId = `%${requestBody.nodeId}%`;
|
||||
}
|
||||
const [kpiPlan, total] = await AppDataSource.getRepository(KpiPlan)
|
||||
.createQueryBuilder("kpiPlan")
|
||||
.leftJoinAndSelect("kpiPlan.kpiPeriod", "kpiPeriod")
|
||||
.andWhere(condition, parameters)
|
||||
.andWhere(requestBody.year ? "kpiPlan.year LIKE :year" : "1=1", {
|
||||
year: `%${requestBody.year}%`,
|
||||
})
|
||||
.andWhere(requestBody.period ? "kpiPlan.period LIKE :period" : "1=1", {
|
||||
period: `%${requestBody.period}%`,
|
||||
})
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.orWhere("kpiPlan.including LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiPlan.includingName LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiPlan.year LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiPlan.period LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
});
|
||||
}),
|
||||
)
|
||||
.select([
|
||||
"kpiPlan.id",
|
||||
"kpiPeriod.year",
|
||||
"kpiPeriod.durationKPI",
|
||||
"kpiPlan.including",
|
||||
"kpiPlan.includingName",
|
||||
"kpiPlan.createdAt",
|
||||
])
|
||||
.orderBy("kpiPlan.createdAt", "DESC")
|
||||
.skip((requestBody.page - 1) * requestBody.pageSize)
|
||||
.take(requestBody.pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
return new HttpSuccess({ data: kpiPlan, total });
|
||||
}
|
||||
|
||||
/**
|
||||
* API list ตัวชี้วัดตามแผนฯ
|
||||
* @param page
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue