Fix ระบบทะเบียนประวัติ (ลูกจ้างชั่วคราว) >> ค้นหารายชื่อลูกจ้างชั่วคราว #1647

This commit is contained in:
Bright 2025-07-22 11:25:45 +07:00
parent bda80475d1
commit ffb9ea327d

View file

@ -1589,31 +1589,37 @@ export class ProfileEmployeeTempController extends Controller {
keyword2: `${posLevel}`,
},
)
// .andWhere(
// isProbation != undefined && isProbation != null
// ? `profileEmployee.isProbation = ${isProbation}`
// : "1=1",
// )
// .andWhere(
// isRetire != undefined && isRetire != null
// ? isRetire == true
// ? `profileEmployee.dateRetire IS null`
// : `profileEmployee.dateRetire IS NOT NULL`
// : "1=1",
// )
.andWhere(
"profileEmployee.employeeClass = :type", {
type: type ? type.trim().toLocaleUpperCase() : "TEMP"
}
)
.orWhere(
`current_holderTemps.orgRootId is null AND current_holderTemps.orgChild1Id is null AND
current_holderTemps.orgChild2Id is null AND current_holderTemps.orgChild3Id is null AND
current_holderTemps.orgChild4Id is null AND profileEmployee.createdUserId = :keycloak AND
profileEmployee.employeeClass = :type`, {
keycloak: request.user.sub,
type: type ? type.trim().toLocaleUpperCase() : "TEMP",
}
new Brackets((qb) => {
if (!searchKeyword) {
qb.andWhere(
`current_holderTemps.orgRootId is null AND current_holderTemps.orgChild1Id is null AND
current_holderTemps.orgChild2Id is null AND current_holderTemps.orgChild3Id is null AND
current_holderTemps.orgChild4Id is null AND profileEmployee.createdUserId = :keycloak AND
profileEmployee.employeeClass = :type
`,
{
keycloak: request.user.sub,
type: type ? type.trim().toLocaleUpperCase() : "TEMP"
}
)
}
else {
qb.andWhere(
searchKeyword != undefined && searchKeyword != null && searchKeyword != ""
? queryLike
: "1=1",
{
keyword: `%${searchKeyword}%`,
},
)
}
}),
)
.skip((page - 1) * pageSize)
.take(pageSize)