check workflow

This commit is contained in:
kittapath 2024-10-22 08:21:16 +07:00
parent e3e6a1df36
commit a4647e102a
14 changed files with 84 additions and 73 deletions

View file

@ -230,18 +230,18 @@ export class kpiCapacityController extends Controller {
@Get("group")
async GetKpiCapacityTypeGROUP(@Query("positionName") positionName: string) {
let position = await this.positionRepository.findOne({
where: {
where: {
name: Like(`${positionName}`),
kpiLink: Not(IsNull()) || Not("")
kpiLink: Not(IsNull()) || Not(""),
},
relations: ["kpiLink", "kpiLink.kpiCapacitys"],
});
if (position == null) {
position = await this.positionRepository.findOne({
where: {
name: "นักจัดการงานทั่วไป",
kpiLink: Not(IsNull()) || Not("")
where: {
name: "นักจัดการงานทั่วไป",
kpiLink: Not(IsNull()) || Not(""),
},
relations: ["kpiLink", "kpiLink.kpiCapacitys"],
});
@ -310,7 +310,8 @@ export class kpiCapacityController extends Controller {
],
})
async GetKpiCapacityByIdEdit(@Request() request: RequestWithUser, @Path() id: string) {
let _data = await new permission().PermissionGet(request, "SYS_EVA_COMPETENCY");
let _workflow = await new permission().Workflow(request, id, "SYS_EVA_COMPETENCY");
if (_workflow == false) await new permission().PermissionGet(request, "SYS_EVA_COMPETENCY");
const kpiCapacity = await this.kpiCapacityRepository.findOne({
where: { id: id },
select: ["type", "name", "description"],

View file

@ -118,7 +118,8 @@ export class kpiGroupController extends Controller {
nameGroupKPI: "string", //ชื่อกลุ่มงาน
})
async KpiGroupByIdEdit(@Request() request: RequestWithUser, @Path() id: string) {
let _data = await new permission().PermissionGet(request, "SYS_EVA_COMPETENCY");
let _workflow = await new permission().Workflow(request, id, "SYS_EVA_COMPETENCY");
if (_workflow == false) await new permission().PermissionGet(request, "SYS_EVA_COMPETENCY");
const kpiGroup = await this.kpiGroupRepository.findOne({
where: { id: id },
select: ["nameGroupKPI"],

View file

@ -136,7 +136,7 @@ export class kpiLinkController extends Controller {
...requestBody,
kpiCapacitys: [],
});
const chkCapacity = await this.kpiCapacityRepository.find({
where: {
id: In(requestBody.kpiCapacityIds),
@ -181,7 +181,8 @@ export class kpiLinkController extends Controller {
*/
@Get("edit/{id}")
async KpiLinkByIdEdit(@Request() request: RequestWithUser, @Path() id: string) {
let _data = await new permission().PermissionGet(request, "SYS_EVA_COMPETENCY");
let _workflow = await new permission().Workflow(request, id, "SYS_EVA_COMPETENCY");
if (_workflow == false) await new permission().PermissionGet(request, "SYS_EVA_COMPETENCY");
const kpiLink = await this.kpiLinkRepository.findOne({
where: { id: id },
relations: ["positions", "kpiCapacitys", "kpiGroup"],

View file

@ -175,7 +175,8 @@ export class kpiPeriodController extends Controller {
endDate: "datetime", //วันสิ้นสุด
})
async OpenKpiPeriodById(@Path() id: string, @Request() request: RequestWithUser) {
await new permission().PermissionGet(request, "SYS_KPI_ROUND");
let _workflow = await new permission().Workflow(request, id, "SYS_KPI_ROUND");
if (_workflow == false) await new permission().PermissionGet(request, "SYS_KPI_ROUND");
const kpiPeriod = await this.kpiPeriodRepository.findOne({
where: { id: id },
});

View file

@ -310,7 +310,8 @@ export class kpiPlanController extends Controller {
*/
@Get("edit/{id}")
async GetKpiPlanByIdEdit(@Request() request: RequestWithUser, @Path() id: string) {
let _data = await new permission().PermissionGet(request, "SYS_EVA_INDICATOR");
let _workflow = await new permission().Workflow(request, id, "SYS_EVA_INDICATOR");
if (_workflow == false) await new permission().PermissionGet(request, "SYS_EVA_INDICATOR");
const kpiPlan = await this.kpiPlanRepository.findOne({
where: { id: id },
relations: { kpiPeriod: true },

View file

@ -286,7 +286,8 @@ export class kpiRoleController extends Controller {
*/
@Get("edit/{id}")
async GetKpiRoleByIdEdit(@Request() request: RequestWithUser, @Path() id: string) {
let _data = await new permission().PermissionGet(request, "SYS_EVA_INDICATOR");
let _workflow = await new permission().Workflow(request, id, "SYS_EVA_INDICATOR");
if (_workflow == false) await new permission().PermissionGet(request, "SYS_EVA_INDICATOR");
const kpiRole = await this.kpiRoleRepository.findOne({
where: { id: id },
relations: { kpiPeriod: true },

View file

@ -126,7 +126,8 @@ export class kpiSpecialController extends Controller {
*/
@Get("edit/{id}")
async GetKpiSpecialByIdEdit(@Request() request: RequestWithUser, @Path() id: string) {
let _data = await new permission().PermissionGet(request, "SYS_EVA_INDICATOR");
let _workflow = await new permission().Workflow(request, id, "SYS_EVA_INDICATOR");
if (_workflow == false) await new permission().PermissionGet(request, "SYS_EVA_INDICATOR");
const KpiSpecial = await this.kpiSpecialRepository.findOne({
where: { id: id },
});

View file

@ -177,7 +177,6 @@ export class KpiUserCapacityController extends Controller {
*/
@Get("{id}")
async GetKpiUserCapacityById(@Request() request: RequestWithUser, @Path() id: string) {
// await new permission().PermissionGet(request, "SYS_KPI_LIST");
const kpiUserCapacity = await this.kpiUserCapacityRepository.findOne({
where: { id: id },
relations: ["kpiCapacity"],
@ -212,7 +211,6 @@ export class KpiUserCapacityController extends Controller {
@Query("id") id: string, //kpiUserEvaluationId
@Query("type") type: string,
) {
// await new permission().PermissionGet(request, "SYS_KPI_LIST");
const [kpiUserCapacity, total] = await AppDataSource.getRepository(KpiUserCapacity)
.createQueryBuilder("kpiUserCapacity")
.leftJoinAndSelect("kpiUserCapacity.kpiCapacity", "kpiCapacity")

View file

@ -240,7 +240,6 @@ export class KpiUserDevelopmentController extends Controller {
*/
@Get("{id}")
async GetKpiUserDevelopmentDetail(@Request() request: RequestWithUser, @Path() id: string) {
// await new permission().PermissionGet(request, "SYS_KPI_LIST");
const getKpiUserDevelopment = await this.kpiUserDevelopmentRepository.findOne({
relations: ["kpiUserEvaluation", "developmentProjects"],
where: { id: id },
@ -282,7 +281,6 @@ export class KpiUserDevelopmentController extends Controller {
*/
@Get()
async GetKpiUserDevelopment(@Request() request: RequestWithUser, @Query("id") id: string) {
// await new permission().PermissionGet(request, "SYS_KPI_LIST");//USER
const kpiUserDevelopment = await this.kpiUserDevelopmentRepository.find({
where: {
kpiUserEvaluationId: id,
@ -452,7 +450,8 @@ export class KpiUserDevelopmentController extends Controller {
@Request() request: RequestWithUser,
@Path("id") id: string,
) {
await new permission().PermissionGet(request, "SYS_RESULT");
let _workflow = await new permission().Workflow(request, id, "SYS_RESULT");
if (_workflow == false) await new permission().PermissionGet(request, "SYS_RESULT");
const kpiUserDevelopment = await this.kpiUserDevelopmentRepository.findOne({
relations: [
"kpiUserEvaluation",
@ -514,23 +513,29 @@ export class KpiUserDevelopmentController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลพัฒนาตนเองนี้");
}
if (type.trim().toLocaleUpperCase() == "OFFICER") {
await new permission().PermissionOrgUserGet(
request,
"SYS_REGISTRY_OFFICER",
getKpiUserDevelopment.kpiUserEvaluation.profileId,
);
let _workflow = await new permission().Workflow(request, id, "SYS_REGISTRY_OFFICER");
if (_workflow == false)
await new permission().PermissionOrgUserGet(
request,
"SYS_REGISTRY_OFFICER",
getKpiUserDevelopment.kpiUserEvaluation.profileId,
);
} else if (type.trim().toLocaleUpperCase() == "EMPLOYEE") {
await new permission().PermissionOrgUserGet(
request,
"SYS_REGISTRY_EMP",
getKpiUserDevelopment.kpiUserEvaluation.profileId,
);
let _workflow = await new permission().Workflow(request, id, "SYS_REGISTRY_EMP");
if (_workflow == false)
await new permission().PermissionOrgUserGet(
request,
"SYS_REGISTRY_EMP",
getKpiUserDevelopment.kpiUserEvaluation.profileId,
);
} else if (type.trim().toLocaleUpperCase() == "TEMP") {
await new permission().PermissionOrgUserGet(
request,
"SYS_REGISTRY_TEMP",
getKpiUserDevelopment.kpiUserEvaluation.profileId,
);
let _workflow = await new permission().Workflow(request, id, "SYS_REGISTRY_TEMP");
if (_workflow == false)
await new permission().PermissionOrgUserGet(
request,
"SYS_REGISTRY_TEMP",
getKpiUserDevelopment.kpiUserEvaluation.profileId,
);
} else if (type.trim().toLocaleUpperCase() == "USER") {
} else {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถเข้าถึงข้อมูลนี้ได้");

View file

@ -1327,7 +1327,8 @@ export class KpiUserEvaluationController extends Controller {
*/
@Get("admin/{id}")
async GetKpiAdminEvaluationById(@Path() id: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_KPI_LIST");
let _workflow = await new permission().Workflow(req, id, "SYS_KPI_LIST");
if (_workflow == false) await new permission().PermissionGet(req, "SYS_KPI_LIST");
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
relations: ["kpiPeriod"],
where: { id: id },
@ -1631,7 +1632,7 @@ export class KpiUserEvaluationController extends Controller {
})
.then(async () => {})
.catch((error) => {
console.error('Error details:', error.response.data);
console.error("Error details:", error.response.data);
});
kpiUserEvaluation.kpiUserDevelopments.map(async (kpiUserDevelopment) => {
@ -1652,12 +1653,13 @@ export class KpiUserEvaluationController extends Controller {
isDevelopment20: kpiUserDevelopment.isDevelopment20,
isDevelopment10: kpiUserDevelopment.isDevelopment10,
developmentResults: `${kpiUserDevelopment.achievement10}(10), ${kpiUserDevelopment.achievement5}(5), ${kpiUserDevelopment.achievement0}(0)`,
developmentReport: kpiUserDevelopment.point != null ?kpiUserDevelopment.point.toString():null,
developmentReport:
kpiUserDevelopment.point != null ? kpiUserDevelopment.point.toString() : null,
developmentProjects: kpiUserDevelopment.developmentProjects.map((x) => x.name),
})
.then(async () => {})
.catch((error) => {
console.error('Error details:', error.response.data);
console.error("Error details:", error.response.data);
});
});
@ -1673,7 +1675,7 @@ export class KpiUserEvaluationController extends Controller {
})
.then(async () => {})
.catch((error) => {
console.error('Error details:', error.response.data);
console.error("Error details:", error.response.data);
});
const before = null;
kpiUserEvaluation.lastUpdateUserId = request.user.sub;

View file

@ -190,7 +190,6 @@ export class KpiUserPlannedController extends Controller {
*/
@Get("{id}")
async GetKpiUserPlannedDetail(@Request() request: RequestWithUser, @Path() id: string) {
// await new permission().PermissionGet(request, "SYS_KPI_LIST");
const getKpiUserPlanned = await this.kpiUserPlannedRepository.findOne({
relations: ["kpiPlan", "kpiUserEvaluation"],
where: { id: id },
@ -233,7 +232,6 @@ export class KpiUserPlannedController extends Controller {
*/
@Get()
async GetKpiUserPlanned(@Request() request: RequestWithUser, @Query("id") id: string) {
// await new permission().PermissionGet(request, "SYS_KPI_LIST");//USER
const kpiUserPlanned = await this.kpiUserPlannedRepository.find({
where: {
kpiUserEvaluationId: id,

View file

@ -194,7 +194,6 @@ export class KpiUserRoleController extends Controller {
*/
@Get("{id}")
async GetKpiUserRoleDetail(@Request() request: RequestWithUser, @Path() id: string) {
// await new permission().PermissionGet(request, "SYS_KPI_LIST");
const getKpiUserRole = await this.kpiUserRoleRepository.findOne({
relations: ["kpiRole", "kpiUserEvaluation"],
where: { id: id },
@ -237,7 +236,6 @@ export class KpiUserRoleController extends Controller {
*/
@Get()
async GetKpiUserRole(@Request() request: RequestWithUser, @Query("id") id: string) {
// await new permission().PermissionGet(request, "SYS_KPI_LIST");//USER
const kpiUserRole = await this.kpiUserRoleRepository.find({
where: {
kpiUserEvaluationId: id,

View file

@ -280,7 +280,6 @@ export class KpiUserSpecialController extends Controller {
*/
@Get()
async GetKpiUserSpecial(@Request() request: RequestWithUser, @Query("id") id: string) {
// await new permission().PermissionGet(request, "SYS_KPI_LIST");
const kpiUserSpecial = await this.kpiUserSpecialRepository.find({
where: {
kpiUserEvaluationId: id,