fixed PermissionDelete to PermissionUpdate ในส่วนของลบคนครองและสืบทอดตำแหน่ง
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m0s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m0s
This commit is contained in:
parent
7e4dc6434f
commit
bf0dbdf018
3 changed files with 130 additions and 117 deletions
|
|
@ -1190,8 +1190,8 @@ export class EmployeePositionController extends Controller {
|
||||||
_data.child1 != undefined && _data.child1 != null
|
_data.child1 != undefined && _data.child1 != null
|
||||||
? _data.child1[0] != null
|
? _data.child1[0] != null
|
||||||
? `posMaster.orgChild1Id IN (:...child1)`
|
? `posMaster.orgChild1Id IN (:...child1)`
|
||||||
// : `posMaster.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
: // : `posMaster.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
||||||
: `posMaster.orgChild1Id is null`
|
`posMaster.orgChild1Id is null`
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{
|
{
|
||||||
child1: _data.child1,
|
child1: _data.child1,
|
||||||
|
|
@ -1226,10 +1226,11 @@ export class EmployeePositionController extends Controller {
|
||||||
{
|
{
|
||||||
child4: _data.child4,
|
child4: _data.child4,
|
||||||
},
|
},
|
||||||
)
|
);
|
||||||
|
|
||||||
if (body.keyword != null && body.keyword != "") {
|
if (body.keyword != null && body.keyword != "") {
|
||||||
query.orWhere(
|
query
|
||||||
|
.orWhere(
|
||||||
new Brackets((qb) => {
|
new Brackets((qb) => {
|
||||||
qb.andWhere(
|
qb.andWhere(
|
||||||
body.keyword != null && body.keyword != ""
|
body.keyword != null && body.keyword != ""
|
||||||
|
|
@ -1287,7 +1288,7 @@ export class EmployeePositionController extends Controller {
|
||||||
.andWhere(typeCondition)
|
.andWhere(typeCondition)
|
||||||
.andWhere(revisionCondition);
|
.andWhere(revisionCondition);
|
||||||
}),
|
}),
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let [posMaster, total] = await query
|
let [posMaster, total] = await query
|
||||||
|
|
@ -2413,7 +2414,7 @@ export class EmployeePositionController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("profile/delete/{id}")
|
@Post("profile/delete/{id}")
|
||||||
async deleteEmpHolder(@Path() id: string, @Request() request: RequestWithUser) {
|
async deleteEmpHolder(@Path() id: string, @Request() request: RequestWithUser) {
|
||||||
await new permission().PermissionDelete(request, "SYS_ORG_EMP");
|
await new permission().PermissionUpdate(request, "SYS_ORG_EMP");
|
||||||
const dataMaster = await this.employeePosMasterRepository.findOne({
|
const dataMaster = await this.employeePosMasterRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
relations: ["positions", "orgRevision"],
|
relations: ["positions", "orgRevision"],
|
||||||
|
|
@ -2472,7 +2473,7 @@ export class EmployeePositionController extends Controller {
|
||||||
@Body() requestBody: { draftPositionId: string; publishPositionId: string },
|
@Body() requestBody: { draftPositionId: string; publishPositionId: string },
|
||||||
@Request() request: RequestWithUser,
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
await new permission().PermissionDelete(request, "SYS_ORG_EMP");
|
await new permission().PermissionUpdate(request, "SYS_ORG_EMP");
|
||||||
const findDraft = await this.orgRevisionRepository.findOne({
|
const findDraft = await this.orgRevisionRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
orgRevisionIsDraft: true,
|
orgRevisionIsDraft: true,
|
||||||
|
|
|
||||||
|
|
@ -908,8 +908,8 @@ export class EmployeeTempPositionController extends Controller {
|
||||||
_data.child1 != undefined && _data.child1 != null
|
_data.child1 != undefined && _data.child1 != null
|
||||||
? _data.child1[0] != null
|
? _data.child1[0] != null
|
||||||
? `posMaster.orgChild1Id IN (:...child1)`
|
? `posMaster.orgChild1Id IN (:...child1)`
|
||||||
// : `posMaster.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
: // : `posMaster.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
||||||
: `posMaster.orgChild1Id is null`
|
`posMaster.orgChild1Id is null`
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{
|
{
|
||||||
child1: _data.child1,
|
child1: _data.child1,
|
||||||
|
|
@ -944,10 +944,11 @@ export class EmployeeTempPositionController extends Controller {
|
||||||
{
|
{
|
||||||
child4: _data.child4,
|
child4: _data.child4,
|
||||||
},
|
},
|
||||||
)
|
);
|
||||||
|
|
||||||
if (body.keyword != null && body.keyword != "") {
|
if (body.keyword != null && body.keyword != "") {
|
||||||
query.orWhere(
|
query
|
||||||
|
.orWhere(
|
||||||
new Brackets((qb) => {
|
new Brackets((qb) => {
|
||||||
qb.andWhere(
|
qb.andWhere(
|
||||||
body.keyword != null && body.keyword != ""
|
body.keyword != null && body.keyword != ""
|
||||||
|
|
@ -1005,7 +1006,7 @@ export class EmployeeTempPositionController extends Controller {
|
||||||
.andWhere(typeCondition)
|
.andWhere(typeCondition)
|
||||||
.andWhere(revisionCondition);
|
.andWhere(revisionCondition);
|
||||||
}),
|
}),
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let [posMaster, total] = await query
|
let [posMaster, total] = await query
|
||||||
|
|
@ -2118,7 +2119,7 @@ export class EmployeeTempPositionController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("profile/delete/{id}")
|
@Post("profile/delete/{id}")
|
||||||
async deleteEmpHolder(@Path() id: string, @Request() request: RequestWithUser) {
|
async deleteEmpHolder(@Path() id: string, @Request() request: RequestWithUser) {
|
||||||
await new permission().PermissionDelete(request, "SYS_ORG_TEMP");
|
await new permission().PermissionUpdate(request, "SYS_ORG_TEMP");
|
||||||
const dataMaster = await this.employeeTempPosMasterRepository.findOne({
|
const dataMaster = await this.employeeTempPosMasterRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
relations: ["positions", "orgRevision"],
|
relations: ["positions", "orgRevision"],
|
||||||
|
|
@ -2179,7 +2180,7 @@ export class EmployeeTempPositionController extends Controller {
|
||||||
@Body() requestBody: { draftPositionId: string; publishPositionId: string },
|
@Body() requestBody: { draftPositionId: string; publishPositionId: string },
|
||||||
@Request() request: RequestWithUser,
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
await new permission().PermissionDelete(request, "SYS_ORG_TEMP");
|
await new permission().PermissionUpdate(request, "SYS_ORG_TEMP");
|
||||||
const findDraft = await this.orgRevisionRepository.findOne({
|
const findDraft = await this.orgRevisionRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
orgRevisionIsDraft: true,
|
orgRevisionIsDraft: true,
|
||||||
|
|
|
||||||
|
|
@ -3364,7 +3364,15 @@ export class PositionController extends Controller {
|
||||||
if (orgRevision?.orgRevisionIsCurrent) {
|
if (orgRevision?.orgRevisionIsCurrent) {
|
||||||
const pmWithOrg = await this.posMasterRepository.findOne({
|
const pmWithOrg = await this.posMasterRepository.findOne({
|
||||||
where: { id: posMaster.id },
|
where: { id: posMaster.id },
|
||||||
relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3", "orgChild4", "positions", "positions.posExecutive"],
|
relations: [
|
||||||
|
"orgRoot",
|
||||||
|
"orgChild1",
|
||||||
|
"orgChild2",
|
||||||
|
"orgChild3",
|
||||||
|
"orgChild4",
|
||||||
|
"positions",
|
||||||
|
"positions.posExecutive",
|
||||||
|
],
|
||||||
});
|
});
|
||||||
const _profile = await this.profileRepository.findOne({
|
const _profile = await this.profileRepository.findOne({
|
||||||
where: { id: posMaster.current_holderId },
|
where: { id: posMaster.current_holderId },
|
||||||
|
|
@ -3375,13 +3383,16 @@ export class PositionController extends Controller {
|
||||||
_profile.org = getOrgFullName(pmWithOrg) ?? _null;
|
_profile.org = getOrgFullName(pmWithOrg) ?? _null;
|
||||||
// ถ้าไม่ใช่ตำแหน่งนั่งทับ (isSit = false) ถึงจะอัพเดทตำแหน่งในทะเบียนประวัติ
|
// ถ้าไม่ใช่ตำแหน่งนั่งทับ (isSit = false) ถึงจะอัพเดทตำแหน่งในทะเบียนประวัติ
|
||||||
if (!pmWithOrg.isSit) {
|
if (!pmWithOrg.isSit) {
|
||||||
const selectedPos = (pmWithOrg as any).positions?.find((p: any) => p.positionIsSelected === true);
|
const selectedPos = (pmWithOrg as any).positions?.find(
|
||||||
|
(p: any) => p.positionIsSelected === true,
|
||||||
|
);
|
||||||
if (selectedPos) {
|
if (selectedPos) {
|
||||||
_profile.position = selectedPos.positionName ?? _null;
|
_profile.position = selectedPos.positionName ?? _null;
|
||||||
_profile.posTypeId = selectedPos.posTypeId ?? _null;
|
_profile.posTypeId = selectedPos.posTypeId ?? _null;
|
||||||
_profile.posLevelId = selectedPos.posLevelId ?? _null;
|
_profile.posLevelId = selectedPos.posLevelId ?? _null;
|
||||||
_profile.positionField = selectedPos.positionField ?? _null;
|
_profile.positionField = selectedPos.positionField ?? _null;
|
||||||
_profile.posExecutive = (selectedPos as any).posExecutive?.posExecutiveName ?? _null;
|
_profile.posExecutive =
|
||||||
|
(selectedPos as any).posExecutive?.posExecutiveName ?? _null;
|
||||||
_profile.positionArea = selectedPos.positionArea ?? _null;
|
_profile.positionArea = selectedPos.positionArea ?? _null;
|
||||||
_profile.positionExecutiveField = selectedPos.positionExecutiveField ?? _null;
|
_profile.positionExecutiveField = selectedPos.positionExecutiveField ?? _null;
|
||||||
}
|
}
|
||||||
|
|
@ -3932,7 +3943,7 @@ export class PositionController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("profile/delete/{id}")
|
@Post("profile/delete/{id}")
|
||||||
async deleteHolder(@Path() id: string, @Request() request: RequestWithUser) {
|
async deleteHolder(@Path() id: string, @Request() request: RequestWithUser) {
|
||||||
await new permission().PermissionDelete(request, "SYS_ORG");
|
await new permission().PermissionUpdate(request, "SYS_ORG");
|
||||||
const dataMaster = await this.posMasterRepository.findOne({
|
const dataMaster = await this.posMasterRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
relations: ["positions", "orgRevision"],
|
relations: ["positions", "orgRevision"],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue