fix: searh org
This commit is contained in:
parent
bc418666ac
commit
cc6696cec8
5 changed files with 70 additions and 80 deletions
|
|
@ -1787,10 +1787,8 @@ export class PositionController extends Controller {
|
|||
select: ["posMasterId"],
|
||||
});
|
||||
masterId = masterId.concat(findPosition.map((position: any) => position.posMasterId));
|
||||
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)];
|
||||
|
||||
//serch name สิทธิ์
|
||||
|
|
@ -1823,7 +1821,7 @@ export class PositionController extends Controller {
|
|||
...(body.keyword &&
|
||||
(masterId.length > 0
|
||||
? { id: In(masterId) }
|
||||
: { posMasterNo: Like(`%${body.keyword}%`) })),
|
||||
: keywordAsInt != null ? { posMasterNo: keywordAsInt } : {})),
|
||||
},
|
||||
];
|
||||
let [posMaster, total] = await AppDataSource.getRepository(PosMaster)
|
||||
|
|
@ -2164,11 +2162,11 @@ export class PositionController extends Controller {
|
|||
let checkChildConditions: any = {};
|
||||
let keywordAsInt: any;
|
||||
let searchShortName = "1=1";
|
||||
let searchShortName0 = `CONCAT_WS(" ",orgRoot.orgRootShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
let searchShortName1 = `CONCAT_WS(" ",orgChild1.orgChild1ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
let searchShortName2 = `CONCAT_WS(" ",orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
let searchShortName3 = `CONCAT_WS(" ",orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
let searchShortName4 = `CONCAT_WS(" ",orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
let searchShortName0 = `CONCAT_WS(' ',orgRoot.orgRootShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
let searchShortName1 = `CONCAT_WS(' ',orgChild1.orgChild1ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
let searchShortName2 = `CONCAT_WS(' ',orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
let searchShortName3 = `CONCAT_WS(' ',orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
let searchShortName4 = `CONCAT_WS(' ',orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
let _data = await new permission().PermissionOrgList(request, "SYS_ORG");
|
||||
if (body.type === 0) {
|
||||
typeCondition = {
|
||||
|
|
@ -2178,7 +2176,7 @@ export class PositionController extends Controller {
|
|||
checkChildConditions = {
|
||||
orgChild1Id: IsNull(),
|
||||
};
|
||||
searchShortName = `CONCAT_WS(" ",orgRoot.orgRootShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||
searchShortName = `CONCAT_WS(' ',orgRoot.orgRootShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||
}
|
||||
} else if (body.type === 1) {
|
||||
typeCondition = {
|
||||
|
|
@ -2188,7 +2186,7 @@ export class PositionController extends Controller {
|
|||
checkChildConditions = {
|
||||
orgChild2Id: IsNull(),
|
||||
};
|
||||
searchShortName = `CONCAT_WS(" ",orgChild1.orgChild1ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||
searchShortName = `CONCAT_WS(' ',orgChild1.orgChild1ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||
}
|
||||
} else if (body.type === 2) {
|
||||
typeCondition = {
|
||||
|
|
@ -2198,7 +2196,7 @@ export class PositionController extends Controller {
|
|||
checkChildConditions = {
|
||||
orgChild3Id: IsNull(),
|
||||
};
|
||||
searchShortName = `CONCAT_WS(" ",orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||
searchShortName = `CONCAT_WS(' ',orgChild2.orgChild2ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||
}
|
||||
} else if (body.type === 3) {
|
||||
typeCondition = {
|
||||
|
|
@ -2208,13 +2206,13 @@ export class PositionController extends Controller {
|
|||
checkChildConditions = {
|
||||
orgChild4Id: IsNull(),
|
||||
};
|
||||
searchShortName = `CONCAT_WS(" ",orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||
searchShortName = `CONCAT_WS(' ',orgChild3.orgChild3ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||
}
|
||||
} else if (body.type === 4) {
|
||||
typeCondition = {
|
||||
orgChild4Id: body.id,
|
||||
};
|
||||
searchShortName = `CONCAT_WS(" ",orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||
searchShortName = `CONCAT_WS(' ',orgChild4.orgChild4ShortName,posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||
}
|
||||
let findPosition: any;
|
||||
let masterId = new Array();
|
||||
|
|
@ -2251,10 +2249,8 @@ export class PositionController extends Controller {
|
|||
select: ["posMasterId"],
|
||||
});
|
||||
masterId = masterId.concat(findPosition.map((position: any) => position.posMasterId));
|
||||
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)];
|
||||
}
|
||||
|
||||
|
|
@ -2281,7 +2277,7 @@ export class PositionController extends Controller {
|
|||
...(body.keyword &&
|
||||
(masterId.length > 0
|
||||
? { id: In(masterId) }
|
||||
: { posMasterNo: Like(`%${body.keyword}%`) })),
|
||||
: keywordAsInt != null ? { posMasterNo: keywordAsInt } : {})),
|
||||
},
|
||||
];
|
||||
|
||||
|
|
@ -5478,10 +5474,8 @@ export class PositionController extends Controller {
|
|||
select: ["posMasterId"],
|
||||
});
|
||||
masterId = masterId.concat(findPosition.map((position: any) => position.posMasterId));
|
||||
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)];
|
||||
}
|
||||
|
||||
|
|
@ -5508,7 +5502,7 @@ export class PositionController extends Controller {
|
|||
...(body.keyword &&
|
||||
(masterId.length > 0
|
||||
? { id: In(masterId) }
|
||||
: { posMasterNo: Like(`%${body.keyword}%`) })),
|
||||
: keywordAsInt != null ? { posMasterNo: keywordAsInt } : {})),
|
||||
...(!body.isAll && { isCondition: true }),
|
||||
},
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue