This commit is contained in:
Warunee Tamkoo 2025-01-11 12:45:40 +07:00
parent 6d6cdc047b
commit 27e54e914a
2 changed files with 22 additions and 7 deletions

View file

@ -100,6 +100,9 @@ export class AssignController extends Controller {
createdFullName: request.user.name,
updateUserId: request.user.sub,
updateFullName: request.user.name,
other4_desc: requestBody.other4_desc ?? "",
other5_no1_desc: requestBody.other5_no1_desc ?? "",
other_desc: requestBody.other_desc ?? "",
};
const before = null;
const assign = await this.assignRepository.save(data, { data: request });
@ -259,6 +262,9 @@ export class AssignController extends Controller {
id: assign_id,
updateUserId: request.user.sub,
updateFullName: request.user.name,
other4_desc: requestBody.other4_desc ?? "",
other5_no1_desc: requestBody.other5_no1_desc ?? "",
other_desc: requestBody.other_desc ?? "",
};
await this.assignJobRepository.delete({ assign_id });
@ -555,7 +561,11 @@ export class AssignController extends Controller {
*
*/
@Get("")
async GetAssign(@Query() assign_id: string, @Request() request: RequestWithUser) {
async GetAssign(
@Query() assign_id: string,
@Query() isReport: boolean = false,
@Request() request: RequestWithUser,
) {
let _workflow = await new permission().Workflow(request, assign_id, "SYS_PROBATION");
if (_workflow == false) await new permission().PermissionGet(request, "SYS_PROBATION");
@ -653,10 +663,16 @@ export class AssignController extends Controller {
law_id: x.id,
});
let description = await x.description;
if (isReport) {
const descriptionSplit = await x.description.split(" ");
description = await x.description.replace(descriptionSplit[0], "");
}
return {
id: x.id,
selected: assignLaw > 0 ? 1 : 0,
description: x.description,
description: description,
status_select: x.status_select,
};
}),

View file

@ -15,10 +15,7 @@ export class AssignPermissionsController extends Controller {
private assignRepository = AppDataSource.getRepository(Assign);
@Get("{id}")
async GetAssignPermissions(
@Request() request: RequestWithUser,
@Path() id: string
) {
async GetAssignPermissions(@Request() request: RequestWithUser, @Path() id: string) {
const director = await this.assignDirector.find({
where: { assign_id: id },
});
@ -29,9 +26,10 @@ export class AssignPermissionsController extends Controller {
console.error("Error calling API:", error);
});
const role = director.find((e: any) => e.personal_id === personalId)?.role;
const role = await director.find((e: any) => e.personal_id === personalId)?.role;
const reportPersonId = await this.assignRepository.findOneBy({
id,
reportPersonId: personalId,
});
@ -55,6 +53,7 @@ export class AssignPermissionsController extends Controller {
tab5: {
isEdit: Boolean(reportPersonId),
isView: true,
reportPersonId,
},
tab6: {
isEdit: true,