add role parent

This commit is contained in:
mamoss 2025-11-29 14:56:58 +07:00
parent 072d9a6880
commit bd9c270cd7
9 changed files with 231 additions and 241 deletions

View file

@ -2219,7 +2219,7 @@ export class ProfileController extends Controller {
_data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null`
: `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1",
{
child1: _data.child1,
@ -6137,7 +6137,7 @@ export class ProfileController extends Controller {
_data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null`
: `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1",
{ child1: _data.child1 },
)
@ -6524,7 +6524,7 @@ export class ProfileController extends Controller {
_data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null`
: `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1",
{ child1: _data.child1 },
)
@ -6632,6 +6632,7 @@ export class ProfileController extends Controller {
position: _data.position,
posNo: shortName ?? null,
rootId: holder?.orgRoot?.id ?? null,
child1Id: holder?.orgChild1Id ?? null,
root: holder?.orgRoot?.orgRootName ?? null,
rootDnaId: holder?.orgRoot == null ? null : holder?.orgRoot?.ancestorDNA,
orgRootShortName: holder?.orgRoot?.orgRootShortName ?? null,
@ -7352,10 +7353,10 @@ export class ProfileController extends Controller {
nodeDnaId: null,
type: profile.employeeClass,
salary: profile.amount,
posNo: null
// root?.orgRootShortName && posMaster?.posMasterNo
// ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}`
// : "",
posNo: null,
// root?.orgRootShortName && posMaster?.posMasterNo
// ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}`
// : "",
};
if (_profile.child4Id != null) {
_profile.node = 4;
@ -7521,10 +7522,10 @@ export class ProfileController extends Controller {
nodeDnaId: null,
salary: profile ? profile.amount : null,
amountSpecial: profile ? profile.amountSpecial : null,
posNo: null
// root?.orgRootShortName && posMaster?.posMasterNo
// ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}`
// : "",
posNo: null,
// root?.orgRootShortName && posMaster?.posMasterNo
// ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}`
// : "",
};
if (_profile.child4Id != null) {
@ -8867,7 +8868,7 @@ export class ProfileController extends Controller {
_data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null`
: `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1",
{ child1: _data.child1 },
)
@ -9390,7 +9391,7 @@ export class ProfileController extends Controller {
_data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null`
: `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1",
{
child1: _data.child1,
@ -9781,21 +9782,26 @@ export class ProfileController extends Controller {
.leftJoinAndSelect("current_holders.positions", "positions")
.leftJoinAndSelect("positions.posExecutive", "posExecutive")
.andWhere(
new Brackets(qb => {
new Brackets((qb) => {
qb.where("profile.position LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("posLevel.posLevelName LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("posType.posTypeName LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword", { keyword: `%${body.keyword}%` });
})
.orWhere(
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword",
{ keyword: `%${body.keyword}%` },
);
}),
)
.andWhere("profile.isLeave = false")
.andWhere("current_holders.orgRevisionId = :orgRevisionId", { orgRevisionId: orgRevisionActive.id });
.andWhere("current_holders.orgRevisionId = :orgRevisionId", {
orgRevisionId: orgRevisionActive.id,
});
const [findProfile, total] = await query
.orderBy("profile.citizenId", "ASC")
.skip((body.page - 1) * body.pageSize)
.take(body.pageSize)
.getManyAndCount();
const [findProfile, total] = await query
.orderBy("profile.citizenId", "ASC")
.skip((body.page - 1) * body.pageSize)
.take(body.pageSize)
.getManyAndCount();
const mapDataProfile = await Promise.all(
findProfile.map(async (item: Profile) => {
@ -9807,9 +9813,10 @@ export class ProfileController extends Controller {
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id);
const position =
posMaster == null ||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.positions == null ||
item.current_holders?.find((x) => x.orgRevisionId == orgRevisionActive.id)?.positions.length ==
0 ||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.positions ==
null ||
item.current_holders?.find((x) => x.orgRevisionId == orgRevisionActive.id)?.positions
.length == 0 ||
item.current_holders
.find((x) => x.orgRevisionId == orgRevisionActive.id)
?.positions?.find((position) => position.positionIsSelected == true) == null
@ -9837,18 +9844,20 @@ export class ProfileController extends Controller {
item.current_holders.length == 0
? null
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null &&
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild4 !=
null
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
?.orgChild4 != null
? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}`
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null &&
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild3 !=
null
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
?.orgChild3 != null
? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}`
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null &&
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) !=
null &&
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
?.orgChild2 != null
? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}`
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null &&
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) !=
null &&
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
?.orgChild1 != null
? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}`
@ -10775,7 +10784,7 @@ export class ProfileController extends Controller {
await this.profileRepo.save(profile, { data: request });
setLogDataDiff(request, { before, after: profile });
if (requestBody.isLeave == true) {
if(orgRevisionRef){
if (orgRevisionRef) {
await CreatePosMasterHistoryOfficer(orgRevisionRef.id, request, "DELETE");
}
await removeProfileInOrganize(profile.id, "OFFICER");