import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm"; import { EntityBase } from "./base/Base"; import { KpiUserEvaluation } from "./kpiUserEvaluation"; import { KpiPlan } from "./kpiPlan"; import { KpiUserEvaluationReasonPlan } from "./kpiUserEvaluationReasonPlan"; @Entity("kpiUserPlanned") export class KpiUserPlanned extends EntityBase { @Column({ nullable: true, comment: "ค่าเป้าหมาย", default: null, }) target: string; @Column({ nullable: true, comment: "หน่วยนับ", default: null, }) unit: string; @Column({ nullable: true, comment: "น้ำหนัก", default: null, }) weight: number; @Column({ nullable: true, comment: "นิยามหรือความหมาย", default: null, }) meaning: string; @Column({ nullable: true, comment: "สูตรคำนวณ", default: null, }) formula: string; @Column({ nullable: true, length: 40, comment: "คีย์นอก(FK)ของตาราง kpiUserEvaluation", default: null, }) kpiUserEvaluationId: string; @ManyToOne(() => KpiUserEvaluation, (kpiUserEvaluation) => kpiUserEvaluation.kpiUserPlanneds) @JoinColumn({ name: "kpiUserEvaluationId" }) kpiUserEvaluation: KpiUserEvaluation; @Column({ nullable: true, length: 40, comment: "คีย์นอก(FK)ของตาราง kpiPlan", default: null, }) kpiPlanId: string; @ManyToOne(() => KpiPlan, (kpiPlan) => kpiPlan.kpiUserPlanneds) @JoinColumn({ name: "kpiPlanId" }) kpiPlan: KpiPlan; @Column({ nullable: true, comment: "ระดับคะแนน", default: null, }) point: number; @Column({ type: "double", nullable: true, default: null, comment: "ผลการประเมิน", }) summary: number; @Column({ nullable: true, comment: "ข้อมูลเอกสารหลักฐาน", default: null, }) documentInfoEvidence: string; @Column({ nullable: true, type: "datetime", comment: "ช่วงเวลาเริ่มเก็บข้อมูล", default: null, }) startDate: Date | null; @Column({ nullable: true, type: "datetime", comment: "ช่วงเวลาสิ้นสุดเก็บข้อมูล", default: null, }) endDate: Date | null; @Column({ nullable: true, comment: "ผลสำเร็จของงาน 1", default: null, }) achievement1: string; @Column({ nullable: true, comment: "ผลสำเร็จของงาน 2", default: null, }) achievement2: string; @Column({ nullable: true, comment: "ผลสำเร็จของงาน 3", default: null, }) achievement3: string; @Column({ nullable: true, comment: "ผลสำเร็จของงาน 4", default: null, }) achievement4: string; @Column({ nullable: true, comment: "ผลสำเร็จของงาน 5", default: null, }) achievement5: string; @OneToMany( () => KpiUserEvaluationReasonPlan, (kpiUserEvaluationReasonPlan) => kpiUserEvaluationReasonPlan.kpiUserPlanned, ) kpiUserEvaluationReasonPlans: KpiUserEvaluationReasonPlan[]; } export class CreateKpiUserPlanned { @Column() target: string; @Column() unit: string | null; @Column() weight: number; @Column() meaning: string; @Column() formula: string; @Column("uuid") kpiUserEvaluationId: string; @Column("uuid") kpiPlanId: string; @Column() documentInfoEvidence: string; @Column({ nullable: true }) startDate?: Date | null; @Column({ nullable: true }) endDate?: Date | null; @Column() achievement1: string; @Column() achievement2: string; @Column() achievement3: string; @Column() achievement4: string; @Column() achievement5: string; } export class UpdateKpiUserPlanned { @Column() target: string; @Column() unit: string | null; @Column() weight: number; @Column() meaning: string; @Column() formula: string; @Column("uuid") kpiUserEvaluationId: string; @Column("uuid") kpiPlanId: string; @Column() documentInfoEvidence: string; @Column({ nullable: true }) startDate?: Date | null; @Column({ nullable: true }) endDate?: Date | null; @Column() achievement1: string; @Column() achievement2: string; @Column() achievement3: string; @Column() achievement4: string; @Column() achievement5: string; } export class KpiUserPlannedDataPoint { id: string; point: number; summary: number; }