Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop

This commit is contained in:
kittapath 2024-09-04 16:15:47 +07:00
commit f0aa757b79
2 changed files with 65 additions and 3 deletions

View file

@ -3559,7 +3559,19 @@ export class OrganizationController extends Controller {
* *
*/ */
@Get("act/{id}") @Get("act/{id}")
async detailAct(@Path() id: string) { async detailAct(@Path() id: string, @Request() request: RequestWithUser) {
let _data = {
root: null,
child1: null,
child2: null,
child3: null,
child4: null,
};
if (!request.user.role.includes("SUPER_ADMIN")) {
_data = await new permission().PermissionOrgList(request, "SYS_ACTING");
}
const orgRevision = await this.orgRevisionRepository.findOne({ where: { id } }); const orgRevision = await this.orgRevisionRepository.findOne({ where: { id } });
if (!orgRevision) { if (!orgRevision) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
@ -3568,6 +3580,16 @@ export class OrganizationController extends Controller {
const orgRootData = await AppDataSource.getRepository(OrgRoot) const orgRootData = await AppDataSource.getRepository(OrgRoot)
.createQueryBuilder("orgRoot") .createQueryBuilder("orgRoot")
.where("orgRoot.orgRevisionId = :id", { id }) .where("orgRoot.orgRevisionId = :id", { id })
.andWhere(
_data.root != undefined && _data.root != null
? _data.root[0] != null
? `orgRoot.id IN (:...node)`
: `orgRoot.id is null`
: "1=1",
{
node: _data.root,
},
)
.leftJoinAndSelect("orgRoot.posMasters", "posMasters") .leftJoinAndSelect("orgRoot.posMasters", "posMasters")
.leftJoinAndSelect("posMasters.current_holder", "current_holder") .leftJoinAndSelect("posMasters.current_holder", "current_holder")
.orderBy("orgRoot.orgRootOrder", "ASC") .orderBy("orgRoot.orgRootOrder", "ASC")
@ -3579,6 +3601,16 @@ export class OrganizationController extends Controller {
? await AppDataSource.getRepository(OrgChild1) ? await AppDataSource.getRepository(OrgChild1)
.createQueryBuilder("orgChild1") .createQueryBuilder("orgChild1")
.where("orgChild1.orgRootId IN (:...ids)", { ids: orgRootIds }) .where("orgChild1.orgRootId IN (:...ids)", { ids: orgRootIds })
.andWhere(
_data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null
? `orgChild1.id IN (:...node)`
: `orgChild1.id is null`
: "1=1",
{
node: _data.child1,
},
)
.leftJoinAndSelect("orgChild1.posMasters", "posMasters") .leftJoinAndSelect("orgChild1.posMasters", "posMasters")
.leftJoinAndSelect("posMasters.current_holder", "current_holder") .leftJoinAndSelect("posMasters.current_holder", "current_holder")
.orderBy("orgChild1.orgChild1Order", "ASC") .orderBy("orgChild1.orgChild1Order", "ASC")
@ -3591,6 +3623,16 @@ export class OrganizationController extends Controller {
? await AppDataSource.getRepository(OrgChild2) ? await AppDataSource.getRepository(OrgChild2)
.createQueryBuilder("orgChild2") .createQueryBuilder("orgChild2")
.where("orgChild2.orgChild1Id IN (:...ids)", { ids: orgChild1Ids }) .where("orgChild2.orgChild1Id IN (:...ids)", { ids: orgChild1Ids })
.andWhere(
_data.child2 != undefined && _data.child2 != null
? _data.child2[0] != null
? `orgChild2.id IN (:...node)`
: `orgChild2.id is null`
: "1=1",
{
node: _data.child2,
},
)
.leftJoinAndSelect("orgChild2.posMasters", "posMasters") .leftJoinAndSelect("orgChild2.posMasters", "posMasters")
.leftJoinAndSelect("posMasters.current_holder", "current_holder") .leftJoinAndSelect("posMasters.current_holder", "current_holder")
.orderBy("orgChild2.orgChild2Order", "ASC") .orderBy("orgChild2.orgChild2Order", "ASC")
@ -3603,6 +3645,16 @@ export class OrganizationController extends Controller {
? await AppDataSource.getRepository(OrgChild3) ? await AppDataSource.getRepository(OrgChild3)
.createQueryBuilder("orgChild3") .createQueryBuilder("orgChild3")
.where("orgChild3.orgChild2Id IN (:...ids)", { ids: orgChild2Ids }) .where("orgChild3.orgChild2Id IN (:...ids)", { ids: orgChild2Ids })
.andWhere(
_data.child3 != undefined && _data.child3 != null
? _data.child3[0] != null
? `orgChild3.id IN (:...node)`
: `orgChild3.id is null`
: "1=1",
{
node: _data.child3,
},
)
.leftJoinAndSelect("orgChild3.posMasters", "posMasters") .leftJoinAndSelect("orgChild3.posMasters", "posMasters")
.leftJoinAndSelect("posMasters.current_holder", "current_holder") .leftJoinAndSelect("posMasters.current_holder", "current_holder")
.orderBy("orgChild3.orgChild3Order", "ASC") .orderBy("orgChild3.orgChild3Order", "ASC")
@ -3615,6 +3667,16 @@ export class OrganizationController extends Controller {
? await AppDataSource.getRepository(OrgChild4) ? await AppDataSource.getRepository(OrgChild4)
.createQueryBuilder("orgChild4") .createQueryBuilder("orgChild4")
.where("orgChild4.orgChild3Id IN (:...ids)", { ids: orgChild3Ids }) .where("orgChild4.orgChild3Id IN (:...ids)", { ids: orgChild3Ids })
.andWhere(
_data.child4 != undefined && _data.child4 != null
? _data.child4[0] != null
? `orgChild4.id IN (:...node)`
: `orgChild4.id is null`
: "1=1",
{
node: _data.child4,
},
)
.leftJoinAndSelect("orgChild4.posMasters", "posMasters") .leftJoinAndSelect("orgChild4.posMasters", "posMasters")
.leftJoinAndSelect("posMasters.current_holder", "current_holder") .leftJoinAndSelect("posMasters.current_holder", "current_holder")
.orderBy("orgChild4.orgChild4Order", "ASC") .orderBy("orgChild4.orgChild4Order", "ASC")

View file

@ -452,7 +452,7 @@ export class PositionController extends Controller {
}); });
break; break;
case "all": case "ALL":
findPosDict = await this.posDictRepository.find({ findPosDict = await this.posDictRepository.find({
where: [ where: [
{ posDictName: Like(`%${keyword}%`) }, { posDictName: Like(`%${keyword}%`) },