#2427 and migration
This commit is contained in:
parent
7f3408e2f5
commit
28b5408d5b
6 changed files with 159 additions and 5 deletions
|
|
@ -39,6 +39,7 @@ import { AuthRole } from "../entities/AuthRole";
|
|||
import { RequestWithUser } from "../middlewares/user";
|
||||
import permission from "../interfaces/permission";
|
||||
import { resolveNodeLevel, setLogDataDiff } from "../interfaces/utils";
|
||||
import { getPosMasterNo, getOrgFullName } from "../utils/org-formatting";
|
||||
import { PosMasterAssign } from "../entities/PosMasterAssign";
|
||||
import { Assign } from "../entities/Assign";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
|
|
@ -3793,7 +3794,7 @@ export class PositionController extends Controller {
|
|||
await new permission().PermissionUpdate(request, "SYS_ORG");
|
||||
const dataMaster = await this.posMasterRepository.findOne({
|
||||
where: { id: requestBody.posMaster },
|
||||
relations: ["positions"],
|
||||
relations: ["positions", "orgRoot", "orgChild1", "orgChild2", "orgChild3", "orgChild4"],
|
||||
});
|
||||
if (!dataMaster) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งนี้");
|
||||
|
|
@ -3825,6 +3826,7 @@ export class PositionController extends Controller {
|
|||
if (_profile) {
|
||||
let _position = await this.positionRepository.findOne({
|
||||
where: { id: requestBody.position, posMasterId: requestBody.posMaster },
|
||||
relations: ["posExecutive"],
|
||||
});
|
||||
if (_position) {
|
||||
// ถ้าไม่ใช่ตำแหน่งนั่งทับ (isSit = false) ถึงจะอัพเดทตำแหน่งในทะเบียนประวัติ
|
||||
|
|
@ -3832,6 +3834,12 @@ export class PositionController extends Controller {
|
|||
_profile.position = _position.positionName;
|
||||
_profile.posTypeId = _position.posTypeId;
|
||||
_profile.posLevelId = _position.posLevelId;
|
||||
_profile.positionField = _position.positionField ?? undefined;
|
||||
_profile.posExecutive = _position.posExecutive?.posExecutiveName ?? undefined;
|
||||
_profile.positionArea = _position.positionArea ?? undefined;
|
||||
_profile.positionExecutiveField = _position.positionExecutiveField ?? undefined;
|
||||
_profile.posMasterNo = getPosMasterNo(dataMaster);
|
||||
_profile.org = getOrgFullName(dataMaster);
|
||||
await this.profileRepository.save(_profile);
|
||||
setLogDataDiff(request, { before, after: _profile });
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue