fix: searh org

This commit is contained in:
Adisak 2026-05-26 18:10:34 +07:00
parent bc418666ac
commit cc6696cec8
5 changed files with 70 additions and 80 deletions

View file

@ -777,11 +777,11 @@ export class EmployeeTempPositionController extends Controller {
let checkChildConditions: any = {};
let keywordAsInt: any;
let searchShortName = "1=1";
let searchShortName0 = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNo)`;
let searchShortName1 = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNo)`;
let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNo)`;
let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNo)`;
let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNo)`;
let searchShortName0 = `CONCAT(orgRoot.orgRootShortName,' ',posMaster.posMasterNo)`;
let searchShortName1 = `CONCAT(orgChild1.orgChild1ShortName,' ',posMaster.posMasterNo)`;
let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName,' ',posMaster.posMasterNo)`;
let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName,' ',posMaster.posMasterNo)`;
let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName,' ',posMaster.posMasterNo)`;
let _data = await new permission().PermissionOrgList(request, "SYS_ORG_TEMP");
if (body.type === 0) {
typeCondition = {
@ -791,7 +791,7 @@ export class EmployeeTempPositionController extends Controller {
checkChildConditions = {
orgChild1Id: IsNull(),
};
searchShortName = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
searchShortName = `CONCAT(orgRoot.orgRootShortName,' ',posMaster.posMasterNo) like '%${body.keyword}%'`;
} else {
}
} else if (body.type === 1) {
@ -802,7 +802,7 @@ export class EmployeeTempPositionController extends Controller {
checkChildConditions = {
orgChild2Id: IsNull(),
};
searchShortName = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
searchShortName = `CONCAT(orgChild1.orgChild1ShortName,' ',posMaster.posMasterNo) like '%${body.keyword}%'`;
} else {
}
} else if (body.type === 2) {
@ -813,7 +813,7 @@ export class EmployeeTempPositionController extends Controller {
checkChildConditions = {
orgChild3Id: IsNull(),
};
searchShortName = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
searchShortName = `CONCAT(orgChild2.orgChild2ShortName,' ',posMaster.posMasterNo) like '%${body.keyword}%'`;
} else {
}
} else if (body.type === 3) {
@ -824,14 +824,14 @@ export class EmployeeTempPositionController extends Controller {
checkChildConditions = {
orgChild4Id: IsNull(),
};
searchShortName = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
searchShortName = `CONCAT(orgChild3.orgChild3ShortName,' ',posMaster.posMasterNo) like '%${body.keyword}%'`;
} else {
}
} else if (body.type === 4) {
typeCondition = {
orgChild4Id: body.id,
};
searchShortName = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
searchShortName = `CONCAT(orgChild4.orgChild4ShortName,' ',posMaster.posMasterNo) like '%${body.keyword}%'`;
}
let findPosition: any;
let masterId = new Array();
@ -859,10 +859,8 @@ export class EmployeeTempPositionController extends Controller {
select: ["posMasterTempId"],
});
masterId = masterId.concat(findPosition.map((position: any) => position.posMasterTempId));
keywordAsInt = body.keyword == null ? null : parseInt(body.keyword, 10);
if (isNaN(keywordAsInt)) {
keywordAsInt = "P@ssw0rd!z";
}
const numericMatch = body.keyword == null ? null : body.keyword.match(/\d+/);
keywordAsInt = numericMatch ? parseInt(numericMatch[0], 10) : null;
masterId = [...new Set(masterId)];
}
@ -877,7 +875,7 @@ export class EmployeeTempPositionController extends Controller {
...(body.keyword &&
(masterId.length > 0
? { id: In(masterId) }
: { posMasterNo: Like(`%${body.keyword}%`) })),
: keywordAsInt != null ? { posMasterNo: keywordAsInt } : {})),
},
];
let query = AppDataSource.getRepository(EmployeeTempPosMaster)