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

This commit is contained in:
kittapath 2024-09-06 13:48:53 +07:00
commit ca88ab0d48
2 changed files with 64 additions and 87 deletions

View file

@ -3570,17 +3570,18 @@ export class OrganizationController extends Controller {
*/ */
@Get("act/{id}") @Get("act/{id}")
async detailAct(@Path() id: string, @Request() request: RequestWithUser) { async detailAct(@Path() id: string, @Request() request: RequestWithUser) {
let _data = { // let _data = {
root: null, // root: null,
child1: null, // child1: null,
child2: null, // child2: null,
child3: null, // child3: null,
child4: null, // child4: null,
}; // };
if (!request.user.role.includes("SUPER_ADMIN")) { // if (!request.user.role.includes("SUPER_ADMIN")) {
_data = await new permission().PermissionOrgList(request, "SYS_ACTING"); // _data = await new permission().PermissionOrgList(request, "SYS_ACTING");
} // }
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) {
@ -3590,16 +3591,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( // .andWhere(
_data.root != undefined && _data.root != null // _data.root != undefined && _data.root != null
? _data.root[0] != null // ? _data.root[0] != null
? `orgRoot.id IN (:...node)` // ? `orgRoot.id IN (:...node)`
: `orgRoot.id is null` // : `orgRoot.id is null`
: "1=1", // : "1=1",
{ // {
node: _data.root, // 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")
@ -3611,16 +3612,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( // .andWhere(
_data.child1 != undefined && _data.child1 != null // _data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null // ? _data.child1[0] != null
? `orgChild1.id IN (:...node)` // ? `orgChild1.id IN (:...node)`
: `orgChild1.id is null` // : `orgChild1.id is null`
: "1=1", // : "1=1",
{ // {
node: _data.child1, // 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")
@ -3633,16 +3634,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( // .andWhere(
_data.child2 != undefined && _data.child2 != null // _data.child2 != undefined && _data.child2 != null
? _data.child2[0] != null // ? _data.child2[0] != null
? `orgChild2.id IN (:...node)` // ? `orgChild2.id IN (:...node)`
: `orgChild2.id is null` // : `orgChild2.id is null`
: "1=1", // : "1=1",
{ // {
node: _data.child2, // 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")
@ -3655,16 +3656,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( // .andWhere(
_data.child3 != undefined && _data.child3 != null // _data.child3 != undefined && _data.child3 != null
? _data.child3[0] != null // ? _data.child3[0] != null
? `orgChild3.id IN (:...node)` // ? `orgChild3.id IN (:...node)`
: `orgChild3.id is null` // : `orgChild3.id is null`
: "1=1", // : "1=1",
{ // {
node: _data.child3, // 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")
@ -3677,16 +3678,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( // .andWhere(
_data.child4 != undefined && _data.child4 != null // _data.child4 != undefined && _data.child4 != null
? _data.child4[0] != null // ? _data.child4[0] != null
? `orgChild4.id IN (:...node)` // ? `orgChild4.id IN (:...node)`
: `orgChild4.id is null` // : `orgChild4.id is null`
: "1=1", // : "1=1",
{ // {
node: _data.child4, // 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

@ -3321,18 +3321,7 @@ export class PositionController extends Controller {
isAll: boolean; isAll: boolean;
}, },
) { ) {
// let _data = { await new permission().PermissionGet(request,"SYS_ACTING");
// root: null,
// child1: null,
// child2: null,
// child3: null,
// child4: null,
// }
// if (!request.user.role.includes("SUPER_ADMIN")) {
// _data = await new permission().PermissionOrgList(request, "SYS_ORG");
// }
const posMasterMain = await this.posMasterRepository.findOne({ const posMasterMain = await this.posMasterRepository.findOne({
where: { id: body.posmasterId }, where: { id: body.posmasterId },
relations: ["posMasterActs"], relations: ["posMasterActs"],
@ -3363,21 +3352,8 @@ export class PositionController extends Controller {
current_holderId: Not(IsNull()), current_holderId: Not(IsNull()),
id: Not(In(posId)), id: Not(In(posId)),
}; };
// console.log("ddddd",_data);
// typeCondition = {
// orgRoot: _data.root && _data.root[0] ? { id: In(_data.root) } : { id: IsNull() },
// orgChild1: _data.child1 && _data.child1[0] ? { id: In(_data.child1) } : { id: IsNull() },
// orgChild2: _data.child2 && _data.child2[0] ? { id: In(_data.child2) } : { id: IsNull() },
// orgChild3: _data.child3 && _data.child3[0] ? { id: In(_data.child3) } : { id: IsNull() },
// orgChild4: _data.child4 && _data.child4[0] ? { id: In(_data.child4) } : { id: IsNull() },
// current_holderId: Not(IsNull()),
// id: Not(In(posId)),
// };
} }
// console.log("typeCondition>>>",typeCondition);
const posMaster = await this.posMasterRepository.find({ const posMaster = await this.posMasterRepository.find({
where: typeCondition, where: typeCondition,
relations: [ relations: [