Merge branch 'develop'

This commit is contained in:
mamoss 2025-11-29 15:36:34 +07:00
commit 10dc1670b8
9 changed files with 231 additions and 241 deletions

View file

@ -215,7 +215,7 @@ export class CommandController extends Controller {
_data.child1 != undefined && _data.child1 != null _data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null ? _data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null` : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1", : "1=1",
{ {
child1: _data.child1, child1: _data.child1,
@ -1477,7 +1477,7 @@ export class CommandController extends Controller {
} }
// @Get("XXX") // @Get("XXX")
async cronjobUpdateRetirementStatus(/*@Request() request: RequestWithUser*/) { async cronjobUpdateRetirementStatus(/*@Request() request: RequestWithUser*/) {
const adminToken = await getToken() ?? ""; const adminToken = (await getToken()) ?? "";
const today = new Date(); const today = new Date();
today.setUTCHours(0, 0, 0, 0); today.setUTCHours(0, 0, 0, 0);
let type: string = "OFFICER"; let type: string = "OFFICER";
@ -1672,7 +1672,7 @@ export class CommandController extends Controller {
positionIsSelected: false, positionIsSelected: false,
lastUpdateFullName: "System Administrator", lastUpdateFullName: "System Administrator",
lastUpdatedAt: _Date, lastUpdatedAt: _Date,
} },
); );
_posMaster.isSit = false; _posMaster.isSit = false;
_posMaster.current_holderId = null; _posMaster.current_holderId = null;
@ -1702,7 +1702,7 @@ export class CommandController extends Controller {
positionIsSelected: false, positionIsSelected: false,
lastUpdateFullName: "System Administrator", lastUpdateFullName: "System Administrator",
lastUpdatedAt: _Date, lastUpdatedAt: _Date,
} },
); );
_posMaster.isSit = false; _posMaster.isSit = false;
_posMaster.next_holderId = null; _posMaster.next_holderId = null;
@ -1730,7 +1730,7 @@ export class CommandController extends Controller {
positionIsSelected: false, positionIsSelected: false,
lastUpdateFullName: "System Administrator", lastUpdateFullName: "System Administrator",
lastUpdatedAt: _Date, lastUpdatedAt: _Date,
} },
); );
_posMaster.isSit = false; _posMaster.isSit = false;
_posMaster.current_holderId = null; _posMaster.current_holderId = null;
@ -1977,62 +1977,68 @@ export class CommandController extends Controller {
if (commandCode == "C-PM-21") { if (commandCode == "C-PM-21") {
profileTemp.position = profile?.positionTemp ?? "-"; profileTemp.position = profile?.positionTemp ?? "-";
profileTemp.posLevel = profile?.posLevelNameTemp ?? "-"; profileTemp.posLevel = profile?.posLevelNameTemp ?? "-";
profileTemp.org = (profile?.child4Temp == null ? "" : profile?.child4Temp + "\n") + profileTemp.org =
(profile?.child4Temp == null ? "" : profile?.child4Temp + "\n") +
(profile?.child3Temp == null ? "" : profile?.child3Temp + "\n") + (profile?.child3Temp == null ? "" : profile?.child3Temp + "\n") +
(profile?.child2Temp == null ? "" : profile?.child2Temp + "\n") + (profile?.child2Temp == null ? "" : profile?.child2Temp + "\n") +
(profile?.child1Temp == null ? "" : profile?.child1Temp + "\n") + (profile?.child1Temp == null ? "" : profile?.child1Temp + "\n") +
(profile?.rootTemp == null ? "" : profile?.rootTemp) (profile?.rootTemp == null ? "" : profile?.rootTemp);
if (profile?.nodeTemp) { if (profile?.nodeTemp) {
switch (profile?.nodeTemp) { switch (profile?.nodeTemp) {
case "4": case "4":
profileTemp.posNo = `${profile.child4ShortNameTemp} ${profile?.posMasterNoTemp}`; profileTemp.posNo = `${profile.child4ShortNameTemp} ${profile?.posMasterNoTemp}`;
break break;
case "3": case "3":
profileTemp.posNo = `${profile.child3ShortNameTemp} ${profile?.posMasterNoTemp}`; profileTemp.posNo = `${profile.child3ShortNameTemp} ${profile?.posMasterNoTemp}`;
break break;
case "2": case "2":
profileTemp.posNo = `${profile.child2ShortNameTemp} ${profile?.posMasterNoTemp}`; profileTemp.posNo = `${profile.child2ShortNameTemp} ${profile?.posMasterNoTemp}`;
break break;
case "1": case "1":
profileTemp.posNo = `${profile.child1ShortNameTemp} ${profile?.posMasterNoTemp}`; profileTemp.posNo = `${profile.child1ShortNameTemp} ${profile?.posMasterNoTemp}`;
break break;
case "0": case "0":
profileTemp.posNo = `${profile.rootShortNameTemp} ${profile?.posMasterNoTemp}`; profileTemp.posNo = `${profile.rootShortNameTemp} ${profile?.posMasterNoTemp}`;
break break;
default: break; default:
break;
} }
} }
} }
return { return {
no: Extension.ToThaiNumber((idx + 1).toString()), no: Extension.ToThaiNumber((idx + 1).toString()),
org: commandCode != "C-PM-21" org:
? profile?.isLeave == false commandCode != "C-PM-21"
? (_child4 == null ? "" : _child4 + "\n") + ? profile?.isLeave == false
(_child3 == null ? "" : _child3 + "\n") + ? (_child4 == null ? "" : _child4 + "\n") +
(_child2 == null ? "" : _child2 + "\n") + (_child3 == null ? "" : _child3 + "\n") +
(_child1 == null ? "" : _child1 + "\n") + (_child2 == null ? "" : _child2 + "\n") +
(_root == null ? "" : _root) (_child1 == null ? "" : _child1 + "\n") +
: orgLeave (_root == null ? "" : _root)
: profileTemp.org, : orgLeave
: profileTemp.org,
fullName: `${x.prefix}${x.firstName} ${x.lastName}`, fullName: `${x.prefix}${x.firstName} ${x.lastName}`,
citizenId: Extension.ToThaiNumber(x.citizenId), citizenId: Extension.ToThaiNumber(x.citizenId),
position: commandCode != "C-PM-21" position:
? profile?.position commandCode != "C-PM-21"
? profile?.position ? profile?.position
: "-" ? profile?.position
: profileTemp.position, : "-"
posLevel: commandCode != "C-PM-21" : profileTemp.position,
? profile?.posType && profile?.posLevel posLevel:
? Extension.ToThaiNumber( commandCode != "C-PM-21"
`${profile?.posType.posTypeShortName} ${profile?.posLevel.posLevelName}`, ? profile?.posType && profile?.posLevel
) ? Extension.ToThaiNumber(
: "-" `${profile?.posType.posTypeShortName} ${profile?.posLevel.posLevelName}`,
: Extension.ToThaiNumber(profileTemp.posLevel), )
posNo: commandCode != "C-PM-21" : "-"
? shortName : Extension.ToThaiNumber(profileTemp.posLevel),
? Extension.ToThaiNumber(shortName) posNo:
: "-" commandCode != "C-PM-21"
: Extension.ToThaiNumber(profileTemp.posNo), ? shortName
? Extension.ToThaiNumber(shortName)
: "-"
: Extension.ToThaiNumber(profileTemp.posNo),
amount: x.amount ? Extension.ToThaiNumber(x.amount.toLocaleString()) : "-", amount: x.amount ? Extension.ToThaiNumber(x.amount.toLocaleString()) : "-",
dateRetire: profile?.dateRetire dateRetire: profile?.dateRetire
? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile?.dateRetire)) ? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile?.dateRetire))
@ -4274,16 +4280,15 @@ export class CommandController extends Controller {
const posMaster: any = await this.posMasterRepository.findOne({ const posMaster: any = await this.posMasterRepository.findOne({
where: { where: {
current_holderId: item.profileId, current_holderId: item.profileId,
orgRevision:{ orgRevision: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
} },
}, },
relations:['orgRevision'] relations: ["orgRevision"],
}); });
const orgRevisionRef = posMaster ? posMaster.id : null;
const orgRevisionRef = posMaster?posMaster.id: null;
//ลบตำแหน่งที่รักษาการแทน //ลบตำแหน่งที่รักษาการแทน
const code = _command?.commandType?.code; const code = _command?.commandType?.code;
@ -4784,7 +4789,7 @@ export class CommandController extends Controller {
_profile.leaveDate = item.commandDateAffect ?? _null; _profile.leaveDate = item.commandDateAffect ?? _null;
_profile.leaveType = exceptClear.LeaveType ?? _null; _profile.leaveType = exceptClear.LeaveType ?? _null;
} else { } else {
if(orgRevisionRef){ if (orgRevisionRef) {
await CreatePosMasterHistoryOfficer(orgRevisionRef.id, req, "DELETE"); await CreatePosMasterHistoryOfficer(orgRevisionRef.id, req, "DELETE");
} }
await removeProfileInOrganize(_profile.id, "OFFICER"); await removeProfileInOrganize(_profile.id, "OFFICER");
@ -5718,7 +5723,7 @@ export class CommandController extends Controller {
posNumCodeSit: _posNumCodeSit, posNumCodeSit: _posNumCodeSit,
posNumCodeSitAbb: _posNumCodeSitAbb, posNumCodeSitAbb: _posNumCodeSitAbb,
}); });
if(orgRevisionRef){ if (orgRevisionRef) {
await CreatePosMasterHistoryOfficer(orgRevisionRef.id, req, "DELETE"); await CreatePosMasterHistoryOfficer(orgRevisionRef.id, req, "DELETE");
} }
await removeProfileInOrganize(profile.id, "OFFICER"); await removeProfileInOrganize(profile.id, "OFFICER");

View file

@ -104,16 +104,13 @@ export class DevelopmentRequestController extends Controller {
); );
}), }),
) )
.orderBy("developmentRequest.createdAt", "DESC") .orderBy("developmentRequest.createdAt", "DESC");
if (sortBy) { if (sortBy) {
query = query.orderBy( query = query.orderBy(`developmentRequest.${sortBy}`, descending ? "DESC" : "ASC");
`developmentRequest.${sortBy}`, }
descending ? "DESC" : "ASC"
);
}
const [lists, total] = await query const [lists, total] = await query
.skip((page - 1) * pageSize) .skip((page - 1) * pageSize)
.take(pageSize) .take(pageSize)
.getManyAndCount(); .getManyAndCount();
@ -166,7 +163,7 @@ export class DevelopmentRequestController extends Controller {
data.child1 != undefined && data.child1 != null data.child1 != undefined && data.child1 != null
? data.child1[0] != null ? data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null` : `current_holders.orgChild1Id is ${data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1", : "1=1",
{ {
child1: data.child1, child1: data.child1,
@ -250,20 +247,16 @@ export class DevelopmentRequestController extends Controller {
); );
}), }),
) )
.orderBy("developmentRequest.createdAt", "DESC") .orderBy("developmentRequest.createdAt", "DESC");
if (sortBy) { if (sortBy) {
query = query.orderBy( query = query.orderBy(`developmentRequest.${sortBy}`, descending ? "DESC" : "ASC");
`developmentRequest.${sortBy}`,
descending ? "DESC" : "ASC"
);
} }
const [lists, total] = await query const [lists, total] = await query
.skip((page - 1) * pageSize) .skip((page - 1) * pageSize)
.take(pageSize) .take(pageSize)
.getManyAndCount(); .getManyAndCount();
const _data = lists.map((item) => ({ ...item, profile: null })); const _data = lists.map((item) => ({ ...item, profile: null }));
return new HttpSuccess({ data: _data, total }); return new HttpSuccess({ data: _data, total });

View file

@ -1211,6 +1211,7 @@ export class OrganizationDotnetController extends Controller {
let pos = await this.posMasterRepository.findOne({ let pos = await this.posMasterRepository.findOne({
relations: ["current_holder"], relations: ["current_holder"],
where: { where: {
current_holder: Not(IsNull()),
orgRevision: { orgRevision: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
@ -1234,6 +1235,7 @@ export class OrganizationDotnetController extends Controller {
let pos = await this.posMasterRepository.findOne({ let pos = await this.posMasterRepository.findOne({
relations: ["current_holder"], relations: ["current_holder"],
where: { where: {
current_holder: Not(IsNull()),
orgRevision: { orgRevision: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
@ -1256,6 +1258,7 @@ export class OrganizationDotnetController extends Controller {
let pos = await this.posMasterRepository.findOne({ let pos = await this.posMasterRepository.findOne({
relations: ["current_holder"], relations: ["current_holder"],
where: { where: {
current_holder: Not(IsNull()),
orgRevision: { orgRevision: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
@ -1278,6 +1281,7 @@ export class OrganizationDotnetController extends Controller {
let pos = await this.posMasterRepository.findOne({ let pos = await this.posMasterRepository.findOne({
relations: ["current_holder"], relations: ["current_holder"],
where: { where: {
current_holder: Not(IsNull()),
orgRevision: { orgRevision: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
@ -1300,6 +1304,7 @@ export class OrganizationDotnetController extends Controller {
let pos = await this.posMasterRepository.findOne({ let pos = await this.posMasterRepository.findOne({
relations: ["current_holder"], relations: ["current_holder"],
where: { where: {
current_holder: Not(IsNull()),
orgRevision: { orgRevision: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
@ -1511,6 +1516,7 @@ export class OrganizationDotnetController extends Controller {
let pos = await this.posMasterRepository.findOne({ let pos = await this.posMasterRepository.findOne({
relations: ["current_holder"], relations: ["current_holder"],
where: { where: {
current_holder: Not(IsNull()),
orgRevision: { orgRevision: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
@ -1534,6 +1540,7 @@ export class OrganizationDotnetController extends Controller {
let pos = await this.posMasterRepository.findOne({ let pos = await this.posMasterRepository.findOne({
relations: ["current_holder"], relations: ["current_holder"],
where: { where: {
current_holder: Not(IsNull()),
orgRevision: { orgRevision: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
@ -1556,6 +1563,7 @@ export class OrganizationDotnetController extends Controller {
let pos = await this.posMasterRepository.findOne({ let pos = await this.posMasterRepository.findOne({
relations: ["current_holder"], relations: ["current_holder"],
where: { where: {
current_holder: Not(IsNull()),
orgRevision: { orgRevision: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
@ -1578,6 +1586,7 @@ export class OrganizationDotnetController extends Controller {
let pos = await this.posMasterRepository.findOne({ let pos = await this.posMasterRepository.findOne({
relations: ["current_holder"], relations: ["current_holder"],
where: { where: {
current_holder: Not(IsNull()),
orgRevision: { orgRevision: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
@ -1600,6 +1609,7 @@ export class OrganizationDotnetController extends Controller {
let pos = await this.posMasterRepository.findOne({ let pos = await this.posMasterRepository.findOne({
relations: ["current_holder"], relations: ["current_holder"],
where: { where: {
current_holder: Not(IsNull()),
orgRevision: { orgRevision: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, orgRevisionIsDraft: false,

View file

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

View file

@ -75,19 +75,16 @@ export class ProfileEditController extends Controller {
); );
}), }),
) )
.orderBy("ProfileEdit.createdAt", "DESC") .orderBy("ProfileEdit.createdAt", "DESC");
if (sortBy) { if (sortBy) {
query = query.orderBy( query = query.orderBy(`ProfileEdit.${sortBy}`, descending ? "DESC" : "ASC");
`ProfileEdit.${sortBy}`,
descending ? "DESC" : "ASC"
);
} }
const [getProfileEdit, total] = await query const [getProfileEdit, total] = await query
.skip((page - 1) * pageSize) .skip((page - 1) * pageSize)
.take(pageSize) .take(pageSize)
.getManyAndCount(); .getManyAndCount();
const _data = getProfileEdit.map((item) => ({ const _data = getProfileEdit.map((item) => ({
id: item.id, id: item.id,
@ -153,7 +150,7 @@ export class ProfileEditController extends Controller {
data.child1 != undefined && data.child1 != null data.child1 != undefined && data.child1 != null
? data.child1[0] != null ? data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null` : `current_holders.orgChild1Id is ${data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1", : "1=1",
{ {
child1: data.child1, child1: data.child1,
@ -216,26 +213,20 @@ export class ProfileEditController extends Controller {
); );
}), }),
) )
.orderBy("ProfileEdit.createdAt", "DESC") .orderBy("ProfileEdit.createdAt", "DESC");
if (sortBy) { if (sortBy) {
if(sortBy == "fullname"){ if (sortBy == "fullname") {
query = query.orderBy( query = query.orderBy(`profile.firstName`, descending ? "DESC" : "ASC");
`profile.firstName`, } else {
descending ? "DESC" : "ASC" query = query.orderBy(`ProfileEdit.${sortBy}`, descending ? "DESC" : "ASC");
);
}else{
query = query.orderBy(
`ProfileEdit.${sortBy}`,
descending ? "DESC" : "ASC"
);
} }
} }
const [getProfileEdit, total] = await query const [getProfileEdit, total] = await query
.skip((page - 1) * pageSize) .skip((page - 1) * pageSize)
.take(pageSize) .take(pageSize)
.getManyAndCount(); .getManyAndCount();
const _data = getProfileEdit.map((item) => ({ const _data = getProfileEdit.map((item) => ({
id: item.id, id: item.id,

View file

@ -148,7 +148,7 @@ export class ProfileEditEmployeeController extends Controller {
data.child1 != undefined && data.child1 != null data.child1 != undefined && data.child1 != null
? data.child1[0] != null ? data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null` : `current_holders.orgChild1Id is ${data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1", : "1=1",
{ {
child1: data.child1, child1: data.child1,
@ -211,26 +211,20 @@ export class ProfileEditEmployeeController extends Controller {
); );
}), }),
) )
.orderBy("ProfileEdit.createdAt", "DESC") .orderBy("ProfileEdit.createdAt", "DESC");
if (sortBy) { if (sortBy) {
if(sortBy == "fullname"){ if (sortBy == "fullname") {
query = query.orderBy( query = query.orderBy(`profileEmployee.firstName`, descending ? "DESC" : "ASC");
`profileEmployee.firstName`, } else {
descending ? "DESC" : "ASC" query = query.orderBy(`ProfileEdit.${sortBy}`, descending ? "DESC" : "ASC");
);
}else{
query = query.orderBy(
`ProfileEdit.${sortBy}`,
descending ? "DESC" : "ASC"
);
} }
} }
let [getProfileEdit, total] = await query let [getProfileEdit, total] = await query
.skip((page - 1) * pageSize) .skip((page - 1) * pageSize)
.take(pageSize) .take(pageSize)
.getManyAndCount(); .getManyAndCount();
const _data = getProfileEdit.map((item) => ({ const _data = getProfileEdit.map((item) => ({
id: item.id, id: item.id,

View file

@ -2034,12 +2034,15 @@ export class ProfileEmployeeController extends Controller {
if (!result) { if (!result) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
} }
try{ try {
await new permission().PermissionOrgUserDelete(request, "SYS_REGISTRY_EMP", result.id); await new permission().PermissionOrgUserDelete(request, "SYS_REGISTRY_EMP", result.id);
await this.informationHistoryRepository.delete({ profileEmployeeId: id }); await this.informationHistoryRepository.delete({ profileEmployeeId: id });
await this.profileRepo.remove(result); await this.profileRepo.remove(result);
} catch { } catch {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถลบข้อมูลได้ เนื่องจากข้อมูลนี้ถูกใช้งานในระบบอื่น"); throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่สามารถลบข้อมูลได้ เนื่องจากข้อมูลนี้ถูกใช้งานในระบบอื่น",
);
} }
return new HttpSuccess(); return new HttpSuccess();
} }
@ -2837,7 +2840,7 @@ export class ProfileEmployeeController extends Controller {
_data.child1 != undefined && _data.child1 != null _data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null ? _data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null` : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1", : "1=1",
{ {
child1: _data.child1, child1: _data.child1,
@ -3582,10 +3585,10 @@ export class ProfileEmployeeController extends Controller {
nodeDnaId: null, nodeDnaId: null,
salary: profile ? profile.amount : null, salary: profile ? profile.amount : null,
amountSpecial: profile ? profile.amountSpecial : null, amountSpecial: profile ? profile.amountSpecial : null,
posNo: null posNo: null,
// root?.orgRootShortName && posMaster?.posMasterNo // root?.orgRootShortName && posMaster?.posMasterNo
// ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}` // ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}`
// : "", // : "",
}; };
if (_profile.child4Id != null) { if (_profile.child4Id != null) {
_profile.node = 4; _profile.node = 4;
@ -3716,7 +3719,7 @@ export class ProfileEmployeeController extends Controller {
_data.child1 != undefined && _data.child1 != null _data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null ? _data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null` : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1", : "1=1",
{ child1: _data.child1 }, { child1: _data.child1 },
) )
@ -4274,7 +4277,7 @@ export class ProfileEmployeeController extends Controller {
_data.child1 != undefined && _data.child1 != null _data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null ? _data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null` : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1", : "1=1",
{ {
child1: _data.child1, child1: _data.child1,
@ -4435,22 +4438,26 @@ export class ProfileEmployeeController extends Controller {
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4") .leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
.leftJoinAndSelect("current_holders.positions", "positions") .leftJoinAndSelect("current_holders.positions", "positions")
.andWhere( .andWhere(
new Brackets(qb => { new Brackets((qb) => {
qb.where("profileEmployee.position LIKE :keyword", { keyword: `%${body.keyword}%` }) qb.where("profileEmployee.position LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("posLevel.posLevelName LIKE :keyword", { keyword: `%${body.keyword}%` }) .orWhere("posLevel.posLevelName LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("posType.posTypeName LIKE :keyword", { keyword: `%${body.keyword}%` }) .orWhere("posType.posTypeName LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("CONCAT(profileEmployee.prefix, profileEmployee.firstName, ' ', profileEmployee.lastName) LIKE :keyword", { keyword: `%${body.keyword}%` }); .orWhere(
}) "CONCAT(profileEmployee.prefix, profileEmployee.firstName, ' ', profileEmployee.lastName) LIKE :keyword",
{ keyword: `%${body.keyword}%` },
);
}),
) )
.andWhere("profileEmployee.isLeave = false") .andWhere("profileEmployee.isLeave = false")
.andWhere("current_holders.orgRevisionId = :orgRevisionId", { orgRevisionId: orgRevisionActive.id }); .andWhere("current_holders.orgRevisionId = :orgRevisionId", {
orgRevisionId: orgRevisionActive.id,
});
if (body.type) { if (body.type) {
const typeUpper = body.type.trim().toUpperCase(); const typeUpper = body.type.trim().toUpperCase();
if (typeUpper === "EMPLOYEE") { if (typeUpper === "EMPLOYEE") {
query = query.andWhere("profileEmployee.employeeClass = 'PERM'"); query = query.andWhere("profileEmployee.employeeClass = 'PERM'");
} } else if (typeUpper === "TEMP") {
else if (typeUpper === "TEMP"){
query = query.andWhere("profileEmployee.employeeClass = 'TEMP'"); query = query.andWhere("profileEmployee.employeeClass = 'TEMP'");
} }
} }
@ -4471,9 +4478,10 @@ export class ProfileEmployeeController extends Controller {
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id); : item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id);
const position = const position =
posMaster == null || posMaster == null ||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.positions == null || item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.positions ==
item.current_holders?.find((x) => x.orgRevisionId == orgRevisionActive.id)?.positions.length == null ||
0 || item.current_holders?.find((x) => x.orgRevisionId == orgRevisionActive.id)?.positions
.length == 0 ||
item.current_holders item.current_holders
.find((x) => x.orgRevisionId == orgRevisionActive.id) .find((x) => x.orgRevisionId == orgRevisionActive.id)
?.positions?.find((position) => position.positionIsSelected == true) == null ?.positions?.find((position) => position.positionIsSelected == true) == null
@ -4486,18 +4494,20 @@ export class ProfileEmployeeController extends Controller {
item.current_holders.length == 0 item.current_holders.length == 0
? null ? null
: 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)?.orgChild4 != item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
null ?.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)?.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) != null &&
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild3 != item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
null ?.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)?.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) item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
?.orgChild2 != null ?.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)?.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) item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
?.orgChild1 != null ?.orgChild1 != null
? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}` ? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}`

View file

@ -120,7 +120,7 @@ export class ProfileSalaryTempController extends Controller {
_data.child1 != undefined && _data.child1 != null _data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null ? _data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null` : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1", : "1=1",
{ {
child1: _data.child1, child1: _data.child1,
@ -322,52 +322,42 @@ export class ProfileSalaryTempController extends Controller {
.andWhere("current_holders.orgRootId = :rootId", { .andWhere("current_holders.orgRootId = :rootId", {
rootId: rootId, rootId: rootId,
}) })
.addSelect("CASE WHEN current_holders.posMasterNo IS NULL THEN 1 ELSE 0 END", "sort_order") .addSelect("CASE WHEN current_holders.posMasterNo IS NULL THEN 1 ELSE 0 END", "sort_order");
// .orderBy(`${sortBy}`, sort) // .orderBy(`${sortBy}`, sort)
if (sortBy) { if (sortBy) {
if(sortBy == "posLevel"){ if (sortBy == "posLevel") {
query = query.orderBy( query = query.orderBy(`posLevel.posLevelName`, descending ? "DESC" : "ASC");
`posLevel.posLevelName`, } else if (sortBy == "posType") {
descending ? "DESC" : "ASC" query = query.orderBy(`posType.posTypeName`, descending ? "DESC" : "ASC");
); } else if (sortBy == "posExecutive") {
}else if(sortBy == "posType"){ query = query.orderBy(`posExecutive.posExecutiveName`, descending ? "DESC" : "ASC");
query = query.orderBy( } else if (sortBy == "posNo") {
`posType.posTypeName`, query = query
descending ? "DESC" : "ASC" .orderBy("orgChild4.orgChild4ShortName", descending ? "DESC" : "ASC")
); .addOrderBy("orgChild3.orgChild3ShortName", descending ? "DESC" : "ASC")
}else if(sortBy == "posExecutive"){ .addOrderBy("orgChild2.orgChild2ShortName", descending ? "DESC" : "ASC")
query = query.orderBy( .addOrderBy("orgChild1.orgChild1ShortName", descending ? "DESC" : "ASC")
`posExecutive.posExecutiveName`, .addOrderBy("orgRoot.orgRootShortName", descending ? "DESC" : "ASC")
descending ? "DESC" : "ASC" .addOrderBy("current_holders.posMasterNo", descending ? "DESC" : "ASC");
); } else {
}else if(sortBy == "posNo"){ query = query.orderBy(`profile.${sortBy}`, descending ? "DESC" : "ASC");
query = query.orderBy("orgChild4.orgChild4ShortName",descending ? "DESC" : "ASC")
.addOrderBy("orgChild3.orgChild3ShortName",descending ? "DESC" : "ASC")
.addOrderBy("orgChild2.orgChild2ShortName",descending ? "DESC" : "ASC")
.addOrderBy("orgChild1.orgChild1ShortName",descending ? "DESC" : "ASC")
.addOrderBy("orgRoot.orgRootShortName",descending ? "DESC" : "ASC")
.addOrderBy("current_holders.posMasterNo",descending ? "DESC" : "ASC")
}else{
query = query.orderBy(
`profile.${sortBy}`,
descending ? "DESC" : "ASC"
);
} }
}else{ } else {
query = query.orderBy("sort_order", "ASC") query = query
.addOrderBy("orgRoot.orgRootOrder", "ASC") .orderBy("sort_order", "ASC")
.addOrderBy("orgChild1.orgChild1Order", "ASC") .addOrderBy("orgRoot.orgRootOrder", "ASC")
.addOrderBy("orgChild2.orgChild2Order", "ASC") .addOrderBy("orgChild1.orgChild1Order", "ASC")
.addOrderBy("orgChild3.orgChild3Order", "ASC") .addOrderBy("orgChild2.orgChild2Order", "ASC")
.addOrderBy("orgChild4.orgChild4Order", "ASC") .addOrderBy("orgChild3.orgChild3Order", "ASC")
.addOrderBy("current_holders.posMasterNo", "ASC") .addOrderBy("orgChild4.orgChild4Order", "ASC")
.addOrderBy("current_holders.posMasterNo", "ASC");
} }
const [record, total] = await query const [record, total] = await query
.skip((page - 1) * pageSize) .skip((page - 1) * pageSize)
.take(pageSize) .take(pageSize)
.getManyAndCount(); .getManyAndCount();
const data = await Promise.all( const data = await Promise.all(
record.map((_data) => { record.map((_data) => {
@ -541,7 +531,7 @@ export class ProfileSalaryTempController extends Controller {
_data.child1 != undefined && _data.child1 != null _data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null ? _data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null` : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1", : "1=1",
{ {
child1: _data.child1, child1: _data.child1,
@ -755,36 +745,24 @@ export class ProfileSalaryTempController extends Controller {
.andWhere("current_holders.orgRootId = :rootId", { .andWhere("current_holders.orgRootId = :rootId", {
rootId: rootId, rootId: rootId,
}) })
.orderBy("current_holders.posMasterNo", "ASC") .orderBy("current_holders.posMasterNo", "ASC");
// .orderBy(`${sortBy}`, sort) // .orderBy(`${sortBy}`, sort)
if (sortBy) { if (sortBy) {
if(sortBy == "posLevel"){ if (sortBy == "posLevel") {
query = query.orderBy( query = query.orderBy(`posLevel.posLevelName`, descending ? "DESC" : "ASC");
`posLevel.posLevelName`, } else if (sortBy == "posType") {
descending ? "DESC" : "ASC" query = query.orderBy(`posType.posTypeName`, descending ? "DESC" : "ASC");
); } else if (sortBy == "posNo") {
}else if(sortBy == "posType"){ query = query.orderBy(`orgRoot.orgRootShortName`, descending ? "DESC" : "ASC");
query = query.orderBy( } else {
`posType.posTypeName`, query = query.orderBy(`profileEmployee.${sortBy}`, descending ? "DESC" : "ASC");
descending ? "DESC" : "ASC"
);
}else if(sortBy == "posNo"){
query = query.orderBy(
`orgRoot.orgRootShortName`,
descending ? "DESC" : "ASC"
);
}else{
query = query.orderBy(
`profileEmployee.${sortBy}`,
descending ? "DESC" : "ASC"
);
} }
} }
const [record, total] = await query const [record, total] = await query
.skip((page - 1) * pageSize) .skip((page - 1) * pageSize)
.take(pageSize) .take(pageSize)
.getManyAndCount(); .getManyAndCount();
const data = await Promise.all( const data = await Promise.all(
record.map((_data) => { record.map((_data) => {
@ -1192,7 +1170,7 @@ export class ProfileSalaryTempController extends Controller {
order: { order: "DESC" }, order: { order: "DESC" },
}); });
if (salary) { if (salary) {
dest_item = salary.order+1; dest_item = salary.order + 1;
} }
// const profile = await this.profileRepo.findOneBy({ id: body.profileId }); // const profile = await this.profileRepo.findOneBy({ id: body.profileId });
// if (!profile) { // if (!profile) {
@ -1210,7 +1188,7 @@ export class ProfileSalaryTempController extends Controller {
order: { order: "DESC" }, order: { order: "DESC" },
}); });
if (salary) { if (salary) {
dest_item = salary.order+1; dest_item = salary.order + 1;
} }
// const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileId }); // const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileId });
// if (!profile) { // if (!profile) {

View file

@ -97,7 +97,7 @@ class CheckAuth {
} else if (privilege == "PARENT") { } else if (privilege == "PARENT") {
data = { data = {
root: [x.orgRootId], root: [x.orgRootId],
child1: null, child1: [null],
child2: null, child2: null,
child3: null, child3: null,
child4: null, child4: null,