รายชื่อผู้ได้รับสำเนาคำสั่ง

This commit is contained in:
kittapath 2024-10-22 16:09:46 +07:00
parent 0ddec18725
commit ecadf565ac
2 changed files with 84 additions and 5 deletions

View file

@ -580,9 +580,41 @@ export class WorkflowController extends Controller {
where: {
id: body.stateUserCommentId,
},
relations: ["state", "state.workflow", "state.stateOperators"],
});
if (!stateUserComment)
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลขั้นตอนการอนุมัติ");
stateUserComment.state.stateOperators;
const workflow = await this.workflowRepo.findOne({
where: {
refId: stateUserComment.state.workflow.refId,
sysName: stateUserComment.state.workflow.sysName,
},
relations: ["stateOperatorUsers"],
});
if (!workflow) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่สามารถดำเนินการกระบวนการนี้ได้");
let profileNow = workflow.stateOperatorUsers
.filter((x) =>
stateUserComment.state.stateOperators.map((s) => s.operator).includes(x.operator),
)
.map((x) => ({
receiverUserId: x.profile,
notiLink: "",
}));
await new CallAPI()
.PostData(req, "/placement/noti/profiles", {
subject: `ผู้บังคับบัญชาดำเนินการ`,
body: `ผู้บังคับบัญชาดำเนินการ`,
receiverUserIds: profileNow,
payload: "", //แนบไฟล์
isSendMail: true,
isSendInbox: true,
isSendNotification: true,
})
.catch((error) => {
console.error("Error calling API:", error);
});
let _null: any = null;
stateUserComment.isAccept = body.isAccept == null ? _null : body.isAccept;
stateUserComment.isApprove = body.isApprove == null ? _null : body.isApprove;