ค้นหาสถานะ

This commit is contained in:
Kittapath 2024-05-09 15:20:49 +07:00
parent 427fc8a142
commit 9a85609e93
4 changed files with 45 additions and 13 deletions

View file

@ -162,21 +162,21 @@ export class kpiSpecialController extends Controller {
keyword?: string | null;
},
) {
let condition: any = {};
if (requestBody.keyword !== undefined && requestBody.keyword !== "") {
condition = {
where: [
{
including: Like(`%${requestBody.keyword}%`),
includingName: Like(`%${requestBody.keyword}%`),
},
],
};
}
// let condition: any = {};
// if (requestBody.keyword !== undefined && requestBody.keyword !== "") {
// condition = {
// where: [
// {
// including: Like(`%${requestBody.keyword}%`),
// includingName: Like(`%${requestBody.keyword}%`),
// },
// ],
// };
// }
const [kpiSpecial, total] = await AppDataSource.getRepository(KpiSpecial)
.createQueryBuilder("kpiSpecial")
.andWhere(condition)
// .andWhere(condition)
.andWhere(requestBody.year ? "kpiSpecial.year LIKE :year" : "1=1", {
year: `%${requestBody.year}%`,
})

View file

@ -58,6 +58,9 @@ export class KpiUserEvaluationController extends Controller {
@Query("pageSize") pageSize: number = 10,
@Query("kpiPeriodId") kpiPeriodId?: string,
@Query("keyword") keyword?: string,
@Query("status") status?: string,
@Query("results") results?: string,
@Query("reqedit") reqedit?: string,
) {
let profileId: any = null;
await new CallAPI()
@ -73,6 +76,21 @@ export class KpiUserEvaluationController extends Controller {
.andWhere(kpiPeriodId ? "kpiPeriodId LIKE :kpiPeriodId" : "1=1", {
kpiPeriodId: kpiPeriodId,
})
.andWhere(status != null && status != undefined ? "evaluationStatus LIKE :status" : "1=1", {
status: status,
})
.andWhere(
results != null && results != undefined ? "evaluationResults LIKE :results" : "1=1",
{
results: results,
},
)
.andWhere(
reqedit != null && reqedit != undefined ? "evaluationReqEdit LIKE :reqedit" : "1=1",
{
reqedit: reqedit,
},
)
.andWhere(
new Brackets((qb) => {
qb.orWhere("kpiUserEvaluation.evaluatorId LIKE :profileId", {

View file

@ -88,7 +88,7 @@ export class KpiUserEvaluation extends EntityBase {
nullable: true,
length: 40,
comment: "คำขอแก้ไข",
default: "NEW",
default: null,
})
evaluationReqEdit: string;

View file

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableKpiSpecialDateNullable11715242826033 implements MigrationInterface {
name = 'UpdateTableKpiSpecialDateNullable11715242826033'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` CHANGE \`evaluationReqEdit\` \`evaluationReqEdit\` varchar(40) NULL COMMENT 'คำขอแก้ไข'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` CHANGE \`evaluationReqEdit\` \`evaluationReqEdit\` varchar(40) NULL COMMENT 'คำขอแก้ไข' DEFAULT 'NEW'`);
}
}