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