search กำหนดสิทธิ์
This commit is contained in:
parent
c102857dc2
commit
aed9691019
2 changed files with 90 additions and 176 deletions
|
|
@ -1543,9 +1543,6 @@ export class PositionController extends Controller {
|
||||||
searchShortName = `CONCAT(orgRoot.orgRootShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
searchShortName = `CONCAT(orgRoot.orgRootShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.type === 1) {
|
} else if (body.type === 1) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild1Id: body.id,
|
orgChild1Id: body.id,
|
||||||
|
|
@ -1557,9 +1554,6 @@ export class PositionController extends Controller {
|
||||||
searchShortName = `CONCAT(orgChild1.orgChild1ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
searchShortName = `CONCAT(orgChild1.orgChild1ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.type === 2) {
|
} else if (body.type === 2) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild2Id: body.id,
|
orgChild2Id: body.id,
|
||||||
|
|
@ -1571,9 +1565,6 @@ export class PositionController extends Controller {
|
||||||
searchShortName = `CONCAT(orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
searchShortName = `CONCAT(orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.type === 3) {
|
} else if (body.type === 3) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild3Id: body.id,
|
orgChild3Id: body.id,
|
||||||
|
|
@ -1585,21 +1576,18 @@ export class PositionController extends Controller {
|
||||||
searchShortName = `CONCAT(orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
searchShortName = `CONCAT(orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.type === 4) {
|
} else if (body.type === 4) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild4Id: body.id,
|
orgChild4Id: body.id,
|
||||||
};
|
};
|
||||||
searchShortName = `CONCAT(orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
searchShortName = `CONCAT(orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
body.isAll = true;
|
body.isAll = true;
|
||||||
}
|
}
|
||||||
|
if (body.isBlank == true) {
|
||||||
|
typeCondition.current_holderId = IsNull();
|
||||||
|
}
|
||||||
let findPosition: any;
|
let findPosition: any;
|
||||||
let masterId = new Array();
|
let masterId = new Array();
|
||||||
let _authRoleId = new Array();
|
let _authRoleId = new Array();
|
||||||
|
|
@ -3642,79 +3630,52 @@ export class PositionController extends Controller {
|
||||||
orgRootId: body.nodeId,
|
orgRootId: body.nodeId,
|
||||||
orgChild1Id: IsNull(),
|
orgChild1Id: IsNull(),
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 1) {
|
} else if (body.node === 1) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild1Id: body.nodeId,
|
orgChild1Id: body.nodeId,
|
||||||
orgChild2Id: IsNull(),
|
orgChild2Id: IsNull(),
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 2) {
|
} else if (body.node === 2) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild2Id: body.nodeId,
|
orgChild2Id: body.nodeId,
|
||||||
orgChild3Id: IsNull(),
|
orgChild3Id: IsNull(),
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 3) {
|
} else if (body.node === 3) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild3Id: body.nodeId,
|
orgChild3Id: body.nodeId,
|
||||||
orgChild4Id: IsNull(),
|
orgChild4Id: IsNull(),
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 4) {
|
} else if (body.node === 4) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild4Id: body.nodeId,
|
orgChild4Id: body.nodeId,
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (body.node === 0) {
|
if (body.node === 0) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgRootId: body.nodeId,
|
orgRootId: body.nodeId,
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 1) {
|
} else if (body.node === 1) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild1Id: body.nodeId,
|
orgChild1Id: body.nodeId,
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 2) {
|
} else if (body.node === 2) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild2Id: body.nodeId,
|
orgChild2Id: body.nodeId,
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 3) {
|
} else if (body.node === 3) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild3Id: body.nodeId,
|
orgChild3Id: body.nodeId,
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 4) {
|
} else if (body.node === 4) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild4Id: body.nodeId,
|
orgChild4Id: body.nodeId,
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (body.isBlank == true) {
|
||||||
|
typeCondition.current_holderId = IsNull();
|
||||||
|
}
|
||||||
|
|
||||||
const [posMaster, total] = await AppDataSource.getRepository(PosMaster)
|
const [posMaster, total] = await AppDataSource.getRepository(PosMaster)
|
||||||
.createQueryBuilder("posMaster")
|
.createQueryBuilder("posMaster")
|
||||||
|
|
@ -3930,79 +3891,52 @@ export class PositionController extends Controller {
|
||||||
orgRootId: body.nodeId,
|
orgRootId: body.nodeId,
|
||||||
orgChild1Id: IsNull(),
|
orgChild1Id: IsNull(),
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 1) {
|
} else if (body.node === 1) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild1Id: body.nodeId,
|
orgChild1Id: body.nodeId,
|
||||||
orgChild2Id: IsNull(),
|
orgChild2Id: IsNull(),
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 2) {
|
} else if (body.node === 2) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild2Id: body.nodeId,
|
orgChild2Id: body.nodeId,
|
||||||
orgChild3Id: IsNull(),
|
orgChild3Id: IsNull(),
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 3) {
|
} else if (body.node === 3) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild3Id: body.nodeId,
|
orgChild3Id: body.nodeId,
|
||||||
orgChild4Id: IsNull(),
|
orgChild4Id: IsNull(),
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 4) {
|
} else if (body.node === 4) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild4Id: body.nodeId,
|
orgChild4Id: body.nodeId,
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (body.node === 0) {
|
if (body.node === 0) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgRootId: body.nodeId,
|
orgRootId: body.nodeId,
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 1) {
|
} else if (body.node === 1) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild1Id: body.nodeId,
|
orgChild1Id: body.nodeId,
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 2) {
|
} else if (body.node === 2) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild2Id: body.nodeId,
|
orgChild2Id: body.nodeId,
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 3) {
|
} else if (body.node === 3) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild3Id: body.nodeId,
|
orgChild3Id: body.nodeId,
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 4) {
|
} else if (body.node === 4) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild4Id: body.nodeId,
|
orgChild4Id: body.nodeId,
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (body.isBlank == true) {
|
||||||
|
typeCondition.current_holderId = IsNull();
|
||||||
|
}
|
||||||
|
|
||||||
const [posMaster, total] = await AppDataSource.getRepository(PosMaster)
|
const [posMaster, total] = await AppDataSource.getRepository(PosMaster)
|
||||||
.createQueryBuilder("posMaster")
|
.createQueryBuilder("posMaster")
|
||||||
|
|
@ -4186,79 +4120,52 @@ export class PositionController extends Controller {
|
||||||
orgRootId: body.nodeId,
|
orgRootId: body.nodeId,
|
||||||
orgChild1Id: IsNull(),
|
orgChild1Id: IsNull(),
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 1) {
|
} else if (body.node === 1) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild1Id: body.nodeId,
|
orgChild1Id: body.nodeId,
|
||||||
orgChild2Id: IsNull(),
|
orgChild2Id: IsNull(),
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 2) {
|
} else if (body.node === 2) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild2Id: body.nodeId,
|
orgChild2Id: body.nodeId,
|
||||||
orgChild3Id: IsNull(),
|
orgChild3Id: IsNull(),
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 3) {
|
} else if (body.node === 3) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild3Id: body.nodeId,
|
orgChild3Id: body.nodeId,
|
||||||
orgChild4Id: IsNull(),
|
orgChild4Id: IsNull(),
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 4) {
|
} else if (body.node === 4) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild4Id: body.nodeId,
|
orgChild4Id: body.nodeId,
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (body.node === 0) {
|
if (body.node === 0) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgRootId: body.nodeId,
|
orgRootId: body.nodeId,
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 1) {
|
} else if (body.node === 1) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild1Id: body.nodeId,
|
orgChild1Id: body.nodeId,
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 2) {
|
} else if (body.node === 2) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild2Id: body.nodeId,
|
orgChild2Id: body.nodeId,
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 3) {
|
} else if (body.node === 3) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild3Id: body.nodeId,
|
orgChild3Id: body.nodeId,
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
} else if (body.node === 4) {
|
} else if (body.node === 4) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgChild4Id: body.nodeId,
|
orgChild4Id: body.nodeId,
|
||||||
};
|
};
|
||||||
if (body.isBlank == true) {
|
|
||||||
typeCondition.current_holderId = IsNull();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (body.isBlank == true) {
|
||||||
|
typeCondition.current_holderId = IsNull();
|
||||||
|
}
|
||||||
|
|
||||||
const [posMaster, total] = await AppDataSource.getRepository(EmployeePosMaster)
|
const [posMaster, total] = await AppDataSource.getRepository(EmployeePosMaster)
|
||||||
.createQueryBuilder("posMaster")
|
.createQueryBuilder("posMaster")
|
||||||
|
|
@ -4383,9 +4290,10 @@ export class PositionController extends Controller {
|
||||||
posTypeId: position.posTypeId,
|
posTypeId: position.posTypeId,
|
||||||
posTypeName: position.posType == null ? null : position.posType.posTypeName,
|
posTypeName: position.posType == null ? null : position.posType.posTypeName,
|
||||||
posLevelId: position.posLevelId,
|
posLevelId: position.posLevelId,
|
||||||
posLevelName: position.posType == null && position.posLevel == null
|
posLevelName:
|
||||||
? null
|
position.posType == null && position.posLevel == null
|
||||||
: `${position.posType.posTypeShortName} ${position.posLevel.posLevelName}`,
|
? null
|
||||||
|
: `${position.posType.posTypeShortName} ${position.posLevel.posLevelName}`,
|
||||||
// posExecutiveId: position.posExecutiveId,
|
// posExecutiveId: position.posExecutiveId,
|
||||||
// posExecutiveName:
|
// posExecutiveName:
|
||||||
// position.posExecutive == null ? null : position.posExecutive.posExecutiveName,
|
// position.posExecutive == null ? null : position.posExecutive.posExecutiveName,
|
||||||
|
|
|
||||||
|
|
@ -1256,30 +1256,30 @@ export class ProfileController extends Controller {
|
||||||
];
|
];
|
||||||
|
|
||||||
const leave_raw = await this.profileLeaveRepository
|
const leave_raw = await this.profileLeaveRepository
|
||||||
.createQueryBuilder('profileLeave')
|
.createQueryBuilder("profileLeave")
|
||||||
.leftJoinAndSelect('profileLeave.leaveType', 'leaveType')
|
.leftJoinAndSelect("profileLeave.leaveType", "leaveType")
|
||||||
.select([
|
.select([
|
||||||
'profileLeave.leaveTypeId',
|
"profileLeave.leaveTypeId",
|
||||||
'leaveType.name as name',
|
"leaveType.name as name",
|
||||||
'leaveType.code as code',
|
"leaveType.code as code",
|
||||||
'profileLeave.status',
|
"profileLeave.status",
|
||||||
'profileLeave.profileId',
|
"profileLeave.profileId",
|
||||||
'MAX(profileLeave.dateLeaveStart) as maxDateLeaveStart'
|
"MAX(profileLeave.dateLeaveStart) as maxDateLeaveStart",
|
||||||
])
|
])
|
||||||
.addSelect('SUM(profileLeave.leaveDays)', 'totalLeaveDays')
|
.addSelect("SUM(profileLeave.leaveDays)", "totalLeaveDays")
|
||||||
.where('profileLeave.profileId = :profileId', { profileId: id })
|
.where("profileLeave.profileId = :profileId", { profileId: id })
|
||||||
.andWhere('profileLeave.status = :status', { status: 'approve' })
|
.andWhere("profileLeave.status = :status", { status: "approve" })
|
||||||
.groupBy('profileLeave.leaveTypeId')
|
.groupBy("profileLeave.leaveTypeId")
|
||||||
.orderBy('code', 'ASC')
|
.orderBy("code", "ASC")
|
||||||
.addOrderBy('maxDateLeaveStart', 'ASC')
|
.addOrderBy("maxDateLeaveStart", "ASC")
|
||||||
.getRawMany();
|
.getRawMany();
|
||||||
|
|
||||||
const leaves: any[] = [];
|
const leaves: any[] = [];
|
||||||
|
|
||||||
leave_raw.forEach((item) => {
|
leave_raw.forEach((item) => {
|
||||||
const leaveTypeCode = item.code ? item.code.trim().toUpperCase() : '';
|
const leaveTypeCode = item.code ? item.code.trim().toUpperCase() : "";
|
||||||
if (leaveTypeCode.startsWith('LV-')) {
|
if (leaveTypeCode.startsWith("LV-")) {
|
||||||
const lvIndex = parseInt(leaveTypeCode.split('-')[1], 10);
|
const lvIndex = parseInt(leaveTypeCode.split("-")[1], 10);
|
||||||
|
|
||||||
if (lvIndex >= 1 && lvIndex <= 11) {
|
if (lvIndex >= 1 && lvIndex <= 11) {
|
||||||
const leaveTypeCodeKey = `leaveTypeCodeLv${lvIndex}`;
|
const leaveTypeCodeKey = `leaveTypeCodeLv${lvIndex}`;
|
||||||
|
|
@ -1287,68 +1287,69 @@ export class ProfileController extends Controller {
|
||||||
const leaveTypeNameKey = `leaveTypeNameLv${lvIndex}`;
|
const leaveTypeNameKey = `leaveTypeNameLv${lvIndex}`;
|
||||||
|
|
||||||
const leaveDate = new Date(item.maxDateLeaveStart);
|
const leaveDate = new Date(item.maxDateLeaveStart);
|
||||||
const year = leaveDate?Extension.ToThaiNumber((leaveDate.getFullYear()).toString()):"";
|
const year = leaveDate ? Extension.ToThaiNumber(leaveDate.getFullYear().toString()) : "";
|
||||||
|
|
||||||
let yearData = leaves.find((data) => data.year === year);
|
let yearData = leaves.find((data) => data.year === year);
|
||||||
if (!yearData) {
|
if (!yearData) {
|
||||||
yearData = { year };
|
yearData = { year };
|
||||||
|
|
||||||
for (let i = 1; i <= 11; i++) {
|
for (let i = 1; i <= 11; i++) {
|
||||||
yearData[`leaveTypeCodeLv${i}`] = '-';
|
yearData[`leaveTypeCodeLv${i}`] = "-";
|
||||||
yearData[`totalLeaveDaysLv${i}`] = '-';
|
yearData[`totalLeaveDaysLv${i}`] = "-";
|
||||||
yearData[`leaveTypeNameLv${i}`] = '-';
|
yearData[`leaveTypeNameLv${i}`] = "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
leaves.push(yearData);
|
leaves.push(yearData);
|
||||||
}
|
}
|
||||||
|
|
||||||
yearData[leaveTypeCodeKey] = item.code?item.code:"-";
|
yearData[leaveTypeCodeKey] = item.code ? item.code : "-";
|
||||||
yearData[totalLeaveDaysKey] = item.totalLeaveDays? Extension.ToThaiNumber((item.totalLeaveDays).toString())
|
yearData[totalLeaveDaysKey] = item.totalLeaveDays
|
||||||
: "-";
|
? Extension.ToThaiNumber(item.totalLeaveDays.toString())
|
||||||
yearData[leaveTypeNameKey] = item.name?item.name:"-";
|
: "-";
|
||||||
|
yearData[leaveTypeNameKey] = item.name ? item.name : "-";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const leave2_raw = await this.profileLeaveRepository
|
const leave2_raw = await this.profileLeaveRepository
|
||||||
.createQueryBuilder('profileLeave')
|
.createQueryBuilder("profileLeave")
|
||||||
.leftJoinAndSelect('profileLeave.leaveType', 'leaveType')
|
.leftJoinAndSelect("profileLeave.leaveType", "leaveType")
|
||||||
.select([
|
.select([
|
||||||
'profileLeave.leaveTypeId',
|
"profileLeave.leaveTypeId",
|
||||||
'profileLeave.dateLeaveStart',
|
"profileLeave.dateLeaveStart",
|
||||||
'profileLeave.dateLeaveEnd',
|
"profileLeave.dateLeaveEnd",
|
||||||
'leaveType.name as name',
|
"leaveType.name as name",
|
||||||
'leaveType.code as code',
|
"leaveType.code as code",
|
||||||
'profileLeave.status',
|
"profileLeave.status",
|
||||||
'profileLeave.profileId',
|
"profileLeave.profileId",
|
||||||
'profileLeave.leaveDays',
|
"profileLeave.leaveDays",
|
||||||
'profileLeave.reason',
|
"profileLeave.reason",
|
||||||
])
|
])
|
||||||
.where('profileLeave.profileId = :profileId', { profileId: id })
|
.where("profileLeave.profileId = :profileId", { profileId: id })
|
||||||
.andWhere('leaveType.code IN (:...codes)', { codes: ["LV-008", "LV-009", "LV-010"] })
|
.andWhere("leaveType.code IN (:...codes)", { codes: ["LV-008", "LV-009", "LV-010"] })
|
||||||
.andWhere('profileLeave.status = :status', { status: 'approve' })
|
.andWhere("profileLeave.status = :status", { status: "approve" })
|
||||||
.orderBy('leaveType.code', 'ASC')
|
.orderBy("leaveType.code", "ASC")
|
||||||
.getRawMany();
|
.getRawMany();
|
||||||
const leaves2 =
|
const leaves2 =
|
||||||
leave2_raw.length > 0
|
leave2_raw.length > 0
|
||||||
? leave2_raw.map((item) => ({
|
? leave2_raw.map((item) => ({
|
||||||
date: item.dateLeaveStart
|
date: item.dateLeaveStart
|
||||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateLeaveStart))
|
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateLeaveStart))
|
||||||
: (item.dateLeaveEnd
|
: item.dateLeaveEnd
|
||||||
? " - " + Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateLeaveEnd))
|
? " - " + Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.dateLeaveEnd))
|
||||||
: ""),
|
: "",
|
||||||
type: item.name || "-",
|
type: item.name || "-",
|
||||||
leaveDays: item.leaveDays ? Extension.ToThaiNumber(item.leaveDays) : "-",
|
leaveDays: item.leaveDays ? Extension.ToThaiNumber(item.leaveDays) : "-",
|
||||||
reason: item.reason || "-",
|
reason: item.reason || "-",
|
||||||
}))
|
}))
|
||||||
: [
|
: [
|
||||||
{
|
{
|
||||||
date: "-",
|
date: "-",
|
||||||
type: "-",
|
type: "-",
|
||||||
leaveDays: "-",
|
leaveDays: "-",
|
||||||
reason: "-",
|
reason: "-",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const children_raw = await this.profileChildrenRepository.find({
|
const children_raw = await this.profileChildrenRepository.find({
|
||||||
where: { profileId: id },
|
where: { profileId: id },
|
||||||
});
|
});
|
||||||
|
|
@ -7014,18 +7015,23 @@ export class ProfileController extends Controller {
|
||||||
position == null || position.posExecutive == null ? null : position.posExecutive.id,
|
position == null || position.posExecutive == null ? null : position.posExecutive.id,
|
||||||
rootId: root == null ? null : root.id,
|
rootId: root == null ? null : root.id,
|
||||||
root: root == null ? null : root.orgRootName,
|
root: root == null ? null : root.orgRootName,
|
||||||
|
rootDnaId: root == null ? null : root.ancestorDNA,
|
||||||
rootShortName: root == null ? null : root.orgRootShortName,
|
rootShortName: root == null ? null : root.orgRootShortName,
|
||||||
child1Id: child1 == null ? null : child1.id,
|
child1Id: child1 == null ? null : child1.id,
|
||||||
child1: child1 == null ? null : child1.orgChild1Name,
|
child1: child1 == null ? null : child1.orgChild1Name,
|
||||||
|
child1DnaId: child1 == null ? null : child1.ancestorDNA,
|
||||||
child1ShortName: child1 == null ? null : child1.orgChild1ShortName,
|
child1ShortName: child1 == null ? null : child1.orgChild1ShortName,
|
||||||
child2Id: child2 == null ? null : child2.id,
|
child2Id: child2 == null ? null : child2.id,
|
||||||
child2: child2 == null ? null : child2.orgChild2Name,
|
child2: child2 == null ? null : child2.orgChild2Name,
|
||||||
|
child2DnaId: child2 == null ? null : child2.ancestorDNA,
|
||||||
child2ShortName: child2 == null ? null : child2.orgChild2ShortName,
|
child2ShortName: child2 == null ? null : child2.orgChild2ShortName,
|
||||||
child3Id: child3 == null ? null : child3.id,
|
child3Id: child3 == null ? null : child3.id,
|
||||||
child3: child3 == null ? null : child3.orgChild3Name,
|
child3: child3 == null ? null : child3.orgChild3Name,
|
||||||
|
child3DnaId: child3 == null ? null : child3.ancestorDNA,
|
||||||
child3ShortName: child3 == null ? null : child3.orgChild3ShortName,
|
child3ShortName: child3 == null ? null : child3.orgChild3ShortName,
|
||||||
child4Id: child4 == null ? null : child4.id,
|
child4Id: child4 == null ? null : child4.id,
|
||||||
child4: child4 == null ? null : child4.orgChild4Name,
|
child4: child4 == null ? null : child4.orgChild4Name,
|
||||||
|
child4DnaId: child4 == null ? null : child4.ancestorDNA,
|
||||||
child4ShortName: child4 == null ? null : child4.orgChild4ShortName,
|
child4ShortName: child4 == null ? null : child4.orgChild4ShortName,
|
||||||
node: null,
|
node: null,
|
||||||
nodeId: null,
|
nodeId: null,
|
||||||
|
|
@ -9405,7 +9411,7 @@ export class ProfileController extends Controller {
|
||||||
});
|
});
|
||||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
const before = structuredClone(profile);
|
const before = structuredClone(profile);
|
||||||
let _null:any = null;
|
let _null: any = null;
|
||||||
profile.isLeave = requestBody.isLeave;
|
profile.isLeave = requestBody.isLeave;
|
||||||
profile.leaveReason = requestBody.leaveReason;
|
profile.leaveReason = requestBody.leaveReason;
|
||||||
profile.dateLeave = requestBody.dateLeave;
|
profile.dateLeave = requestBody.dateLeave;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue