Commit 7792eb25 by Nattana Chaiyamat

Primary Key

parent 18faf9dd
...@@ -186,8 +186,10 @@ ...@@ -186,8 +186,10 @@
</div> </div>
</div> </div>
<div class="ti-modal-body padding-16px pt-0 overflow-y-0"> <div class="ti-modal-body padding-16px pt-0 overflow-y-0">
<label for="input-label" class="ti-form-label mt-2rem">รหัสระดับ<span <label for="input-label" class="ti-form-label mt-2rem">รหัสระดับ<span class="text-danger">*
class="text-danger">*</span></label> <ng-container *ngIf="currentModal=='add'&&checkPrimary()">
รหัสระดับซ้ำ
</ng-container></span></label>
<input type="text" id="input-label" class="ti-form-input w-1/2" <input type="text" id="input-label" class="ti-form-input w-1/2"
[ngClass]="{'!bg-input-readonly':currentModal=='edit'}" [readonly]="currentModal=='edit'" [ngClass]="{'!bg-input-readonly':currentModal=='edit'}" [readonly]="currentModal=='edit'"
[(ngModel)]="configPermission.select.userLevel"> [(ngModel)]="configPermission.select.userLevel">
...@@ -206,8 +208,8 @@ ...@@ -206,8 +208,8 @@
</button> </button>
<button type="button" class="ti-btn ti-btn-success" <button type="button" class="ti-btn ti-btn-success"
data-hs-overlay="#role-permission-config-alert-modal" data-hs-overlay="#role-permission-config-alert-modal"
[class.ti-btn-disabled]="!configPermission.select.userLevel||!configPermission.select.tdesc" [class.ti-btn-disabled]="!configPermission.select.userLevel||!configPermission.select.tdesc||(currentModal=='add'&&checkPrimary())"
[disabled]="!configPermission.select.userLevel||!configPermission.select.tdesc"> [disabled]="!configPermission.select.userLevel||!configPermission.select.tdesc||(currentModal=='add'&&checkPrimary())">
บันทึกข้อมูล บันทึกข้อมูล
</button> </button>
</div> </div>
......
...@@ -182,4 +182,9 @@ export class RolePermissionConfigComponent { ...@@ -182,4 +182,9 @@ export class RolePermissionConfigComponent {
this.cdr.detectChanges() this.cdr.detectChanges()
}) })
} }
checkPrimary() {
return this.configPermission.dataList.find(x => x.data.userLevel == this.configPermission.select.userLevel)
}
} }
...@@ -212,7 +212,12 @@ ...@@ -212,7 +212,12 @@
</div> </div>
</div> </div>
<div class="ti-modal-body padding-16px pt-0 overflow-y-0"> <div class="ti-modal-body padding-16px pt-0 overflow-y-0">
<label class="ti-form-label mt-2rem">ชื่อล็อกอิน<span class="text-danger">*</span></label> <label class="ti-form-label mt-2rem">ชื่อล็อกอิน
<span class="text-danger">*
<ng-container *ngIf="currentModal=='add'&&checkPrimary()">
ชื่อล็อกอินซ้ำ
</ng-container>
</span></label>
<input type="text" class="ti-form-input" <input type="text" class="ti-form-input"
oninput="this.value = this.value.replace(/[\u0E00-\u0E7F]/g, '')" oninput="this.value = this.value.replace(/[\u0E00-\u0E7F]/g, '')"
[ngClass]="{'bg-input-readonly':currentModal=='edit'}" [readonly]="currentModal=='edit'" [ngClass]="{'bg-input-readonly':currentModal=='edit'}" [readonly]="currentModal=='edit'"
...@@ -281,8 +286,8 @@ ...@@ -281,8 +286,8 @@
ย้อนกลับ ย้อนกลับ
</button> </button>
<button type="button" class="ti-btn ti-btn-success" data-hs-overlay="#user-setting-alert-modal" <button type="button" class="ti-btn ti-btn-success" data-hs-overlay="#user-setting-alert-modal"
[class.ti-btn-disabled]="!user.select.usernameId||!user.select.employee.employeeId||!user.select.role.roleId||!user.select.level.userLevel" [class.ti-btn-disabled]="!user.select.usernameId||!user.select.employee.employeeId||!user.select.role.roleId||!user.select.level.userLevel||(currentModal=='add'&&checkPrimary())"
[disabled]="!user.select.usernameId||!user.select.employee.employeeId||!user.select.role.roleId||!user.select.level.userLevel"> [disabled]="!user.select.usernameId||!user.select.employee.employeeId||!user.select.role.roleId||!user.select.level.userLevel||(currentModal=='add'&&checkPrimary())">
บันทึกข้อมูล บันทึกข้อมูล
</button> </button>
</div> </div>
...@@ -789,7 +794,8 @@ ...@@ -789,7 +794,8 @@
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-danger" href="javascript:void(0);" <a class="ti-btn ti-btn-danger" href="javascript:void(0);"
data-hs-overlay="#user-setting-alert-modal" (click)="updateUser('delete')" *ngIf="numDataListChecked"> data-hs-overlay="#user-setting-alert-modal" (click)="updateUser('delete')"
*ngIf="numDataListChecked">
ลบข้อมูล ลบข้อมูล
</a> </a>
</ng-container> </ng-container>
......
...@@ -316,4 +316,8 @@ export class UserSettingsComponent { ...@@ -316,4 +316,8 @@ export class UserSettingsComponent {
this.numDataListChecked = this.user.dataList.filter(x => x.check).length; this.numDataListChecked = this.user.dataList.filter(x => x.check).length;
this.isDataListChecked = Boolean(this.numDataListChecked) this.isDataListChecked = Boolean(this.numDataListChecked)
} }
checkPrimary() {
return this.user.dataList.find(x => x.data.usernameId == this.user.select.usernameId)
}
} }
...@@ -177,7 +177,11 @@ ...@@ -177,7 +177,11 @@
<div class="space-y-3"> <div class="space-y-3">
<div class="grid grid-cols-12 gap-x-6"> <div class="grid grid-cols-12 gap-x-6">
<label class="col-span-3 ti-form-label text-primary mt-2 align-center">รหัสพนักงาน<span <label class="col-span-3 ti-form-label text-primary mt-2 align-center">รหัสพนักงาน<span
class="text-danger">*</span></label> class="text-danger">*
<ng-container *ngIf="(modalType=='add')&&checkPrimary()">
<br>รหัสพนักงานซ้ำ
</ng-container>
</span></label>
<input type="text" class="col-span-6 ti-form-input" [ngClass]="{'bg-input-readonly':modalType=='update'}" <input type="text" class="col-span-6 ti-form-input" [ngClass]="{'bg-input-readonly':modalType=='update'}"
oninput="this.value = this.value.replace(/[^a-zA-Z0-9\u0E00-\uFFFF]/g, '')" maxlength="15" oninput="this.value = this.value.replace(/[^a-zA-Z0-9\u0E00-\uFFFF]/g, '')" maxlength="15"
[readonly]="modalType=='update'" [(ngModel)]="employee.select.employeeId"> [readonly]="modalType=='update'" [(ngModel)]="employee.select.employeeId">
...@@ -586,8 +590,8 @@ ...@@ -586,8 +590,8 @@
ย้อนกลับ ย้อนกลับ
</button> </button>
<button type="button" class="ti-btn ti-btn-success" <button type="button" class="ti-btn ti-btn-success"
data-hs-overlay="#sub-employee-registration-alert-add-modal" [class.ti-btn-disabled]="checkEmployeeModel()" data-hs-overlay="#sub-employee-registration-alert-add-modal" [class.ti-btn-disabled]="checkEmployeeModel()||(modalType=='add'&&checkPrimary())"
[disabled]="checkEmployeeModel()"> [disabled]="checkEmployeeModel()||(modalType=='add'&&checkPrimary())">
บันทึกข้อมูล บันทึกข้อมูล
</button> </button>
</div> </div>
......
...@@ -284,7 +284,7 @@ export class SubEmployeeRegistrationComponent { ...@@ -284,7 +284,7 @@ export class SubEmployeeRegistrationComponent {
this.bu1.loading = false this.bu1.loading = false
this.bu1Service.getList().subscribe({ this.bu1Service.getList().subscribe({
next: response => { next: response => {
this.bu1.dataList = response.map((x: any) => new MyBu1Model(x)) this.bu1.dataList = response?.map((x: any) => new MyBu1Model(x)) || []
this.bu1.loading = false this.bu1.loading = false
this.searchChange() this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
...@@ -318,7 +318,7 @@ export class SubEmployeeRegistrationComponent { ...@@ -318,7 +318,7 @@ export class SubEmployeeRegistrationComponent {
this.bu2.loading = false this.bu2.loading = false
this.bu2Service.getListByParent(this.employee.select.bu1.bu1id).subscribe({ this.bu2Service.getListByParent(this.employee.select.bu1.bu1id).subscribe({
next: response => { next: response => {
this.bu2.dataList = response.map((x: any) => new MyBu2Model(x)) this.bu2.dataList = response?.map((x: any) => new MyBu2Model(x)) || []
this.bu2.loading = false this.bu2.loading = false
this.searchChange() this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
...@@ -351,7 +351,7 @@ export class SubEmployeeRegistrationComponent { ...@@ -351,7 +351,7 @@ export class SubEmployeeRegistrationComponent {
this.bu3.loading = false this.bu3.loading = false
this.bu3Service.getListByParent(this.employee.select.bu2.bu2id).subscribe({ this.bu3Service.getListByParent(this.employee.select.bu2.bu2id).subscribe({
next: response => { next: response => {
this.bu3.dataList = response.map((x: any) => new MyBu3Model(x)) this.bu3.dataList = response?.map((x: any) => new MyBu3Model(x)) || []
this.bu3.loading = false this.bu3.loading = false
this.searchChange() this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
...@@ -383,7 +383,7 @@ export class SubEmployeeRegistrationComponent { ...@@ -383,7 +383,7 @@ export class SubEmployeeRegistrationComponent {
this.bu4.loading = false this.bu4.loading = false
this.bu4Service.getListByParent(this.employee.select.bu3.bu3id).subscribe({ this.bu4Service.getListByParent(this.employee.select.bu3.bu3id).subscribe({
next: response => { next: response => {
this.bu4.dataList = response.map((x: any) => new MyBu4Model(x)) this.bu4.dataList = response?.map((x: any) => new MyBu4Model(x)) || []
this.bu4.loading = false this.bu4.loading = false
this.searchChange() this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
...@@ -414,7 +414,7 @@ export class SubEmployeeRegistrationComponent { ...@@ -414,7 +414,7 @@ export class SubEmployeeRegistrationComponent {
this.bu5.loading = false this.bu5.loading = false
this.bu5Service.getListByParent(this.employee.select.bu4.bu4id).subscribe({ this.bu5Service.getListByParent(this.employee.select.bu4.bu4id).subscribe({
next: response => { next: response => {
this.bu5.dataList = response.map((x: any) => new MyBu5Model(x)) this.bu5.dataList = response?.map((x: any) => new MyBu5Model(x)) || []
this.bu5.loading = false this.bu5.loading = false
this.searchChange() this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
...@@ -444,7 +444,7 @@ export class SubEmployeeRegistrationComponent { ...@@ -444,7 +444,7 @@ export class SubEmployeeRegistrationComponent {
this.bu6.loading = false this.bu6.loading = false
this.bu6Service.getListByParent(this.employee.select.bu5.bu5id).subscribe({ this.bu6Service.getListByParent(this.employee.select.bu5.bu5id).subscribe({
next: response => { next: response => {
this.bu6.dataList = response.map((x: any) => new MyBu6Model(x)) this.bu6.dataList = response?.map((x: any) => new MyBu6Model(x)) || []
this.bu6.loading = false this.bu6.loading = false
this.searchChange() this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
...@@ -473,7 +473,7 @@ export class SubEmployeeRegistrationComponent { ...@@ -473,7 +473,7 @@ export class SubEmployeeRegistrationComponent {
this.bu7.loading = false this.bu7.loading = false
this.bu7Service.getListByParent(this.employee.select.bu6.bu6id).subscribe({ this.bu7Service.getListByParent(this.employee.select.bu6.bu6id).subscribe({
next: response => { next: response => {
this.bu7.dataList = response.map((x: any) => new MyBu7Model(x)) this.bu7.dataList = response?.map((x: any) => new MyBu7Model(x)) || []
this.bu7.loading = false this.bu7.loading = false
this.searchChange() this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
...@@ -694,4 +694,8 @@ export class SubEmployeeRegistrationComponent { ...@@ -694,4 +694,8 @@ export class SubEmployeeRegistrationComponent {
}).join('')); }).join(''));
return JSON.parse(jsonPayload); return JSON.parse(jsonPayload);
} }
checkPrimary() {
return this.employee.dataList.find(x => x.data.employeeId == this.employee.select.employeeId)
}
} }
...@@ -171,7 +171,7 @@ ...@@ -171,7 +171,7 @@
<div class="ti-modal-body "> <div class="ti-modal-body ">
<label for="input-label" class="ti-form-label mt-2rem"> <label for="input-label" class="ti-form-label mt-2rem">
<span class="text-danger"> <span class="text-danger">
* รหัสตำแหน่ง *
<ng-container *ngIf="modalStatus=='add'&&checkPrimary()"> <ng-container *ngIf="modalStatus=='add'&&checkPrimary()">
รหัสตำแหน่งซ้ำ รหัสตำแหน่งซ้ำ
</ng-container> </ng-container>
......
...@@ -146,12 +146,15 @@ ...@@ -146,12 +146,15 @@
</div> </div>
</div> </div>
<div class="ti-modal-body" style="padding-top: 0px;"> <div class="ti-modal-body" style="padding-top: 0px;">
<label for="input-label" class="ti-form-label mt-1rem">รหัสงาน<span class="text-danger">*</span></label> <label for="input-label" class="ti-form-label mt-1rem">รหัสงาน<span class="text-danger">*
<ng-container *ngIf="modalStatus=='add'&&checkPrimary()">
รหัสงานซ้ำ
</ng-container>
</span></label>
<input type="text" id="input-label" <input type="text" id="input-label"
class="ti-form-input {{modalStatus == 'edit' ? 'bg-input-readonly' : ''}}" class="ti-form-input {{modalStatus == 'edit' ? 'bg-input-readonly' : ''}}"
[attr.readonly]="modalStatus == 'edit' ? true : null" [(ngModel)]="selectJob.jobcodeId" [attr.readonly]="modalStatus == 'edit' ? true : null" [(ngModel)]="selectJob.jobcodeId"
(ngModelChange)="checkJodid()"> (ngModelChange)="checkJodid()">
<span *ngIf="checkJobCodeId&&modalStatus=='add'" class="text-danger">รหัสงานซ้ำ</span>
<label for="detail_th" class="ti-form-label mt-1rem">ชื่อลักษณะงาน (ไทย)<span <label for="detail_th" class="ti-form-label mt-1rem">ชื่อลักษณะงาน (ไทย)<span
class="text-danger">*</span></label> class="text-danger">*</span></label>
<input type="text" id="detail_th" class="ti-form-input " [(ngModel)]="selectJob.tdesc"> <input type="text" id="detail_th" class="ti-form-input " [(ngModel)]="selectJob.tdesc">
...@@ -223,8 +226,8 @@ ...@@ -223,8 +226,8 @@
ย้อนกลับ ย้อนกลับ
</button> </button>
<button <button
class="ti-btn ti-btn-success {{checkJobCodeId&&modalStatus=='add'||!selectJob.jobcodeId||!selectJob.tdesc ? 'ti-btn-disabled' : ''}}" class="ti-btn ti-btn-success {{checkJobCodeId&&modalStatus=='add'||!selectJob.jobcodeId||!selectJob.tdesc||(modalStatus=='add'&&checkPrimary()) ? 'ti-btn-disabled' : ''}}"
[disabled]="checkJobCodeId&&modalStatus=='add'||!selectJob.jobcodeId||!selectJob.tdesc" [disabled]="checkJobCodeId&&modalStatus=='add'||!selectJob.jobcodeId||!selectJob.tdesc||(modalStatus=='add'&&checkPrimary())"
data-hs-overlay="#company-registration-page-alert-modal"> data-hs-overlay="#company-registration-page-alert-modal">
บันทึกข้อมูล บันทึกข้อมูล
</button> </button>
......
...@@ -41,8 +41,8 @@ export class ImportDataComponent { ...@@ -41,8 +41,8 @@ export class ImportDataComponent {
selectJob: JobCodeModel = new MyJobCodeModel({}) selectJob: JobCodeModel = new MyJobCodeModel({})
modalStatus = '' modalStatus = ''
positionList:PositionModel[]=[] positionList: PositionModel[] = []
positionId='' positionId = ''
bu1List: Bu1Model[] = [] bu1List: Bu1Model[] = []
bu1Id = '' bu1Id = ''
...@@ -65,9 +65,9 @@ export class ImportDataComponent { ...@@ -65,9 +65,9 @@ export class ImportDataComponent {
bu7List: Bu7Model[] = [] bu7List: Bu7Model[] = []
bu7Id = '' bu7Id = ''
supervisorPositionId='' supervisorPositionId = ''
employeeList:EmployeeModel[]=[] employeeList: EmployeeModel[] = []
checkJobCodeId=false checkJobCodeId = false
constructor( constructor(
private toastr: ToastrService, private toastr: ToastrService,
private fileService: FileService, private fileService: FileService,
...@@ -81,7 +81,7 @@ export class ImportDataComponent { ...@@ -81,7 +81,7 @@ export class ImportDataComponent {
private bu5Service: Bu5Service, private bu5Service: Bu5Service,
private bu6Service: Bu6Service, private bu6Service: Bu6Service,
private bu7Service: Bu7Service, private bu7Service: Bu7Service,
private employeeService:EmployeeService private employeeService: EmployeeService
) { } ) { }
ngOnInit(): void { ngOnInit(): void {
this.getListJob(); this.getListJob();
...@@ -123,7 +123,7 @@ export class ImportDataComponent { ...@@ -123,7 +123,7 @@ export class ImportDataComponent {
} }
}) })
} }
checkJodid(){ checkJodid() {
let check = this.jobCodeList.some(x => x.jobcodeId == this.selectJob.jobcodeId) let check = this.jobCodeList.some(x => x.jobcodeId == this.selectJob.jobcodeId)
this.checkJobCodeId = check this.checkJobCodeId = check
...@@ -143,7 +143,7 @@ export class ImportDataComponent { ...@@ -143,7 +143,7 @@ export class ImportDataComponent {
this.bu7Id = item.bu7.bu7id this.bu7Id = item.bu7.bu7id
console.log("🚀 ~ ImportDataComponent ~ edit ~ this.selectJob:", this.selectJob) console.log("🚀 ~ ImportDataComponent ~ edit ~ this.selectJob:", this.selectJob)
} }
add(){ add() {
this.selectJob = new MyJobCodeModel({}) this.selectJob = new MyJobCodeModel({})
this.checkJobCodeId = false this.checkJobCodeId = false
this.positionId = '' this.positionId = ''
...@@ -292,7 +292,7 @@ export class ImportDataComponent { ...@@ -292,7 +292,7 @@ export class ImportDataComponent {
let value = this.positionList.find(x => x.positionId == this.positionId); let value = this.positionList.find(x => x.positionId == this.positionId);
if (value) { if (value) {
this.selectJob.position = value this.selectJob.position = value
}else{ } else {
this.selectJob.position = new MyPositionModel({}) this.selectJob.position = new MyPositionModel({})
} }
} }
...@@ -300,7 +300,7 @@ export class ImportDataComponent { ...@@ -300,7 +300,7 @@ export class ImportDataComponent {
let value = this.positionList.find(x => x.positionId == this.supervisorPositionId); let value = this.positionList.find(x => x.positionId == this.supervisorPositionId);
if (value) { if (value) {
this.selectJob.supervisorPosition = value this.selectJob.supervisorPosition = value
}else{ } else {
this.selectJob.supervisorPosition = new MyPositionModel({}) this.selectJob.supervisorPosition = new MyPositionModel({})
} }
} }
...@@ -319,7 +319,7 @@ export class ImportDataComponent { ...@@ -319,7 +319,7 @@ export class ImportDataComponent {
let value = this.bu1List.find(x => x.bu1id == this.bu1Id); let value = this.bu1List.find(x => x.bu1id == this.bu1Id);
if (value) { if (value) {
this.selectJob.bu1 = value this.selectJob.bu1 = value
}else{ } else {
this.selectJob.bu1 = new MyBu1Model({}) this.selectJob.bu1 = new MyBu1Model({})
} }
} }
...@@ -338,7 +338,7 @@ export class ImportDataComponent { ...@@ -338,7 +338,7 @@ export class ImportDataComponent {
let value = this.bu2List.find(x => x.bu2id == this.bu2Id); let value = this.bu2List.find(x => x.bu2id == this.bu2Id);
if (value) { if (value) {
this.selectJob.bu2 = value this.selectJob.bu2 = value
}else{ } else {
this.selectJob.bu2 = new MyBu2Model({}) this.selectJob.bu2 = new MyBu2Model({})
} }
} }
...@@ -357,7 +357,7 @@ export class ImportDataComponent { ...@@ -357,7 +357,7 @@ export class ImportDataComponent {
let value = this.bu3List.find(x => x.bu3id == this.bu3Id); let value = this.bu3List.find(x => x.bu3id == this.bu3Id);
if (value) { if (value) {
this.selectJob.bu3 = value this.selectJob.bu3 = value
}else{ } else {
this.selectJob.bu3 = new MyBu3Model({}) this.selectJob.bu3 = new MyBu3Model({})
} }
} }
...@@ -376,7 +376,7 @@ export class ImportDataComponent { ...@@ -376,7 +376,7 @@ export class ImportDataComponent {
let value = this.bu4List.find(x => x.bu4id == this.bu4Id); let value = this.bu4List.find(x => x.bu4id == this.bu4Id);
if (value) { if (value) {
this.selectJob.bu4 = value this.selectJob.bu4 = value
}else{ } else {
this.selectJob.bu4 = new MyBu4Model({}) this.selectJob.bu4 = new MyBu4Model({})
} }
} }
...@@ -394,7 +394,7 @@ export class ImportDataComponent { ...@@ -394,7 +394,7 @@ export class ImportDataComponent {
let value = this.bu5List.find(x => x.bu5id == this.bu5Id); let value = this.bu5List.find(x => x.bu5id == this.bu5Id);
if (value) { if (value) {
this.selectJob.bu5 = value this.selectJob.bu5 = value
}else{ } else {
this.selectJob.bu5 = new MyBu5Model({}) this.selectJob.bu5 = new MyBu5Model({})
} }
} }
...@@ -413,7 +413,7 @@ export class ImportDataComponent { ...@@ -413,7 +413,7 @@ export class ImportDataComponent {
let value = this.bu6List.find(x => x.bu6id == this.bu6Id); let value = this.bu6List.find(x => x.bu6id == this.bu6Id);
if (value) { if (value) {
this.selectJob.bu6 = value this.selectJob.bu6 = value
}else{ } else {
this.selectJob.bu6 = new MyBu6Model({}) this.selectJob.bu6 = new MyBu6Model({})
} }
} }
...@@ -431,7 +431,7 @@ export class ImportDataComponent { ...@@ -431,7 +431,7 @@ export class ImportDataComponent {
let value = this.bu7List.find(x => x.bu7id == this.bu7Id); let value = this.bu7List.find(x => x.bu7id == this.bu7Id);
if (value) { if (value) {
this.selectJob.bu7 = value this.selectJob.bu7 = value
}else{ } else {
this.selectJob.bu7 = new MyBu7Model({}) this.selectJob.bu7 = new MyBu7Model({})
} }
} }
...@@ -441,5 +441,7 @@ export class ImportDataComponent { ...@@ -441,5 +441,7 @@ export class ImportDataComponent {
modal.classList.add("hidden"); // ซ่อน Modal modal.classList.add("hidden"); // ซ่อน Modal
} }
} }
checkPrimary() {
return this.jobCodeList.find(x => x.jobcodeId == this.selectJob.jobcodeId)
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment