Merge branch 'develop' of github.com:Frappet/bma-ehr-kpi into develop
This commit is contained in:
commit
b671316601
3 changed files with 61 additions and 14 deletions
|
|
@ -69,6 +69,8 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
kpiUserEvaluation.lastName = x.lastName
|
kpiUserEvaluation.lastName = x.lastName
|
||||||
})
|
})
|
||||||
.catch((x) => {});
|
.catch((x) => {});
|
||||||
|
kpiUserEvaluation.evaluationStatus = requestBody.evaluationStatus
|
||||||
|
kpiUserEvaluation.evaluationResults = requestBody.evaluationResults
|
||||||
kpiUserEvaluation.createdUserId = request.user.sub;
|
kpiUserEvaluation.createdUserId = request.user.sub;
|
||||||
kpiUserEvaluation.createdFullName = request.user.name;
|
kpiUserEvaluation.createdFullName = request.user.name;
|
||||||
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
||||||
|
|
@ -111,6 +113,8 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kpiUserEvaluation) {
|
if (kpiUserEvaluation) {
|
||||||
|
kpiUserEvaluation.evaluationStatus = requestBody.evaluationStatus
|
||||||
|
kpiUserEvaluation.evaluationResults = requestBody.evaluationResults
|
||||||
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
||||||
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
kpiUserEvaluation.lastUpdateFullName = request.user.name;
|
||||||
this.kpiUserEvalutionRepository.merge(kpiUserEvaluation, requestBody);
|
this.kpiUserEvalutionRepository.merge(kpiUserEvaluation, requestBody);
|
||||||
|
|
@ -130,7 +134,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
async GetKpiUserEvaluationById(@Path() id: string) {
|
async GetKpiUserEvaluationById(@Path() id: string) {
|
||||||
const KpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
const KpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
select: ["id", "profileId", "prefix", "firstName", "lastName", "kpiPeriodId"],
|
select: ["id", "profileId", "prefix", "firstName", "lastName", "kpiPeriodId", "evaluationStatus", "evaluationResults", "createdAt"],
|
||||||
})
|
})
|
||||||
if (!KpiUserEvaluation) {
|
if (!KpiUserEvaluation) {
|
||||||
throw new HttpError(
|
throw new HttpError(
|
||||||
|
|
@ -151,23 +155,23 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
async listKpiUserEvaluation(
|
async listKpiUserEvaluation(
|
||||||
@Query("page") page: number = 1,
|
@Query("page") page: number = 1,
|
||||||
@Query("pageSize") pageSize: number = 10,
|
@Query("pageSize") pageSize: number = 10,
|
||||||
@Query("period") period?: string,
|
@Query("kpiPeriodId") kpiPeriodId?: string,
|
||||||
@Query("keyword") keyword?: string,
|
// @Query("keyword") keyword?: string,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
|
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||||
.createQueryBuilder("kpiUserEvaluation")
|
.createQueryBuilder("kpiUserEvaluation")
|
||||||
.leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod")
|
// .leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod")
|
||||||
.andWhere(
|
// .andWhere(
|
||||||
keyword == undefined
|
// keyword == undefined
|
||||||
? "1=1"
|
// ? "1=1"
|
||||||
: [
|
// : [
|
||||||
{ prefix: Like(`%${keyword}%`) },
|
// { prefix: Like(`%${keyword}%`) },
|
||||||
{ firstName: Like(`%${keyword}%`) },
|
// { firstName: Like(`%${keyword}%`) },
|
||||||
{ lastName: Like(`%${keyword}%`) },
|
// { lastName: Like(`%${keyword}%`) },
|
||||||
],
|
// ],
|
||||||
)
|
// )
|
||||||
.andWhere(period ? "kpiPeriod.durationKPI LIKE :period" : "1=1", { period: `%${period}%` })
|
.andWhere(kpiPeriodId ? "kpiPeriodId LIKE :kpiPeriodId" : "1=1", { kpiPeriodId: `%${kpiPeriodId}%` })
|
||||||
.orderBy("kpiUserEvaluation.createdAt", "ASC")
|
.orderBy("kpiUserEvaluation.createdAt", "ASC")
|
||||||
.skip((page - 1) * pageSize)
|
.skip((page - 1) * pageSize)
|
||||||
.take(pageSize)
|
.take(pageSize)
|
||||||
|
|
@ -180,6 +184,9 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
firstname: item.firstName,
|
firstname: item.firstName,
|
||||||
lastname: item.lastName,
|
lastname: item.lastName,
|
||||||
kpiPeriodId: item.kpiPeriodId,
|
kpiPeriodId: item.kpiPeriodId,
|
||||||
|
evaluationStatus: item.evaluationStatus,
|
||||||
|
evaluationResults: item.evaluationResults,
|
||||||
|
createdAt: item.createdAt,
|
||||||
}));
|
}));
|
||||||
return new HttpSuccess({ data: mapData, total });
|
return new HttpSuccess({ data: mapData, total });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,22 @@ export class KpiUserEvaluation extends EntityBase {
|
||||||
})
|
})
|
||||||
profileId: string;
|
profileId: string;
|
||||||
|
|
||||||
|
@Column({ // PENDING = รอการประเมิน , INPROGRESS = กําลังประเมิน , DONE = ประเมินเสร็จสิ้น
|
||||||
|
nullable: true,
|
||||||
|
length: 40,
|
||||||
|
comment: "สถานะการประเมินผล",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
evaluationStatus: string;
|
||||||
|
|
||||||
|
@Column({ // PASSED = ผ่านการประเมิน , NOTPASSED = ไม่ผ่านการประเมิน
|
||||||
|
nullable: true,
|
||||||
|
length: 40,
|
||||||
|
comment: "ผลการประเมิน",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
evaluationResults: string;
|
||||||
|
|
||||||
@ManyToOne(() => KpiPeriod, (kpiPeriod) => kpiPeriod.kpiUserEvaluation)
|
@ManyToOne(() => KpiPeriod, (kpiPeriod) => kpiPeriod.kpiUserEvaluation)
|
||||||
@JoinColumn({ name: "kpiPeriodId" })
|
@JoinColumn({ name: "kpiPeriodId" })
|
||||||
kpiPeriod: KpiPeriod;
|
kpiPeriod: KpiPeriod;
|
||||||
|
|
@ -91,6 +107,10 @@ export class createKpiUserEvaluation {
|
||||||
kpiPeriodId: string;
|
kpiPeriodId: string;
|
||||||
@Column()
|
@Column()
|
||||||
profileId: string;
|
profileId: string;
|
||||||
|
@Column()
|
||||||
|
evaluationStatus: string;
|
||||||
|
@Column()
|
||||||
|
evaluationResults: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class updateKpiUserEvaluation {
|
export class updateKpiUserEvaluation {
|
||||||
|
|
@ -104,4 +124,8 @@ export class updateKpiUserEvaluation {
|
||||||
kpiPeriodId: string;
|
kpiPeriodId: string;
|
||||||
@Column()
|
@Column()
|
||||||
profileId: string;
|
profileId: string;
|
||||||
|
@Column()
|
||||||
|
evaluationStatus: string;
|
||||||
|
@Column()
|
||||||
|
evaluationResults: string;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class AddFieldsTableUserEvaluation1713774054952 implements MigrationInterface {
|
||||||
|
name = 'AddFieldsTableUserEvaluation1713774054952'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`evaluationStatus\` varchar(40) NULL COMMENT 'สถานะการประเมินผล'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`evaluationResults\` varchar(40) NULL COMMENT 'ผลการประเมิน'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`evaluationResults\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`evaluationStatus\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue