Add workflow ขอแก้ไขข้อมูลทะเบียนประวัติ (ลูกจ้างประจำ) #2222
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m3s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m3s
Fix เพิ่มรายการแต่ไม่แสดงใน Tab รายการตำแหน่ง/เงินเดือนหลังจากแก้ไขแล้ว #2243
This commit is contained in:
parent
217ec1d7f6
commit
2a2635ad83
2 changed files with 40 additions and 2 deletions
|
|
@ -26,7 +26,8 @@ import { RequestWithUser } from "../middlewares/user";
|
||||||
import { Brackets } from "typeorm";
|
import { Brackets } from "typeorm";
|
||||||
import permission from "../interfaces/permission";
|
import permission from "../interfaces/permission";
|
||||||
import { OrgRevision } from "../entities/OrgRevision";
|
import { OrgRevision } from "../entities/OrgRevision";
|
||||||
|
import { OrgRoot } from "../entities/OrgRoot";
|
||||||
|
import CallAPI from "../interfaces/call-api";
|
||||||
@Route("api/v1/org/profile-employee/edit")
|
@Route("api/v1/org/profile-employee/edit")
|
||||||
@Tags("ProfileEmployeeEdit")
|
@Tags("ProfileEmployeeEdit")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -34,6 +35,7 @@ export class ProfileEditEmployeeController extends Controller {
|
||||||
private profileEmployeeRepo = AppDataSource.getRepository(ProfileEmployee);
|
private profileEmployeeRepo = AppDataSource.getRepository(ProfileEmployee);
|
||||||
private profileEditRepository = AppDataSource.getRepository(ProfileEdit);
|
private profileEditRepository = AppDataSource.getRepository(ProfileEdit);
|
||||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||||
|
private orgRootRepo = AppDataSource.getRepository(OrgRoot);
|
||||||
|
|
||||||
@Get("user")
|
@Get("user")
|
||||||
public async detailProfileEditUserEmp(
|
public async detailProfileEditUserEmp(
|
||||||
|
|
@ -294,10 +296,32 @@ export class ProfileEditEmployeeController extends Controller {
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
@Body() body: CreateProfileEmployeeEdit,
|
@Body() body: CreateProfileEmployeeEdit,
|
||||||
) {
|
) {
|
||||||
const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: req.user.sub });
|
// const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: req.user.sub });
|
||||||
|
const profile = await this.profileEmployeeRepo.findOne({
|
||||||
|
relations: {
|
||||||
|
current_holders: true
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
keycloak: req.user.sub,
|
||||||
|
current_holders: {
|
||||||
|
orgRevision: {
|
||||||
|
orgRevisionIsCurrent: true,
|
||||||
|
orgRevisionIsDraft: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
|
const orgRoot = await this.orgRootRepo.findOne({
|
||||||
|
select: {
|
||||||
|
isDeputy: true
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
id: profile.current_holders.find(x => x.orgRootId)!.orgRootId ?? ""
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const data = new ProfileEdit();
|
const data = new ProfileEdit();
|
||||||
const meta = {
|
const meta = {
|
||||||
|
|
@ -312,6 +336,19 @@ export class ProfileEditEmployeeController extends Controller {
|
||||||
data.status = "PENDING";
|
data.status = "PENDING";
|
||||||
await this.profileEditRepository.save(data);
|
await this.profileEditRepository.save(data);
|
||||||
|
|
||||||
|
await new CallAPI()
|
||||||
|
.PostData(req, "/org/workflow/add-workflow", {
|
||||||
|
refId: data.id,
|
||||||
|
sysName: "REGISTRY_PROFILE_EMP",
|
||||||
|
posLevelName: "EMP",
|
||||||
|
posTypeName: "EMP",
|
||||||
|
fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`,
|
||||||
|
isDeputy: orgRoot?.isDeputy ?? false
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("Error calling API:", error);
|
||||||
|
});
|
||||||
|
|
||||||
return new HttpSuccess(data.id);
|
return new HttpSuccess(data.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1212,6 +1212,7 @@ export class ProfileSalaryTempController extends Controller {
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
lastUpdatedAt: new Date(),
|
lastUpdatedAt: new Date(),
|
||||||
isEdit: true,
|
isEdit: true,
|
||||||
|
isDelete: false,
|
||||||
};
|
};
|
||||||
Object.assign(data, { ...body, ...meta });
|
Object.assign(data, { ...body, ...meta });
|
||||||
await this.salaryRepo.save(data, { data: req });
|
await this.salaryRepo.save(data, { data: req });
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue