Commit 1c0dc14d by Nakarin Luankla

UPDATE JD

parent 5c57a862
...@@ -15,7 +15,7 @@ import { EmployeeService } from 'src/app/shared/services/employee.service'; ...@@ -15,7 +15,7 @@ import { EmployeeService } from 'src/app/shared/services/employee.service';
import { PLService } from 'src/app/shared/services/pl.service'; import { PLService } from 'src/app/shared/services/pl.service';
import { PositionService } from 'src/app/shared/services/position.service'; import { PositionService } from 'src/app/shared/services/position.service';
import { BranchService } from 'src/app/shared/services/่branch.service'; import { BranchService } from 'src/app/shared/services/่branch.service';
import { JobCodeService } from 'src/app/shared/services/job-code.service'; import { JobCodeService } from 'src/app/shared/services/job-code.service';
export interface DataEmployee { export interface DataEmployee {
loading: boolean loading: boolean
select: EmployeeModel | any select: EmployeeModel | any
......
...@@ -129,7 +129,7 @@ import { MatInputModule } from '@angular/material/input'; ...@@ -129,7 +129,7 @@ import { MatInputModule } from '@angular/material/input';
import { DateAdapter, MAT_DATE_FORMATS } from '@angular/material/core'; import { DateAdapter, MAT_DATE_FORMATS } from '@angular/material/core';
import { NativeDateAdapter } from '@angular/material/core'; import { NativeDateAdapter } from '@angular/material/core';
import { BranchService } from 'src/app/shared/services/่branch.service'; import { BranchService } from 'src/app/shared/services/่branch.service';
import { JobCodeService } from 'src/app/shared/services/job-code.service'; import { JobCodeService } from 'src/app/shared/services/job-code.service';
import { FileService } from 'src/app/shared/services/file.service'; import { FileService } from 'src/app/shared/services/file.service';
import { CompetencyGroupGradeService } from 'src/app/shared/services/competency-group-grade.service'; import { CompetencyGroupGradeService } from 'src/app/shared/services/competency-group-grade.service';
import { IndicatorsCoursesService } from 'src/app/shared/services/indicators-courses.service'; import { IndicatorsCoursesService } from 'src/app/shared/services/indicators-courses.service';
......
...@@ -3,7 +3,7 @@ import { ToastrService } from 'ngx-toastr'; ...@@ -3,7 +3,7 @@ import { ToastrService } from 'ngx-toastr';
import { JobCodeModel, MyJobCodeModel } from 'src/app/shared/model/job-code.model'; import { JobCodeModel, MyJobCodeModel } from 'src/app/shared/model/job-code.model';
import { JobModel, MyJobModel } from 'src/app/shared/model/job.model'; import { JobModel, MyJobModel } from 'src/app/shared/model/job.model';
import { FileService } from 'src/app/shared/services/file.service'; import { FileService } from 'src/app/shared/services/file.service';
import { JobCodeService } from 'src/app/shared/services/job-code.service'; import { JobCodeService } from 'src/app/shared/services/job-code.service';
@Component({ @Component({
...@@ -14,12 +14,16 @@ import { JobCodeService } from 'src/app/shared/services/่job-code.service'; ...@@ -14,12 +14,16 @@ import { JobCodeService } from 'src/app/shared/services/่job-code.service';
export class SubJobCompetencyComponent { export class SubJobCompetencyComponent {
currentPage = 1 currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1); page = Array.from({ length: 1 }, (_, i) => i + 1);
pageSize=10
search = "" search = ""
jobCodeList:JobCodeModel[]=[] jobCodeList:JobCodeModel[]=[]
loading = false loading = false
selectedFile: File | null = null; selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์'; selectedFileName: string = 'กรุณาเลือกไฟล์';
selectJob:JobCodeModel=new MyJobCodeModel({})
modalStatus=''
constructor( constructor(
private toastr: ToastrService, private toastr: ToastrService,
private fileService: FileService, private fileService: FileService,
...@@ -34,7 +38,7 @@ export class SubJobCompetencyComponent { ...@@ -34,7 +38,7 @@ export class SubJobCompetencyComponent {
this.jobcodeService.getList().subscribe({ this.jobcodeService.getList().subscribe({
next: response => { next: response => {
this.jobCodeList = response.map((x: any) => new MyJobCodeModel(x)) this.jobCodeList = response.map((x: any) => new MyJobCodeModel(x))
console.log("🚀 ~ SubJobCompetencyComponent ~ this.jobcodeService.getList ~ this.jobCodeList:", this.jobCodeList) this.jobCodeList = this.jobCodeList.sort((a, b) => a.jobcodeId.localeCompare(b.jobcodeId))
this.loading = false this.loading = false
this.searchChange() this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
...@@ -47,9 +51,27 @@ export class SubJobCompetencyComponent { ...@@ -47,9 +51,27 @@ export class SubJobCompetencyComponent {
searchChange() { searchChange() {
this.currentPage = 1 this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.jobcodeFilter().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)
}
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')
} }
this.cdr.detectChanges()
})
}
deleteCompany(){
}
jobcodeFilter() { jobcodeFilter() {
return this.jobCodeList.filter(x => return this.jobCodeList.filter(x =>
x.tdesc.toLowerCase().includes(this.search.toLowerCase()) || x.tdesc.toLowerCase().includes(this.search.toLowerCase()) ||
...@@ -69,19 +91,19 @@ export class SubJobCompetencyComponent { ...@@ -69,19 +91,19 @@ export class SubJobCompetencyComponent {
} }
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
// this.bu3ListLoading = true this.loading = true
this.fileService.upload(formData, 'MJOBCODE_COMPETENCY').subscribe({ this.fileService.upload(formData, 'MJOBCODE_COMPETENCY').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
// this.getBu3List() this.getListJob();
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
// this.bu3ListLoading = false this.loading = false
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
// this.bu3ListLoading = false this.loading = false
} }
}) })
} }
......
...@@ -32,6 +32,7 @@ export interface JobCodeModel { ...@@ -32,6 +32,7 @@ export interface JobCodeModel {
equalification: string equalification: string
jobObjective: string jobObjective: string
supervisor: string supervisor: string
competencyWorkText: string
} }
export class MyJobCodeModel implements JobCodeModel { export class MyJobCodeModel implements JobCodeModel {
...@@ -58,6 +59,7 @@ export class MyJobCodeModel implements JobCodeModel { ...@@ -58,6 +59,7 @@ export class MyJobCodeModel implements JobCodeModel {
equalification: string equalification: string
jobObjective: string jobObjective: string
supervisor: string supervisor: string
competencyWorkText: string
constructor(data: Partial<JobCodeModel>) { constructor(data: Partial<JobCodeModel>) {
this.jobcodeId = data.jobcodeId || "" this.jobcodeId = data.jobcodeId || ""
this.tdesc = data.tdesc || "" this.tdesc = data.tdesc || ""
...@@ -82,6 +84,7 @@ export class MyJobCodeModel implements JobCodeModel { ...@@ -82,6 +84,7 @@ export class MyJobCodeModel implements JobCodeModel {
this.equalification = data.equalification || "" this.equalification = data.equalification || ""
this.jobObjective = data.jobObjective || "" this.jobObjective = data.jobObjective || ""
this.supervisor = data.supervisor || "" this.supervisor = data.supervisor || ""
this.competencyWorkText = data.competencyWorkText || ""
} }
} }
import { HttpClient, HttpHeaders } from '@angular/common/http'; import { HttpClient, HttpHeaders } from '@angular/common/http';
...@@ -3,6 +3,7 @@ import { Injectable } from '@angular/core'; ...@@ -3,6 +3,7 @@ import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment'; import { environment } from 'src/environments/environment';
import { JobCodeModel } from '../model/job-code.model'; import { JobCodeModel } from '../model/job-code.model';
import { AlertModel } from '../model/alert.model';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
...@@ -18,9 +19,9 @@ export class JobCodeService { ...@@ -18,9 +19,9 @@ export class JobCodeService {
getById(jobcodeId: string): Observable<JobCodeModel> { getById(jobcodeId: string): Observable<JobCodeModel> {
return this.http.get<JobCodeModel>(this.urlApi + "/" + jobcodeId) return this.http.get<JobCodeModel>(this.urlApi + "/" + jobcodeId)
} }
// post(body: JobCodeModel): Observable<AlertModel> { post(body: JobCodeModel): Observable<AlertModel> {
// return this.http.post<AlertModel>(this.urlApi, body) return this.http.post<AlertModel>(this.urlApi, body)
// } }
// delete(body: JobCodeModel | JobCodeModel[]): Observable<AlertModel> { // delete(body: JobCodeModel | JobCodeModel[]): Observable<AlertModel> {
// const options = { // const options = {
// headers: new HttpHeaders({ // headers: new HttpHeaders({
......
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