Commit 6c349735 by Natthaphat

ทะเบียนระดับวุฒิการศึกษา

parent db403a28
...@@ -52,6 +52,11 @@ export const admin: Routes = [ ...@@ -52,6 +52,11 @@ export const admin: Routes = [
import('./company-department/category-company/category-company.component').then((m) => m.CategoryCompanyComponent), import('./company-department/category-company/category-company.component').then((m) => m.CategoryCompanyComponent),
}, },
{ {
path: 'degree-manage',
loadComponent: () =>
import('./company-department/degree-manage/degree-manage.component').then((m) => m.DegreeManageComponent),
},
{
path: 'job-types', path: 'job-types',
loadComponent: () => loadComponent: () =>
import('./company-department/job-type/job-type.component').then((m) => m.JobTypeComponent), import('./company-department/job-type/job-type.component').then((m) => m.JobTypeComponent),
......
...@@ -31,24 +31,6 @@ import { CategoryCompanyService } from '../../../services/category-company.servi ...@@ -31,24 +31,6 @@ import { CategoryCompanyService } from '../../../services/category-company.servi
styleUrls: ['./category-company.component.css'] styleUrls: ['./category-company.component.css']
}) })
export class CategoryCompanyComponent implements OnInit { export class CategoryCompanyComponent implements OnInit {
quillConfig = {
toolbar: [
['link'],
['bold', 'italic', 'underline', 'strike'],
['blockquote', 'code-block'],
[{ 'header': 1 }, { 'header': 2 }],
[{ 'list': 'ordered' }, { 'list': 'bullet' }],
[{ 'script': 'sub' }, { 'script': 'super' }],
[{ 'indent': '-1' }, { 'indent': '+1' }],
[{ 'direction': 'rtl' }],
[{ 'size': ['small', false, 'large', 'huge'] }],
[{ 'header': [1, 2, 3, 4, 5, 6, false] }],
[{ 'color': [] }, { 'background': [] }],
[{ 'align': [] }],
['clean'],
]
};
@ViewChild('closeModal') public childModal?: ElementRef; @ViewChild('closeModal') public childModal?: ElementRef;
@ViewChild('modalDetail') modalDetail!: TemplateRef<any>; @ViewChild('modalDetail') modalDetail!: TemplateRef<any>;
...@@ -125,7 +107,7 @@ export class CategoryCompanyComponent implements OnInit { ...@@ -125,7 +107,7 @@ export class CategoryCompanyComponent implements OnInit {
if (this.modalStatus == 'add') { if (this.modalStatus == 'add') {
console.log(this.category); console.log(this.category);
this.categoryCompanyService.post(this.category).subscribe(result => { this.categoryCompanyService.post(this.category).subscribe(result => {
swal("Save Success!!", "บันทึกเวอร์ชั่นสำเร็จ", "success"); swal("Save Success!!", "บันทึกประเภทสำเร็จ", "success");
this.ngOnInit() this.ngOnInit()
this.childModal?.nativeElement.click() this.childModal?.nativeElement.click()
}) })
...@@ -133,7 +115,7 @@ export class CategoryCompanyComponent implements OnInit { ...@@ -133,7 +115,7 @@ export class CategoryCompanyComponent implements OnInit {
const respone = new CategoryModel(this.category); const respone = new CategoryModel(this.category);
this.categoryCompanyService.post(respone).subscribe(result => { this.categoryCompanyService.post(respone).subscribe(result => {
console.log(result) console.log(result)
swal("Update Success!!", "บันทึกเวอร์ชั่นสำเร็จ", "success"); swal("Update Success!!", "บันทึกประเภทสำเร็จ", "success");
this.ngOnInit() this.ngOnInit()
this.childModal?.nativeElement.click() this.childModal?.nativeElement.click()
}) })
......
...@@ -34,23 +34,6 @@ import { CountryModel } from "../../../models/country.model"; ...@@ -34,23 +34,6 @@ import { CountryModel } from "../../../models/country.model";
styleUrl: './country-registration.component.css' styleUrl: './country-registration.component.css'
}) })
export class CountryRegistrationComponent { export class CountryRegistrationComponent {
quillConfig = {
toolbar: [
['link'],
['bold', 'italic', 'underline', 'strike'],
['blockquote', 'code-block'],
[{ 'header': 1 }, { 'header': 2 }],
[{ 'list': 'ordered' }, { 'list': 'bullet' }],
[{ 'script': 'sub' }, { 'script': 'super' }],
[{ 'indent': '-1' }, { 'indent': '+1' }],
[{ 'direction': 'rtl' }],
[{ 'size': ['small', false, 'large', 'huge'] }],
[{ 'header': [1, 2, 3, 4, 5, 6, false] }],
[{ 'color': [] }, { 'background': [] }],
[{ 'align': [] }],
['clean'],
]
};
@ViewChild('closeModal') public childModal?: ElementRef; @ViewChild('closeModal') public childModal?: ElementRef;
@ViewChild('modalDetail') modalDetail!: TemplateRef<any>; @ViewChild('modalDetail') modalDetail!: TemplateRef<any>;
...@@ -127,7 +110,7 @@ export class CountryRegistrationComponent { ...@@ -127,7 +110,7 @@ export class CountryRegistrationComponent {
if (this.modalStatus == 'add') { if (this.modalStatus == 'add') {
console.log(this.country); console.log(this.country);
this.countryService.post(this.country).subscribe(result => { this.countryService.post(this.country).subscribe(result => {
swal("Save Success!!", "บันทึกเวอร์ชั่นสำเร็จ", "success"); swal("Save Success!!", "บันทึกประเทศสำเร็จ", "success");
this.ngOnInit() this.ngOnInit()
this.childModal?.nativeElement.click() this.childModal?.nativeElement.click()
}) })
...@@ -135,7 +118,7 @@ export class CountryRegistrationComponent { ...@@ -135,7 +118,7 @@ export class CountryRegistrationComponent {
const respone = new CountryModel(this.country); const respone = new CountryModel(this.country);
this.countryService.post(respone).subscribe(result => { this.countryService.post(respone).subscribe(result => {
console.log(result) console.log(result)
swal("Update Success!!", "บันทึกเวอร์ชั่นสำเร็จ", "success"); swal("Update Success!!", "บันทึกประเทศสำเร็จ", "success");
this.ngOnInit() this.ngOnInit()
this.childModal?.nativeElement.click() this.childModal?.nativeElement.click()
}) })
......
/* tslint:disable:no-unused-variable */
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { DegreeManageComponent } from './degree-manage.component';
describe('DegreeManageComponent', () => {
let component: DegreeManageComponent;
let fixture: ComponentFixture<DegreeManageComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ DegreeManageComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(DegreeManageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { CommonModule } from "@angular/common";
import { ChangeDetectionStrategy, Component, ElementRef, TemplateRef, ViewChild } from '@angular/core';
import { NgSelectModule } from "@ng-select/ng-select";
import { TranslateModule, TranslateService } from "@ngx-translate/core";
import { FormsModule } from "@angular/forms";
import swal from 'sweetalert';
import { MatPaginator, PageEvent } from "@angular/material/paginator";
import { FileUploadModule } from 'ng2-file-upload';
import { FileItem, FileUploader, ParsedResponseHeaders } from "ng2-file-upload";
import { Router } from "@angular/router";
import { QuillModule } from "ngx-quill";
import { MatDialog } from "@angular/material/dialog";
import { SharedModule } from "../../../../shared/shared.module";
import { PdpaConfigComponent } from "../../pdpa-manage/pdpa-config/pdpa-config.component";
import { MyPdpaModel, PdpaModel } from "../../../models/pdpa.model";
import { DegreeModel } from "../../../models/degree.model";
import { DegreeService } from "../../../services/degree.service";
@Component({
selector: 'app-degree-manage',
standalone: true,
imports: [
CommonModule,
SharedModule,
TranslateModule,
NgSelectModule,
FormsModule,
MatPaginator,
FileUploadModule,
PdpaConfigComponent,
QuillModule
],
templateUrl: './degree-manage.component.html',
styleUrl: './degree-manage.component.css'
})
export class DegreeManageComponent {
@ViewChild('closeModal') public childModal?: ElementRef;
@ViewChild('modalDetail') modalDetail!: TemplateRef<any>;
currentTab = 1
allSelected = false;
someSelected = false;
itemsList: DegreeModel[] = []
filterList: DegreeModel[] = []
degree: DegreeModel = new DegreeModel()
selectedItems = new Map<string, boolean>();
pageIndex = 0;
modalStatus: "add" | "edit" = "add"
isSaving = false;
get searchTerm(): string {
return this._searchTerm;
}
set searchTerm(val: string) {
this.pageIndex = 0;
this.allSelected = false
this._searchTerm = val;
if (val != '') {
this.filterList = this.filter(val);
} else {
this.updatePagedItems()
}
}
_searchTerm = "";
constructor(private degreeService: DegreeService, public translate: TranslateService, private modal: MatDialog) {
}
ngOnInit(): void {
this.degreeService.list().subscribe(res => {
this.itemsList = res.map(item => new DegreeModel(item, this.translate));
this.filterList = [...this.itemsList];
});
}
filter(v: string) {
return this.itemsList?.filter(
(x) =>
x.degreeId?.toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
x.thName?.toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
x.engName?.toLowerCase().indexOf(v.toLowerCase()) !== -1 ||
x.higher?.toLowerCase().indexOf(v.toLowerCase()) !== -1
);
}
new() {
this.modalStatus = 'add'
this.degree = new DegreeModel();
}
view(item: DegreeModel) {
this.modalStatus = 'edit';
this.degree = new DegreeModel(item, this.translate);
}
save() {
swal({
title: "Are you sure?",
text: "คุณต้องการบันทึกหรือไม่",
icon: "warning",
dangerMode: false,
buttons: ["Cancel", "Confirm"],
})
.then((willDelete: any) => {
if (willDelete) {
if (this.modalStatus == 'add') {
console.log(this.degree);
this.degreeService.post(this.degree).subscribe(result => {
swal("Save Success!!", "บันทึกระดับการศึกษาสำเร็จ", "success");
this.ngOnInit()
this.childModal?.nativeElement.click()
})
} else if (this.modalStatus == 'edit') {
const respone = new DegreeModel(this.degree);
this.degreeService.post(respone).subscribe(result => {
console.log(result)
swal("Update Success!!", "บันทึกระดับการศึกษาสำเร็จ", "success");
this.ngOnInit()
this.childModal?.nativeElement.click()
})
}
}
});
}
deletedegree(item: DegreeModel) {
const versionText = `${this.translate.instant('degree')}: ${item.thName}`;
swal({
title: "Are you sure?",
text: `Confirm to delete :\n${versionText}\!`,
icon: "warning",
dangerMode: true,
buttons: ["Cancel", "Yes,Delete it!"],
}).then((willDelete: any) => {
if (willDelete) {
const res = new DegreeModel(item)
console.log(res);
this.degreeService.delete(res).subscribe(result => {
swal("Delete Success!!", "ลบข้อมูลสำเร็จ", "success");
this.ngOnInit();
});
}
});
}
deleteSelect() {
let degreeConfig = '';
this.selectedItems.forEach((isSelected, res) => {
if (isSelected) {
const degree = this.itemsList.find(degree => degree.degreeId === res) as DegreeModel;
if (degree) {
degreeConfig += `${this.translate.instant('degree')}: ${degree.thName}\n`;
}
}
});
swal({
title: "Are you sure?",
text: degreeConfig,
icon: "warning",
dangerMode: true,
buttons: ["Cancel", "Yes, Delete it!"],
})
.then((willDelete: any) => {
if (willDelete) {
this.selectedItems.forEach((isSelected, res) => {
if (isSelected) {
const degree = this.itemsList.find(degree => degree.degreeId === res);
if (degree) {
const newdegree = new DegreeModel(degree)
console.log(newdegree);
this.degreeService.delete(newdegree).subscribe(result => {
swal("Delete Success!!", "ลบข้อมูลที่เลือกสำเร็จ", "success");
this.ngOnInit();
});
}
}
});
}
});
}
updatePagedItems() {
const startIndex = this.pageIndex * 10;
const endIndex = startIndex + 10;
this.filterList = this.itemsList.slice(startIndex, endIndex);
}
toggleAll(event: any) {
this.allSelected = event.target.checked;
this.selectedItems.clear();
this.itemsList.forEach(item => {
this.selectedItems.set(item.degreeId, this.allSelected);
});
this.someSelected = this.itemsList.some(item => this.selectedItems.get(item.degreeId));
}
onCheckboxChange(degreeId: string) {
const isSelected = this.selectedItems.get(degreeId) || false;
this.selectedItems.set(degreeId, !isSelected);
this.allSelected = this.itemsList.every(item => this.selectedItems.get(item.degreeId));
this.someSelected = this.itemsList.some(item => this.selectedItems.get(item.degreeId));
}
filterEmp(empId: string) {
this.degree = this.itemsList.filter(e => e.degreeId == empId)[0]
}
}
\ No newline at end of file
import { HttpClient, HttpHeaders } from "@angular/common/http";
import { Injectable } from "@angular/core";
import { environment } from "../../../environments/environment";
import { Observable } from "rxjs";
import { DegreeModel } from "../models/degree.model";
@Injectable({
providedIn: 'root'
})
export class DegreeService {
constructor(private http: HttpClient) { }
list(): Observable<DegreeModel[]> {
return this.http.get<DegreeModel[]>(`${environment.baseUrl}/degree/list`);
}
post(body: any): Observable<any> {
return this.http.post(`${environment.baseUrl}/degree`, body, { observe: 'response' });
}
delete(body: any): Observable<any> {
const option = {
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
body: body
};
return this.http.delete<any>(`${environment.baseUrl}/degree`, option);
}
}
...@@ -131,6 +131,7 @@ export class NavService implements OnDestroy { ...@@ -131,6 +131,7 @@ export class NavService implements OnDestroy {
{ path: '/company-departments/company-info', title: 'ข้อมูลบริษัท', type: 'link' }, { path: '/company-departments/company-info', title: 'ข้อมูลบริษัท', type: 'link' },
{ path: '/admin/country-registration', title: 'ทะเบียนประเทศ', type: 'link' }, { path: '/admin/country-registration', title: 'ทะเบียนประเทศ', type: 'link' },
{ path: '/admin/category-company', title: 'ทะเบียนประเภทบริษัท', type: 'link' }, { path: '/admin/category-company', title: 'ทะเบียนประเภทบริษัท', type: 'link' },
{ path: '/admin/degree-manage', title: 'ทะเบียนระดับวุฒิการศึกษา', type: 'link' },
{ path: '/admin/job-types', title: 'จัดการประเภทงาน', type: 'link' }, { path: '/admin/job-types', title: 'จัดการประเภทงาน', type: 'link' },
{ path: '/admin/provinces', title: 'จัดการจังหวัด', type: 'link' }, { path: '/admin/provinces', title: 'จัดการจังหวัด', type: 'link' },
], ],
......
...@@ -97,5 +97,7 @@ ...@@ -97,5 +97,7 @@
"Country":"Country", "Country":"Country",
"Description(TH)":"Description(TH)", "Description(TH)":"Description(TH)",
"Description(ENG)":"Description(ENG)", "Description(ENG)":"Description(ENG)",
"JobtypeId":"JobtypeId" "JobtypeId":"JobtypeId",
"Degree ID":"Degree ID",
"Degree":"Degree"
} }
...@@ -97,5 +97,7 @@ ...@@ -97,5 +97,7 @@
"Country":"ประเทศ", "Country":"ประเทศ",
"Description(TH)":"รายละเอียด(ไทย)", "Description(TH)":"รายละเอียด(ไทย)",
"Description(ENG)":"รายละเอียด(อังกฤษ)", "Description(ENG)":"รายละเอียด(อังกฤษ)",
"JobtypeId":"รหัสประเภทงาน" "JobtypeId":"รหัสประเภทงาน",
"Degree ID":"รหัสระดับการศึกษา",
"Degree":"ระดับการศึกษา"
} }
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