Commit 0214dcf8 by Nakarin Luankla

UPDATE การจัดการรายละเอียดงาน > ลักษณะงาน

parent 65385195
......@@ -256,7 +256,7 @@
data-hs-overlay="#sub-job-competency-component-modal-edit">
ย้อนกลับ
</button>
<button class="ti-btn ti-btn-success {{checkJobCodeId&&modalStatus=='add'||!selectJob.jobcodeId ? 'ti-btn-disabled' : ''}}" [disabled]="checkJobCodeId&&modalStatus=='add'||!selectJob.jobcodeId"
<button class="ti-btn ti-btn-success {{checkJobCodeId&&modalStatus=='add'||!selectJob.jobcodeId||!selectJob.tdesc ? 'ti-btn-disabled' : ''}}" [disabled]="checkJobCodeId&&modalStatus=='add'||!selectJob.jobcodeId||!selectJob.tdesc"
data-hs-overlay="#company-registration-page-alert-modal">
บันทึกข้อมูล
</button>
......
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { ChangeDetectorRef, Component} from '@angular/core';
import { ToastrService } from 'ngx-toastr';
import { JobModel, MyJobModel } from 'src/app/shared/model/job.model';
import { JobCodeModel, MyJobCodeModel } from 'src/app/shared/model/job-code.model';
import { FileService } from 'src/app/shared/services/file.service';
import { JobCodeService } from 'src/app/shared/services/job-code.service';
@Component({
......@@ -11,70 +13,142 @@ import { JobModel, MyJobModel } from 'src/app/shared/model/job.model';
export class SubJobQualificationsComponent {
currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1);
jobList: JobModel[] = []
job: JobModel = new MyJobModel({})
pageSize=10
search = ""
jobCodeList:JobCodeModel[]=[]
loading = false
selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์';
selectJob:JobCodeModel=new MyJobCodeModel({})
modalStatus=''
constructor(
private toastr: ToastrService
private toastr: ToastrService,
private fileService: FileService,
private jobcodeService: JobCodeService,
private cdr: ChangeDetectorRef,
) { }
ngOnInit(): void {
this.getListJob();
}
getListJob(){
this.loading = false
this.jobcodeService.getList().subscribe({
next: response => {
this.jobCodeList = response.map((x: any) => new MyJobCodeModel(x))
this.jobCodeList = this.jobCodeList.sort((a, b) => a.jobcodeId.localeCompare(b.jobcodeId))
this.loading = false
this.searchChange()
this.cdr.detectChanges()
}, error: error => {
this.loading = false
this.cdr.detectChanges()
}
})
}
searchChange() {
this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.jobListFilter().length / 10) }, (_, i) => i + 1);
this.page = Array.from({ length: Math.ceil(this.jobcodeFilter().length / this.pageSize) }, (_, i) => i + 1);
}
edit(item :JobCodeModel){
this.selectJob = new MyJobCodeModel({})
this.selectJob = new MyJobCodeModel(item)
}
clearValue(){
this.selectJob.educationExperienceText = ''
this.selectJob.cerLicensedText = ''
this.selectJob.especiallyTrainingText = ''
this.selectJob.otherAbilitiesText = ''
}
jobListFilter() {
return this.jobList.filter(x => x.jobid.includes(this.search) ||
x.tdesc.includes(this.search) ||
x.edesc.includes(this.search))
save(){
this.jobcodeService.post(this.selectJob).subscribe((response:any) => {
if (response.success) {
this.showAlert(response.message, 'success')
this.selectJob = new MyJobCodeModel({})
this.getListJob();
} else {
this.showAlert(response.message, 'error')
}
selectJob(job: JobModel) {
// this.showSuccess()
this.job = new MyJobModel(job)
this.cdr.detectChanges()
})
}
deleteJob(){
this.jobcodeService.delete(this.selectJob).subscribe((response:any) => {
if (response.success) {
this.showAlert(response.message, 'success')
this.selectJob = new MyJobCodeModel({})
this.getListJob();
} else {
this.showAlert(response.message, 'error')
}
this.cdr.detectChanges()
})
}
jobcodeFilter() {
return this.jobCodeList.filter(x =>
x.tdesc.toLowerCase().includes(this.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.search.toLowerCase()) ||
x.jobcodeId.toLowerCase().includes(this.search.toLowerCase())
)
}
onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์"
}
showSuccessAdd() {
this.toastr.success('บันทึกข้อมูลสำเร็จ', 'เเจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
uploadFile() {
if (!this.selectedFile) {
alert('กรุณาเลือกไฟล์ก่อนอัปโหลด')
return
}
const formData = new FormData();
formData.append('file', this.selectedFile);
this.loading = true
this.fileService.uploadExcel(formData, 'IMPORT_PROPERTY').subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getListJob();
} else {
this.showAlert(response.message, 'error')
this.loading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.loading = false
}
})
}
showSuccessEdit() {
this.toastr.success('เเก้ไขข้อมูลสำเร็จ', 'เเจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
downloadFile() {
const fileName = 'IMPORT_MJOBCODEV2.xlsx'
this.fileService.downloadTemplate(fileName).subscribe({
next: response => {
const url = window.URL.createObjectURL(response);
const a = document.createElement("a");
a.href = url;
a.download = fileName;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, error: error => {
this.showAlert(error.message, 'error')
}
})
showSuccessDelete() {
this.toastr.success('ลบข้อมูลสำเร็จ', 'เเจ้งเตือน', {
}
showAlert(text: string, type: 'success' | 'error') {
this.toastr[type](text, 'แจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
}
addBu1() {
// this.bu1Service.post(this.bu1).subscribe((response:any) => {
// if (response.success) {
// this.getBu1List()
// }
// })
}
editBu1() {
// this.bu1Service.post(this.bu1).subscribe((response:any) => {
// if (response.success) {
// this.getBu1List()
// }
// })
}
deleteJob(job: JobModel) {
// this.bu1Service.delete(new MyBu1Model(bu1)).subscribe((response:any) => {
// if (response.success) {
// this.getBu1List()
// }
// })
})
}
}
......@@ -45,6 +45,10 @@ export interface JobCodeModel {
otherWorkText: string
otherWorkPercent: number
kpiWorkText: string
educationExperienceText: string
cerLicensedText: string
especiallyTrainingText: string
otherAbilitiesText: string
}
export class MyJobCodeModel implements JobCodeModel {
......@@ -84,6 +88,10 @@ export class MyJobCodeModel implements JobCodeModel {
otherWorkText: string
otherWorkPercent: number
kpiWorkText: string
educationExperienceText: string
cerLicensedText: string
especiallyTrainingText: string
otherAbilitiesText: string
constructor(data: Partial<JobCodeModel>) {
this.jobcodeId = data.jobcodeId || ""
this.tdesc = data.tdesc || ""
......@@ -121,6 +129,10 @@ export class MyJobCodeModel implements JobCodeModel {
this.otherWorkText = data.otherWorkText || ""
this.otherWorkPercent = data.otherWorkPercent ?? 0
this.kpiWorkText = data.kpiWorkText || ""
this.educationExperienceText = data.educationExperienceText || ""
this.cerLicensedText = data.cerLicensedText || ""
this.especiallyTrainingText = data.especiallyTrainingText || ""
this.otherAbilitiesText = data.otherAbilitiesText || ""
}
}
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