Commit c8b0be7c by DESKTOP-E3GSHH7\myhr

เเก้ตอนบันทึกข้อมูลเสร็จmodal เปิด เเต่หน้าไม่สามารถกดอะไรได้ เพิ่มpointer hover

parent c3010f5d
<div class="modal-header"> <!-- <div class="modal-header">
<h5 class="modal-title" id="editLabel">ข้อความแจ้งเตือน</h5> <h5 class="modal-title" id="editLabel">ข้อความแจ้งเตือน</h5>
<button type="button" class="close" (click)="activeModal.dismiss('dismiss')" aria-label="Close"> <button type="button" class="close" (click)="activeModal.dismiss('dismiss')" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
...@@ -16,4 +16,23 @@ ...@@ -16,4 +16,23 @@
<ng-template #InnerHTML> <ng-template #InnerHTML>
<div class="modal-body" [innerHTML]="innerHTML"> <div class="modal-body" [innerHTML]="innerHTML">
</div> </div>
</ng-template> -->
<div class="modal-header">
<h5 class="modal-title" id="editLabel">ข้อความแจ้งเตือน</h5>
<button type="button" class="close" (click)="close()" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<ng-container *ngIf="data.innerHTML != undefined then InnerHTML else Message"></ng-container>
<ng-template #Message>
<div class="modal-body">
{{data.message}}
</div>
</ng-template>
<ng-template #InnerHTML>
<div class="modal-body" [innerHTML]="data.innerHTML">
</div>
</ng-template> </ng-template>
\ No newline at end of file
import { Component, Input, OnInit } from '@angular/core'; import { Component, OnInit, Inject } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { MatDialogRef, MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
@Component({ @Component({
selector: 'app-alert-modal', selector: 'app-alert-modal',
templateUrl: './alert-modal.component.html', templateUrl: './alert-modal.component.html',
styleUrls: ['./alert-modal.component.scss'] styleUrls: ['./alert-modal.component.scss'],
standalone: true,
imports: [
CommonModule,
FormsModule,
MatDialogModule
]
}) })
export class AlertModalComponent implements OnInit { export class AlertModalComponent implements OnInit {
@Input() message: string = "" constructor(
@Input() innerHTML?: string public dialogRef: MatDialogRef<AlertModalComponent>,
constructor(public activeModal: NgbActiveModal) { } @Inject(MAT_DIALOG_DATA) public data: { message: string; innerHTML?: string }
) { }
ngOnInit(): void { ngOnInit(): void {
} }
} close(): void {
this.dialogRef.close();
}
}
\ No newline at end of file
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
<td> <td>
<div> <div>
<span class="block mb-1"> <span class="block mb-1">
<i class="fa fa-link text-blue-600 text-base flex-shrink-0" (click)="openLink(data.link1)" <i class="fa fa-link text-blue-600 text-base flex-shrink-0 cursor-pointer active: hover:text-danger" (click)="openLink(data.link1)"
style="font-size: 20px;"></i> style="font-size: 20px;"></i>
</span> </span>
</div> </div>
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
<td> <td>
<div> <div>
<span class="block mb-1"> <span class="block mb-1">
<i class="fa fa-download text-blue-600 text-base flex-shrink-0" (click)="downloadFile(data.logId)" <i class="fa fa-download text-blue-600 text-base flex-shrink-0 cursor-pointer active hover:text-success" (click)="downloadFile(data.logId)"
style="font-size: 20px;"></i> style="font-size: 20px;"></i>
</span> </span>
</div> </div>
......
...@@ -154,10 +154,10 @@ export class ListCourseComponent implements OnInit { ...@@ -154,10 +154,10 @@ export class ListCourseComponent implements OnInit {
if (willDelete) { if (willDelete) {
this.courseService.deleteCourse(item).subscribe(result => { this.courseService.deleteCourse(item).subscribe(result => {
if (result) { if (result) {
this.openAlertModalWithMatDialog('ลบข้อมูลสำเร็จ'); swal("ลบสำเร็จ!!", "บันทึกข้อมูลสำเร็จ", "success");
this.getListCourse(); this.getListCourse();
} else { } else {
this.openAlertModalWithMatDialog('ไม่สามารถลบข้อมูลได้'); swal("สำเร็จบางส่วน/ข้อผิดพลาด!!", "มีการลบข้อมูลบางส่วนไม่สำเร็จ หรือมีข้อผิดพลาด", "warning");
} }
}, error => { }, error => {
this.openAlertModalWithMatDialog(error.message); this.openAlertModalWithMatDialog(error.message);
...@@ -186,14 +186,15 @@ export class ListCourseComponent implements OnInit { ...@@ -186,14 +186,15 @@ export class ListCourseComponent implements OnInit {
console.log(this.modelCourse); console.log(this.modelCourse);
this.courseService.createCourse(this.modelCourse).subscribe(res => { this.courseService.createCourse(this.modelCourse).subscribe(res => {
if (res) { if (res) {
this.openAlertModalWithMatDialog('อัพเดทข้อมูลสำเร็จ'); swal("บันทึกสำเร็จ!!", "อัพเดทข้อมูลสำเร็จ", "success");
this.closeDialog(); this.closeDialog();
this.getListCourse(); this.getListCourse();
} else { } else {
this.openAlertModalWithMatDialog('ไม่สามารถอัพเดทข้อมูลได้'); swal('ไม่สามารถอัพเดทข้อมูลได้');
} }
}, error => { }, error => {
this.openAlertModalWithMatDialog(error.message); console.error("เกิดข้อผิดพลาดในการบันทึก/อัปเดต:", error);
swal("ข้อผิดพลาด!!", "ไม่สามารถบันทึก/อัปเดตข้อมูลได้", "error");
}); });
} }
}); });
...@@ -210,14 +211,15 @@ export class ListCourseComponent implements OnInit { ...@@ -210,14 +211,15 @@ export class ListCourseComponent implements OnInit {
if (willSave) { if (willSave) {
this.courseService.createCourse(this.modelCourse).subscribe(res => { this.courseService.createCourse(this.modelCourse).subscribe(res => {
if (res) { if (res) {
this.openAlertModalWithMatDialog('บันทึกข้อมูลสำเร็จ'); swal("บันทึกสำเร็จ!!", "บันทึกข้อมูลสมาชิก", "success");
this.closeDialog(); this.closeDialog();
this.getListCourse(); this.getListCourse();
} else { } else {
this.openAlertModalWithMatDialog('ไม่สามารถสร้างเอกสารได้'); swal('ไม่สามารถสร้างเอกสารได้');
} }
}, error => { }, error => {
this.openAlertModalWithMatDialog(error.message); console.error("เกิดข้อผิดพลาดในการบันทึก/อัปเดต:", error);
swal("ข้อผิดพลาด!!", "ไม่สามารถบันทึก/อัปเดตข้อมูลได้", "error");
}); });
} }
}); });
......
...@@ -149,7 +149,7 @@ ...@@ -149,7 +149,7 @@
<td style="justify-items: center;"> <td style="justify-items: center;">
<div> <div>
<span class="block mb-1"> <span class="block mb-1">
<i class="fa fa-link text-blue-600 text-base flex-shrink-0" (click)="openLink(data.link1)" <i class="fa fa-link text-blue-600 text-base flex-shrink-0 cursor-pointer active: hover:text-danger" (click)="openLink(data.link1)"
style="font-size: 20px;"></i> style="font-size: 20px;"></i>
</span> </span>
</div> </div>
...@@ -157,7 +157,7 @@ ...@@ -157,7 +157,7 @@
<td style="justify-items: center;"> <td style="justify-items: center;">
<div> <div>
<span class="block mb-1"> <span class="block mb-1">
<i class="fa fa-download text-blue-600 text-base flex-shrink-0" <i class="fa fa-download text-blue-600 text-base flex-shrink-0 cursor-pointer active hover:text-success"
(click)="downloadFile(data.logId,'tha')" style="font-size: 20px;"></i> (click)="downloadFile(data.logId,'tha')" style="font-size: 20px;"></i>
</span> </span>
</div> </div>
...@@ -165,7 +165,7 @@ ...@@ -165,7 +165,7 @@
<td style="justify-items: center;"> <td style="justify-items: center;">
<div> <div>
<span class="block mb-1"> <span class="block mb-1">
<i class="fa fa-download text-blue-600 text-base flex-shrink-0" <i class="fa fa-download text-blue-600 text-base flex-shrink-0 cursor-pointer active hover:text-success"
(click)="downloadFile(data.logId,'eng')" style="font-size: 20px;"></i> (click)="downloadFile(data.logId,'eng')" style="font-size: 20px;"></i>
</span> </span>
</div> </div>
......
...@@ -155,10 +155,10 @@ export class ListDocComponent implements OnInit { ...@@ -155,10 +155,10 @@ export class ListDocComponent implements OnInit {
if (willDelete) { if (willDelete) {
this.documentService.deleteExcel(item).subscribe(result => { this.documentService.deleteExcel(item).subscribe(result => {
if (result) { if (result) {
this.openAlertModalWithMatDialog('ลบข้อมูลสำเร็จ'); swal("ลบสำเร็จ!!", "บันทึกข้อมูลสำเร็จ", "success");
this.getListDoc(); // โหลดข้อมูลใหม่ทั้งหมดและใช้ applyFilterAndPagination this.getListDoc(); // โหลดข้อมูลใหม่ทั้งหมดและใช้ applyFilterAndPagination
} else { } else {
this.openAlertModalWithMatDialog('ไม่สามารถลบข้อมูลได้'); swal("สำเร็จบางส่วน/ข้อผิดพลาด!!", "มีการลบข้อมูลบางส่วนไม่สำเร็จ หรือมีข้อผิดพลาด", "warning");
} }
}, error => { }, error => {
this.openAlertModalWithMatDialog(error.message); this.openAlertModalWithMatDialog(error.message);
...@@ -187,14 +187,15 @@ export class ListDocComponent implements OnInit { ...@@ -187,14 +187,15 @@ export class ListDocComponent implements OnInit {
console.log(this.modelDoc); console.log(this.modelDoc);
this.documentService.createDoc(this.modelDoc).subscribe(res => { this.documentService.createDoc(this.modelDoc).subscribe(res => {
if (res) { if (res) {
this.openAlertModalWithMatDialog('อัพเดทข้อมูลสำเร็จ'); swal("บันทึกสำเร็จ!!", "อัพเดทข้อมูลสำเร็จ", "success");
this.closeDialog(); // ปิด MatDialog this.closeDialog(); // ปิด MatDialog
this.getListDoc(); // โหลดข้อมูลใหม่ทั้งหมดและใช้ applyFilterAndPagination this.getListDoc(); // โหลดข้อมูลใหม่ทั้งหมดและใช้ applyFilterAndPagination
} else { } else {
this.openAlertModalWithMatDialog('ไม่สามารถอัพเดทข้อมูลได้'); swal('ไม่สามารถอัพเดทข้อมูลได้');
} }
}, error => { }, error => {
this.openAlertModalWithMatDialog(error.message); console.error("เกิดข้อผิดพลาดในการบันทึก/อัปเดต:", error);
swal("ข้อผิดพลาด!!", "ไม่สามารถบันทึก/อัปเดตข้อมูลได้", "error");
}); });
} }
}); });
...@@ -211,14 +212,15 @@ export class ListDocComponent implements OnInit { ...@@ -211,14 +212,15 @@ export class ListDocComponent implements OnInit {
if (willSave) { if (willSave) {
this.documentService.createDoc(this.modelDoc).subscribe(res => { this.documentService.createDoc(this.modelDoc).subscribe(res => {
if (res) { if (res) {
this.openAlertModalWithMatDialog('บันทึกข้อมูลสำเร็จ'); swal("บันทึกสำเร็จ!!", "บันทึกข้อมูลสมาชิก", "success");
this.closeDialog(); // ปิด MatDialog this.closeDialog(); // ปิด MatDialog
this.getListDoc(); // โหลดข้อมูลใหม่ทั้งหมดและใช้ applyFilterAndPagination this.getListDoc(); // โหลดข้อมูลใหม่ทั้งหมดและใช้ applyFilterAndPagination
} else { } else {
this.openAlertModalWithMatDialog('ไม่สามารถสร้างเอกสารได้'); swal('ไม่สามารถสร้างเอกสารได้');
} }
}, error => { }, error => {
this.openAlertModalWithMatDialog(error.message); console.error("เกิดข้อผิดพลาดในการบันทึก/อัปเดต:", error);
swal("ข้อผิดพลาด!!", "ไม่สามารถบันทึก/อัปเดตข้อมูลได้", "error");
}); });
} }
}); });
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
{{ 'All List' | translate}} {{ 'All List' | translate}}
</div> </div>
<div class="flex flex-wrap gap-2"> <div class="flex flex-wrap gap-2">
<a href="javascript:void(0);" class="hs-dropdown-toggle ti-btn ti-btn-primary-full me-2" <a href="javascript:void(0);" class="hs-dropdown-toggle ti-btn ti-btn-primary-full me-2 hover:scale-105 transition duration-300"
(click)="openEditExcelDialog()"><i class="ri-add-line font-semibold align-middle"></i>{{ 'Create' | (click)="openEditExcelDialog()"><i class="ri-add-line font-semibold align-middle"></i>{{ 'Create' |
translate}} translate}}
</a> </a>
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
<td> <td>
<div> <div>
<span class="block mb-1"> <span class="block mb-1">
<i class="fa fa-link text-blue-600 text-base flex-shrink-0" (click)="openLink(data.link1)" <i class="fa fa-link text-blue-600 text-base flex-shrink-0 cursor-pointer active: hover:text-danger hover:scale-125 transition duration-300" (click)="openLink(data.link1)"
style="font-size: 20px;"></i> style="font-size: 20px;"></i>
</span> </span>
</div> </div>
...@@ -77,8 +77,8 @@ ...@@ -77,8 +77,8 @@
<td> <td>
<div> <div>
<span class="block mb-1"> <span class="block mb-1">
<i class="fa fa-download text-blue-600 text-base flex-shrink-0" (click)="downloadFile(data.logId)" <i class="fa fa-download text-blue-600 text-base flex-shrink-0 cursor-pointer active hover:text-success hover:scale-125 transition duration-300"
style="font-size: 20px;"></i> (click)="downloadFile(data.logId)" style="font-size: 20px;"></i>
</span> </span>
</div> </div>
</td> </td>
...@@ -121,7 +121,8 @@ ...@@ -121,7 +121,8 @@
<div class="box-footer"> <div class="box-footer">
<div class="flex items-center flex-wrap overflow-auto"> <div class="flex items-center flex-wrap overflow-auto">
<div class="mb-2 sm:mb-0"> <div class="mb-2 sm:mb-0">
<select class="custom-select m-r-5" style="width: auto" [(ngModel)]="pageSize" (ngModelChange)="goToPage(0)"> <select class="custom-select m-r-5" style="width: auto" [(ngModel)]="pageSize"
(ngModelChange)="goToPage(0)">
<option [ngValue]="10">รายการต่อหน้า: 10</option> <option [ngValue]="10">รายการต่อหน้า: 10</option>
<option [ngValue]="50">รายการต่อหน้า: 50</option> <option [ngValue]="50">รายการต่อหน้า: 50</option>
<option [ngValue]="100">รายการต่อหน้า: 100</option> <option [ngValue]="100">รายการต่อหน้า: 100</option>
...@@ -158,7 +159,8 @@ ...@@ -158,7 +159,8 @@
</div> </div>
</div> </div>
<div class="box p-4" *ngIf="checkType === '1'"> <div class="flex flex-wrap -mx-2"> <div class="box p-4" *ngIf="checkType === '1'">
<div class="flex flex-wrap -mx-2">
<div class="w-full"> <div class="w-full">
<div class="py-3 px-2"> <div class="py-3 px-2">
<input type="text" <input type="text"
......
...@@ -2,7 +2,6 @@ import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core'; ...@@ -2,7 +2,6 @@ import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
import { NgbModal, NgbPaginationModule } from '@ng-bootstrap/ng-bootstrap'; import { NgbModal, NgbPaginationModule } from '@ng-bootstrap/ng-bootstrap';
import { ExcelModel } from '../../../models/excel.model'; import { ExcelModel } from '../../../models/excel.model';
import { ExcelService } from '../../../services/excel.service'; import { ExcelService } from '../../../services/excel.service';
import { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component';
import { AlertModalComponent } from '../alert-modal/alert-modal.component'; import { AlertModalComponent } from '../alert-modal/alert-modal.component';
import { UploadService } from '../../../services/upload.service'; import { UploadService } from '../../../services/upload.service';
import { TagService } from '../../../services/tag.service'; import { TagService } from '../../../services/tag.service';
...@@ -35,7 +34,6 @@ import swal from 'sweetalert'; ...@@ -35,7 +34,6 @@ import swal from 'sweetalert';
SharedModule, SharedModule,
MatDialogModule, MatDialogModule,
TranslateModule, TranslateModule,
NgbPaginationModule,
TagInputModule, TagInputModule,
], ],
}) })
...@@ -43,12 +41,12 @@ export class ListExcelComponent implements OnInit { ...@@ -43,12 +41,12 @@ export class ListExcelComponent implements OnInit {
@ViewChild("editTemplateModal") editTemplateModalRef!: TemplateRef<any>; @ViewChild("editTemplateModal") editTemplateModalRef!: TemplateRef<any>;
@ViewChild("listexcel") listexcel: any; @ViewChild("listexcel") listexcel: any;
page = 1; page = 1;
pageSize = 10; pageSize = 10;
pageIndex: number = 0; pageIndex: number = 0;
maxPagesToShow: number = 3; maxPagesToShow: number = 3;
originalListExcel: ExcelModel[] = []; originalListExcel: ExcelModel[] = [];
listExcel: ExcelModel[] = []; listExcel: ExcelModel[] = [];
paginatedExcels: ExcelModel[] = []; paginatedExcels: ExcelModel[] = [];
...@@ -62,12 +60,11 @@ export class ListExcelComponent implements OnInit { ...@@ -62,12 +60,11 @@ export class ListExcelComponent implements OnInit {
listGroup: GroupModel[] = []; listGroup: GroupModel[] = [];
constructor( constructor(
private modalService: NgbModal,
private excelService: ExcelService, private excelService: ExcelService,
private uploadService: UploadService, private uploadService: UploadService,
private tagService: TagService, private tagService: TagService,
private groupService: GroupService, private groupService: GroupService,
private dialog: MatDialog, private dialog: MatDialog,
) { ) {
} }
...@@ -79,7 +76,7 @@ export class ListExcelComponent implements OnInit { ...@@ -79,7 +76,7 @@ export class ListExcelComponent implements OnInit {
const totalPagesAfterFilter = Math.ceil(this.listExcel.length / this.pageSize); const totalPagesAfterFilter = Math.ceil(this.listExcel.length / this.pageSize);
if (this.pageIndex >= totalPagesAfterFilter && totalPagesAfterFilter > 0) { if (this.pageIndex >= totalPagesAfterFilter && totalPagesAfterFilter > 0) {
this.pageIndex = totalPagesAfterFilter - 1; this.pageIndex = totalPagesAfterFilter - 1;
} else if (totalPagesAfterFilter === 0) { } else if (totalPagesAfterFilter === 0) {
this.pageIndex = 0; this.pageIndex = 0;
} }
...@@ -148,7 +145,7 @@ export class ListExcelComponent implements OnInit { ...@@ -148,7 +145,7 @@ export class ListExcelComponent implements OnInit {
'application/vnd.ms-excel.sheet.macroEnabled.12' 'application/vnd.ms-excel.sheet.macroEnabled.12'
]; ];
if (!allowedTypes.includes(file.type)) { if (!allowedTypes.includes(file.type)) {
this.openAlertModalWithMatDialog('อัพโหลดได้เฉพาะไฟล์ *.xlsx *.xlsm เท่านั้น'); this.openAlertModalWithMatDialog('อัพโหลดได้เฉพาะไฟล์ *.xlsx *.xlsm เท่านั้น');
} else { } else {
let base64 = event.target!.result as string; let base64 = event.target!.result as string;
this.modelExcel.excelObj = base64.split(',')[1]; this.modelExcel.excelObj = base64.split(',')[1];
...@@ -163,7 +160,7 @@ export class ListExcelComponent implements OnInit { ...@@ -163,7 +160,7 @@ export class ListExcelComponent implements OnInit {
try { try {
const data = await this.excelService.downloadFile(logId).toPromise(); const data = await this.excelService.downloadFile(logId).toPromise();
if (data) { if (data) {
const fileName = `${logId}.${this.modelExcel.fileType || 'xlsx'}`; const fileName = `${logId}.${this.modelExcel.fileType || 'xlsx'}`;
saveAs(new Blob([data]), fileName); saveAs(new Blob([data]), fileName);
} }
} catch (error) { } catch (error) {
...@@ -183,10 +180,10 @@ export class ListExcelComponent implements OnInit { ...@@ -183,10 +180,10 @@ export class ListExcelComponent implements OnInit {
if (willDelete) { if (willDelete) {
this.excelService.deleteExcel(item).subscribe(result => { this.excelService.deleteExcel(item).subscribe(result => {
if (result) { if (result) {
this.openAlertModalWithMatDialog('ลบข้อมูลสำเร็จ'); swal("ลบสำเร็จ!!", "บันทึกข้อมูลสำเร็จ", "success");
this.getListExcel(); this.getListExcel();
} else { } else {
this.openAlertModalWithMatDialog('ไม่สามารถลบข้อมูลได้'); swal("สำเร็จบางส่วน/ข้อผิดพลาด!!", "มีการลบข้อมูลบางส่วนไม่สำเร็จ หรือมีข้อผิดพลาด", "warning");
} }
}, error => { }, error => {
this.openAlertModalWithMatDialog(error.message); this.openAlertModalWithMatDialog(error.message);
...@@ -215,14 +212,15 @@ export class ListExcelComponent implements OnInit { ...@@ -215,14 +212,15 @@ export class ListExcelComponent implements OnInit {
console.log(this.modelExcel); console.log(this.modelExcel);
this.excelService.createExcel(this.modelExcel).subscribe(res => { this.excelService.createExcel(this.modelExcel).subscribe(res => {
if (res) { if (res) {
this.openAlertModalWithMatDialog('อัพเดทข้อมูลสำเร็จ'); swal("บันทึกสำเร็จ!!", "อัพเดทข้อมูลสำเร็จ", "success");
this.closeDialog(); this.closeDialog();
this.getListExcel(); this.getListExcel();
} else { } else {
this.openAlertModalWithMatDialog('ไม่สามารถอัพเดทข้อมูลได้'); swal('ไม่สามารถอัพเดทข้อมูลได้');
} }
}, error => { }, error => {
this.openAlertModalWithMatDialog(error.message); console.error("เกิดข้อผิดพลาดในการบันทึก/อัปเดต:", error);
swal("ข้อผิดพลาด!!", "ไม่สามารถบันทึก/อัปเดตข้อมูลได้", "error");
}); });
} }
}); });
...@@ -239,18 +237,79 @@ export class ListExcelComponent implements OnInit { ...@@ -239,18 +237,79 @@ export class ListExcelComponent implements OnInit {
if (willSave) { if (willSave) {
this.excelService.createExcel(this.modelExcel).subscribe(res => { this.excelService.createExcel(this.modelExcel).subscribe(res => {
if (res) { if (res) {
this.openAlertModalWithMatDialog('บันทึกข้อมูลสำเร็จ'); swal("บันทึกสำเร็จ!!", "บันทึกข้อมูลสมาชิก", "success");
this.closeDialog(); this.closeDialog();
this.getListExcel(); this.getListExcel();
} else { } else {
this.openAlertModalWithMatDialog('ไม่สามารถสร้างเอกสารได้'); swal('ไม่สามารถสร้างเอกสารได้');
} }
}, error => { }, error => {
this.openAlertModalWithMatDialog(error.message); console.error("เกิดข้อผิดพลาดในการบันทึก/อัปเดต:", error);
swal("ข้อผิดพลาด!!", "ไม่สามารถบันทึก/อัปเดตข้อมูลได้", "error");
}); });
} }
}); });
} }
// onUpdate() {
// swal({
// title: "คุณแน่ใจหรือไม่?",
// text: "คุณต้องการอัพเดทข้อมูลหรือไม่",
// icon: "warning",
// dangerMode: false,
// buttons: ["ยกเลิก", "ยืนยัน"],
// }).then((willUpdate: boolean) => {
// if (willUpdate) {
// this.excelService.createExcel(this.modelExcel).subscribe({
// next: (res) => {
// console.log('Excel update response:', res);
// if (res) {
// // this.openAlertModalWithMatDialog('อัพเดทข้อมูลสำเร็จ');
// } else {
// this.openAlertModalWithMatDialog('ไม่สามารถอัพเดทข้อมูลได้ (res is false/null)');
// }
// this.closeDialog();
// this.getListExcel();
// },
// error: (error) => {
// this.openAlertModalWithMatDialog(error.message || 'เกิดข้อผิดพลาดในการอัปเดทข้อมูล');
// this.closeDialog();
// },
// });
// } else {
// this.closeDialog();
// }
// });
// }
// onCreate() {
// swal({
// title: "คุณแน่ใจหรือไม่?",
// text: "คุณต้องการบันทึกหรือไม่",
// icon: "warning",
// dangerMode: false,
// buttons: ["ยกเลิก", "ยืนยัน"],
// }).then((willSave: boolean) => {
// if (willSave) {
// this.excelService.createExcel(this.modelExcel).subscribe({
// next: (res) => {
// if (res) {
// // this.openAlertModalWithMatDialog('บันทึกข้อมูลสำเร็จ'); // <--- ลบบรรทัดนี้ออก
// } else {
// this.openAlertModalWithMatDialog('ไม่สามารถสร้างเอกสารได้ (res is false/null)');
// }
// this.closeDialog();
// this.getListExcel();
// },
// error: (error) => {
// this.openAlertModalWithMatDialog(error.message || 'เกิดข้อผิดพลาดในการสร้างเอกสาร');
// this.closeDialog();
// },
// });
// } else {
// this.closeDialog();
// }
// });
// }
onSumit() { onSumit() {
if (this.checkEdit) { if (this.checkEdit) {
...@@ -260,20 +319,26 @@ export class ListExcelComponent implements OnInit { ...@@ -260,20 +319,26 @@ export class ListExcelComponent implements OnInit {
} }
} }
async getExcelById(targetModal: NgbModal, id: string) { async getExcelById(id: string) { // <--- แก้ไขตรงนี้
try { try {
const data = await this.excelService.getExcelById(id).toPromise(); const data = await this.excelService.getExcelById(id).toPromise();
this.modelExcel = new ExcelModel(data!); this.modelExcel = new ExcelModel(data!);
console.log("🚀 ~ ListExcelComponent ~ getExcelById ~ this.modelExcel:", this.modelExcel); console.log("🚀 ~ ListExcelComponent ~ getExcelById ~ this.modelExcel:", this.modelExcel);
if (data) { if (data) {
this.modalService.open(targetModal, { this.dialogRef = this.dialog.open(this.editTemplateModalRef, {
centered: true, width: '1100px',
backdrop: 'static', disableClose: true,
size: 'lg' });
this.dialogRef.afterClosed().subscribe((result: boolean) => {
console.log('Excel dialog opened by getExcelById closed with result:', result);
if (result === true) {
this.getListExcel();
}
}); });
} }
} catch (error) { } catch (error) {
console.error('Error loading data:', error); console.error('Error loading data:', error);
this.openAlertModalWithMatDialog('ไม่สามารถโหลดข้อมูลได้'); // เพิ่มการแจ้งเตือน
} }
} }
...@@ -289,15 +354,15 @@ export class ListExcelComponent implements OnInit { ...@@ -289,15 +354,15 @@ export class ListExcelComponent implements OnInit {
} else if (status === '2') { } else if (status === '2') {
return 'ไม่อนุมัติ'; return 'ไม่อนุมัติ';
} else { } else {
return 'ไม่ทราบสถานะ'; return 'ไม่ทราบสถานะ';
} }
} }
async getListExcel() { async getListExcel() {
try { try {
const data = await this.excelService.getListExcel().toPromise(); const data = await this.excelService.getListExcel().toPromise();
this.originalListExcel = data!.map(x => new ExcelModel(x)); this.originalListExcel = data!.map(x => new ExcelModel(x));
this.applyFilterAndPagination(); this.applyFilterAndPagination();
} catch (error) { } catch (error) {
console.error('Error loading data:', error); console.error('Error loading data:', error);
this.openAlertModalWithMatDialog('ไม่สามารถโหลดรายการ Excel ได้'); this.openAlertModalWithMatDialog('ไม่สามารถโหลดรายการ Excel ได้');
...@@ -305,7 +370,7 @@ export class ListExcelComponent implements OnInit { ...@@ -305,7 +370,7 @@ export class ListExcelComponent implements OnInit {
} }
get totalFilteredItems(): number { get totalFilteredItems(): number {
return this.listExcel.length; return this.listExcel.length;
} }
get totalPages(): number { get totalPages(): number {
...@@ -325,9 +390,9 @@ export class ListExcelComponent implements OnInit { ...@@ -325,9 +390,9 @@ export class ListExcelComponent implements OnInit {
goToPage(page: number) { goToPage(page: number) {
if (page >= 0 && page < this.totalPages) { if (page >= 0 && page < this.totalPages) {
this.pageIndex = page; this.pageIndex = page;
this.applyFilterAndPagination(); this.applyFilterAndPagination();
} else if (this.totalPages === 0 && page === 0) { } else if (this.totalPages === 0 && page === 0) {
this.pageIndex = 0; this.pageIndex = 0;
this.applyFilterAndPagination(); this.applyFilterAndPagination();
} }
} }
...@@ -370,9 +435,6 @@ export class ListExcelComponent implements OnInit { ...@@ -370,9 +435,6 @@ export class ListExcelComponent implements OnInit {
}); });
} }
closeBtnClick() {
this.modalService.dismissAll();
}
coverDate(date: string) { coverDate(date: string) {
return date.split('-').reverse().join('/'); return date.split('-').reverse().join('/');
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
<td> <td>
<div> <div>
<span class="block mb-1"> <span class="block mb-1">
<i class="fa fa-link text-blue-600 text-base flex-shrink-0 cursor-pointer" <i class="fa fa-link text-blue-600 text-base flex-shrink-0 cursor-pointer active: hover:text-danger hover:scale-125 transition duration-300"
(click)="openLink(data.link1)" style="font-size: 20px;"></i> (click)="openLink(data.link1)" style="font-size: 20px;"></i>
</span> </span>
</div> </div>
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
<td> <td>
<div> <div>
<span class="block mb-1"> <span class="block mb-1">
<i class="fa fa-download text-blue-600 text-base flex-shrink-0 cursor-pointer" <i class="fa fa-download text-blue-600 text-base flex-shrink-0 cursor-pointer active hover:text-success hover:scale-125 transition duration-300"
(click)="downloadFile(data.widgetId)" style="font-size: 20px;"></i> (click)="downloadFile(data.widgetId)" style="font-size: 20px;"></i>
</span> </span>
</div> </div>
......
...@@ -167,10 +167,10 @@ export class ListWidgetsComponent implements OnInit { ...@@ -167,10 +167,10 @@ export class ListWidgetsComponent implements OnInit {
if (willDelete) { if (willDelete) {
this.widgetService.deleteWidget(item).subscribe(result => { this.widgetService.deleteWidget(item).subscribe(result => {
if (result) { if (result) {
this.openAlertModalWithMatDialog('ลบข้อมูลสำเร็จ'); swal("ลบสำเร็จ!!", "บันทึกข้อมูลสำเร็จ", "success");
this.getListWidgets(); // Re-fetch and re-apply filter/pagination this.getListWidgets(); // Re-fetch and re-apply filter/pagination
} else { } else {
this.openAlertModalWithMatDialog('ไม่สามารถลบข้อมูลได้'); swal("สำเร็จบางส่วน/ข้อผิดพลาด!!", "มีการลบข้อมูลบางส่วนไม่สำเร็จ หรือมีข้อผิดพลาด", "warning");
} }
}, error => { }, error => {
this.openAlertModalWithMatDialog(error.message); this.openAlertModalWithMatDialog(error.message);
...@@ -199,14 +199,15 @@ export class ListWidgetsComponent implements OnInit { ...@@ -199,14 +199,15 @@ export class ListWidgetsComponent implements OnInit {
console.log(this.modelWidget); console.log(this.modelWidget);
this.widgetService.createWidget(this.modelWidget).subscribe(res => { this.widgetService.createWidget(this.modelWidget).subscribe(res => {
if (res) { if (res) {
this.openAlertModalWithMatDialog('อัพเดทข้อมูลสำเร็จ'); swal("บันทึกสำเร็จ!!", "อัพเดทข้อมูลสำเร็จ", "success");
this.closeDialog(); this.closeDialog();
this.getListWidgets(); // Re-fetch and re-apply filter/pagination this.getListWidgets(); // Re-fetch and re-apply filter/pagination
} else { } else {
this.openAlertModalWithMatDialog('ไม่สามารถอัพเดทข้อมูลได้'); swal('ไม่สามารถอัพเดทข้อมูลได้');
} }
}, error => { }, error => {
this.openAlertModalWithMatDialog(error.message); console.error("เกิดข้อผิดพลาดในการบันทึก/อัปเดต:", error);
swal("ข้อผิดพลาด!!", "ไม่สามารถบันทึก/อัปเดตข้อมูลได้", "error");
}); });
} }
}); });
...@@ -223,14 +224,15 @@ export class ListWidgetsComponent implements OnInit { ...@@ -223,14 +224,15 @@ export class ListWidgetsComponent implements OnInit {
if (willSave) { if (willSave) {
this.widgetService.createWidget(this.modelWidget).subscribe(res => { this.widgetService.createWidget(this.modelWidget).subscribe(res => {
if (res) { if (res) {
this.openAlertModalWithMatDialog('บันทึกข้อมูลสำเร็จ'); swal("บันทึกสำเร็จ!!", "บันทึกข้อมูลสมาชิก", "success");
this.closeDialog(); this.closeDialog();
this.getListWidgets(); // Re-fetch and re-apply filter/pagination this.getListWidgets(); // Re-fetch and re-apply filter/pagination
} else { } else {
this.openAlertModalWithMatDialog('ไม่สามารถสร้างเอกสารได้'); swal('ไม่สามารถสร้างเอกสารได้');
} }
}, error => { }, error => {
this.openAlertModalWithMatDialog(error.message); console.error("เกิดข้อผิดพลาดในการบันทึก/อัปเดต:", error);
swal("ข้อผิดพลาด!!", "ไม่สามารถบันทึก/อัปเดตข้อมูลได้", "error");
}); });
} }
}); });
......
...@@ -52,7 +52,8 @@ ...@@ -52,7 +52,8 @@
</div> </div>
<div> <div>
<button <button
class="bg-primary inline-flex items-center px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-md shadow-md transition duration-150 ease-in-out focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50" class="bg-primary inline-flex items-center px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-md shadow-md
active hover:bg-success hover:scale-110 transition duration-300 ease-in-out focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50"
(click)="openView(c.id)" (click)="openView(c.id)"
> >
รายละเอียด รายละเอียด
......
...@@ -52,7 +52,8 @@ ...@@ -52,7 +52,8 @@
</div> </div>
<div> <div>
<button <button
class="bg-primary inline-flex items-center px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-md shadow-md transition duration-150 ease-in-out focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50" class="bg-primary inline-flex items-center px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-md shadow-md
active hover:bg-success hover:scale-110 transition duration-300 ease-in-out focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50"
(click)="openView(c.id)" (click)="openView(c.id)"
> >
รายละเอียด รายละเอียด
......
...@@ -50,7 +50,9 @@ ...@@ -50,7 +50,9 @@
</div> </div>
<div> <div>
<button <button
class="bg-primary inline-flex items-center px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-md shadow-md transition duration-150 ease-in-out focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50" class="bg-primary inline-flex items-center px-4 py-2 bg-blue-600 hover:bg-blue-700
text-white text-sm font-medium rounded-md shadow-md ease-in-out focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50
active hover:bg-success hover:scale-110 transition duration-300"
(click)="openView(c.id)" (click)="openView(c.id)"
> >
รายละเอียด รายละเอียด
......
...@@ -53,7 +53,8 @@ ...@@ -53,7 +53,8 @@
</div> </div>
<div> <div>
<button <button
class="bg-primary inline-flex items-center px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-md shadow-md transition duration-150 ease-in-out focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50" class="bg-primary inline-flex items-center px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-md shadow-md
active hover:bg-success hover:scale-110 transition duration-300 ease-in-out focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50"
(click)="openView(c.id)"> (click)="openView(c.id)">
รายละเอียด รายละเอียด
</button> </button>
......
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