Commit a19d8b26 by Nattana Chaiyamat

การประเมินจัดการประสิทธิภาพ > การจัดการประเมิน > กำหนดผู้ประเมิน

parent ec9cdf18
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
</div> </div>
<div *ngIf="currentPath==3" id="underline-3" class="hidden" role="tabpanel" <div *ngIf="currentPath==3" id="underline-3" class="hidden" role="tabpanel"
aria-labelledby="underline-item-3"> aria-labelledby="underline-item-3">
<app-set-approvers (sendPathTitle)="pathTitle=$event"></app-set-approvers> <app-set-approvers></app-set-approvers>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -3,6 +3,7 @@ import { ToastrService } from 'ngx-toastr'; ...@@ -3,6 +3,7 @@ import { ToastrService } from 'ngx-toastr';
import { EmployeeModel, MyEmployeeModel } from 'src/app/shared/model/employee.model'; import { EmployeeModel, MyEmployeeModel } from 'src/app/shared/model/employee.model';
import { GroupApproveModel, MyGroupApproveModel } from 'src/app/shared/model/group-approve.model'; import { GroupApproveModel, MyGroupApproveModel } from 'src/app/shared/model/group-approve.model';
import { EmployeeService } from 'src/app/shared/services/employee.service'; import { EmployeeService } from 'src/app/shared/services/employee.service';
import { FileService } from 'src/app/shared/services/file.service';
import { GroupApproveService } from 'src/app/shared/services/group-approve.service'; import { GroupApproveService } from 'src/app/shared/services/group-approve.service';
interface table { interface table {
currentPage: number, currentPage: number,
...@@ -16,7 +17,7 @@ interface table { ...@@ -16,7 +17,7 @@ interface table {
styleUrls: ['./set-approvers.component.scss'] styleUrls: ['./set-approvers.component.scss']
}) })
export class SetApproversComponent { export class SetApproversComponent {
@Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>();
currentPage = 1 currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1); page = Array.from({ length: 1 }, (_, i) => i + 1);
groupapprove_list: GroupApproveModel[] = [] groupapprove_list: GroupApproveModel[] = []
...@@ -35,16 +36,67 @@ export class SetApproversComponent { ...@@ -35,16 +36,67 @@ export class SetApproversComponent {
empnumber = 0 empnumber = 0
currentModel: 'add' | 'edit' | 'delete' = "add" currentModel: 'add' | 'edit' | 'delete' = "add"
selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์';
constructor(private groupapproveService: GroupApproveService, constructor(private groupapproveService: GroupApproveService,
private toastr: ToastrService, private toastr: ToastrService,
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef,
private employeeService: EmployeeService, private employeeService: EmployeeService,
private fileService: FileService
) { } ) { }
ngOnInit(): void { ngOnInit(): void {
this.getGroupapprove_list() this.getGroupapprove_list()
this.getEemployeeList() this.getEemployeeList()
} }
onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์"
}
uploadFile() {
if (!this.selectedFile) {
alert('กรุณาเลือกไฟล์ก่อนอัปโหลด')
return
}
const formData = new FormData();
formData.append('file', this.selectedFile);
this.groupapprove_listLoading = true
this.fileService.uploadExcel(formData, '').subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getGroupapprove_list()
} else {
this.showAlert(response.message, 'error')
this.groupapprove_listLoading = false
this.cdr.detectChanges()
}
}, error: error => {
this.showAlert(error.message, 'error')
this.groupapprove_listLoading = false
this.cdr.detectChanges()
}
})
}
downloadFile() {
const fileName = '.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')
}
})
}
getEemployeeList() { getEemployeeList() {
this.employee_listLoading = true this.employee_listLoading = true
this.employeeService.getList().subscribe({ this.employeeService.getList().subscribe({
...@@ -107,7 +159,7 @@ export class SetApproversComponent { ...@@ -107,7 +159,7 @@ export class SetApproversComponent {
this.page = Array.from({ length: Math.ceil(this.groupapprove_listFilter().length / 10) }, (_, i) => i + 1); this.page = Array.from({ length: Math.ceil(this.groupapprove_listFilter().length / 10) }, (_, i) => i + 1);
} }
groupapprove_listFilter() { groupapprove_listFilter() {
return this.groupapprove_list.filter(x => x.apsapprove1.employeeId||x.apsapprove2.employeeId||x.apsapprove3.employeeId||x.apsapprove4.employeeId||x.apsapprove5.employeeId.toLowerCase().includes(this.search.toLowerCase()) || return this.groupapprove_list.filter(x => x.apsapprove1.employeeId || x.apsapprove2.employeeId || x.apsapprove3.employeeId || x.apsapprove4.employeeId || x.apsapprove5.employeeId.toLowerCase().includes(this.search.toLowerCase()) ||
x.apsapprove1.fname || x.apsapprove1.lname.toLowerCase().includes(this.search.toLowerCase()) || x.apsapprove1.fname || x.apsapprove1.lname.toLowerCase().includes(this.search.toLowerCase()) ||
x.apsapprove2.fname || x.apsapprove2.lname.toLowerCase().includes(this.search.toLowerCase()) || x.apsapprove2.fname || x.apsapprove2.lname.toLowerCase().includes(this.search.toLowerCase()) ||
x.apsapprove3.fname || x.apsapprove3.lname.toLowerCase().includes(this.search.toLowerCase()) || x.apsapprove3.fname || x.apsapprove3.lname.toLowerCase().includes(this.search.toLowerCase()) ||
...@@ -130,14 +182,17 @@ export class SetApproversComponent { ...@@ -130,14 +182,17 @@ export class SetApproversComponent {
this.groupapproveService.post(this.groupapprove).subscribe({ this.groupapproveService.post(this.groupapprove).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success')
this.getGroupapprove_list() this.getGroupapprove_list()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.groupapprove_listLoading = false this.groupapprove_listLoading = false
this.cdr.detectChanges()
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.groupapprove_listLoading = false this.groupapprove_listLoading = false
this.cdr.detectChanges()
} }
}) })
} }
...@@ -146,36 +201,26 @@ export class SetApproversComponent { ...@@ -146,36 +201,26 @@ export class SetApproversComponent {
this.groupapproveService.delete(this.groupapprove).subscribe({ this.groupapproveService.delete(this.groupapprove).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success')
this.getGroupapprove_list() this.getGroupapprove_list()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.groupapprove_listLoading = false this.groupapprove_listLoading = false
this.cdr.detectChanges()
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.groupapprove_listLoading = false this.groupapprove_listLoading = false
this.cdr.detectChanges()
} }
}) })
} }
clear() {
showSuccess() { const data = new MyEmployeeModel({});
this.toastr.success('บันทึกข้อมูลสำเร็จ', 'เเจ้งเตือน', { this.groupapprove.apsapprove1 = data
timeOut: 3000, this.groupapprove.apsapprove2 = data
positionClass: 'toast-top-right', this.groupapprove.apsapprove3 = data
}); this.groupapprove.apsapprove4 = data
} this.groupapprove.apsapprove5 = data
showSuccessEdit() {
this.toastr.success('เเก้ไขข้อมูลสำเร็จ', 'เเจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
}
showSuccessDelete() {
this.toastr.success('ลบข้อมูลสำเร็จ', 'เเจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
} }
} }
\ No newline at end of file
...@@ -141,6 +141,7 @@ import { ManageUserComponent } from '../company-components/account-settings/mana ...@@ -141,6 +141,7 @@ import { ManageUserComponent } from '../company-components/account-settings/mana
import { PmstypeService } from 'src/app/shared/services/pmstype.service'; import { PmstypeService } from 'src/app/shared/services/pmstype.service';
import { PmstopicService } from 'src/app/shared/services/pmstopic.service'; import { PmstopicService } from 'src/app/shared/services/pmstopic.service';
import { PmsGroupAssessmentService } from 'src/app/shared/services/pms-group-assessment.service'; import { PmsGroupAssessmentService } from 'src/app/shared/services/pms-group-assessment.service';
import { PmsGroupApproveService } from 'src/app/shared/services/pms-group-approve.service';
export const MY_DATE_FORMATS = { export const MY_DATE_FORMATS = {
parse: { parse: {
...@@ -312,6 +313,7 @@ export class CustomDateAdapter extends NativeDateAdapter { ...@@ -312,6 +313,7 @@ export class CustomDateAdapter extends NativeDateAdapter {
PmstypeService, PmstypeService,
PmstopicService, PmstopicService,
PmsGroupAssessmentService, PmsGroupAssessmentService,
PmsGroupApproveService,
{ {
provide: HTTP_INTERCEPTORS, provide: HTTP_INTERCEPTORS,
useClass: HttpRequestInterceptor, useClass: HttpRequestInterceptor,
......
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { GroupApproveModel } from '../model/group-approve.model';
import { AlertModel } from '../model/alert.model';
@Injectable({
providedIn: 'root'
})
export class PmsGroupApproveService {
api = "/pms-group-approve"
urlApi = environment.baseUrl + this.api
constructor(private http: HttpClient) {
}
getByPersonalLevel(plId: string): Observable<GroupApproveModel> {
return this.http.get<GroupApproveModel>(this.urlApi + "/" + plId);
}
getList(): Observable<GroupApproveModel[]> {
return this.http.get<GroupApproveModel[]>(this.urlApi + "/lists")
}
post(body: GroupApproveModel): Observable<AlertModel> {
return this.http.post<AlertModel>(this.urlApi, body)
}
delete(body: GroupApproveModel): Observable<AlertModel> {
const options = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body
};
return this.http.delete<AlertModel>(this.urlApi, options)
}
}
\ No newline at end of file
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