fix แสดงกรณีรักษาการแทนผิด #2472
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m0s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m0s
This commit is contained in:
parent
760fef5c2f
commit
60191a23d7
3 changed files with 144 additions and 8 deletions
|
|
@ -23,6 +23,7 @@ import { viewDirector } from "../entities/view/viewDirector";
|
|||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||
import { OrgRoot } from "../entities/OrgRoot";
|
||||
import { getPosMasterPositions } from "../services/PositionService";
|
||||
@Route("api/v1/org/workflow")
|
||||
@Tags("Workflow")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -1071,12 +1072,49 @@ export class WorkflowController extends Controller {
|
|||
]);
|
||||
|
||||
// 8. ปรับ response mapping (ถ้าจำเป็น)
|
||||
const processedData = data.map((x: any) => ({
|
||||
...x,
|
||||
posExecutiveNameOrg:
|
||||
(x.posExecutiveName ?? "") +
|
||||
(x.orgChild4 ?? x.orgChild3 ?? x.orgChild2 ?? x.orgChild1 ?? x.orgRoot ?? ""),
|
||||
}));
|
||||
let posMasterPositionMap: Map<string, string> = new Map();
|
||||
|
||||
if (body.isAct) {
|
||||
// ดึง posMasterId ทั้งหมด (36 ตัวแรกของ key) เพื่อ query positionName
|
||||
const posMasterIds = data
|
||||
.map((x) => x.key?.substring(0, 36))
|
||||
.filter((id) => id && id.length === 36);
|
||||
posMasterPositionMap = await getPosMasterPositions(posMasterIds);
|
||||
}
|
||||
|
||||
const processedData = data.map((x: any) => {
|
||||
let newPositionSign = x.positionSign;
|
||||
|
||||
if (body.isAct) {
|
||||
// ตำแหน่งของคนที่เลือกไปรักษาการ
|
||||
let childPosition = "";
|
||||
if (x.posType === "อำนวยการ" || x.posType === "บริหาร") {
|
||||
childPosition = x.posExecutiveName || "";
|
||||
if (!childPosition) {
|
||||
childPosition = `${x.position || ""}ระดับ${x.posLevel || ""}`.trim();
|
||||
}
|
||||
} else {
|
||||
childPosition = `${x.position || ""}${x.posLevel || ""}`.trim();
|
||||
}
|
||||
|
||||
// ตำแหน่งที่รักษาการแทน
|
||||
const posMasterId = x.key?.substring(0, 36);
|
||||
const targetPosition = x.positionSign
|
||||
? x.positionSign
|
||||
: posMasterPositionMap.get(posMasterId) || "";
|
||||
|
||||
// สร้าง positionSign ใหม่
|
||||
newPositionSign = `${childPosition} รักษาการในตำแหน่ง${targetPosition}`;
|
||||
}
|
||||
|
||||
return {
|
||||
...x,
|
||||
positionSign: newPositionSign,
|
||||
posExecutiveNameOrg:
|
||||
(x.posExecutiveName ?? "") +
|
||||
(x.orgChild4 ?? x.orgChild3 ?? x.orgChild2 ?? x.orgChild1 ?? x.orgRoot ?? ""),
|
||||
};
|
||||
});
|
||||
|
||||
return new HttpSuccess({ data: processedData, total });
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue