posMasterOrder เพิ่มตำแหน่ง
This commit is contained in:
parent
632dc300da
commit
59d3734184
1 changed files with 45 additions and 0 deletions
|
|
@ -335,6 +335,13 @@ export class PositionController extends Controller {
|
|||
if (!orgChild4) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงสร้าง");
|
||||
} else {
|
||||
const order:any = await this.posMasterRepository.findOne({
|
||||
where: {
|
||||
orgChild4Id: orgChild4.id
|
||||
},
|
||||
order: { posMasterNo: "DESC" }
|
||||
})
|
||||
posMaster.posMasterOrder = order.posMasterOrder == null ? 1: order.posMasterOrder+1
|
||||
posMaster.orgRootId = orgChild4.orgRootId;
|
||||
posMaster.orgChild1Id = orgChild4.orgChild1Id;
|
||||
posMaster.orgChild2Id = orgChild4.orgChild2Id;
|
||||
|
|
@ -343,6 +350,14 @@ export class PositionController extends Controller {
|
|||
posMaster.orgRevisionId = orgChild4.orgRevisionId;
|
||||
}
|
||||
} else {
|
||||
const order:any = await this.posMasterRepository.findOne({
|
||||
where: {
|
||||
orgChild3Id: orgChild3.id,
|
||||
orgChild4Id: IsNull() || ""
|
||||
},
|
||||
order: { posMasterNo: "DESC" }
|
||||
})
|
||||
posMaster.posMasterOrder = order.posMasterOrder == null ? 1: order.posMasterOrder+1
|
||||
posMaster.orgRootId = orgChild3.orgRootId;
|
||||
posMaster.orgChild1Id = orgChild3.orgChild1Id;
|
||||
posMaster.orgChild2Id = orgChild3.orgChild2Id;
|
||||
|
|
@ -350,17 +365,47 @@ export class PositionController extends Controller {
|
|||
posMaster.orgRevisionId = orgChild3.orgRevisionId;
|
||||
}
|
||||
} else {
|
||||
const order:any = await this.posMasterRepository.findOne({
|
||||
where: {
|
||||
orgChild2Id: orgChild2.id,
|
||||
orgChild3Id: IsNull() || "",
|
||||
orgChild4Id: IsNull() || "",
|
||||
},
|
||||
order: { posMasterNo: "DESC" }
|
||||
})
|
||||
posMaster.posMasterOrder = order.posMasterOrder == null ? 1: order.posMasterOrder+1
|
||||
posMaster.orgRootId = orgChild2.orgRootId;
|
||||
posMaster.orgChild1Id = orgChild2.orgChild1Id;
|
||||
posMaster.orgChild2Id = orgChild2.id;
|
||||
posMaster.orgRevisionId = orgChild2.orgRevisionId;
|
||||
}
|
||||
} else {
|
||||
const order:any = await this.posMasterRepository.findOne({
|
||||
where: {
|
||||
orgChild1Id: orgChild1.id,
|
||||
orgChild2Id: IsNull() || "",
|
||||
orgChild3Id: IsNull() || "",
|
||||
orgChild4Id: IsNull() || "",
|
||||
},
|
||||
order: { posMasterNo: "DESC" }
|
||||
})
|
||||
posMaster.posMasterOrder = order.posMasterOrder == null ? 1: order.posMasterOrder+1
|
||||
posMaster.orgRootId = orgChild1.orgRootId;
|
||||
posMaster.orgChild1Id = orgChild1.id;
|
||||
posMaster.orgRevisionId = orgChild1.orgRevisionId;
|
||||
}
|
||||
} else {
|
||||
const order:any = await this.posMasterRepository.findOne({
|
||||
where: {
|
||||
orgRootId: orgRoot.id,
|
||||
orgChild1Id: IsNull() || "",
|
||||
orgChild2Id: IsNull() || "",
|
||||
orgChild3Id: IsNull() || "",
|
||||
orgChild4Id: IsNull() || "",
|
||||
},
|
||||
order: { posMasterNo: "DESC" }
|
||||
})
|
||||
posMaster.posMasterOrder = order.posMasterOrder == null ? 1: order.posMasterOrder+1
|
||||
posMaster.orgRootId = orgRoot.id;
|
||||
posMaster.orgRevisionId = orgRoot.orgRevisionId;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue