แก้ค้นหา
This commit is contained in:
parent
2217355dea
commit
07e1d04def
1 changed files with 31 additions and 2 deletions
|
|
@ -1136,7 +1136,7 @@ export class PositionController extends Controller {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const [posMaster, total] = await AppDataSource.getRepository(PosMaster)
|
let [posMaster, total] = await AppDataSource.getRepository(PosMaster)
|
||||||
.createQueryBuilder("posMaster")
|
.createQueryBuilder("posMaster")
|
||||||
.leftJoinAndSelect("posMaster.orgRoot", "orgRoot")
|
.leftJoinAndSelect("posMaster.orgRoot", "orgRoot")
|
||||||
.leftJoinAndSelect("posMaster.orgChild1", "orgChild1")
|
.leftJoinAndSelect("posMaster.orgChild1", "orgChild1")
|
||||||
|
|
@ -1196,6 +1196,35 @@ export class PositionController extends Controller {
|
||||||
.take(body.pageSize)
|
.take(body.pageSize)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
||||||
|
//แก้ค้นหา
|
||||||
|
let _position: any[] = [];
|
||||||
|
let x: any = null
|
||||||
|
let y: any = null
|
||||||
|
if (body.keyword != null && body.keyword != ""){
|
||||||
|
const position = await this.positionRepository.find({
|
||||||
|
relations: ["posType", "posLevel", "posExecutive"],
|
||||||
|
where: { posMasterId: In(posMaster.map(x => x.id))},
|
||||||
|
order: { createdAt: "ASC" }
|
||||||
|
});
|
||||||
|
for(let data of position){
|
||||||
|
x = data.posMasterId
|
||||||
|
if(y != x){
|
||||||
|
if(
|
||||||
|
data.positionName.includes(body.keyword) ||
|
||||||
|
data.posType.posTypeName.includes(body.keyword) ||
|
||||||
|
data.posLevel.posLevelName.includes(body.keyword)
|
||||||
|
){
|
||||||
|
_position.push(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
y = x
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_position.length > 0){
|
||||||
|
posMaster = posMaster.filter((x) => _position.some(y => y.posMasterId === x.id));
|
||||||
|
}
|
||||||
|
|
||||||
const formattedData = await Promise.all(
|
const formattedData = await Promise.all(
|
||||||
posMaster.map(async (posMaster) => {
|
posMaster.map(async (posMaster) => {
|
||||||
const positions = await this.positionRepository.find({
|
const positions = await this.positionRepository.find({
|
||||||
|
|
@ -1296,7 +1325,7 @@ export class PositionController extends Controller {
|
||||||
profilePosition: profile == null || profile.position == null ? null : profile.position,
|
profilePosition: profile == null || profile.position == null ? null : profile.position,
|
||||||
profilePostype: type == null || type.posTypeName == null ? null : type.posTypeName,
|
profilePostype: type == null || type.posTypeName == null ? null : type.posTypeName,
|
||||||
profilePoslevel: level == null || level.posLevelName == null ? null : level.posLevelName,
|
profilePoslevel: level == null || level.posLevelName == null ? null : level.posLevelName,
|
||||||
positions: positions.map((position) => ({
|
positions: positions.map((position:any) => ({
|
||||||
id: position.id,
|
id: position.id,
|
||||||
positionName: position.positionName,
|
positionName: position.positionName,
|
||||||
positionField: position.positionField,
|
positionField: position.positionField,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue