no message

This commit is contained in:
Kittapath 2024-02-08 19:46:18 +07:00
parent a1b4d054c0
commit ca9a699d42

View file

@ -67,6 +67,13 @@ export class ReportController extends Controller {
order: { orgRootOrder: "ASC" }, order: { orgRootOrder: "ASC" },
relations: [ relations: [
"posMasters", "posMasters",
"posMasters.orgRoot",
"posMasters.orgChild1",
"posMasters.orgChild2",
"posMasters.orgChild3",
"posMasters.orgChild4",
"posMasters.next_holder",
"posMasters.next_holder",
"posMasters.next_holder", "posMasters.next_holder",
"posMasters.next_holder.posLevel", "posMasters.next_holder.posLevel",
"posMasters.next_holder.posType", "posMasters.next_holder.posType",
@ -87,11 +94,16 @@ export class ReportController extends Controller {
const orgRootIds = orgRootData.map((orgRoot) => orgRoot.id) || null; const orgRootIds = orgRootData.map((orgRoot) => orgRoot.id) || null;
const orgChild1Data = await this.child1Repository.find({ const orgChild1Data = await this.child1Repository.find({
where: { where: {
orgRevisionId: In(orgRootIds), orgRootId: In(orgRootIds),
}, },
order: { orgChild1Order: "ASC" }, order: { orgChild1Order: "ASC" },
relations: [ relations: [
"posMasters", "posMasters",
"posMasters.orgRoot",
"posMasters.orgChild1",
"posMasters.orgChild2",
"posMasters.orgChild3",
"posMasters.orgChild4",
"posMasters.next_holder", "posMasters.next_holder",
"posMasters.next_holder.posLevel", "posMasters.next_holder.posLevel",
"posMasters.next_holder.posType", "posMasters.next_holder.posType",
@ -112,11 +124,16 @@ export class ReportController extends Controller {
const orgChild1Ids = orgChild1Data.map((orgChild1) => orgChild1.id) || null; const orgChild1Ids = orgChild1Data.map((orgChild1) => orgChild1.id) || null;
const orgChild2Data = await this.child2Repository.find({ const orgChild2Data = await this.child2Repository.find({
where: { where: {
orgRevisionId: In(orgChild1Ids), orgChild1: In(orgChild1Ids),
}, },
order: { orgChild2Order: "ASC" }, order: { orgChild2Order: "ASC" },
relations: [ relations: [
"posMasters", "posMasters",
"posMasters.orgRoot",
"posMasters.orgChild1",
"posMasters.orgChild2",
"posMasters.orgChild3",
"posMasters.orgChild4",
"posMasters.next_holder", "posMasters.next_holder",
"posMasters.next_holder.posLevel", "posMasters.next_holder.posLevel",
"posMasters.next_holder.posType", "posMasters.next_holder.posType",
@ -137,11 +154,16 @@ export class ReportController extends Controller {
const orgChild2Ids = orgChild2Data.map((orgChild2) => orgChild2.id) || null; const orgChild2Ids = orgChild2Data.map((orgChild2) => orgChild2.id) || null;
const orgChild3Data = await this.child3Repository.find({ const orgChild3Data = await this.child3Repository.find({
where: { where: {
orgRevisionId: In(orgChild2Ids), orgChild2: In(orgChild2Ids),
}, },
order: { orgChild3Order: "ASC" }, order: { orgChild3Order: "ASC" },
relations: [ relations: [
"posMasters", "posMasters",
"posMasters.orgRoot",
"posMasters.orgChild1",
"posMasters.orgChild2",
"posMasters.orgChild3",
"posMasters.orgChild4",
"posMasters.next_holder", "posMasters.next_holder",
"posMasters.next_holder.posLevel", "posMasters.next_holder.posLevel",
"posMasters.next_holder.posType", "posMasters.next_holder.posType",
@ -162,11 +184,16 @@ export class ReportController extends Controller {
const orgChild3Ids = orgChild3Data.map((orgChild3) => orgChild3.id) || null; const orgChild3Ids = orgChild3Data.map((orgChild3) => orgChild3.id) || null;
const orgChild4Data = await this.child4Repository.find({ const orgChild4Data = await this.child4Repository.find({
where: { where: {
orgRevisionId: In(orgChild3Ids), orgChild3: In(orgChild3Ids),
}, },
order: { orgChild4Order: "ASC" }, order: { orgChild4Order: "ASC" },
relations: [ relations: [
"posMasters", "posMasters",
"posMasters.orgRoot",
"posMasters.orgChild1",
"posMasters.orgChild2",
"posMasters.orgChild3",
"posMasters.orgChild4",
"posMasters.next_holder", "posMasters.next_holder",
"posMasters.next_holder.posLevel", "posMasters.next_holder.posLevel",
"posMasters.next_holder.posType", "posMasters.next_holder.posType",
@ -211,6 +238,7 @@ export class ReportController extends Controller {
let data = new Array(); let data = new Array();
let _node: any; let _node: any;
let no = 1;
for (let orgRoot of orgRootData) { for (let orgRoot of orgRootData) {
await Promise.all( await Promise.all(
orgRoot.posMasters orgRoot.posMasters
@ -280,7 +308,7 @@ export class ReportController extends Controller {
? posMaster.positions.find((x: any) => (x.isSit = true))?.posType ? posMaster.positions.find((x: any) => (x.isSit = true))?.posType
?.posTypeName ?.posTypeName
: posMaster.next_holder.posType == null : posMaster.next_holder.posType == null
? "" ? "-"
: posMaster.next_holder.posType.posTypeName, : posMaster.next_holder.posType.posTypeName,
posLevel: posLevel:
posMaster.next_holder == null posMaster.next_holder == null
@ -289,7 +317,7 @@ export class ReportController extends Controller {
? posMaster.positions.find((x: any) => (x.isSit = true))?.posLevel ? posMaster.positions.find((x: any) => (x.isSit = true))?.posLevel
?.posLevelName ?.posLevelName
: posMaster.next_holder.posLevel == null : posMaster.next_holder.posLevel == null
? "" ? "-"
: posMaster.next_holder.posLevel.posLevelName, : posMaster.next_holder.posLevel.posLevelName,
posExecutive: posExecutive:
posMaster.next_holder == null posMaster.next_holder == null
@ -298,7 +326,7 @@ export class ReportController extends Controller {
? posMaster.positions.find((x: any) => (x.isSit = true))?.posExecutive ? posMaster.positions.find((x: any) => (x.isSit = true))?.posExecutive
?.posExecutiveName ?.posExecutiveName
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.positions.find((x: any) => (x.isSit = true)) : positionMasterProfileOld.positions.find((x: any) => (x.isSit = true))
?.posExecutive?.posExecutiveName, ?.posExecutive?.posExecutiveName,
@ -306,7 +334,7 @@ export class ReportController extends Controller {
posMaster.next_holder == null posMaster.next_holder == null
? orgRoot.orgRootName ? orgRoot.orgRootName
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.orgChild4 != null : positionMasterProfileOld.orgChild4 != null
? positionMasterProfileOld.orgChild4.orgChild4Name ? positionMasterProfileOld.orgChild4.orgChild4Name
: positionMasterProfileOld.orgChild3 != null : positionMasterProfileOld.orgChild3 != null
@ -317,12 +345,12 @@ export class ReportController extends Controller {
? positionMasterProfileOld.orgChild1.orgChild1Name ? positionMasterProfileOld.orgChild1.orgChild1Name
: positionMasterProfileOld.orgRoot != null : positionMasterProfileOld.orgRoot != null
? positionMasterProfileOld.orgRoot.orgRootName ? positionMasterProfileOld.orgRoot.orgRootName
: "", : "-",
profileOrgShortName: profileOrgShortName:
posMaster.next_holder == null posMaster.next_holder == null
? orgRoot.orgRootShortName ? orgRoot.orgRootShortName
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.orgChild4 != null : positionMasterProfileOld.orgChild4 != null
? positionMasterProfileOld.orgChild4.orgChild4ShortName ? positionMasterProfileOld.orgChild4.orgChild4ShortName
: positionMasterProfileOld.orgChild3 != null : positionMasterProfileOld.orgChild3 != null
@ -333,7 +361,7 @@ export class ReportController extends Controller {
? positionMasterProfileOld.orgChild1.orgChild1ShortName ? positionMasterProfileOld.orgChild1.orgChild1ShortName
: positionMasterProfileOld.orgRoot != null : positionMasterProfileOld.orgRoot != null
? positionMasterProfileOld.orgRoot.orgRootShortName ? positionMasterProfileOld.orgRoot.orgRootShortName
: "", : "-",
profileFullname: profileFullname:
posMaster.next_holder == null posMaster.next_holder == null
? "- ว่าง -" ? "- ว่าง -"
@ -341,10 +369,10 @@ export class ReportController extends Controller {
profilePosMasterNo: profilePosMasterNo:
posMaster.next_holder == null posMaster.next_holder == null
? positionMasterOld == null ? positionMasterOld == null
? "" ? "-"
: positionMasterOld.posMasterNo : positionMasterOld.posMasterNo
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.posMasterNo, : positionMasterProfileOld.posMasterNo,
profilePositionName: profilePositionName:
posMaster.next_holder == null posMaster.next_holder == null
@ -358,7 +386,7 @@ export class ReportController extends Controller {
? posType.join(" หรือ ") ? posType.join(" หรือ ")
: profilePosType.join(" หรือ ") : profilePosType.join(" หรือ ")
: posMaster.next_holder.posType == null : posMaster.next_holder.posType == null
? "" ? "-"
: posMaster.next_holder.posType.posTypeName, : posMaster.next_holder.posType.posTypeName,
profilePosLevel: profilePosLevel:
posMaster.next_holder == null posMaster.next_holder == null
@ -366,7 +394,7 @@ export class ReportController extends Controller {
? posLevel.join(" หรือ ") ? posLevel.join(" หรือ ")
: profilePosLevel.join(" หรือ ") : profilePosLevel.join(" หรือ ")
: posMaster.next_holder.posLevel == null : posMaster.next_holder.posLevel == null
? "" ? "-"
: posMaster.next_holder.posLevel.posLevelName, : posMaster.next_holder.posLevel.posLevelName,
profilePosExecutive: profilePosExecutive:
posMaster.next_holder == null posMaster.next_holder == null
@ -374,7 +402,7 @@ export class ReportController extends Controller {
? posExecutive.join(" หรือ ") ? posExecutive.join(" หรือ ")
: profilePosExecutive.join(" หรือ ") : profilePosExecutive.join(" หรือ ")
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.positions.find( : positionMasterProfileOld.positions.find(
(x: any) => (x.positionIsSelected = true), (x: any) => (x.positionIsSelected = true),
)?.posExecutive?.posExecutiveName, )?.posExecutive?.posExecutiveName,
@ -382,19 +410,20 @@ export class ReportController extends Controller {
if (_node == null) { if (_node == null) {
const head = { const head = {
posMasterNo: node.orgTreeShortName, posMasterNo: node.orgTreeShortName,
profileFullname: node.orgTreeName, profileFullname: node.profileOrgName,
posExecutive: "", posExecutive: node.orgTreeName,
positionName: "", positionName: "",
posType: "", posType: "",
posLevel: "", posLevel: "",
profilePosMasterNo: node.profileOrgShortName, profilePosMasterNo: node.profileOrgShortName,
profilePosExecutive: node.profileOrgName, profilePosExecutive: "",
profilePositionName: "", profilePositionName: "",
profilePosType: "", profilePosType: "",
profilePosLevel: "", profilePosLevel: "",
}; };
data.push(head); data.push(head);
const _head = { const _head = {
no: no,
posMasterNo: node.posMasterNo, posMasterNo: node.posMasterNo,
profileFullname: node.profileFullname, profileFullname: node.profileFullname,
posExecutive: node.posExecutive, posExecutive: node.posExecutive,
@ -410,9 +439,9 @@ export class ReportController extends Controller {
data.push(_head); data.push(_head);
} else { } else {
if ( if (
node.orgTreeShortName != _node.orgTreeShortName && node.orgTreeShortName != _node.orgTreeShortName ||
node.orgTreeName != _node.orgTreeName && node.orgTreeName != _node.orgTreeName ||
node.profileOrgShortName != _node.profileOrgShortName && node.profileOrgShortName != _node.profileOrgShortName ||
node.profileOrgName != _node.profileOrgName node.profileOrgName != _node.profileOrgName
) { ) {
const head = { const head = {
@ -421,8 +450,8 @@ export class ReportController extends Controller {
? "" ? ""
: node.orgTreeShortName, : node.orgTreeShortName,
profileFullname: profileFullname:
node.orgTreeName == _node.orgTreeName ? "" : node.orgTreeName, node.profileOrgName == _node.profileOrgName ? "" : node.profileOrgName,
posExecutive: "", posExecutive: node.orgTreeName == _node.orgTreeName ? "" : node.orgTreeName,
positionName: "", positionName: "",
posType: "", posType: "",
posLevel: "", posLevel: "",
@ -430,8 +459,7 @@ export class ReportController extends Controller {
node.profileOrgShortName == _node.profileOrgShortName node.profileOrgShortName == _node.profileOrgShortName
? "" ? ""
: node.profileOrgShortName, : node.profileOrgShortName,
profilePosExecutive: profilePosExecutive: "",
node.profileOrgName == _node.profileOrgName ? "" : node.profileOrgName,
profilePositionName: "", profilePositionName: "",
profilePosType: "", profilePosType: "",
profilePosLevel: "", profilePosLevel: "",
@ -440,6 +468,7 @@ export class ReportController extends Controller {
_node == null; _node == null;
} }
const head = { const head = {
no: no,
posMasterNo: node.posMasterNo == _node.posMasterNo ? "" : node.posMasterNo, posMasterNo: node.posMasterNo == _node.posMasterNo ? "" : node.posMasterNo,
profileFullname: node.profileFullname, profileFullname: node.profileFullname,
posExecutive: node.posExecutive == _node.posExecutive ? "" : node.posExecutive, posExecutive: node.posExecutive == _node.posExecutive ? "" : node.posExecutive,
@ -465,6 +494,7 @@ export class ReportController extends Controller {
}; };
data.push(head); data.push(head);
} }
no += 1;
_node = node; _node = node;
} }
}), }),
@ -548,7 +578,7 @@ export class ReportController extends Controller {
? posMaster.positions.find((x: any) => (x.isSit = true))?.posType ? posMaster.positions.find((x: any) => (x.isSit = true))?.posType
?.posTypeName ?.posTypeName
: posMaster.next_holder.posType == null : posMaster.next_holder.posType == null
? "" ? "-"
: posMaster.next_holder.posType.posTypeName, : posMaster.next_holder.posType.posTypeName,
posLevel: posLevel:
posMaster.next_holder == null posMaster.next_holder == null
@ -557,7 +587,7 @@ export class ReportController extends Controller {
? posMaster.positions.find((x: any) => (x.isSit = true))?.posLevel ? posMaster.positions.find((x: any) => (x.isSit = true))?.posLevel
?.posLevelName ?.posLevelName
: posMaster.next_holder.posLevel == null : posMaster.next_holder.posLevel == null
? "" ? "-"
: posMaster.next_holder.posLevel.posLevelName, : posMaster.next_holder.posLevel.posLevelName,
posExecutive: posExecutive:
posMaster.next_holder == null posMaster.next_holder == null
@ -566,7 +596,7 @@ export class ReportController extends Controller {
? posMaster.positions.find((x: any) => (x.isSit = true))?.posExecutive ? posMaster.positions.find((x: any) => (x.isSit = true))?.posExecutive
?.posExecutiveName ?.posExecutiveName
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.positions.find((x: any) => (x.isSit = true)) : positionMasterProfileOld.positions.find((x: any) => (x.isSit = true))
?.posExecutive?.posExecutiveName, ?.posExecutive?.posExecutiveName,
@ -574,7 +604,7 @@ export class ReportController extends Controller {
posMaster.next_holder == null posMaster.next_holder == null
? orgChild1.orgChild1Name ? orgChild1.orgChild1Name
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.orgChild4 != null : positionMasterProfileOld.orgChild4 != null
? positionMasterProfileOld.orgChild4.orgChild4Name ? positionMasterProfileOld.orgChild4.orgChild4Name
: positionMasterProfileOld.orgChild3 != null : positionMasterProfileOld.orgChild3 != null
@ -585,12 +615,12 @@ export class ReportController extends Controller {
? positionMasterProfileOld.orgChild1.orgChild1Name ? positionMasterProfileOld.orgChild1.orgChild1Name
: positionMasterProfileOld.orgRoot != null : positionMasterProfileOld.orgRoot != null
? positionMasterProfileOld.orgRoot.orgRootName ? positionMasterProfileOld.orgRoot.orgRootName
: "", : "-",
profileOrgShortName: profileOrgShortName:
posMaster.next_holder == null posMaster.next_holder == null
? orgChild1.orgChild1ShortName ? orgChild1.orgChild1ShortName
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.orgChild4 != null : positionMasterProfileOld.orgChild4 != null
? positionMasterProfileOld.orgChild4.orgChild4ShortName ? positionMasterProfileOld.orgChild4.orgChild4ShortName
: positionMasterProfileOld.orgChild3 != null : positionMasterProfileOld.orgChild3 != null
@ -601,7 +631,7 @@ export class ReportController extends Controller {
? positionMasterProfileOld.orgChild1.orgChild1ShortName ? positionMasterProfileOld.orgChild1.orgChild1ShortName
: positionMasterProfileOld.orgRoot != null : positionMasterProfileOld.orgRoot != null
? positionMasterProfileOld.orgRoot.orgRootShortName ? positionMasterProfileOld.orgRoot.orgRootShortName
: "", : "-",
profileFullname: profileFullname:
posMaster.next_holder == null posMaster.next_holder == null
? "- ว่าง -" ? "- ว่าง -"
@ -609,10 +639,10 @@ export class ReportController extends Controller {
profilePosMasterNo: profilePosMasterNo:
posMaster.next_holder == null posMaster.next_holder == null
? positionMasterOld == null ? positionMasterOld == null
? "" ? "-"
: positionMasterOld.posMasterNo : positionMasterOld.posMasterNo
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.posMasterNo, : positionMasterProfileOld.posMasterNo,
profilePositionName: profilePositionName:
posMaster.next_holder == null posMaster.next_holder == null
@ -626,7 +656,7 @@ export class ReportController extends Controller {
? posType.join(" หรือ ") ? posType.join(" หรือ ")
: profilePosType.join(" หรือ ") : profilePosType.join(" หรือ ")
: posMaster.next_holder.posType == null : posMaster.next_holder.posType == null
? "" ? "-"
: posMaster.next_holder.posType.posTypeName, : posMaster.next_holder.posType.posTypeName,
profilePosLevel: profilePosLevel:
posMaster.next_holder == null posMaster.next_holder == null
@ -634,7 +664,7 @@ export class ReportController extends Controller {
? posLevel.join(" หรือ ") ? posLevel.join(" หรือ ")
: profilePosLevel.join(" หรือ ") : profilePosLevel.join(" หรือ ")
: posMaster.next_holder.posLevel == null : posMaster.next_holder.posLevel == null
? "" ? "-"
: posMaster.next_holder.posLevel.posLevelName, : posMaster.next_holder.posLevel.posLevelName,
profilePosExecutive: profilePosExecutive:
posMaster.next_holder == null posMaster.next_holder == null
@ -642,7 +672,7 @@ export class ReportController extends Controller {
? posExecutive.join(" หรือ ") ? posExecutive.join(" หรือ ")
: profilePosExecutive.join(" หรือ ") : profilePosExecutive.join(" หรือ ")
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.positions.find( : positionMasterProfileOld.positions.find(
(x: any) => (x.positionIsSelected = true), (x: any) => (x.positionIsSelected = true),
)?.posExecutive?.posExecutiveName, )?.posExecutive?.posExecutiveName,
@ -650,19 +680,20 @@ export class ReportController extends Controller {
if (_node == null) { if (_node == null) {
const head = { const head = {
posMasterNo: node.orgTreeShortName, posMasterNo: node.orgTreeShortName,
profileFullname: node.orgTreeName, profileFullname: node.profileOrgName,
posExecutive: "", posExecutive: node.orgTreeName,
positionName: "", positionName: "",
posType: "", posType: "",
posLevel: "", posLevel: "",
profilePosMasterNo: node.profileOrgShortName, profilePosMasterNo: node.profileOrgShortName,
profilePosExecutive: node.profileOrgName, profilePosExecutive: "",
profilePositionName: "", profilePositionName: "",
profilePosType: "", profilePosType: "",
profilePosLevel: "", profilePosLevel: "",
}; };
data.push(head); data.push(head);
const _head = { const _head = {
no: no,
posMasterNo: node.posMasterNo, posMasterNo: node.posMasterNo,
profileFullname: node.profileFullname, profileFullname: node.profileFullname,
posExecutive: node.posExecutive, posExecutive: node.posExecutive,
@ -678,9 +709,9 @@ export class ReportController extends Controller {
data.push(_head); data.push(_head);
} else { } else {
if ( if (
node.orgTreeShortName != _node.orgTreeShortName && node.orgTreeShortName != _node.orgTreeShortName ||
node.orgTreeName != _node.orgTreeName && node.orgTreeName != _node.orgTreeName ||
node.profileOrgShortName != _node.profileOrgShortName && node.profileOrgShortName != _node.profileOrgShortName ||
node.profileOrgName != _node.profileOrgName node.profileOrgName != _node.profileOrgName
) { ) {
const head = { const head = {
@ -689,8 +720,8 @@ export class ReportController extends Controller {
? "" ? ""
: node.orgTreeShortName, : node.orgTreeShortName,
profileFullname: profileFullname:
node.orgTreeName == _node.orgTreeName ? "" : node.orgTreeName, node.profileOrgName == _node.profileOrgName ? "" : node.profileOrgName,
posExecutive: "", posExecutive: node.orgTreeName == _node.orgTreeName ? "" : node.orgTreeName,
positionName: "", positionName: "",
posType: "", posType: "",
posLevel: "", posLevel: "",
@ -698,8 +729,7 @@ export class ReportController extends Controller {
node.profileOrgShortName == _node.profileOrgShortName node.profileOrgShortName == _node.profileOrgShortName
? "" ? ""
: node.profileOrgShortName, : node.profileOrgShortName,
profilePosExecutive: profilePosExecutive: "",
node.profileOrgName == _node.profileOrgName ? "" : node.profileOrgName,
profilePositionName: "", profilePositionName: "",
profilePosType: "", profilePosType: "",
profilePosLevel: "", profilePosLevel: "",
@ -708,6 +738,7 @@ export class ReportController extends Controller {
_node == null; _node == null;
} }
const head = { const head = {
no: no,
posMasterNo: node.posMasterNo == _node.posMasterNo ? "" : node.posMasterNo, posMasterNo: node.posMasterNo == _node.posMasterNo ? "" : node.posMasterNo,
profileFullname: node.profileFullname, profileFullname: node.profileFullname,
posExecutive: posExecutive:
@ -735,6 +766,7 @@ export class ReportController extends Controller {
}; };
data.push(head); data.push(head);
} }
no += 1;
_node = node; _node = node;
} }
}), }),
@ -748,7 +780,10 @@ export class ReportController extends Controller {
orgChild2.posMasters orgChild2.posMasters
.sort((a, b) => a.posMasterOrder - b.posMasterOrder) .sort((a, b) => a.posMasterOrder - b.posMasterOrder)
.map(async (posMaster) => { .map(async (posMaster) => {
const positionName = [...new Set(posMaster.positions.map((x) => x.positionName))]; if (posMaster.orgChild3 == null) {
const positionName = [
...new Set(posMaster.positions.map((x) => x.positionName)),
];
const posType = [ const posType = [
...new Set(posMaster.positions.map((x) => x.posType.posTypeName)), ...new Set(posMaster.positions.map((x) => x.posType.posTypeName)),
]; ];
@ -817,7 +852,7 @@ export class ReportController extends Controller {
? posMaster.positions.find((x: any) => (x.isSit = true))?.posType ? posMaster.positions.find((x: any) => (x.isSit = true))?.posType
?.posTypeName ?.posTypeName
: posMaster.next_holder.posType == null : posMaster.next_holder.posType == null
? "" ? "-"
: posMaster.next_holder.posType.posTypeName, : posMaster.next_holder.posType.posTypeName,
posLevel: posLevel:
posMaster.next_holder == null posMaster.next_holder == null
@ -826,7 +861,7 @@ export class ReportController extends Controller {
? posMaster.positions.find((x: any) => (x.isSit = true))?.posLevel ? posMaster.positions.find((x: any) => (x.isSit = true))?.posLevel
?.posLevelName ?.posLevelName
: posMaster.next_holder.posLevel == null : posMaster.next_holder.posLevel == null
? "" ? "-"
: posMaster.next_holder.posLevel.posLevelName, : posMaster.next_holder.posLevel.posLevelName,
posExecutive: posExecutive:
posMaster.next_holder == null posMaster.next_holder == null
@ -835,15 +870,16 @@ export class ReportController extends Controller {
? posMaster.positions.find((x: any) => (x.isSit = true))?.posExecutive ? posMaster.positions.find((x: any) => (x.isSit = true))?.posExecutive
?.posExecutiveName ?.posExecutiveName
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.positions.find((x: any) => (x.isSit = true)) : positionMasterProfileOld.positions.find(
?.posExecutive?.posExecutiveName, (x: any) => (x.isSit = true),
)?.posExecutive?.posExecutiveName,
profileOrgName: profileOrgName:
posMaster.next_holder == null posMaster.next_holder == null
? orgChild2.orgChild2Name ? orgChild2.orgChild2Name
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.orgChild4 != null : positionMasterProfileOld.orgChild4 != null
? positionMasterProfileOld.orgChild4.orgChild4Name ? positionMasterProfileOld.orgChild4.orgChild4Name
: positionMasterProfileOld.orgChild3 != null : positionMasterProfileOld.orgChild3 != null
@ -854,12 +890,12 @@ export class ReportController extends Controller {
? positionMasterProfileOld.orgChild1.orgChild1Name ? positionMasterProfileOld.orgChild1.orgChild1Name
: positionMasterProfileOld.orgRoot != null : positionMasterProfileOld.orgRoot != null
? positionMasterProfileOld.orgRoot.orgRootName ? positionMasterProfileOld.orgRoot.orgRootName
: "", : "-",
profileOrgShortName: profileOrgShortName:
posMaster.next_holder == null posMaster.next_holder == null
? orgChild2.orgChild2ShortName ? orgChild2.orgChild2ShortName
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.orgChild4 != null : positionMasterProfileOld.orgChild4 != null
? positionMasterProfileOld.orgChild4.orgChild4ShortName ? positionMasterProfileOld.orgChild4.orgChild4ShortName
: positionMasterProfileOld.orgChild3 != null : positionMasterProfileOld.orgChild3 != null
@ -870,7 +906,7 @@ export class ReportController extends Controller {
? positionMasterProfileOld.orgChild1.orgChild1ShortName ? positionMasterProfileOld.orgChild1.orgChild1ShortName
: positionMasterProfileOld.orgRoot != null : positionMasterProfileOld.orgRoot != null
? positionMasterProfileOld.orgRoot.orgRootShortName ? positionMasterProfileOld.orgRoot.orgRootShortName
: "", : "-",
profileFullname: profileFullname:
posMaster.next_holder == null posMaster.next_holder == null
? "- ว่าง -" ? "- ว่าง -"
@ -878,10 +914,10 @@ export class ReportController extends Controller {
profilePosMasterNo: profilePosMasterNo:
posMaster.next_holder == null posMaster.next_holder == null
? positionMasterOld == null ? positionMasterOld == null
? "" ? "-"
: positionMasterOld.posMasterNo : positionMasterOld.posMasterNo
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.posMasterNo, : positionMasterProfileOld.posMasterNo,
profilePositionName: profilePositionName:
posMaster.next_holder == null posMaster.next_holder == null
@ -895,7 +931,7 @@ export class ReportController extends Controller {
? posType.join(" หรือ ") ? posType.join(" หรือ ")
: profilePosType.join(" หรือ ") : profilePosType.join(" หรือ ")
: posMaster.next_holder.posType == null : posMaster.next_holder.posType == null
? "" ? "-"
: posMaster.next_holder.posType.posTypeName, : posMaster.next_holder.posType.posTypeName,
profilePosLevel: profilePosLevel:
posMaster.next_holder == null posMaster.next_holder == null
@ -903,7 +939,7 @@ export class ReportController extends Controller {
? posLevel.join(" หรือ ") ? posLevel.join(" หรือ ")
: profilePosLevel.join(" หรือ ") : profilePosLevel.join(" หรือ ")
: posMaster.next_holder.posLevel == null : posMaster.next_holder.posLevel == null
? "" ? "-"
: posMaster.next_holder.posLevel.posLevelName, : posMaster.next_holder.posLevel.posLevelName,
profilePosExecutive: profilePosExecutive:
posMaster.next_holder == null posMaster.next_holder == null
@ -911,7 +947,7 @@ export class ReportController extends Controller {
? posExecutive.join(" หรือ ") ? posExecutive.join(" หรือ ")
: profilePosExecutive.join(" หรือ ") : profilePosExecutive.join(" หรือ ")
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.positions.find( : positionMasterProfileOld.positions.find(
(x: any) => (x.positionIsSelected = true), (x: any) => (x.positionIsSelected = true),
)?.posExecutive?.posExecutiveName, )?.posExecutive?.posExecutiveName,
@ -919,19 +955,20 @@ export class ReportController extends Controller {
if (_node == null) { if (_node == null) {
const head = { const head = {
posMasterNo: node.orgTreeShortName, posMasterNo: node.orgTreeShortName,
profileFullname: node.orgTreeName, profileFullname: node.profileOrgName,
posExecutive: "", posExecutive: node.orgTreeName,
positionName: "", positionName: "",
posType: "", posType: "",
posLevel: "", posLevel: "",
profilePosMasterNo: node.profileOrgShortName, profilePosMasterNo: node.profileOrgShortName,
profilePosExecutive: node.profileOrgName, profilePosExecutive: "",
profilePositionName: "", profilePositionName: "",
profilePosType: "", profilePosType: "",
profilePosLevel: "", profilePosLevel: "",
}; };
data.push(head); data.push(head);
const _head = { const _head = {
no: no,
posMasterNo: node.posMasterNo, posMasterNo: node.posMasterNo,
profileFullname: node.profileFullname, profileFullname: node.profileFullname,
posExecutive: node.posExecutive, posExecutive: node.posExecutive,
@ -947,9 +984,9 @@ export class ReportController extends Controller {
data.push(_head); data.push(_head);
} else { } else {
if ( if (
node.orgTreeShortName != _node.orgTreeShortName && node.orgTreeShortName != _node.orgTreeShortName ||
node.orgTreeName != _node.orgTreeName && node.orgTreeName != _node.orgTreeName ||
node.profileOrgShortName != _node.profileOrgShortName && node.profileOrgShortName != _node.profileOrgShortName ||
node.profileOrgName != _node.profileOrgName node.profileOrgName != _node.profileOrgName
) { ) {
const head = { const head = {
@ -958,8 +995,9 @@ export class ReportController extends Controller {
? "" ? ""
: node.orgTreeShortName, : node.orgTreeShortName,
profileFullname: profileFullname:
node.profileOrgName == _node.profileOrgName ? "" : node.profileOrgName,
posExecutive:
node.orgTreeName == _node.orgTreeName ? "" : node.orgTreeName, node.orgTreeName == _node.orgTreeName ? "" : node.orgTreeName,
posExecutive: "",
positionName: "", positionName: "",
posType: "", posType: "",
posLevel: "", posLevel: "",
@ -967,8 +1005,7 @@ export class ReportController extends Controller {
node.profileOrgShortName == _node.profileOrgShortName node.profileOrgShortName == _node.profileOrgShortName
? "" ? ""
: node.profileOrgShortName, : node.profileOrgShortName,
profilePosExecutive: profilePosExecutive: "",
node.profileOrgName == _node.profileOrgName ? "" : node.profileOrgName,
profilePositionName: "", profilePositionName: "",
profilePosType: "", profilePosType: "",
profilePosLevel: "", profilePosLevel: "",
@ -977,6 +1014,7 @@ export class ReportController extends Controller {
_node == null; _node == null;
} }
const head = { const head = {
no: no,
posMasterNo: node.posMasterNo == _node.posMasterNo ? "" : node.posMasterNo, posMasterNo: node.posMasterNo == _node.posMasterNo ? "" : node.posMasterNo,
profileFullname: node.profileFullname, profileFullname: node.profileFullname,
posExecutive: posExecutive:
@ -1004,7 +1042,9 @@ export class ReportController extends Controller {
}; };
data.push(head); data.push(head);
} }
no += 1;
_node = node; _node = node;
}
}), }),
); );
_node = null; _node = null;
@ -1016,6 +1056,7 @@ export class ReportController extends Controller {
orgChild3.posMasters orgChild3.posMasters
.sort((a, b) => a.posMasterOrder - b.posMasterOrder) .sort((a, b) => a.posMasterOrder - b.posMasterOrder)
.map(async (posMaster) => { .map(async (posMaster) => {
if (posMaster.orgChild3 == null) {
const positionName = [ const positionName = [
...new Set(posMaster.positions.map((x) => x.positionName)), ...new Set(posMaster.positions.map((x) => x.positionName)),
]; ];
@ -1087,7 +1128,7 @@ export class ReportController extends Controller {
? posMaster.positions.find((x: any) => (x.isSit = true))?.posType ? posMaster.positions.find((x: any) => (x.isSit = true))?.posType
?.posTypeName ?.posTypeName
: posMaster.next_holder.posType == null : posMaster.next_holder.posType == null
? "" ? "-"
: posMaster.next_holder.posType.posTypeName, : posMaster.next_holder.posType.posTypeName,
posLevel: posLevel:
posMaster.next_holder == null posMaster.next_holder == null
@ -1096,7 +1137,7 @@ export class ReportController extends Controller {
? posMaster.positions.find((x: any) => (x.isSit = true))?.posLevel ? posMaster.positions.find((x: any) => (x.isSit = true))?.posLevel
?.posLevelName ?.posLevelName
: posMaster.next_holder.posLevel == null : posMaster.next_holder.posLevel == null
? "" ? "-"
: posMaster.next_holder.posLevel.posLevelName, : posMaster.next_holder.posLevel.posLevelName,
posExecutive: posExecutive:
posMaster.next_holder == null posMaster.next_holder == null
@ -1105,7 +1146,7 @@ export class ReportController extends Controller {
? posMaster.positions.find((x: any) => (x.isSit = true))?.posExecutive ? posMaster.positions.find((x: any) => (x.isSit = true))?.posExecutive
?.posExecutiveName ?.posExecutiveName
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.positions.find( : positionMasterProfileOld.positions.find(
(x: any) => (x.isSit = true), (x: any) => (x.isSit = true),
)?.posExecutive?.posExecutiveName, )?.posExecutive?.posExecutiveName,
@ -1114,7 +1155,7 @@ export class ReportController extends Controller {
posMaster.next_holder == null posMaster.next_holder == null
? orgChild3.orgChild3Name ? orgChild3.orgChild3Name
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.orgChild4 != null : positionMasterProfileOld.orgChild4 != null
? positionMasterProfileOld.orgChild4.orgChild4Name ? positionMasterProfileOld.orgChild4.orgChild4Name
: positionMasterProfileOld.orgChild3 != null : positionMasterProfileOld.orgChild3 != null
@ -1125,12 +1166,12 @@ export class ReportController extends Controller {
? positionMasterProfileOld.orgChild1.orgChild1Name ? positionMasterProfileOld.orgChild1.orgChild1Name
: positionMasterProfileOld.orgRoot != null : positionMasterProfileOld.orgRoot != null
? positionMasterProfileOld.orgRoot.orgRootName ? positionMasterProfileOld.orgRoot.orgRootName
: "", : "-",
profileOrgShortName: profileOrgShortName:
posMaster.next_holder == null posMaster.next_holder == null
? orgChild3.orgChild3ShortName ? orgChild3.orgChild3ShortName
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.orgChild4 != null : positionMasterProfileOld.orgChild4 != null
? positionMasterProfileOld.orgChild4.orgChild4ShortName ? positionMasterProfileOld.orgChild4.orgChild4ShortName
: positionMasterProfileOld.orgChild3 != null : positionMasterProfileOld.orgChild3 != null
@ -1141,7 +1182,7 @@ export class ReportController extends Controller {
? positionMasterProfileOld.orgChild1.orgChild1ShortName ? positionMasterProfileOld.orgChild1.orgChild1ShortName
: positionMasterProfileOld.orgRoot != null : positionMasterProfileOld.orgRoot != null
? positionMasterProfileOld.orgRoot.orgRootShortName ? positionMasterProfileOld.orgRoot.orgRootShortName
: "", : "-",
profileFullname: profileFullname:
posMaster.next_holder == null posMaster.next_holder == null
? "- ว่าง -" ? "- ว่าง -"
@ -1149,10 +1190,10 @@ export class ReportController extends Controller {
profilePosMasterNo: profilePosMasterNo:
posMaster.next_holder == null posMaster.next_holder == null
? positionMasterOld == null ? positionMasterOld == null
? "" ? "-"
: positionMasterOld.posMasterNo : positionMasterOld.posMasterNo
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.posMasterNo, : positionMasterProfileOld.posMasterNo,
profilePositionName: profilePositionName:
posMaster.next_holder == null posMaster.next_holder == null
@ -1166,7 +1207,7 @@ export class ReportController extends Controller {
? posType.join(" หรือ ") ? posType.join(" หรือ ")
: profilePosType.join(" หรือ ") : profilePosType.join(" หรือ ")
: posMaster.next_holder.posType == null : posMaster.next_holder.posType == null
? "" ? "-"
: posMaster.next_holder.posType.posTypeName, : posMaster.next_holder.posType.posTypeName,
profilePosLevel: profilePosLevel:
posMaster.next_holder == null posMaster.next_holder == null
@ -1174,7 +1215,7 @@ export class ReportController extends Controller {
? posLevel.join(" หรือ ") ? posLevel.join(" หรือ ")
: profilePosLevel.join(" หรือ ") : profilePosLevel.join(" หรือ ")
: posMaster.next_holder.posLevel == null : posMaster.next_holder.posLevel == null
? "" ? "-"
: posMaster.next_holder.posLevel.posLevelName, : posMaster.next_holder.posLevel.posLevelName,
profilePosExecutive: profilePosExecutive:
posMaster.next_holder == null posMaster.next_holder == null
@ -1182,7 +1223,7 @@ export class ReportController extends Controller {
? posExecutive.join(" หรือ ") ? posExecutive.join(" หรือ ")
: profilePosExecutive.join(" หรือ ") : profilePosExecutive.join(" หรือ ")
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.positions.find( : positionMasterProfileOld.positions.find(
(x: any) => (x.positionIsSelected = true), (x: any) => (x.positionIsSelected = true),
)?.posExecutive?.posExecutiveName, )?.posExecutive?.posExecutiveName,
@ -1190,19 +1231,20 @@ export class ReportController extends Controller {
if (_node == null) { if (_node == null) {
const head = { const head = {
posMasterNo: node.orgTreeShortName, posMasterNo: node.orgTreeShortName,
profileFullname: node.orgTreeName, profileFullname: node.profileOrgName,
posExecutive: "", posExecutive: node.orgTreeName,
positionName: "", positionName: "",
posType: "", posType: "",
posLevel: "", posLevel: "",
profilePosMasterNo: node.profileOrgShortName, profilePosMasterNo: node.profileOrgShortName,
profilePosExecutive: node.profileOrgName, profilePosExecutive: "",
profilePositionName: "", profilePositionName: "",
profilePosType: "", profilePosType: "",
profilePosLevel: "", profilePosLevel: "",
}; };
data.push(head); data.push(head);
const _head = { const _head = {
no: no,
posMasterNo: node.posMasterNo, posMasterNo: node.posMasterNo,
profileFullname: node.profileFullname, profileFullname: node.profileFullname,
posExecutive: node.posExecutive, posExecutive: node.posExecutive,
@ -1218,9 +1260,9 @@ export class ReportController extends Controller {
data.push(_head); data.push(_head);
} else { } else {
if ( if (
node.orgTreeShortName != _node.orgTreeShortName && node.orgTreeShortName != _node.orgTreeShortName ||
node.orgTreeName != _node.orgTreeName && node.orgTreeName != _node.orgTreeName ||
node.profileOrgShortName != _node.profileOrgShortName && node.profileOrgShortName != _node.profileOrgShortName ||
node.profileOrgName != _node.profileOrgName node.profileOrgName != _node.profileOrgName
) { ) {
const head = { const head = {
@ -1229,8 +1271,11 @@ export class ReportController extends Controller {
? "" ? ""
: node.orgTreeShortName, : node.orgTreeShortName,
profileFullname: profileFullname:
node.profileOrgName == _node.profileOrgName
? ""
: node.profileOrgName,
posExecutive:
node.orgTreeName == _node.orgTreeName ? "" : node.orgTreeName, node.orgTreeName == _node.orgTreeName ? "" : node.orgTreeName,
posExecutive: "",
positionName: "", positionName: "",
posType: "", posType: "",
posLevel: "", posLevel: "",
@ -1238,8 +1283,7 @@ export class ReportController extends Controller {
node.profileOrgShortName == _node.profileOrgShortName node.profileOrgShortName == _node.profileOrgShortName
? "" ? ""
: node.profileOrgShortName, : node.profileOrgShortName,
profilePosExecutive: profilePosExecutive: "",
node.profileOrgName == _node.profileOrgName ? "" : node.profileOrgName,
profilePositionName: "", profilePositionName: "",
profilePosType: "", profilePosType: "",
profilePosLevel: "", profilePosLevel: "",
@ -1248,7 +1292,9 @@ export class ReportController extends Controller {
_node == null; _node == null;
} }
const head = { const head = {
posMasterNo: node.posMasterNo == _node.posMasterNo ? "" : node.posMasterNo, no: no,
posMasterNo:
node.posMasterNo == _node.posMasterNo ? "" : node.posMasterNo,
profileFullname: node.profileFullname, profileFullname: node.profileFullname,
posExecutive: posExecutive:
node.posExecutive == _node.posExecutive ? "" : node.posExecutive, node.posExecutive == _node.posExecutive ? "" : node.posExecutive,
@ -1271,11 +1317,15 @@ export class ReportController extends Controller {
profilePosType: profilePosType:
node.profilePosType == _node.profilePosType ? "" : node.profilePosType, node.profilePosType == _node.profilePosType ? "" : node.profilePosType,
profilePosLevel: profilePosLevel:
node.profilePosLevel == _node.profilePosLevel ? "" : node.profilePosLevel, node.profilePosLevel == _node.profilePosLevel
? ""
: node.profilePosLevel,
}; };
data.push(head); data.push(head);
} }
no += 1;
_node = node; _node = node;
}
}), }),
); );
_node = null; _node = null;
@ -1358,7 +1408,7 @@ export class ReportController extends Controller {
? posMaster.positions.find((x: any) => (x.isSit = true))?.posType ? posMaster.positions.find((x: any) => (x.isSit = true))?.posType
?.posTypeName ?.posTypeName
: posMaster.next_holder.posType == null : posMaster.next_holder.posType == null
? "" ? "-"
: posMaster.next_holder.posType.posTypeName, : posMaster.next_holder.posType.posTypeName,
posLevel: posLevel:
posMaster.next_holder == null posMaster.next_holder == null
@ -1367,7 +1417,7 @@ export class ReportController extends Controller {
? posMaster.positions.find((x: any) => (x.isSit = true))?.posLevel ? posMaster.positions.find((x: any) => (x.isSit = true))?.posLevel
?.posLevelName ?.posLevelName
: posMaster.next_holder.posLevel == null : posMaster.next_holder.posLevel == null
? "" ? "-"
: posMaster.next_holder.posLevel.posLevelName, : posMaster.next_holder.posLevel.posLevelName,
posExecutive: posExecutive:
posMaster.next_holder == null posMaster.next_holder == null
@ -1376,7 +1426,7 @@ export class ReportController extends Controller {
? posMaster.positions.find((x: any) => (x.isSit = true))?.posExecutive ? posMaster.positions.find((x: any) => (x.isSit = true))?.posExecutive
?.posExecutiveName ?.posExecutiveName
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.positions.find( : positionMasterProfileOld.positions.find(
(x: any) => (x.isSit = true), (x: any) => (x.isSit = true),
)?.posExecutive?.posExecutiveName, )?.posExecutive?.posExecutiveName,
@ -1385,7 +1435,7 @@ export class ReportController extends Controller {
posMaster.next_holder == null posMaster.next_holder == null
? orgChild4.orgChild4Name ? orgChild4.orgChild4Name
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.orgChild4 != null : positionMasterProfileOld.orgChild4 != null
? positionMasterProfileOld.orgChild4.orgChild4Name ? positionMasterProfileOld.orgChild4.orgChild4Name
: positionMasterProfileOld.orgChild3 != null : positionMasterProfileOld.orgChild3 != null
@ -1396,12 +1446,12 @@ export class ReportController extends Controller {
? positionMasterProfileOld.orgChild1.orgChild1Name ? positionMasterProfileOld.orgChild1.orgChild1Name
: positionMasterProfileOld.orgRoot != null : positionMasterProfileOld.orgRoot != null
? positionMasterProfileOld.orgRoot.orgRootName ? positionMasterProfileOld.orgRoot.orgRootName
: "", : "-",
profileOrgShortName: profileOrgShortName:
posMaster.next_holder == null posMaster.next_holder == null
? orgChild4.orgChild4ShortName ? orgChild4.orgChild4ShortName
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.orgChild4 != null : positionMasterProfileOld.orgChild4 != null
? positionMasterProfileOld.orgChild4.orgChild4ShortName ? positionMasterProfileOld.orgChild4.orgChild4ShortName
: positionMasterProfileOld.orgChild3 != null : positionMasterProfileOld.orgChild3 != null
@ -1412,7 +1462,7 @@ export class ReportController extends Controller {
? positionMasterProfileOld.orgChild1.orgChild1ShortName ? positionMasterProfileOld.orgChild1.orgChild1ShortName
: positionMasterProfileOld.orgRoot != null : positionMasterProfileOld.orgRoot != null
? positionMasterProfileOld.orgRoot.orgRootShortName ? positionMasterProfileOld.orgRoot.orgRootShortName
: "", : "-",
profileFullname: profileFullname:
posMaster.next_holder == null posMaster.next_holder == null
? "- ว่าง -" ? "- ว่าง -"
@ -1420,10 +1470,10 @@ export class ReportController extends Controller {
profilePosMasterNo: profilePosMasterNo:
posMaster.next_holder == null posMaster.next_holder == null
? positionMasterOld == null ? positionMasterOld == null
? "" ? "-"
: positionMasterOld.posMasterNo : positionMasterOld.posMasterNo
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.posMasterNo, : positionMasterProfileOld.posMasterNo,
profilePositionName: profilePositionName:
posMaster.next_holder == null posMaster.next_holder == null
@ -1437,7 +1487,7 @@ export class ReportController extends Controller {
? posType.join(" หรือ ") ? posType.join(" หรือ ")
: profilePosType.join(" หรือ ") : profilePosType.join(" หรือ ")
: posMaster.next_holder.posType == null : posMaster.next_holder.posType == null
? "" ? "-"
: posMaster.next_holder.posType.posTypeName, : posMaster.next_holder.posType.posTypeName,
profilePosLevel: profilePosLevel:
posMaster.next_holder == null posMaster.next_holder == null
@ -1445,7 +1495,7 @@ export class ReportController extends Controller {
? posLevel.join(" หรือ ") ? posLevel.join(" หรือ ")
: profilePosLevel.join(" หรือ ") : profilePosLevel.join(" หรือ ")
: posMaster.next_holder.posLevel == null : posMaster.next_holder.posLevel == null
? "" ? "-"
: posMaster.next_holder.posLevel.posLevelName, : posMaster.next_holder.posLevel.posLevelName,
profilePosExecutive: profilePosExecutive:
posMaster.next_holder == null posMaster.next_holder == null
@ -1453,7 +1503,7 @@ export class ReportController extends Controller {
? posExecutive.join(" หรือ ") ? posExecutive.join(" หรือ ")
: profilePosExecutive.join(" หรือ ") : profilePosExecutive.join(" หรือ ")
: positionMasterProfileOld == null : positionMasterProfileOld == null
? "" ? "-"
: positionMasterProfileOld.positions.find( : positionMasterProfileOld.positions.find(
(x: any) => (x.positionIsSelected = true), (x: any) => (x.positionIsSelected = true),
)?.posExecutive?.posExecutiveName, )?.posExecutive?.posExecutiveName,
@ -1461,19 +1511,20 @@ export class ReportController extends Controller {
if (_node == null) { if (_node == null) {
const head = { const head = {
posMasterNo: node.orgTreeShortName, posMasterNo: node.orgTreeShortName,
profileFullname: node.orgTreeName, profileFullname: node.profileOrgName,
posExecutive: "", posExecutive: node.orgTreeName,
positionName: "", positionName: "",
posType: "", posType: "",
posLevel: "", posLevel: "",
profilePosMasterNo: node.profileOrgShortName, profilePosMasterNo: node.profileOrgShortName,
profilePosExecutive: node.profileOrgName, profilePosExecutive: "",
profilePositionName: "", profilePositionName: "",
profilePosType: "", profilePosType: "",
profilePosLevel: "", profilePosLevel: "",
}; };
data.push(head); data.push(head);
const _head = { const _head = {
no: no,
posMasterNo: node.posMasterNo, posMasterNo: node.posMasterNo,
profileFullname: node.profileFullname, profileFullname: node.profileFullname,
posExecutive: node.posExecutive, posExecutive: node.posExecutive,
@ -1489,9 +1540,9 @@ export class ReportController extends Controller {
data.push(_head); data.push(_head);
} else { } else {
if ( if (
node.orgTreeShortName != _node.orgTreeShortName && node.orgTreeShortName != _node.orgTreeShortName ||
node.orgTreeName != _node.orgTreeName && node.orgTreeName != _node.orgTreeName ||
node.profileOrgShortName != _node.profileOrgShortName && node.profileOrgShortName != _node.profileOrgShortName ||
node.profileOrgName != _node.profileOrgName node.profileOrgName != _node.profileOrgName
) { ) {
const head = { const head = {
@ -1500,8 +1551,11 @@ export class ReportController extends Controller {
? "" ? ""
: node.orgTreeShortName, : node.orgTreeShortName,
profileFullname: profileFullname:
node.profileOrgName == _node.profileOrgName
? ""
: node.profileOrgName,
posExecutive:
node.orgTreeName == _node.orgTreeName ? "" : node.orgTreeName, node.orgTreeName == _node.orgTreeName ? "" : node.orgTreeName,
posExecutive: "",
positionName: "", positionName: "",
posType: "", posType: "",
posLevel: "", posLevel: "",
@ -1509,10 +1563,7 @@ export class ReportController extends Controller {
node.profileOrgShortName == _node.profileOrgShortName node.profileOrgShortName == _node.profileOrgShortName
? "" ? ""
: node.profileOrgShortName, : node.profileOrgShortName,
profilePosExecutive: profilePosExecutive: "",
node.profileOrgName == _node.profileOrgName
? ""
: node.profileOrgName,
profilePositionName: "", profilePositionName: "",
profilePosType: "", profilePosType: "",
profilePosLevel: "", profilePosLevel: "",
@ -1521,6 +1572,7 @@ export class ReportController extends Controller {
_node == null; _node == null;
} }
const head = { const head = {
no: no,
posMasterNo: posMasterNo:
node.posMasterNo == _node.posMasterNo ? "" : node.posMasterNo, node.posMasterNo == _node.posMasterNo ? "" : node.posMasterNo,
profileFullname: node.profileFullname, profileFullname: node.profileFullname,
@ -1551,6 +1603,7 @@ export class ReportController extends Controller {
}; };
data.push(head); data.push(head);
} }
no += 1;
_node = node; _node = node;
}), }),
); );