no message

This commit is contained in:
Kittapath 2024-02-07 12:43:49 +07:00
parent ca82158a20
commit 148fa2c81c
6 changed files with 65 additions and 30 deletions

View file

@ -99,7 +99,10 @@ export class PositionController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล PosLevelId");
}
if (requestBody.posExecutiveId != "") requestBody.posExecutiveId = null;
if (requestBody.posExecutiveId == "") {
requestBody.posExecutiveId = null;
posDict.posExecutiveId = null;
}
if (requestBody.posExecutiveId != null) {
const checkPosExecutiveId = await this.posExecutiveRepository.findOne({

View file

@ -82,6 +82,10 @@ export class ReportController extends Controller {
relations: [
"posMasters",
"posMasters.next_holder",
"posMasters.next_holder.posLevel",
"posMasters.next_holder.posType",
"posMasters.next_holder.current_holders",
"posMasters.next_holder.current_holders.positions",
"posMasters.positions",
"posMasters.positions.posLevel",
"posMasters.positions.posType",
@ -181,18 +185,18 @@ export class ReportController extends Controller {
if (_orgRevisionActive.length > 0) orgRevisionActive = _orgRevisionActive[0];
}
const posMasterOlds = await this.posMasterRepository.find({
where: {
orgRevisionId: orgRevisionActive.id,
},
relations: ["next_holder", "current_holder"],
});
const positionOlds = await this.positionRepository.find({
where: {
posMasterId: In(posMasterOlds.map((posMaster: any) => posMaster.id)),
},
relations: ["posLevel", "posType", "posExecutive"],
});
// const posMasterOlds = await this.posMasterRepository.find({
// where: {
// orgRevisionId: orgRevisionActive.id,
// },
// relations: ["next_holder", "current_holder"],
// });
// const positionOlds = await this.positionRepository.find({
// where: {
// posMasterId: In(posMasterOlds.map((posMaster: any) => posMaster.id)),
// },
// relations: ["posLevel", "posType", "posExecutive"],
// });
let data = new Array();
for (let orgRoot of orgRootData) {
@ -237,6 +241,11 @@ export class ReportController extends Controller {
...new Set(posMaster.positions.map((x) => x.posLevel.posLevelName)),
];
const positionField = [...new Set(posMaster.positions.map((x) => x.positionField))];
const positionMasterOld = posMaster.next_holder.current_holders.find(
(x) => x == orgRevisionActive,
);
console.log(orgRevisionActive);
console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
return {
posMasterNoPrefix: posMaster.posMasterNoPrefix,
posMasterNo: posMaster.posMasterNo,
@ -245,13 +254,37 @@ export class ReportController extends Controller {
posMaster.next_holder == null
? "- ว่าง -"
: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`,
profilePosMasterNo: posMaster.next_holder == null ? null : "xxx",
// profilePosMasterNo:
// posMaster.next_holder == null
// ? posMaster.posMasterNo
// : positionMasterOld == null
// ? null
// : positionMasterOld.posMasterNo,
profilePositionName:
posMaster.next_holder == null ? positionName.join(" หรือ ") : "xxx",
profilePosType: posMaster.next_holder == null ? posType.join(" หรือ ") : "xxx",
profilePosLevel: posMaster.next_holder == null ? posLevel.join(" หรือ ") : "xxx",
profilePositionField:
posMaster.next_holder == null ? positionField.join(" หรือ ") : "xxx",
posMaster.next_holder == null
? positionName.join(" หรือ ")
: posMaster.next_holder.position,
profilePosType:
posMaster.next_holder == null
? posType.join(" หรือ ")
: posMaster.next_holder.posType == null
? null
: posMaster.next_holder.posType.posTypeName,
profilePosLevel:
posMaster.next_holder == null
? posLevel.join(" หรือ ")
: posMaster.next_holder.posLevel == null
? null
: posMaster.next_holder.posLevel.posLevelName,
// profilePositionField:
// posMaster.next_holder == null
// ? positionField.join(" หรือ ")
// : positionMasterOld == null
// ? null
// : positionMasterOld.positions.find((x) => (x.positionIsSelected = true))
// ?.positionField,
// profilePosMasterNo: (posMasterOld == null ? null : posMasterOld.posMasterNo),
// profilePositionName: (positionOld == null ? null : positionOld.positionName),
// profilePosType: (positionOld == null ? null : positionOld.posType.posTypeName),