ปรับบันทึกตำแหน่ง
This commit is contained in:
parent
b3991596b5
commit
69db570268
2 changed files with 72 additions and 0 deletions
|
|
@ -2200,6 +2200,31 @@ export class EmployeePositionController extends Controller {
|
|||
if (posMasterOld != null) posMasterOld.current_holderId = null;
|
||||
if (posMasterOld != null) posMasterOld.next_holderId = null;
|
||||
|
||||
const positionOld = await this.employeePositionRepository.findOne({
|
||||
where: {
|
||||
posMasterId: posMasterOld?.id,
|
||||
positionIsSelected: true
|
||||
}
|
||||
})
|
||||
if (positionOld != null) {
|
||||
positionOld.positionIsSelected = false
|
||||
await this.employeePositionRepository.save(positionOld);
|
||||
}
|
||||
|
||||
const checkPosition = await this.employeePositionRepository.find({
|
||||
where: {
|
||||
posMasterId: body.posmasterId,
|
||||
positionIsSelected: true
|
||||
}
|
||||
})
|
||||
if (checkPosition.length > 0) {
|
||||
const clearPosition = checkPosition.map(positions => ({
|
||||
...positions,
|
||||
positionIsSelected: false
|
||||
}));
|
||||
await this.employeePositionRepository.save(clearPosition);
|
||||
}
|
||||
|
||||
const profile = await this.profileRepository.findOne({
|
||||
where: { id: body.profileId },
|
||||
});
|
||||
|
|
@ -2210,6 +2235,17 @@ export class EmployeePositionController extends Controller {
|
|||
posMaster.next_holderId = body.profileId;
|
||||
if (posMasterOld != null) await this.employeePosMasterRepository.save(posMasterOld);
|
||||
await this.employeePosMasterRepository.save(posMaster);
|
||||
|
||||
const positionNew = await this.employeePositionRepository.findOne({
|
||||
where: {
|
||||
id: body.positionId,
|
||||
posMasterId: body.posmasterId
|
||||
}
|
||||
})
|
||||
if(positionNew != null) {
|
||||
positionNew.positionIsSelected = true
|
||||
await this.employeePositionRepository.save(positionNew);
|
||||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3373,6 +3373,31 @@ export class PositionController extends Controller {
|
|||
},
|
||||
});
|
||||
if (posMasterOld != null) posMasterOld.current_holderId = null;
|
||||
|
||||
const positionOld = await this.positionRepository.findOne({
|
||||
where: {
|
||||
posMasterId: posMasterOld?.id,
|
||||
positionIsSelected: true
|
||||
}
|
||||
})
|
||||
if (positionOld != null) {
|
||||
positionOld.positionIsSelected = false
|
||||
await this.positionRepository.save(positionOld);
|
||||
}
|
||||
|
||||
const checkPosition = await this.positionRepository.find({
|
||||
where: {
|
||||
posMasterId: body.posmasterId,
|
||||
positionIsSelected: true
|
||||
}
|
||||
})
|
||||
if (checkPosition.length > 0) {
|
||||
const clearPosition = checkPosition.map(positions => ({
|
||||
...positions,
|
||||
positionIsSelected: false
|
||||
}));
|
||||
await this.positionRepository.save(clearPosition);
|
||||
}
|
||||
|
||||
const profile = await this.profileRepository.findOne({
|
||||
where: { id: body.profileId },
|
||||
|
|
@ -3383,6 +3408,17 @@ export class PositionController extends Controller {
|
|||
posMaster.current_holderId = body.profileId;
|
||||
if (posMasterOld != null) await this.posMasterRepository.save(posMasterOld);
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
|
||||
const positionNew = await this.positionRepository.findOne({
|
||||
where: {
|
||||
id: body.positionId,
|
||||
posMasterId: body.posmasterId
|
||||
}
|
||||
})
|
||||
if(positionNew != null) {
|
||||
positionNew.positionIsSelected = true
|
||||
await this.positionRepository.save(positionNew);
|
||||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue