Fix Bug KPI เพิ่มเชื่อมโยงกลุ่มงานและตำแหน่ง ตำแหน่งที่เลือกไม่ถูกบันทึก #18
This commit is contained in:
parent
1132840554
commit
8f233cbe2e
1 changed files with 11 additions and 2 deletions
|
|
@ -71,7 +71,7 @@ export class kpiLinkController extends Controller {
|
|||
});
|
||||
await this.kpiLinkRepository.save(kpiLink, { data: request });
|
||||
setLogDataDiff(request, { before, after: kpiLink });
|
||||
|
||||
let _Ids: string[] = []
|
||||
if (requestBody.positions != null) {
|
||||
await Promise.all(
|
||||
requestBody.positions.map(async (positionName) => {
|
||||
|
|
@ -85,6 +85,7 @@ export class kpiLinkController extends Controller {
|
|||
position.createdAt = new Date();
|
||||
position.lastUpdatedAt = new Date();
|
||||
await this.positionRepository.save(position, { data: request });
|
||||
_Ids.push(position.id)
|
||||
setLogDataDiff(request, { before, after: position });
|
||||
}),
|
||||
);
|
||||
|
|
@ -102,7 +103,15 @@ export class kpiLinkController extends Controller {
|
|||
|
||||
await this.kpiLinkRepository.save(kpiLink, { data: request });
|
||||
setLogDataDiff(request, { before, after: kpiLink });
|
||||
|
||||
const chkPosition = await this.positionRepository.find({
|
||||
where: { id: In(_Ids) }
|
||||
});
|
||||
if (chkPosition.length > 0 && chkPosition.every(x => !x.kpiLinkId)) {
|
||||
await this.positionRepository.update(
|
||||
{ id: In(_Ids) },
|
||||
{ kpiLinkId: kpiLink.id }
|
||||
);
|
||||
}
|
||||
return new HttpSuccess(kpiLink.id);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue