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}`, 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( .andWhere(
"profileEmployee.employeeClass = :type", { "profileEmployee.employeeClass = :type", {
type: type ? type.trim().toLocaleUpperCase() : "TEMP" type: type ? type.trim().toLocaleUpperCase() : "TEMP"
} }
) )
.orWhere( .orWhere(
`current_holderTemps.orgRootId is null AND current_holderTemps.orgChild1Id is null AND new Brackets((qb) => {
current_holderTemps.orgChild2Id is null AND current_holderTemps.orgChild3Id is null AND if (!searchKeyword) {
current_holderTemps.orgChild4Id is null AND profileEmployee.createdUserId = :keycloak AND qb.andWhere(
profileEmployee.employeeClass = :type`, { `current_holderTemps.orgRootId is null AND current_holderTemps.orgChild1Id is null AND
keycloak: request.user.sub, current_holderTemps.orgChild2Id is null AND current_holderTemps.orgChild3Id is null AND
type: type ? type.trim().toLocaleUpperCase() : "TEMP", 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) .skip((page - 1) * pageSize)
.take(pageSize) .take(pageSize)