Commit 050194e9 by Nakarin Luankla

Merge branch 'DEV' of https://mygit.myhr.co.th/angular/myAppraisal into DEV

parents ecaaa3cf 491a02aa
...@@ -178,7 +178,7 @@ export class UserSettingsComponent { ...@@ -178,7 +178,7 @@ export class UserSettingsComponent {
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.user.loading = true this.user.loading = true
this.fileService.upload(formData, 'muser').subscribe({ this.fileService.uploadExcel(formData, 'muser').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
...@@ -195,7 +195,7 @@ export class UserSettingsComponent { ...@@ -195,7 +195,7 @@ export class UserSettingsComponent {
} }
downloadFile() { downloadFile() {
const fileName = 'IMPORT_USER.xlsx' const fileName = 'IMPORT_USER.xlsx'
this.fileService.download(fileName).subscribe({ this.fileService.downloadTemplate(fileName).subscribe({
next: response => { next: response => {
const url = window.URL.createObjectURL(response); const url = window.URL.createObjectURL(response);
const a = document.createElement("a"); const a = document.createElement("a");
......
...@@ -65,7 +65,7 @@ export class DepartmentListComponent implements OnInit { ...@@ -65,7 +65,7 @@ export class DepartmentListComponent implements OnInit {
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.bu2ListLoading = true this.bu2ListLoading = true
this.fileService.upload(formData, 'mbu2').subscribe({ this.fileService.uploadExcel(formData, 'mbu2').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
...@@ -83,7 +83,7 @@ export class DepartmentListComponent implements OnInit { ...@@ -83,7 +83,7 @@ export class DepartmentListComponent implements OnInit {
downloadFile() { downloadFile() {
const fileName = 'IMPORT_BU.xlsx' const fileName = 'IMPORT_BU.xlsx'
this.fileService.download(fileName).subscribe({ this.fileService.downloadTemplate(fileName).subscribe({
next: response => { next: response => {
const url = window.URL.createObjectURL(response); const url = window.URL.createObjectURL(response);
const a = document.createElement("a"); const a = document.createElement("a");
......
...@@ -42,7 +42,7 @@ export class DepartmentRegisterComponent implements OnInit { ...@@ -42,7 +42,7 @@ export class DepartmentRegisterComponent implements OnInit {
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.bu1ListLoading = true this.bu1ListLoading = true
this.fileService.upload(formData, 'mbu1').subscribe({ this.fileService.uploadExcel(formData, 'mbu1').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
...@@ -60,7 +60,7 @@ export class DepartmentRegisterComponent implements OnInit { ...@@ -60,7 +60,7 @@ export class DepartmentRegisterComponent implements OnInit {
downloadFile() { downloadFile() {
const fileName = 'IMPORT_BU.xlsx' const fileName = 'IMPORT_BU.xlsx'
this.fileService.download(fileName).subscribe({ this.fileService.downloadTemplate(fileName).subscribe({
next: response => { next: response => {
const url = window.URL.createObjectURL(response); const url = window.URL.createObjectURL(response);
const a = document.createElement("a"); const a = document.createElement("a");
......
...@@ -66,7 +66,7 @@ export class SectionRegistrationComponent implements OnInit { ...@@ -66,7 +66,7 @@ export class SectionRegistrationComponent implements OnInit {
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.bu3ListLoading = true this.bu3ListLoading = true
this.fileService.upload(formData, 'mbu3').subscribe({ this.fileService.uploadExcel(formData, 'mbu3').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
...@@ -84,7 +84,7 @@ export class SectionRegistrationComponent implements OnInit { ...@@ -84,7 +84,7 @@ export class SectionRegistrationComponent implements OnInit {
downloadFile() { downloadFile() {
const fileName = 'IMPORT_BU.xlsx' const fileName = 'IMPORT_BU.xlsx'
this.fileService.download(fileName).subscribe({ this.fileService.downloadTemplate(fileName).subscribe({
next: response => { next: response => {
const url = window.URL.createObjectURL(response); const url = window.URL.createObjectURL(response);
const a = document.createElement("a"); const a = document.createElement("a");
......
...@@ -66,7 +66,7 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -66,7 +66,7 @@ export class SubDepartmentFourComponent implements OnInit {
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.bu7ListLoading = true this.bu7ListLoading = true
this.fileService.upload(formData, 'mbu7').subscribe({ this.fileService.uploadExcel(formData, 'mbu7').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
...@@ -84,7 +84,7 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -84,7 +84,7 @@ export class SubDepartmentFourComponent implements OnInit {
downloadFile() { downloadFile() {
const fileName = 'IMPORT_BU.xlsx' const fileName = 'IMPORT_BU.xlsx'
this.fileService.download(fileName).subscribe({ this.fileService.downloadTemplate(fileName).subscribe({
next: response => { next: response => {
const url = window.URL.createObjectURL(response); const url = window.URL.createObjectURL(response);
const a = document.createElement("a"); const a = document.createElement("a");
......
...@@ -66,7 +66,7 @@ export class SubDepartmentOneComponent implements OnInit { ...@@ -66,7 +66,7 @@ export class SubDepartmentOneComponent implements OnInit {
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.bu4ListLoading = true this.bu4ListLoading = true
this.fileService.upload(formData, 'mbu4').subscribe({ this.fileService.uploadExcel(formData, 'mbu4').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
...@@ -84,7 +84,7 @@ export class SubDepartmentOneComponent implements OnInit { ...@@ -84,7 +84,7 @@ export class SubDepartmentOneComponent implements OnInit {
downloadFile() { downloadFile() {
const fileName = 'IMPORT_BU.xlsx' const fileName = 'IMPORT_BU.xlsx'
this.fileService.download(fileName).subscribe({ this.fileService.downloadTemplate(fileName).subscribe({
next: response => { next: response => {
const url = window.URL.createObjectURL(response); const url = window.URL.createObjectURL(response);
const a = document.createElement("a"); const a = document.createElement("a");
......
...@@ -66,7 +66,7 @@ export class SubDepartmentThreeComponent implements OnInit { ...@@ -66,7 +66,7 @@ export class SubDepartmentThreeComponent implements OnInit {
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.bu6ListLoading = true this.bu6ListLoading = true
this.fileService.upload(formData, 'mbu6').subscribe({ this.fileService.uploadExcel(formData, 'mbu6').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
...@@ -84,7 +84,7 @@ export class SubDepartmentThreeComponent implements OnInit { ...@@ -84,7 +84,7 @@ export class SubDepartmentThreeComponent implements OnInit {
downloadFile() { downloadFile() {
const fileName = 'IMPORT_BU.xlsx' const fileName = 'IMPORT_BU.xlsx'
this.fileService.download(fileName).subscribe({ this.fileService.downloadTemplate(fileName).subscribe({
next: response => { next: response => {
const url = window.URL.createObjectURL(response); const url = window.URL.createObjectURL(response);
const a = document.createElement("a"); const a = document.createElement("a");
......
...@@ -65,7 +65,7 @@ export class SubDepartmentTwoComponent implements OnInit { ...@@ -65,7 +65,7 @@ export class SubDepartmentTwoComponent implements OnInit {
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.bu5ListLoading = true this.bu5ListLoading = true
this.fileService.upload(formData, 'mbu5').subscribe({ this.fileService.uploadExcel(formData, 'mbu5').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
...@@ -83,7 +83,7 @@ export class SubDepartmentTwoComponent implements OnInit { ...@@ -83,7 +83,7 @@ export class SubDepartmentTwoComponent implements OnInit {
downloadFile() { downloadFile() {
const fileName = 'IMPORT_BU.xlsx' const fileName = 'IMPORT_BU.xlsx'
this.fileService.download(fileName).subscribe({ this.fileService.downloadTemplate(fileName).subscribe({
next: response => { next: response => {
const url = window.URL.createObjectURL(response); const url = window.URL.createObjectURL(response);
const a = document.createElement("a"); const a = document.createElement("a");
......
...@@ -142,7 +142,7 @@ export class CompanyRegistrationPageComponent { ...@@ -142,7 +142,7 @@ export class CompanyRegistrationPageComponent {
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.dataLoading = true this.dataLoading = true
this.fileService.upload(formData, '').subscribe({ this.fileService.uploadExcel(formData, '').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
...@@ -161,7 +161,7 @@ export class CompanyRegistrationPageComponent { ...@@ -161,7 +161,7 @@ export class CompanyRegistrationPageComponent {
} }
downloadFile() { downloadFile() {
const fileName = '.xlsx' const fileName = '.xlsx'
this.fileService.download(fileName).subscribe({ this.fileService.downloadTemplate(fileName).subscribe({
next: response => { next: response => {
const url = window.URL.createObjectURL(response); const url = window.URL.createObjectURL(response);
const a = document.createElement("a"); const a = document.createElement("a");
......
...@@ -98,7 +98,7 @@ export class SubEmployeeRegistrationComponent { ...@@ -98,7 +98,7 @@ export class SubEmployeeRegistrationComponent {
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.employee.loading = true this.employee.loading = true
this.fileService.upload(formData, '').subscribe({ this.fileService.uploadExcel(formData, '').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
...@@ -117,7 +117,7 @@ export class SubEmployeeRegistrationComponent { ...@@ -117,7 +117,7 @@ export class SubEmployeeRegistrationComponent {
} }
downloadFile() { downloadFile() {
const fileName = 'IMPORT_MPOSITION.xlsx' const fileName = 'IMPORT_MPOSITION.xlsx'
this.fileService.download(fileName).subscribe({ this.fileService.downloadTemplate(fileName).subscribe({
next: response => { next: response => {
const url = window.URL.createObjectURL(response); const url = window.URL.createObjectURL(response);
const a = document.createElement("a"); const a = document.createElement("a");
......
...@@ -54,7 +54,7 @@ export class EmployeeCategories { ...@@ -54,7 +54,7 @@ export class EmployeeCategories {
const formData = new FormData(); const formData = new FormData();
this.dataLoading = true this.dataLoading = true
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.fileService.upload(formData, 'employment_type').subscribe({ this.fileService.uploadExcel(formData, 'employment_type').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
...@@ -74,7 +74,7 @@ export class EmployeeCategories { ...@@ -74,7 +74,7 @@ export class EmployeeCategories {
downloadFile() { downloadFile() {
const fileName = 'IMPORT_MEMPLOYMENTTYPE.xlsx' const fileName = 'IMPORT_MEMPLOYMENTTYPE.xlsx'
this.fileService.download(fileName).subscribe({ this.fileService.downloadTemplate(fileName).subscribe({
next: response => { next: response => {
const url = window.URL.createObjectURL(response); const url = window.URL.createObjectURL(response);
const a = document.createElement("a"); const a = document.createElement("a");
......
...@@ -55,7 +55,7 @@ export class EmployeeGroupUnit implements OnInit { ...@@ -55,7 +55,7 @@ export class EmployeeGroupUnit implements OnInit {
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.dataLoading = true this.dataLoading = true
this.fileService.upload(formData, 'mgroup').subscribe({ this.fileService.uploadExcel(formData, 'mgroup').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
...@@ -73,7 +73,7 @@ export class EmployeeGroupUnit implements OnInit { ...@@ -73,7 +73,7 @@ export class EmployeeGroupUnit implements OnInit {
downloadFile() { downloadFile() {
const fileName = 'IMPORT_MGROUP.xlsx' const fileName = 'IMPORT_MGROUP.xlsx'
this.fileService.download(fileName).subscribe({ this.fileService.downloadTemplate(fileName).subscribe({
next: response => { next: response => {
const url = window.URL.createObjectURL(response); const url = window.URL.createObjectURL(response);
const a = document.createElement("a"); const a = document.createElement("a");
......
...@@ -56,7 +56,7 @@ export class EmployeeLevel implements OnInit { ...@@ -56,7 +56,7 @@ export class EmployeeLevel implements OnInit {
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.dataLoading = true this.dataLoading = true
this.fileService.upload(formData, 'pl').subscribe({ this.fileService.uploadExcel(formData, 'pl').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
...@@ -76,7 +76,7 @@ export class EmployeeLevel implements OnInit { ...@@ -76,7 +76,7 @@ export class EmployeeLevel implements OnInit {
downloadFile() { downloadFile() {
const fileName = 'IMPORT_PL.xlsx' const fileName = 'IMPORT_PL.xlsx'
this.fileService.download(fileName).subscribe({ this.fileService.downloadTemplate(fileName).subscribe({
next: response => { next: response => {
const url = window.URL.createObjectURL(response); const url = window.URL.createObjectURL(response);
const a = document.createElement("a"); const a = document.createElement("a");
......
...@@ -55,7 +55,7 @@ export class PositionUnitComponent implements OnInit { ...@@ -55,7 +55,7 @@ export class PositionUnitComponent implements OnInit {
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.dataLoading = true this.dataLoading = true
this.fileService.upload(formData, 'mposition').subscribe({ this.fileService.uploadExcel(formData, 'mposition').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
...@@ -75,7 +75,7 @@ export class PositionUnitComponent implements OnInit { ...@@ -75,7 +75,7 @@ export class PositionUnitComponent implements OnInit {
downloadFile() { downloadFile() {
const fileName = 'IMPORT_MPOSITION.xlsx' const fileName = 'IMPORT_MPOSITION.xlsx'
this.fileService.download(fileName).subscribe({ this.fileService.downloadTemplate(fileName).subscribe({
next: response => { next: response => {
const url = window.URL.createObjectURL(response); const url = window.URL.createObjectURL(response);
const a = document.createElement("a"); const a = document.createElement("a");
......
...@@ -158,7 +158,7 @@ ...@@ -158,7 +158,7 @@
</label> </label>
</td> </td>
<td style="font-size: 12px; width: 60%;"> <td style="font-size: 12px; width: 60%;">
{{item.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.competencyTopic.tdesc}} {{item.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.tdesc}}
</td> </td>
<td style="font-size: 12px;text-align: center;"> <td style="font-size: 12px;text-align: center;">
{{item.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.expectation}} {{item.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.expectation}}
...@@ -316,7 +316,7 @@ ...@@ -316,7 +316,7 @@
<td style="font-size: 12px; width: 60%;"> <td style="font-size: 12px; width: 60%;">
{{item.data.competencyIndicatorsCourses0.tdesc}} {{item.data.competencyIndicatorsCourses0.tdesc}}
</td> </td>
<td style="font-size: 12px;text-align: center;"> <td style="font-size: 12px;text-align: center; width: 20%;">
{{item.data.competencyIndicatorsCourses0.expectation}}</td> {{item.data.competencyIndicatorsCourses0.expectation}}</td>
<td class="flex justify-center"> <td class="flex justify-center">
<div class="px-1"> <div class="px-1">
......
...@@ -78,14 +78,27 @@ export class EditGroupCompetenciesComponent { ...@@ -78,14 +78,27 @@ export class EditGroupCompetenciesComponent {
this.page = Array.from({ length: Math.ceil(filteredData.length / 10) }, (_, i) => i + 1); this.page = Array.from({ length: Math.ceil(filteredData.length / 10) }, (_, i) => i + 1);
} }
dataListFilter() { dataListFilter() {
return this.dataList.filter(x => { return this.dataList
const data = x.data .filter(x => {
const match = data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.competencyTopic.competencyTopicId.toLowerCase().includes(this.search.toLowerCase()) || const data = x.data;
data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.competencyTopic.tdesc.toLowerCase().includes(this.search.toLowerCase()) || const match =
data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.expectation.toLocaleLowerCase().includes(this.search.toLocaleLowerCase()) data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.competencyTopic.competencyTopicId.toLowerCase().includes(this.search.toLowerCase()) ||
return match; data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.tdesc.toLowerCase().includes(this.search.toLowerCase()) ||
}); data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.expectation.toLowerCase().includes(this.search.toLowerCase());
return match;
})
.sort((a, b) => {
const topicA = a.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.competencyTopic.competencyTopicId.toLowerCase();
const topicB = b.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.competencyTopic.competencyTopicId.toLowerCase();
const expectationA = a.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.expectation.toLowerCase();
const expectationB = b.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.expectation.toLowerCase();
return topicA.localeCompare(topicB) || expectationA.localeCompare(expectationB);
});
} }
getIndicatorsCoursesList() { getIndicatorsCoursesList() {
this.dataModalLoading = true this.dataModalLoading = true
...@@ -131,7 +144,6 @@ export class EditGroupCompetenciesComponent { ...@@ -131,7 +144,6 @@ export class EditGroupCompetenciesComponent {
this.groupCompetencies.groupAssessment1List = this.dataList.map(x => x.data); this.groupCompetencies.groupAssessment1List = this.dataList.map(x => x.data);
this.groupAssessmentService.post(this.groupCompetencies).subscribe({ this.groupAssessmentService.post(this.groupCompetencies).subscribe({
next: (response) => { next: (response) => {
console.log(response)
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success'); this.showAlert(response.message, 'success');
} else { } else {
......
...@@ -39,7 +39,8 @@ ...@@ -39,7 +39,8 @@
</div> </div>
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-10 m-0 shadow-md" <button type="button" class="ti-btn ti-btn-soft-secondary h-10 m-0 shadow-md"
data-hs-overlay="#competency-topic-page-modal" (click)="modalStatus='add';setData()"> data-hs-overlay="#competency-topic-page-modal"
(click)="modalStatus='add';setData();fileInputMedium.value = '';examFile=null;examFileName = 'กรุณาเลือกไฟล์'">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
Add Add
</button> </button>
...@@ -176,7 +177,8 @@ ...@@ -176,7 +177,8 @@
<div class="ti-modal-center"> <div class="ti-modal-center">
<div class="flex justify-end" style="padding-right: 1rem;"> <div class="flex justify-end" style="padding-right: 1rem;">
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md" (click)="clearData(modalStatus)"> <button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"
(click)="clearData(modalStatus)">
<svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00" <svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00"
xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA" stroke-width="3.84" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA" stroke-width="3.84"
transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)"> transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
...@@ -233,25 +235,31 @@ ...@@ -233,25 +235,31 @@
</div> </div>
</div> </div>
<label class="ti-form-label mt-2rem">แนบไฟล์ข้อสอบ</label> <label class="ti-form-label mt-2rem">แนบไฟล์ข้อสอบ</label>
<div> <div class="flex rounded-md">
<div class="flex rounded-md"> <label class="sr-only">อัปโหลดไฟล์</label>
<label for="file-input-medium" class="sr-only">อัปโหลดไฟล์</label> <input #fileInputMedium id="fileInputMedium" type="file" (change)="onExamSelected($event)" hidden>
<input type="file" id="file-input-medium" name="file-input-medium" <input type="text" [value]="examFileName" readonly onclick="fileInputMedium.click();"
class="block w-full border border-gray-200 focus:shadow-sm dark:focus:shadow-white/10 ltr:rounded-l-md rtl:rounded-r-none text-sm focus:z-10 focus:outline-0 focus:border-gray-200 dark:focus:border-white/10 dark:border-white/10 dark:text-white/70 file:border-0 file:bg-gray-100 ltr:file:mr-4 rtl:file:ml-4 file:py-3 file:px-4 dark:file:bg-black/20 dark:file:text-white/70"> class=" cursor-pointer block w-full border border-gray-200 focus:shadow-sm dark:focus:shadow-white/10 ltr:rounded-l-md rtl:rounded-r-none text-sm focus:z-10 focus:outline-0 focus:border-gray-200 dark:focus:border-white/10 dark:border-white/10 dark:text-white/70 file:border-0 file:bg-gray-100 ltr:file:mr-4 rtl:file:ml-4 file:py-3 file:px-4 dark:file:bg-black/20 dark:file:text-white/70">
<span <span
class="px-4 inline-flex items-center min-w-fit ltr:rounded-r-md rtl:rounded-l-none border ltr:border-l-0 rtl:border-r-0 border-gray-200 bg-gray-50 text-sm dark:bg-black/20 dark:border-white/10"> class="px-4 inline-flex items-center min-w-fit ltr:rounded-r-md rtl:rounded-l-none border ltr:border-l-0 rtl:border-r-0 border-gray-200 bg-gray-50 text-sm dark:bg-black/20 dark:border-white/10">
<button class="text-sm text-gray-500 dark:text-white/70" <button class="text-sm text-gray-500 dark:text-white/70"
onclick="document.getElementById('file-input-medium').click();">Browse</button> onclick="fileInputMedium.click();">Browse</button>
</span> </span>
<div class="flex items-center ml-2"> <div class="flex items-center ml-2">
<button href="javascript:void(0);" <button href="javascript:void(0);"
class="ti-btn ti-btn-soft-danger h-10px m-0 shadow-md rounded-md"> class="ti-btn ti-btn-soft-danger h-10px m-0 shadow-md rounded-md"
<i class="ri-delete-bin-6-line"></i> (click)="fileInputMedium.value = '';examFile=null;examFileName = 'กรุณาเลือกไฟล์'">
Delete <i class="ri-delete-bin-6-line"></i>
</button> Delete
</div> </button>
</div> </div>
</div> </div>
<div class="flex" *ngIf="examFileName==dataSelect.file">
<h1 class="cursor-pointer justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px
text-center text-secondary border-secondary border-b-2 align-items-end"
(click)="dowloadExam(examFileName)">
ดาวน์โหลดไฟล์ข้อสอบ</h1>
</div>
<div class="flex justify-end mt-3rem mb-1rem space-x-4"> <div class="flex justify-end mt-3rem mb-1rem space-x-4">
<button type="button" <button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10" class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
...@@ -560,7 +568,7 @@ ...@@ -560,7 +568,7 @@
<div class="flex justify-end"> <div class="flex justify-end">
<ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'"> <ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" <button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#competency-topic-page-alert-modal"> data-hs-overlay="#competency-topic-page-modal">
<span class="sr-only">Close</span> <span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i> <i class="ti ti-circle-x fs-xxl"></i>
</button> </button>
...@@ -632,6 +640,11 @@ ...@@ -632,6 +640,11 @@
<i class="ti ti-upload"></i> <i class="ti ti-upload"></i>
</button> </button>
</div> </div>
<div class="flex justify-center mt-2rem ">
<h1 class="cursor-pointer justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px
text-center text-secondary border-secondary border-b-2 align-items-end" (click)="downloadFile()">
ดาวน์โหลดตัวอย่างไฟล์</h1>
</div>
<div class="flex justify-center mt-2rem mb-1rem space-x-4"> <div class="flex justify-center mt-2rem mb-1rem space-x-4">
<button type="submit" class="ti-btn ti-btn-secondary" <button type="submit" class="ti-btn ti-btn-secondary"
data-hs-overlay="#competency-topic-upload-modal" [class.ti-btn-disabled]="!selectedFile" data-hs-overlay="#competency-topic-upload-modal" [class.ti-btn-disabled]="!selectedFile"
......
...@@ -12,6 +12,7 @@ export interface DataModel { ...@@ -12,6 +12,7 @@ export interface DataModel {
code: string code: string
definition: string definition: string
type: DataModel2 type: DataModel2
file: string
checked: boolean checked: boolean
} }
export interface DataModel2 { export interface DataModel2 {
...@@ -50,13 +51,15 @@ export class CompetencyTopic { ...@@ -50,13 +51,15 @@ export class CompetencyTopic {
currentModal = ""; currentModal = "";
dataLoading = false dataLoading = false
dataSelectList: DataModel[] = []; dataSelectList: DataModel[] = [];
dataSelect: DataModel = { id: "", name: "", edesc: "", code: "", definition: "", type: { id: "", name: "", edesc: "", code: "", level: "" }, checked: false } dataSelect: DataModel = { id: "", name: "", edesc: "", code: "", definition: "", file: "", type: { id: "", name: "", edesc: "", code: "", level: "" }, checked: false }
competencytypeListLoading = false competencytypeListLoading = false
competencytypeList: DataModel2[] = [] competencytypeList: DataModel2[] = []
competoncyTopicList: { check: boolean; data: DataModel & { checked?: boolean } }[] = [] competoncyTopicList: { check: boolean; data: DataModel & { checked?: boolean } }[] = []
modalStatus = 'add' modalStatus = 'add'
selectedFile: File | null = null; selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์'; selectedFileName: string = 'กรุณาเลือกไฟล์';
examFile: File | null = null;
examFileName: string = 'กรุณาเลือกไฟล์';
selectedItems: string[] = []; selectedItems: string[] = [];
...@@ -74,6 +77,52 @@ export class CompetencyTopic { ...@@ -74,6 +77,52 @@ export class CompetencyTopic {
this.getCompetencytypeList() this.getCompetencytypeList()
} }
onExamSelected(event: any) {
this.examFile = event.target.files.length > 0 ? event.target.files[0] : null;
this.examFileName = this.examFile?.name || "กรุณาเลือกไฟล์"
}
uploadExam() {
if (!this.examFile) {
return
}
const formData = new FormData();
formData.append('file', this.examFile);
this.fileService.uploadFiles(formData).subscribe({
next: response => {
if (response.success) {
this.examFile = null
this.addCompetency_topic(response.resultObject)
} else {
this.showAlert(response.message, 'error')
this.cdr.detectChanges()
}
}, error: error => {
this.showAlert(error.message, 'error')
this.cdr.detectChanges()
}
})
}
dowloadExam(fileName: string) {
this.fileService.dowloadFiles(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);
this.cdr.detectChanges()
}, error: error => {
this.showAlert(error.message, 'error')
this.cdr.detectChanges()
}
})
}
onFileSelected(event: any) { onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null; this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์" this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์"
...@@ -87,7 +136,7 @@ export class CompetencyTopic { ...@@ -87,7 +136,7 @@ export class CompetencyTopic {
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.dataLoading = true this.dataLoading = true
this.fileService.upload(formData, 'competency_topic').subscribe({ this.fileService.uploadExcel(formData, 'competency_topic').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
...@@ -108,7 +157,7 @@ export class CompetencyTopic { ...@@ -108,7 +157,7 @@ export class CompetencyTopic {
downloadFile() { downloadFile() {
const fileName = 'IMPORT_COMPETENCY_TOPIC.xlsx' const fileName = 'IMPORT_COMPETENCY_TOPIC.xlsx'
this.fileService.download(fileName).subscribe({ this.fileService.downloadTemplate(fileName).subscribe({
next: response => { next: response => {
const url = window.URL.createObjectURL(response); const url = window.URL.createObjectURL(response);
const a = document.createElement("a"); const a = document.createElement("a");
...@@ -159,7 +208,7 @@ export class CompetencyTopic { ...@@ -159,7 +208,7 @@ export class CompetencyTopic {
next: response => { next: response => {
this.competoncyTopicList = response.map(x => ({ this.competoncyTopicList = response.map(x => ({
check: false, data: { check: false, data: {
id: x.competencyTopicId, name: x.tdesc, edesc: x.edesc, code: x.competencyType.shortName, definition: x.competencyDetail, id: x.competencyTopicId, name: x.tdesc, edesc: x.edesc, code: x.competencyType.shortName, definition: x.competencyDetail, file: x.competencyFiles,
type: { id: x.competencyType.competencyTypeId, name: x.competencyType.tdesc, edesc: x.competencyType.edesc, code: x.competencyType.shortName, level: x.expectationLevel }, type: { id: x.competencyType.competencyTypeId, name: x.competencyType.tdesc, edesc: x.competencyType.edesc, code: x.competencyType.shortName, level: x.expectationLevel },
checked: false checked: false
} }
...@@ -171,7 +220,6 @@ export class CompetencyTopic { ...@@ -171,7 +220,6 @@ export class CompetencyTopic {
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.dataLoading = false this.dataLoading = false
console.error('Error fetching employee types:', error);
this.cdr.detectChanges() this.cdr.detectChanges()
} }
}) })
...@@ -189,33 +237,38 @@ export class CompetencyTopic { ...@@ -189,33 +237,38 @@ export class CompetencyTopic {
}); });
} }
setData(data?: DataModel) { setData(data?: DataModel) {
this.dataSelect = JSON.parse(JSON.stringify(data || { id: "", name: "", edesc: "", code: "", definition: "", type: { id: "", name: "", edesc: "", code: "", level: "" }, checked: false })); this.examFileName = data?.file || 'กรุณาเลือกไฟล์'
this.dataSelect = JSON.parse(JSON.stringify(data || { id: "", name: "", edesc: "", code: "", definition: "", file: "", type: { id: "", name: "", edesc: "", code: "", level: "" }, checked: false }));
} }
// ฟังก์ชันสำหรับการเพิ่ม ลบ หรือแก้ไข ข้อมูล addCompetency_topic(competencyFiles?: string) {
addCompetency_topic() { if (this.examFile) {
const body = new MyCompetencytopicModel({ this.uploadExam()
competencyTopicId: this.dataSelect.id, tdesc: this.dataSelect.name, edesc: this.dataSelect.edesc, competencyDetail: this.dataSelect.definition, } else {
competencyType: new MyCompetencytypeModel({ competencyTypeId: this.dataSelect.type.id, tdesc: this.dataSelect.type.name, edesc: this.dataSelect.type.edesc, shortName: this.dataSelect.type.code, expectationLevel: this.dataSelect.type.level }), const body = new MyCompetencytopicModel({
}) competencyTopicId: this.dataSelect.id, tdesc: this.dataSelect.name, edesc: this.dataSelect.edesc, competencyDetail: this.dataSelect.definition,
this.dataLoading = true competencyType: new MyCompetencytypeModel({ competencyTypeId: this.dataSelect.type.id, tdesc: this.dataSelect.type.name, edesc: this.dataSelect.type.edesc, shortName: this.dataSelect.type.code, expectationLevel: this.dataSelect.type.level }),
this.competencytopicService.post(body).subscribe({ competencyFiles: competencyFiles || ""
next: response => { })
if (response.success) { this.dataLoading = true
this.showAlert(response.message, 'success') this.competencytopicService.post(body).subscribe({
this.getCompetencytypeList() next: response => {
this.getCompetencytopicList() if (response.success) {
} else { this.showAlert(response.message, 'success')
this.showAlert(response.message, 'error') this.getCompetencytypeList()
this.getCompetencytopicList()
} else {
this.showAlert(response.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
}
}, error: error => {
this.showAlert(error.message, 'error')
this.dataLoading = false this.dataLoading = false
this.cdr.detectChanges() this.cdr.detectChanges()
} }
}, error: error => { })
this.showAlert(error.message, 'error') }
this.dataLoading = false
this.cdr.detectChanges()
}
})
} }
deleteCompetency_topic() { deleteCompetency_topic() {
let body: any let body: any
...@@ -261,7 +314,7 @@ export class CompetencyTopic { ...@@ -261,7 +314,7 @@ export class CompetencyTopic {
if (modalStatus == 'add') { if (modalStatus == 'add') {
this.setData() this.setData()
} else if (modalStatus == 'edit') { } else if (modalStatus == 'edit') {
this.setData({ id: this.dataSelect.id, name: "", edesc: "", code: "", definition: "", type: { id: "", name: "", edesc: "", code: "", level: "" }, checked: this.dataSelect.checked }) this.setData({ id: this.dataSelect.id, name: "", edesc: "", code: "", definition: "", file: "", type: { id: "", name: "", edesc: "", code: "", level: "" }, checked: this.dataSelect.checked })
} }
} }
......
...@@ -215,7 +215,7 @@ ...@@ -215,7 +215,7 @@
<input type="text" id="detail_eng" class="ti-form-input w-2/3" [(ngModel)]="dataSelect.code"> <input type="text" id="detail_eng" class="ti-form-input w-2/3" [(ngModel)]="dataSelect.code">
<label for="detail_eng" class="ti-form-label mt-1rem">ระดับความคาดหวัง *</label> <label for="detail_eng" class="ti-form-label mt-1rem">ระดับความคาดหวัง *</label>
<input type="text" id="detail_eng" class="ti-form-input" style="width: 200px;" <input type="text" id="detail_eng" class="ti-form-input" style="width: 200px;"
[(ngModel)]="dataSelect.level"> oninput="this.value = this.value.replace(/\D/g, '')" [(ngModel)]="dataSelect.level">
<div class="flex justify-end mt-2rem mb-1rem"> <div class="flex justify-end mt-2rem mb-1rem">
<button type="button" <button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10" class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
...@@ -318,10 +318,16 @@ ...@@ -318,10 +318,16 @@
<i class="ti ti-upload"></i> <i class="ti ti-upload"></i>
</button> </button>
</div> </div>
<div class="flex justify-center mt-2rem ">
<h1 class="cursor-pointer justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px
text-center text-secondary border-secondary border-b-2 align-items-end" (click)="downloadFile()">
ดาวน์โหลดตัวอย่างไฟล์</h1>
</div>
<div class="flex justify-center mt-2rem mb-1rem space-x-4"> <div class="flex justify-center mt-2rem mb-1rem space-x-4">
<button type="submit" class="ti-btn ti-btn-secondary" <button type="submit" class="ti-btn ti-btn-secondary"
data-hs-overlay="#type-registration-component-upload-modal" [class.ti-btn-disabled]="!selectedFile" data-hs-overlay="#type-registration-component-upload-modal"
(click)="uploadFile()" [disabled]="!selectedFile" [disabled]="!selectedFile"> [class.ti-btn-disabled]="!selectedFile" (click)="uploadFile()" [disabled]="!selectedFile"
[disabled]="!selectedFile">
อัปโหลด อัปโหลด
</button> </button>
</div> </div>
......
...@@ -60,7 +60,7 @@ export class TypeRegistration { ...@@ -60,7 +60,7 @@ export class TypeRegistration {
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.dataLoading = true this.dataLoading = true
this.fileService.upload(formData, 'competency_type').subscribe({ this.fileService.uploadExcel(formData, 'competency_type').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
...@@ -80,7 +80,7 @@ export class TypeRegistration { ...@@ -80,7 +80,7 @@ export class TypeRegistration {
downloadFile() { downloadFile() {
const fileName = 'IMPORT_COMPETENCY_TYPE.xlsx' const fileName = 'IMPORT_COMPETENCY_TYPE.xlsx'
this.fileService.download(fileName).subscribe({ this.fileService.downloadTemplate(fileName).subscribe({
next: response => { next: response => {
const url = window.URL.createObjectURL(response); const url = window.URL.createObjectURL(response);
const a = document.createElement("a"); const a = document.createElement("a");
......
<div class="w-full min-height-50px mb-10px justify-between items-center"> <div class="w-full min-height-50px mb-10px justify-between items-center">
<div class="flex justify-between"> <div class="flex justify-between">
<div class="flex pr-2"> <div class="flex">
<!-- Content ของ div แรก --> <div class="flex items-center">
<div class="flex gap-x-6"> <input type="checkbox" class="ti-form-checkbox pointer-events-none" id="hs-default-checkbox"
<div class="flex items-center"> [(ngModel)]="isDataListChecked">
<label for="hs-checkbox-group-1" <label for="hs-default-checkbox" class="text-sm text-gray-500 mx-2 pointer-events-none">
class="text-sm text-gray-500 ltr:ml-2 rtl:mr-2 dark:text-white/70">{{mockDataSelect.length}} {{numDataListChecked}} Selected</label>
Selected</label> </div>
</div> <div class="mx-1 flex items-center">
<button (click)="isDataListCheckedAll = !isDataListCheckedAll;dataListCheckAll()"
<div class="flex items-center"> class="focus:ring-2 focus:ring-primary rounded-sm flex item-center">
<i (click)="toggleCheckbox()" <i class="fs-l transition-all duration-200"
[ngClass]="{'ri-checkbox-multiple-line': !isChecked, 'ri-checkbox-multiple-fill': isChecked}" [ngClass]="{'ri-checkbox-multiple-line text-gray-500': !isDataListCheckedAll, 'ri-checkbox-multiple-fill text-primary': isDataListCheckedAll}"></i>
class="ri-checkbox-multiple-line text-gray-500 dark:text-white/70"></i> </button>
<label for="hs-checkbox-group-2" class="text-sm text-gray-500 ltr:ml-2 rtl:mr-2 dark:text-white/70" <label class="text-sm text-gray-500 ml-2">Select All</label>
(click)="toggleCheckbox()">Select All</label>
</div>
</div> </div>
</div> </div>
...@@ -35,28 +32,26 @@ ...@@ -35,28 +32,26 @@
<div class="px-1"> <div class="px-1">
<button type="button" <button type="button"
class="ti-btn ti-btn bg-pink-500/10 text-pink-500 hover:text-white hover:bg-pink-500 ring-offset-white focus:ring-pink-500 dark:focus:ring-offset-white/10 h-10 m-0 shadow-md" class="ti-btn ti-btn bg-pink-500/10 text-pink-500 hover:text-white hover:bg-pink-500 ring-offset-white focus:ring-pink-500 dark:focus:ring-offset-white/10 h-10 m-0 shadow-md"
data-hs-overlay="#assessment-tool-component-modal-add"> data-hs-overlay="#assessment-tool-upload-modal"
(click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ti ti-file-plus"></i> <i class="ti ti-file-plus"></i>
import import
</button> </button>
</div> </div>
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-10 m-0 shadow-md" <button type="button" class="ti-btn ti-btn-soft-secondary h-10 m-0 shadow-md"
data-hs-overlay="#assessment-tool-component-modal-add" (click)="selectAssessment()"> data-hs-overlay="#assessment-tool-modal" (click)="currentModal='add';selectAssessment()">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
Add Add
</button> </button>
</div> </div>
<div class="px-1"> <div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-10 m-0 shadow-md"> <button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-10 m-0 shadow-md"
data-hs-overlay="#assessment-tool-alert-modal"
(click)="currentModal='deleteGroup';selectAssessment()">
<i class="ri-delete-bin-6-line"></i> <i class="ri-delete-bin-6-line"></i>
Delete Delete
</button> </button>
<!-- <button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-10 m-0 shadow-md"
data-hs-overlay="#assessment-tool-component-alert-delete-modal">
<i class="ri-delete-bin-6-line"></i>
Delete
</button> -->
</div> </div>
<div class="px-1"> <div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-10 m-0 shadow-md"> <button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-10 m-0 shadow-md">
...@@ -84,7 +79,7 @@ ...@@ -84,7 +79,7 @@
</ng-container> </ng-container>
</tr> </tr>
</thead> </thead>
<tbody *ngIf="dataLoading"> <tbody *ngIf="assessment.loading">
<tr> <tr>
<td class="text-center" colspan="100%"> <td class="text-center" colspan="100%">
<div *ngFor="let item of [1,2,3]" class="ti-spinner w-8 h-8 text-secondary mx-1" role="status" <div *ngFor="let item of [1,2,3]" class="ti-spinner w-8 h-8 text-secondary mx-1" role="status"
...@@ -94,30 +89,30 @@ ...@@ -94,30 +89,30 @@
</td> </td>
</tr> </tr>
</tbody> </tbody>
<tbody *ngIf="!dataLoading&&!dataListFilter().length"> <tbody *ngIf="!assessment.loading&&!assessmentListFilter().length">
<tr> <tr>
<td class="text-center" colspan="100%"> <td class="text-center" colspan="100%">
ไม่พบข้อมูล ไม่พบข้อมูล
</td> </td>
</tr> </tr>
</tbody> </tbody>
<tbody *ngIf="!dataLoading&&dataListFilter().length"> <tbody *ngIf="!assessment.loading&&assessmentListFilter().length">
<tr <tr
*ngFor="let item of dataListFilter()| slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index"> *ngFor="let item of assessmentListFilter()| slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
<td class="text-center"> <td class="text-center">
<input type="checkbox" class="ti-form-checkbox cursor-pointer" id="checkbox-{{item.id}}" <input type="checkbox" class="ti-form-checkbox cursor-pointer"
[(ngModel)]="item.checked" (change)="checkSelect()"> id="checkbox-{{item.data.assessmentId}}" [(ngModel)]="item.check"
<label for="checkbox-{{item.id}}">&nbsp;{{item.id}}</label> (ngModelChange)="dataListCheck()">
<label for="checkbox-{{item.data.assessmentId}}">&nbsp;{{item.data.assessmentId}}</label>
</td> </td>
<td>{{item.name}}</td> <td>{{item.data.tdesc}}</td>
<td class="text-center">{{item.code}}</td> <td class="text-center">{{item.data.shortName}}</td>
<td class="flex justify-center"> <td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" <i class="ti ti-edit cursor-pointer i-gray fs-l px-1" data-hs-overlay="#assessment-tool-modal"
data-hs-overlay="#assessment-tool-component-modal-edit" (click)="currentModal='edit';selectAssessment(item.data)"></i>
(click)="selectAssessment(item)"></i>
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" <i class="ti ti-trash cursor-pointer i-gray fs-l px-1"
data-hs-overlay="#assessment-tool-component-alert-delete-modal" data-hs-overlay="#assessment-tool-alert-modal"
(click)="selectAssessment(item)"></i> (click)="currentModal='delete';selectAssessment(item.data)"></i>
</td> </td>
</tr> </tr>
</tbody> </tbody>
...@@ -155,92 +150,65 @@ ...@@ -155,92 +150,65 @@
</li> </li>
</ul> </ul>
<ul class="nav-tabs mt-3"> <ul class="nav-tabs mt-3">
<span>Show {{((currentPage-1) * 10)+1}} to {{dataListFilter().length<10 ?dataListFilter().length: <span>Show {{((currentPage-1) * 10)+1}} to {{assessmentListFilter().length<10
(currentPage==page.length ? ((currentPage * 10) - ((currentPage * 10) - dataListFilter().length) ) ?assessmentListFilter().length: (currentPage==page.length ? ((currentPage * 10) - ((currentPage *
:(currentPage * 10) ) }} of {{dataListFilter().length}} items</span> 10) - assessmentListFilter().length) ) :(currentPage * 10) ) }} of {{assessmentListFilter().length}}
items</span>
</ul> </ul>
</nav> </nav>
</div> </div>
<div id="assessment-tool-component-modal-add" class="hs-overlay hidden ti-modal"> <div id="assessment-tool-upload-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)]"> <div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out rounded-md">
<div class="max-h-full overflow-hidden ti-modal-content"> <div class="ti-modal-header bg-primary !rounded-none !rounded-t-sm">
<div class="ti-modal-header"> <h5 class="text-xxl font-bold text-white">
<h3 class="text-xxl font-bold text-primary"> นำเข้าเครื่องมือประเมิน
เพิ่มเครื่องมือประเมิน </h5>
</h3> </div>
<div class="flex justify-end"> <div class="ti-modal-body max-h-full overflow-hidden ti-modal-content !rounded-t-none !rounded-b-sm">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" <h1 class="mt-2" style="text-align: center;">ไฟล์</h1>
data-hs-overlay="#assessment-tool-component-modal-add"> <div class="mt-2 p-2">
<span class="sr-only">Close</span> <div class="flex rounded-md">
<i class="ti ti-circle-x fs-xxl"></i> <input #fileInput id="fileInput" type="file" (change)="onFileSelected($event)" hidden>
<input type="text" [value]="selectedFileName" readonly (click)="fileInput.click()"
class="ti-form-input rounded-none ltr:rounded-l-md rtl:rounded-r-md focus:z-10 cursor-pointer">
<button type="button" (click)="fileInput.click()"
class="inline-flex flex-shrink-0 justify-center items-center h-[2.875rem] w-[2.875rem] ltr:rounded-r-md rtl:rounded-l-md border border-transparent font-semibold bg-secondary text-white hover:bg-secondary focus:z-10 focus:outline-none focus:ring-0 focus:ring-secondary transition-all text-sm">
<i class="ti ti-upload"></i>
</button> </button>
</div> </div>
</div> <div class="flex justify-center mt-2rem ">
<div class="ti-modal-center"> <h1 class="cursor-pointer justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px
<div class="flex justify-end" style="padding-right: 1rem;"> text-center text-secondary border-secondary border-b-2 align-items-end" (click)="downloadFile()">
<div class="px-1"> ดาวน์โหลดตัวอย่างไฟล์</h1>
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md">
<svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00"
xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA" stroke-width="3.84"
transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
<g id="SVGRepo_iconCarrier">
<path d="M15 49A24 24 0 0 1 32 8"></path>
<path d="M49 15a24 24 0 0 1-17 41"></path>
<polyline points="15.03 40 15.03 48.97 8 48.97"></polyline>
<polyline points="48.97 24 48.97 15.03 56 15.03"></polyline>
</g>
</svg>
Clear
</button>
</div>
<div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-45px m-0 shadow-md">
<i class="ti ti-book fs-l"></i>
Help
</button>
</div>
</div> </div>
</div> <div class="flex justify-center mt-2rem mb-1rem space-x-4">
<div class="ti-modal-body" style="padding-top: 0px;"> <button type="submit" class="ti-btn ti-btn-secondary"
<label for="input-label" class="ti-form-label mt-1rem">รหัส *</label> data-hs-overlay="#assessment-tool-upload-modal" [class.ti-btn-disabled]="!selectedFile"
<input type="text" id="input-label" class="ti-form-input w-1/2" [(ngModel)]="dataSelect.id"> (click)="uploadFile()" [disabled]="!selectedFile" [disabled]="!selectedFile">
<label for="detail_th" class="ti-form-label mt-1rem">ชื่อเครื่องมือประเมิน (ไทย)*</label> อัปโหลด
<input type="text" id="detail_th" class="ti-form-input w-full" [(ngModel)]="dataSelect.name">
<label for="detail_eng" class="ti-form-label mt-1rem">ชื่อเครื่องมือประเมิน (อังกฤษ)</label>
<input type="text" id="detail_eng" class="ti-form-input w-full" [(ngModel)]="dataSelect.edesc">
<label for="detail_eng" class="ti-form-label mt-1rem">ชื่อที่ใช้เเสดง *</label>
<input type="text" id="showname" class="ti-form-input w-full" [(ngModel)]="dataSelect.code">
<div class="flex justify-end mt-2rem mb-1rem">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#assessment-tool-component-modal-add">
ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#assessment-tool-component-alert-modal">
บันทึกข้อมูล
</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div id="assessment-tool-component-modal-edit" class="hs-overlay hidden ti-modal"> <div id="assessment-tool-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)]"> <div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)]">
<div class="max-h-full overflow-hidden ti-modal-content"> <div class="max-h-full overflow-hidden ti-modal-content">
<div class="ti-modal-header"> <div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary"> <h3 class="text-xxl font-bold text-primary" *ngIf="currentModal=='add'">
เเก้ไขเครื่องมือประเมิน เพิ่มเครื่องมือประเมิน
</h3>
<h3 class="text-xxl font-bold text-primary" *ngIf="currentModal=='edit'">
แก้ไขเครื่องมือประเมิน
</h3> </h3>
<div class="flex justify-end"> <div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" <button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#assessment-tool-component-modal-edit"> data-hs-overlay="#assessment-tool-modal">
<span class="sr-only">Close</span> <span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i> <i class="ti ti-circle-x fs-xxl"></i>
</button> </button>
...@@ -249,7 +217,8 @@ ...@@ -249,7 +217,8 @@
<div class="ti-modal-center"> <div class="ti-modal-center">
<div class="flex justify-end" style="padding-right: 1rem;"> <div class="flex justify-end" style="padding-right: 1rem;">
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"> <button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"
(click)="clearAssessment(currentModal)">
<svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00" <svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00"
xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA" stroke-width="3.84" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA" stroke-width="3.84"
transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)"> transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
...@@ -274,133 +243,85 @@ ...@@ -274,133 +243,85 @@
</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">รหัส *</label> <label for="input-label" class="ti-form-label mt-1rem">รหัส*</label>
<input type="text" id="input-label" class="ti-form-input w-1/2 bg-input-readonly" readonly <input type="text" id="input-label" class="ti-form-input w-1/2"
[(ngModel)]="dataSelect.id"> [ngClass]="{'bg-input-readonly':currentModal=='edit'}" [readonly]="currentModal=='edit'"
[(ngModel)]="assessment.select.assessmentId">
<label for="detail_th" class="ti-form-label mt-1rem">ชื่อเครื่องมือประเมิน (ไทย)*</label> <label for="detail_th" class="ti-form-label mt-1rem">ชื่อเครื่องมือประเมิน (ไทย)*</label>
<input type="text" id="detail_th" class="ti-form-input w-full" [(ngModel)]="dataSelect.name"> <input type="text" id="detail_th" class="ti-form-input w-full" [(ngModel)]="assessment.select.tdesc">
<label for="detail_eng" class="ti-form-label mt-1rem">ชื่อเครื่องมือประเมิน (อังกฤษ)</label> <label for="detail_eng" class="ti-form-label mt-1rem">ชื่อเครื่องมือประเมิน (อังกฤษ)</label>
<input type="text" id="detail_eng" class="ti-form-input w-full" [(ngModel)]="dataSelect.edesc"> <input type="text" id="detail_eng" class="ti-form-input w-full" [(ngModel)]="assessment.select.edesc">
<label for="detail_eng" class="ti-form-label mt-1rem">ชื่อที่ใช้เเสดง *</label> <label for="detail_eng" class="ti-form-label mt-1rem">ชื่อที่ใช้เเสดง*</label>
<input type="text" id="showname" class="ti-form-input w-full" [(ngModel)]="dataSelect.code"> <input type="text" id="showname" class="ti-form-input w-full" [(ngModel)]="assessment.select.shortName">
<div class="flex justify-end mt-2rem mb-1rem"> <div class="flex justify-end mt-2rem mb-1rem">
<button type="button" <button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10" class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#assessment-tool-component-modal-edit"> data-hs-overlay="#assessment-tool-modal">
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);" <button type="button" class="ti-btn ti-btn-success" data-hs-overlay="#assessment-tool-alert-modal"
data-hs-overlay="#assessment-tool-component-alert-edit-modal"> [class.ti-btn-disabled]="!assessment.select.assessmentId||!assessment.select.tdesc||!assessment.select.shortName"
[disabled]="!assessment.select.assessmentId||!assessment.select.tdesc||!assessment.select.shortName">
บันทึกข้อมูล บันทึกข้อมูล
</a> </button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div id="assessment-tool-component-alert-modal" class="hs-overlay hidden ti-modal"> <div id="assessment-tool-alert-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center"> <div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content w-full"> <div class="max-h-full overflow-hidden ti-modal-content w-full">
<div class="ti-modal-header"> <div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary"> <h3 class="text-xxl font-bold text-primary">
แจ้งเตือน แจ้งเตือน
</h3> </h3>
<div class="flex justify-end"> <div class="flex justify-end" *ngIf="currentModal=='add'||currentModal=='edit'">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" <button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#assessment-tool-component-alert-modal"> data-hs-overlay="#assessment-tool-modal">
<span class="sr-only">Close</span> <span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i> <i class="ti ti-circle-x fs-xxl"></i>
</button> </button>
</div> </div>
</div> <div class="flex justify-end" *ngIf="currentModal=='delete'||currentModal=='deleteGroup'">
<div class="ti-modal-body ">
<p class="mt-1 text-gray-800 dark:text-white/70">
ยืนยันการบันทึกข้อมูลหรือไม่
</p>
<div class="flex justify-end mt-2rem mb-1rem">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#assessment-tool-component-modal-add">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#assessment-tool-component-alert-modal" (click)="addUser()">
บันทึกข้อมูล
</a>
</div>
</div>
</div>
</div>
</div>
<div id="assessment-tool-component-alert-edit-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content w-full">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
แจ้งเตือน
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" <button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#assessment-tool-component-alert-edit-modal"> data-hs-overlay="#assessment-tool-alert-modal">
<span class="sr-only">Close</span> <span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i> <i class="ti ti-circle-x fs-xxl"></i>
</button> </button>
</div> </div>
</div> </div>
<div class="ti-modal-body "> <div class="ti-modal-body ">
<p class="mt-1 text-gray-800 dark:text-white/70"> <p class="mt-1 text-gray-800 dark:text-white/70" *ngIf="currentModal=='add'||currentModal=='edit'">
ยืนยันการเเก้ไขข้อมูลหรือไม่ ยืนยันการบันทึกข้อมูลหรือไม่
</p> </p>
<p class="mt-1 text-gray-800 dark:text-white/70"
<div class="flex justify-end mt-2rem mb-1rem"> *ngIf="currentModal=='delete'||currentModal=='deleteGroup'">
ยืนยันการลบข้อมูลหรือไม่
</p>
<div class="flex justify-end mt-2rem mb-1rem" *ngIf="currentModal=='add'||currentModal=='edit'">
<button type="button" <button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10" class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#assessment-tool-component-modal-edit"> data-hs-overlay="#assessment-tool-modal">
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);" <button type="button" class="ti-btn ti-btn-success" data-hs-overlay="#assessment-tool-alert-modal"
data-hs-overlay="#assessment-tool-component-alert-edit-modal" (click)="addUser()"> (click)="updateAssessment('post')">
บันทึกข้อมูล บันทึกข้อมูล
</a>
</div>
</div>
</div>
</div>
</div>
<div id="assessment-tool-component-alert-delete-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content w-full">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
แจ้งเตือน
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#assessment-tool-component-alert-delete-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button> </button>
</div> </div>
</div> <div class="flex justify-end mt-2rem mb-1rem"
<div class="ti-modal-body "> *ngIf="currentModal=='delete'||currentModal=='deleteGroup'">
<p class="mt-1 text-gray-800 dark:text-white/70">
ยืนยันการลบข้อมูลหรือไม่!
</p>
<div class="flex justify-end mt-2rem mb-1rem">
<button type="button" <button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10" class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#assessment-tool-component-alert-delete-modal"> data-hs-overlay="#assessment-tool-alert-modal">
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);" <button type="button" class="ti-btn ti-btn-danger" data-hs-overlay="#assessment-tool-alert-modal"
data-hs-overlay="#assessment-tool-component-alert-delete-modal" (click)="deleteUser()"> (click)="updateAssessment('delete')">
ลบข้อมูล ลบข้อมูล
</a> </button>
</div> </div>
</div> </div>
</div> </div>
......
import { ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core'; import { ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core';
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
import { MyAssessmentModel } from 'src/app/shared/model/assessment.model'; import { AssessmentModel, MyAssessmentModel } from 'src/app/shared/model/assessment.model';
import { AssessmentService } from 'src/app/shared/services/assessment.service'; import { AssessmentService } from 'src/app/shared/services/assessment.service';
import { FileService } from 'src/app/shared/services/file.service';
export interface DataModel { export interface DataModel {
id: string id: string
name: string name: string
...@@ -15,159 +16,169 @@ export interface DataModel { ...@@ -15,159 +16,169 @@ export interface DataModel {
styleUrls: ['./assessment-tool.component.scss'] styleUrls: ['./assessment-tool.component.scss']
}) })
export class AssessmentToolComponent { export class AssessmentToolComponent {
@Input() pathTitle = ['การประเมินสมรรถนะ', 'ทะเบียนเครื่องมือ', 'เครื่องมือประเมิน'];
@Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>();
activeTab: string = 'tab1'; // กำหนด tab เริ่มต้น
isChecked: boolean = false;
currentPage = 1 currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1); page = Array.from({ length: 1 }, (_, i) => i + 1);
search = "" search = ""
numDataListChecked = 0
isDataListChecked = false
isDataListCheckedAll = false
assessment: { loading: boolean, select: AssessmentModel, dataList: { check: boolean, data: AssessmentModel }[] } = { loading: false, select: new MyAssessmentModel(), dataList: [] }
currentModal: 'add' | 'edit' | 'delete' | 'deleteGroup' = "add"
// ฟังก์ชันในการเปลี่ยนแท็บ selectedFile: File | null = null;
changeTab(tab: { id: string, text: string }) { selectedFileName: string = 'กรุณาเลือกไฟล์';
this.sendPathTitle.emit(['การประเมินสมรรถนะ', 'ทะเบียนเครื่องมือ', tab.text]); constructor(private toastr: ToastrService,
this.activeTab = tab.id; private cdr: ChangeDetectorRef,
private assessmentService: AssessmentService,
private fileService: FileService
) { }
ngOnInit(): void {
this.getAssessmentList()
} }
onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์"
// การจัดการการเปิดปิด modal
modalOptions: {
[nameModal: string]: {
isModalOpen: boolean;
modalSize: string;
backdropClose: boolean;
};
} = {
"add": {
isModalOpen: false,
modalSize: 'm',
backdropClose: true,
},
"edit": {
isModalOpen: false,
modalSize: 'm',
backdropClose: true,
}
};
openModal(name: string, size: string, closeOnBackdrop?: boolean) {
this.modalOptions[name].modalSize = size;
this.modalOptions[name].backdropClose = closeOnBackdrop || false;
this.modalOptions[name].isModalOpen = true;
this.currentModal = name; // ตั้งค่าค่าของ currentModal เป็น 'add' หรือ 'edit'
document.body.style.overflow = 'hidden';
} }
uploadFile() {
closeModal(name: string) { if (!this.selectedFile) {
this.modalOptions[name].isModalOpen = false; alert('กรุณาเลือกไฟล์ก่อนอัปโหลด')
if (!this.isAnyModalOpen()) { return
document.body.style.overflow = ''; // คืนค่าการ Scroll เฉพาะเมื่อ Modal ทั้งหมดปิดแล้ว
} }
} const formData = new FormData();
formData.append('file', this.selectedFile);
isAnyModalOpen(): boolean { this.assessment.loading = true
return Object.values(this.modalOptions).some(modal => modal.isModalOpen); // ตรวจสอบว่า modal อื่นยังเปิดอยู่หรือไม่ this.fileService.uploadExcel(formData, '').subscribe({
} next: response => {
if (response.success) {
// ฟังก์ชันสำหรับการเพิ่ม ลบ หรือแก้ไข ข้อมูล this.showAlert(response.message, 'success')
addUser() { this.getAssessmentList()
const body = new MyAssessmentModel({ assessmentId: this.dataSelect.id, tdesc: this.dataSelect.name, edesc: this.dataSelect.edesc, shortName: this.dataSelect.code }) } else {
this.assessmentService.post(body).subscribe((response: any) => { this.showAlert(response.message, 'error')
if (response.success) { this.assessment.loading = false
this.showSuccess() this.cdr.detectChanges()
this.getAssessmentList() }
}, error: error => {
this.showAlert(error.message, 'error')
this.assessment.loading = false
this.cdr.detectChanges()
} }
}) })
} }
deleteUser() { downloadFile() {
const body = new MyAssessmentModel({ assessmentId: this.dataSelect.id, tdesc: this.dataSelect.name, edesc: this.dataSelect.edesc, shortName: this.dataSelect.code }) const fileName = '.xlsx'
this.assessmentService.delete(body).subscribe((response: any) => { this.fileService.downloadTemplate(fileName).subscribe({
if (response.success) { next: response => {
this.showSuccessDelete() const url = window.URL.createObjectURL(response);
this.getAssessmentList() 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')
} }
}) })
}
currentModal = ""
constructor(private toastr: ToastrService,
private cdr: ChangeDetectorRef,
private assessmentService: AssessmentService
) { }
ngOnInit(): void {
this.getAssessmentList()
} }
getAssessmentList() { getAssessmentList() {
this.dataLoading = true this.assessment.loading = true
this.assessmentService.getList().subscribe({ this.assessmentService.getList().subscribe({
next: response => { next: response => {
this.mockData = response.map(x => ({ id: x.assessmentId, name: x.tdesc, edesc: x.edesc, code: x.shortName, checked: false })) this.assessment.dataList = response.map(x => ({ check: false, data: new MyAssessmentModel(x) }))
this.dataLoading = false this.isDataListCheckedAll = false
this.dataListCheckAll()
this.assessment.loading = false
this.searchChange() this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.dataLoading = false this.assessment.loading = false
this.cdr.detectChanges() this.cdr.detectChanges()
} }
}) })
} }
searchChange() { assessmentListFilter() {
this.currentPage = 1 return this.assessment.dataList.filter(x => {
this.page = Array.from({ length: Math.ceil(this.dataListFilter().length / 10) }, (_, i) => i + 1); const data = x.data
} const match = data.assessmentId.toLowerCase().includes(this.search.toLowerCase()) ||
dataListFilter() { data.tdesc.toLowerCase().includes(this.search.toLowerCase()) ||
return this.mockData.filter(x => { data.shortName.toLowerCase().includes(this.search.toLowerCase())
const data = x return match
const match = data.id.includes(this.search) || data.name.includes(this.search) || data.code.includes(this.search); })
return match;
});
} }
selectAssessment(data?: DataModel) { selectAssessment(data?: AssessmentModel) {
this.dataSelect = JSON.parse(JSON.stringify(data || { id: "", name: "", edesc: "", code: "", checked: false })); this.assessment.select = new MyAssessmentModel(data)
} }
clearAssessment(currentModal: string) {
if (currentModal == 'add') {
toggleCheckbox(): void { this.selectAssessment()
this.isChecked = !this.isChecked; } else if (currentModal == 'edit') {
this.mockData.forEach((item) => { this.selectAssessment(new MyAssessmentModel({ assessmentId: this.assessment.select.assessmentId }))
item.checked = this.isChecked; }
});
this.checkSelect();
} }
searchChange() {
this.currentPage = 1
mockData: DataModel[] = [] this.page = Array.from({ length: Math.ceil(this.assessmentListFilter().length / 10) }, (_, i) => i + 1);
dataLoading = false this.dataListCheck()
dataSelect: DataModel = { id: "", name: "", edesc: "", code: "", checked: false }
mockDataSelect: any = []
checkSelect() {
this.mockDataSelect = this.mockData.filter(item => item.checked);
} }
showAlert(text: string, type: 'success' | 'error') {
this.toastr[type](text, 'แจ้งเตือน', {
showSuccess() {
this.toastr.success('บันทึกข้อมูลสำเร็จ', 'เเจ้งเตือน', {
timeOut: 3000, timeOut: 3000,
positionClass: 'toast-top-right', positionClass: 'toast-top-right',
}); })
} }
showSuccessEdit() { updateAssessment(typeApi: 'post' | 'delete') {
this.toastr.success('เเก้ไขข้อมูลสำเร็จ', 'เเจ้งเตือน', { this.assessment.loading = true
timeOut: 3000, let body: AssessmentModel | AssessmentModel[]
positionClass: 'toast-top-right', switch (this.currentModal) {
}); case ('delete'): {
body = new MyAssessmentModel(this.assessment.select)
break;
}
case ('deleteGroup'): {
body = this.assessment.dataList.filter(x => x.check).map(x => new MyAssessmentModel(x.data))
break;
}
default: {
body = new MyAssessmentModel(this.assessment.select)
}
}
this.assessmentService[typeApi]((body as any)).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getAssessmentList()
this.searchChange()
} else {
this.showAlert(response.message, 'error')
this.assessment.loading = false
}
this.cdr.detectChanges()
}, error: error => {
this.showAlert(error.message, 'error')
this.assessment.loading = false
this.cdr.detectChanges()
}
})
} }
showSuccessDelete() { dataListCheckAll() {
this.toastr.success('ลบข้อมูลสำเร็จ', 'เเจ้งเตือน', { const selectAll = this.isDataListCheckedAll;
timeOut: 3000, this.assessment.dataList.filter(x => {
positionClass: 'toast-top-right', const data = x.data
}); const match = data.assessmentId.toLowerCase().includes(this.search.toLowerCase()) ||
data.tdesc.toLowerCase().includes(this.search.toLowerCase()) ||
data.shortName.toLowerCase().includes(this.search.toLowerCase())
return match
}).forEach(x => x.check = selectAll);
this.dataListCheck();
}
dataListCheck() {
const dataCheck = this.assessmentListFilter();
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false;
this.numDataListChecked = this.assessment.dataList.filter(x => x.check).length;
this.isDataListChecked = Boolean(this.numDataListChecked)
} }
} }
...@@ -15,10 +15,9 @@ ...@@ -15,10 +15,9 @@
</a> </a>
</nav> </nav>
</div> </div>
<div class="mt-3 px-3rem !-mt-3 pt-50px"> <div class="mt-3 px-2rem !-mt-3 pt-50px">
<div id="underline-1" role="tabpanel" aria-labelledby="underline-item-1"> <div id="underline-1" role="tabpanel" aria-labelledby="underline-item-1">
<app-assessment-tool [pathTitle]="pathTitle" <app-assessment-tool></app-assessment-tool>
(sendPathTitle)="pathTitle=$event"></app-assessment-tool>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -103,7 +103,7 @@ export class SubJobCompetencyComponent { ...@@ -103,7 +103,7 @@ export class SubJobCompetencyComponent {
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.loading = true this.loading = true
this.fileService.upload(formData, 'MJOBCODE_COMPETENCY').subscribe({ this.fileService.uploadExcel(formData, 'MJOBCODE_COMPETENCY').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
...@@ -122,7 +122,7 @@ export class SubJobCompetencyComponent { ...@@ -122,7 +122,7 @@ export class SubJobCompetencyComponent {
downloadFile() { downloadFile() {
const fileName = 'IMPORT_MJOBCODEV2.xlsx' const fileName = 'IMPORT_MJOBCODEV2.xlsx'
this.fileService.download(fileName).subscribe({ this.fileService.downloadTemplate(fileName).subscribe({
next: response => { next: response => {
const url = window.URL.createObjectURL(response); const url = window.URL.createObjectURL(response);
const a = document.createElement("a"); const a = document.createElement("a");
......
...@@ -13,12 +13,12 @@ export class MyAssessmentModel implements AssessmentModel { ...@@ -13,12 +13,12 @@ export class MyAssessmentModel implements AssessmentModel {
edesc: string edesc: string
tdesc: string tdesc: string
shortName: string shortName: string
constructor(data: Partial<AssessmentModel>) { constructor(data?: Partial<AssessmentModel>) {
this.assessmentId = data.assessmentId || "" this.assessmentId = data?.assessmentId || ""
this.companyId = data.companyId || "" this.companyId = data?.companyId || ""
this.edesc = data.edesc || "" this.edesc = data?.edesc || ""
this.tdesc = data.tdesc || "" this.tdesc = data?.tdesc || ""
this.shortName = data.shortName || "" this.shortName = data?.shortName || ""
} }
} }
...@@ -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 { AssessmentModel } from '../model/assessment.model'; import { AssessmentModel } from '../model/assessment.model';
import { AlertModel } from '../model/alert.model';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
...@@ -17,16 +18,16 @@ export class AssessmentService { ...@@ -17,16 +18,16 @@ export class AssessmentService {
getList(): Observable<AssessmentModel[]> { getList(): Observable<AssessmentModel[]> {
return this.http.get<AssessmentModel[]>(this.urlApi + "/lists") return this.http.get<AssessmentModel[]>(this.urlApi + "/lists")
} }
post(body: AssessmentModel) { post(body: AssessmentModel): Observable<AlertModel> {
return this.http.post(this.urlApi, body) return this.http.post<AlertModel>(this.urlApi, body)
} }
delete(body: AssessmentModel) { delete(body: AssessmentModel): Observable<AlertModel> {
const options = { const options = {
headers: new HttpHeaders({ headers: new HttpHeaders({
"Content-Type": "application/json", "Content-Type": "application/json",
}), }),
body: body body: body
}; };
return this.http.delete(this.urlApi, options) return this.http.delete<AlertModel>(this.urlApi, options)
} }
} }
\ No newline at end of file
...@@ -9,11 +9,16 @@ import { AlertModel } from '../model/alert.model'; ...@@ -9,11 +9,16 @@ import { AlertModel } from '../model/alert.model';
export class FileService { export class FileService {
constructor(private http: HttpClient) { constructor(private http: HttpClient) {
} }
uploadFiles(formData: any): Observable<AlertModel> {
upload(formData: any, table: string): Observable<AlertModel> { return this.http.post<AlertModel>(environment.baseUrl + '/files/upload', formData)
}
dowloadFiles(filename: string) {
return this.http.get(environment.baseUrl + '/files/download/' + filename, { responseType: "blob" })
}
uploadExcel(formData: any, table: string): Observable<AlertModel> {
return this.http.post<AlertModel>(environment.baseUrl + '/import/excel/' + table, formData) return this.http.post<AlertModel>(environment.baseUrl + '/import/excel/' + table, formData)
} }
download(fileName: string) { downloadTemplate(fileName: string) {
return this.http.get("/assets/template/" + fileName, { responseType: "blob" }) return this.http.get("/assets/template/" + fileName, { responseType: "blob" })
} }
} }
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