fixed PermissionDelete to PermissionUpdate ในส่วนของลบคนครองและสืบทอดตำแหน่ง
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m0s

This commit is contained in:
Warunee Tamkoo 2026-05-11 17:17:49 +07:00
parent 7e4dc6434f
commit bf0dbdf018
3 changed files with 130 additions and 117 deletions

View file

@ -2421,7 +2421,7 @@ export class PositionController extends Controller {
? _data.child1[0] != null
? "posMaster.orgChild1Id IN (:...child1)"
: // : `posMaster.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
`posMaster.orgChild1Id is null`
`posMaster.orgChild1Id is null`
: "1=1",
{ child1: _data.child1 },
)
@ -2983,50 +2983,50 @@ export class PositionController extends Controller {
const type0LastPosMasterNo =
requestBody.type == 0
? await this.posMasterRepository.find({
where: {
orgRootId: requestBody.id,
orgChild1Id: IsNull(),
},
})
where: {
orgRootId: requestBody.id,
orgChild1Id: IsNull(),
},
})
: [];
const type1LastPosMasterNo =
requestBody.type == 1
? await this.posMasterRepository.find({
where: {
orgChild1Id: requestBody.id,
orgChild2Id: IsNull(),
},
})
where: {
orgChild1Id: requestBody.id,
orgChild2Id: IsNull(),
},
})
: [];
const type2LastPosMasterNo =
requestBody.type == 2
? await this.posMasterRepository.find({
where: {
orgChild2Id: requestBody.id,
orgChild3Id: IsNull(),
},
})
where: {
orgChild2Id: requestBody.id,
orgChild3Id: IsNull(),
},
})
: [];
const type3LastPosMasterNo =
requestBody.type == 3
? await this.posMasterRepository.find({
where: {
orgChild3Id: requestBody.id,
orgChild4Id: IsNull(),
},
})
where: {
orgChild3Id: requestBody.id,
orgChild4Id: IsNull(),
},
})
: [];
const type4LastPosMasterNo =
requestBody.type == 4
? await this.posMasterRepository.find({
where: {
orgChild4Id: requestBody.id,
},
})
where: {
orgChild4Id: requestBody.id,
},
})
: [];
const allLastPosMasterNo = [
@ -3364,7 +3364,15 @@ export class PositionController extends Controller {
if (orgRevision?.orgRevisionIsCurrent) {
const pmWithOrg = await this.posMasterRepository.findOne({
where: { id: posMaster.id },
relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3", "orgChild4", "positions", "positions.posExecutive"],
relations: [
"orgRoot",
"orgChild1",
"orgChild2",
"orgChild3",
"orgChild4",
"positions",
"positions.posExecutive",
],
});
const _profile = await this.profileRepository.findOne({
where: { id: posMaster.current_holderId },
@ -3375,13 +3383,16 @@ export class PositionController extends Controller {
_profile.org = getOrgFullName(pmWithOrg) ?? _null;
// ถ้าไม่ใช่ตำแหน่งนั่งทับ (isSit = false) ถึงจะอัพเดทตำแหน่งในทะเบียนประวัติ
if (!pmWithOrg.isSit) {
const selectedPos = (pmWithOrg as any).positions?.find((p: any) => p.positionIsSelected === true);
const selectedPos = (pmWithOrg as any).positions?.find(
(p: any) => p.positionIsSelected === true,
);
if (selectedPos) {
_profile.position = selectedPos.positionName ?? _null;
_profile.posTypeId = selectedPos.posTypeId ?? _null;
_profile.posLevelId = selectedPos.posLevelId ?? _null;
_profile.positionField = selectedPos.positionField ?? _null;
_profile.posExecutive = (selectedPos as any).posExecutive?.posExecutiveName ?? _null;
_profile.posExecutive =
(selectedPos as any).posExecutive?.posExecutiveName ?? _null;
_profile.positionArea = selectedPos.positionArea ?? _null;
_profile.positionExecutiveField = selectedPos.positionExecutiveField ?? _null;
}
@ -3932,7 +3943,7 @@ export class PositionController extends Controller {
*/
@Post("profile/delete/{id}")
async deleteHolder(@Path() id: string, @Request() request: RequestWithUser) {
await new permission().PermissionDelete(request, "SYS_ORG");
await new permission().PermissionUpdate(request, "SYS_ORG");
const dataMaster = await this.posMasterRepository.findOne({
where: { id: id },
relations: ["positions", "orgRevision"],