Commit 3eeeb5e5 by Natthaphat Pankiang

ทะเบียนแผนก, ทะเบียนส่วน, ส่วนย่อย1, ส่วนย่อย2, ส่วนย่อย3, ส่วนย่อย4 import file

parent b490b796
...@@ -3,12 +3,13 @@ ...@@ -3,12 +3,13 @@
<div class="flex pr-2"> <div class="flex pr-2">
<!-- Content ของ div แรก --> <!-- Content ของ div แรก -->
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"> <button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
data-hs-overlay="#department-list-upload-modal">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
นำเข้าข้อมูล นำเข้าข้อมูล
</button> </button>
<a class="mx-2 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" <a class="mx-2 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"
href="javascript:void(0);"> href="javascript:void(0);" (click)="downloadFile()">
ดาวน์โหลดตัวอย่างไฟล์ ดาวน์โหลดตัวอย่างไฟล์
</a> </a>
</div> </div>
...@@ -65,14 +66,24 @@ ...@@ -65,14 +66,24 @@
</ng-container> </ng-container>
</tr> </tr>
</thead> </thead>
<tbody *ngIf="!filterBu2Table().length"> <tbody *ngIf="bu2ListLoading">
<tr>
<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"
aria-label="loading">
<span class="sr-only">Loading...</span>
</div>
</td>
</tr>
</tbody>
<tbody *ngIf="!bu2ListLoading&&!filterBu2Table().length">
<tr> <tr>
<td class="text-center" colspan="100%"> <td class="text-center" colspan="100%">
ไม่พบข้อมูล ไม่พบข้อมูล
</td> </td>
</tr> </tr>
</tbody> </tbody>
<tbody *ngIf="filterBu2Table().length"> <tbody *ngIf="!bu2ListLoading&&filterBu2Table().length">
<tr <tr
*ngFor="let item of filterBu2Table() | slice:((bu2Table.currentPage-1) * 10) : (((bu2Table.currentPage-1) * 10) + 10);let i = index"> *ngFor="let item of filterBu2Table() | slice:((bu2Table.currentPage-1) * 10) : (((bu2Table.currentPage-1) * 10) + 10);let i = index">
<td class="text-center"> <td class="text-center">
...@@ -664,3 +675,33 @@ ...@@ -664,3 +675,33 @@
</div> </div>
</div> </div>
</div> </div>
<div id="department-list-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)] rounded-md">
<div class="ti-modal-header bg-primary !rounded-none !rounded-t-sm">
<h5 class="text-xxl font-bold text-white">
นำเข้าฝ่าย
</h5>
</div>
<div class="ti-modal-body max-h-full overflow-hidden ti-modal-content !rounded-t-none !rounded-b-sm">
<h1 class="mt-2" style="text-align: center;">ไฟล์</h1>
<div class="mt-2 p-2">
<div class="flex rounded-md">
<input #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>
</div>
<div class="flex justify-center mt-2rem mb-1rem space-x-4">
<button type="submit" class="ti-btn ti-btn-secondary" (click)="uploadFile()"
[disabled]="!selectedFile">
อัปโหลด
</button>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
...@@ -4,6 +4,7 @@ import { Bu1Model, MyBu1Model } from 'src/app/shared/model/bu1.model'; ...@@ -4,6 +4,7 @@ import { Bu1Model, MyBu1Model } from 'src/app/shared/model/bu1.model';
import { Bu2Model, MyBu2Model } from 'src/app/shared/model/bu2.model'; import { Bu2Model, MyBu2Model } from 'src/app/shared/model/bu2.model';
import { Bu1Service } from 'src/app/shared/services/bu1.service'; import { Bu1Service } from 'src/app/shared/services/bu1.service';
import { Bu2Service } from 'src/app/shared/services/bu2.service'; import { Bu2Service } from 'src/app/shared/services/bu2.service';
import { FileService } from 'src/app/shared/services/file.service';
interface table { interface table {
currentPage: number, currentPage: number,
page: number[], page: number[],
...@@ -16,12 +17,17 @@ interface table { ...@@ -16,12 +17,17 @@ interface table {
}) })
export class DepartmentListComponent implements OnInit { export class DepartmentListComponent implements OnInit {
bu2List: Bu2Model[] = [] bu2List: Bu2Model[] = []
bu2ListLoading = false
bu2: Bu2Model = new MyBu2Model({}) bu2: Bu2Model = new MyBu2Model({})
bu2Table: table = { bu2Table: table = {
currentPage: 1, currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1), page: Array.from({ length: 1 }, (_, i) => i + 1),
search: "" search: ""
} }
selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์';
bu2Modal: table = { bu2Modal: table = {
currentPage: 1, currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1), page: Array.from({ length: 1 }, (_, i) => i + 1),
...@@ -38,17 +44,71 @@ export class DepartmentListComponent implements OnInit { ...@@ -38,17 +44,71 @@ export class DepartmentListComponent implements OnInit {
constructor(private bu2Service: Bu2Service, constructor(private bu2Service: Bu2Service,
private bu1Service: Bu1Service, private bu1Service: Bu1Service,
private toastr: ToastrService, private toastr: ToastrService,
private cdr: ChangeDetectorRef private cdr: ChangeDetectorRef,
private fileService: FileService
) { } ) { }
ngOnInit(): void { ngOnInit(): void {
this.getBu2List() this.getBu2List()
this.getBu1List() this.getBu1List()
} }
onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์"
}
uploadFile() {
if (!this.selectedFile) {
alert('กรุณาเลือกไฟล์ก่อนอัปโหลด')
return
}
const formData = new FormData();
formData.append('file', this.selectedFile);
this.fileService.upload(formData, 'mbu2').subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getBu2List()
} else {
this.showAlert(response.message, 'error')
}
}, error: error => {
this.showAlert(error.message, 'error')
}
})
}
downloadFile() {
const fileName = 'IMPORT_BU.xlsx'
this.fileService.download(fileName).subscribe({
next: response => {
const url = window.URL.createObjectURL(response);
const a = document.createElement("a");
a.href = url;
a.download = fileName;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, error: error => {
this.showAlert(error.message, 'error')
}
})
}
getBu2List() { getBu2List() {
this.bu2Service.getList().subscribe(response => { this.bu2ListLoading = true
this.bu2Service.getList().subscribe({
next: response => {
this.bu2List = response this.bu2List = response
this.bu2ListLoading = false
this.onBu2TableSearchChange() this.onBu2TableSearchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => {
this.bu2ListLoading = false
this.cdr.detectChanges()
}
}) })
} }
onBu2TableSearchChange() { onBu2TableSearchChange() {
...@@ -108,37 +168,37 @@ export class DepartmentListComponent implements OnInit { ...@@ -108,37 +168,37 @@ export class DepartmentListComponent implements OnInit {
this.bu1 = new MyBu1Model(bu1 || {}) this.bu1 = new MyBu1Model(bu1 || {})
} }
showSuccess() { showAlert(text: string, type: 'success' | 'error') {
this.toastr.success('บันทึกข้อมูลสำเร็จ', 'เเจ้งเตือน', { this.toastr[type](text, 'แจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
}
showSuccessDelete() {
this.toastr.success('ลบข้อมูลสำเร็จ', 'เเจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
}
showSuccessEdit() {
this.toastr.success('เเก้ไขข้อมูลสำเร็จ', 'เเจ้งเตือน', {
timeOut: 3000, timeOut: 3000,
positionClass: 'toast-top-right', positionClass: 'toast-top-right',
}); })
} }
addBu2() { addBu2() {
this.bu2Service.post({ ...this.bu2, parent: this.bu1.bu1id }).subscribe((response: any) => { this.bu2Service.post({ ...this.bu2, parent: this.bu1.bu1id }).subscribe({
next: response => {
if (response.success) { if (response.success) {
this.showSuccess() this.showAlert(response.message, 'success')
this.getBu2List() this.getBu2List()
} else {
this.showAlert(response.message, 'error')
}
}, error: error => {
this.showAlert(error.message, 'error')
} }
}) })
} }
deleteBu2() { deleteBu2() {
this.bu2Service.delete(this.bu2).subscribe((response: any) => { this.bu2Service.delete(this.bu2).subscribe({
next: response => {
if (response.success) { if (response.success) {
this.showSuccessDelete() this.showAlert(response.message, 'success')
this.getBu2List() this.getBu2List()
} else {
this.showAlert(response.message, 'error')
}
}, error: error => {
this.showAlert(error.message, 'error')
} }
}) })
} }
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
<div class="flex justify-between"> <div class="flex justify-between">
<div class="flex pr-2"> <div class="flex pr-2">
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"> <button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
data-hs-overlay="#section-registration-upload-modal">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
นำเข้าข้อมูล นำเข้าข้อมูล
</button> </button>
<a class="mx-2 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" <a class="mx-2 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"
href="javascript:void(0);"> href="javascript:void(0);" (click)="downloadFile()">
ดาวน์โหลดตัวอย่างไฟล์ ดาวน์โหลดตัวอย่างไฟล์
</a> </a>
</div> </div>
...@@ -65,14 +66,24 @@ ...@@ -65,14 +66,24 @@
</ng-container> </ng-container>
</tr> </tr>
</thead> </thead>
<tbody *ngIf="!filterBu3Table().length"> <tbody *ngIf="bu3ListLoading">
<tr>
<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"
aria-label="loading">
<span class="sr-only">Loading...</span>
</div>
</td>
</tr>
</tbody>
<tbody *ngIf="!bu3ListLoading&&!filterBu3Table().length">
<tr> <tr>
<td class="text-center" colspan="100%"> <td class="text-center" colspan="100%">
ไม่พบข้อมูล ไม่พบข้อมูล
</td> </td>
</tr> </tr>
</tbody> </tbody>
<tbody *ngIf="filterBu3Table().length"> <tbody *ngIf="!bu3ListLoading&&filterBu3Table().length">
<tr <tr
*ngFor="let item of filterBu3Table() | slice:((bu3Table.currentPage-1) * 10) : (((bu3Table.currentPage-1) * 10) + 10);let i = index"> *ngFor="let item of filterBu3Table() | slice:((bu3Table.currentPage-1) * 10) : (((bu3Table.currentPage-1) * 10) + 10);let i = index">
<td class="text-center"> <td class="text-center">
...@@ -665,3 +676,33 @@ ...@@ -665,3 +676,33 @@
</div> </div>
</div> </div>
</div> </div>
<div id="section-registration-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)] rounded-md">
<div class="ti-modal-header bg-primary !rounded-none !rounded-t-sm">
<h5 class="text-xxl font-bold text-white">
นำเข้าฝ่าย
</h5>
</div>
<div class="ti-modal-body max-h-full overflow-hidden ti-modal-content !rounded-t-none !rounded-b-sm">
<h1 class="mt-2" style="text-align: center;">ไฟล์</h1>
<div class="mt-2 p-2">
<div class="flex rounded-md">
<input #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>
</div>
<div class="flex justify-center mt-2rem mb-1rem space-x-4">
<button type="submit" class="ti-btn ti-btn-secondary" (click)="uploadFile()"
[disabled]="!selectedFile">
อัปโหลด
</button>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
...@@ -4,6 +4,7 @@ import { Bu2Model, MyBu2Model } from 'src/app/shared/model/bu2.model'; ...@@ -4,6 +4,7 @@ import { Bu2Model, MyBu2Model } from 'src/app/shared/model/bu2.model';
import { Bu3Model, MyBu3Model } from 'src/app/shared/model/bu3.model'; import { Bu3Model, MyBu3Model } from 'src/app/shared/model/bu3.model';
import { Bu2Service } from 'src/app/shared/services/bu2.service'; import { Bu2Service } from 'src/app/shared/services/bu2.service';
import { Bu3Service } from 'src/app/shared/services/bu3.service'; import { Bu3Service } from 'src/app/shared/services/bu3.service';
import { FileService } from 'src/app/shared/services/file.service';
interface table { interface table {
currentPage: number, currentPage: number,
page: number[], page: number[],
...@@ -16,12 +17,17 @@ interface table { ...@@ -16,12 +17,17 @@ interface table {
}) })
export class SectionRegistrationComponent implements OnInit { export class SectionRegistrationComponent implements OnInit {
bu3List: Bu3Model[] = [] bu3List: Bu3Model[] = []
bu3ListLoading = false
bu3: Bu3Model = new MyBu3Model({}) bu3: Bu3Model = new MyBu3Model({})
bu3Table: table = { bu3Table: table = {
currentPage: 1, currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1), page: Array.from({ length: 1 }, (_, i) => i + 1),
search: "" search: ""
} }
selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์';
bu3Modal: table = { bu3Modal: table = {
currentPage: 1, currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1), page: Array.from({ length: 1 }, (_, i) => i + 1),
...@@ -38,17 +44,72 @@ export class SectionRegistrationComponent implements OnInit { ...@@ -38,17 +44,72 @@ export class SectionRegistrationComponent implements OnInit {
constructor(private bu3Service: Bu3Service, constructor(private bu3Service: Bu3Service,
private bu2Service: Bu2Service, private bu2Service: Bu2Service,
private toastr: ToastrService, private toastr: ToastrService,
private cdr: ChangeDetectorRef private cdr: ChangeDetectorRef,
private fileService: FileService
) { } ) { }
ngOnInit(): void { ngOnInit(): void {
this.getBu3List() this.getBu3List()
this.getBu2List() this.getBu2List()
} }
onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์"
}
uploadFile() {
if (!this.selectedFile) {
alert('กรุณาเลือกไฟล์ก่อนอัปโหลด')
return
}
const formData = new FormData();
formData.append('file', this.selectedFile);
this.fileService.upload(formData, 'mbu3').subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getBu3List()
} else {
this.showAlert(response.message, 'error')
}
}, error: error => {
this.showAlert(error.message, 'error')
}
})
}
downloadFile() {
const fileName = 'IMPORT_BU.xlsx'
this.fileService.download(fileName).subscribe({
next: response => {
const url = window.URL.createObjectURL(response);
const a = document.createElement("a");
a.href = url;
a.download = fileName;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, error: error => {
this.showAlert(error.message, 'error')
}
})
}
getBu3List() { getBu3List() {
this.bu3Service.getList().subscribe(response => { this.bu3ListLoading = true
this.bu3Service.getList().subscribe({
next: response => {
this.bu3List = response this.bu3List = response
this.bu3ListLoading = false
this.onBu3TableSearchChange() this.onBu3TableSearchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => {
this.bu3ListLoading = false
this.cdr.detectChanges()
}
}) })
} }
onBu3TableSearchChange() { onBu3TableSearchChange() {
...@@ -84,18 +145,30 @@ export class SectionRegistrationComponent implements OnInit { ...@@ -84,18 +145,30 @@ export class SectionRegistrationComponent implements OnInit {
x.edesc.includes(this.bu3Modal.search)) x.edesc.includes(this.bu3Modal.search))
} }
addBu3() { addBu3() {
this.bu3Service.post({ ...this.bu3, parent: this.bu2.bu2id }).subscribe((response:any) => { this.bu3Service.post({ ...this.bu3, parent: this.bu2.bu2id }).subscribe({
next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success')
this.getBu3List() this.getBu3List()
this.showSuccess() } else {
this.showAlert(response.message, 'error')
}
}, error: error => {
this.showAlert(error.message, 'error')
} }
}) })
} }
deleteBu3() { deleteBu3() {
this.bu3Service.delete(this.bu3).subscribe((response:any) => { this.bu3Service.delete(this.bu3).subscribe({
next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success')
this.getBu3List() this.getBu3List()
this.showSuccessDelete() } else {
this.showAlert(response.message, 'error')
}
}, error: error => {
this.showAlert(error.message, 'error')
} }
}) })
} }
...@@ -123,23 +196,11 @@ export class SectionRegistrationComponent implements OnInit { ...@@ -123,23 +196,11 @@ export class SectionRegistrationComponent implements OnInit {
this.bu2 = new MyBu2Model(bu2 || {}) this.bu2 = new MyBu2Model(bu2 || {})
} }
showSuccess() { showAlert(text: string, type: 'success' | 'error') {
this.toastr.success('บันทึกข้อมูลสำเร็จ', 'เเจ้งเตือน', { this.toastr[type](text, 'แจ้งเตือน', {
timeOut: 3000, timeOut: 3000,
positionClass: 'toast-top-right', positionClass: 'toast-top-right',
}); })
}
showSuccessEdit() {
this.toastr.success('เเก้ไขข้อมูลสำเร็จ', 'เเจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
}
showSuccessDelete() {
this.toastr.success('ลบข้อมูลสำเร็จ', 'เเจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
} }
} }
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
<div class="flex justify-between"> <div class="flex justify-between">
<div class="flex pr-2"> <div class="flex pr-2">
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"> <button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
data-hs-overlay="#sub-department-four-upload-modal">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
นำเข้าข้อมูล นำเข้าข้อมูล
</button> </button>
<a class="mx-2 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" <a class="mx-2 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"
href="javascript:void(0);"> href="javascript:void(0);" (click)="downloadFile()">
ดาวน์โหลดตัวอย่างไฟล์ ดาวน์โหลดตัวอย่างไฟล์
</a> </a>
</div> </div>
...@@ -64,14 +65,24 @@ ...@@ -64,14 +65,24 @@
</ng-container> </ng-container>
</tr> </tr>
</thead> </thead>
<tbody *ngIf="!filterBu7Table().length"> <tbody *ngIf="bu7ListLoading">
<tr>
<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"
aria-label="loading">
<span class="sr-only">Loading...</span>
</div>
</td>
</tr>
</tbody>
<tbody *ngIf="!bu7ListLoading&&!filterBu7Table().length">
<tr> <tr>
<td class="text-center" colspan="100%"> <td class="text-center" colspan="100%">
ไม่พบข้อมูล ไม่พบข้อมูล
</td> </td>
</tr> </tr>
</tbody> </tbody>
<tbody *ngIf="filterBu7Table().length"> <tbody *ngIf="!bu7ListLoading&&filterBu7Table().length">
<tr <tr
*ngFor="let item of filterBu7Table() | slice:((bu7Table.currentPage-1) * 10) : (((bu7Table.currentPage-1) * 10) + 10);let i = index"> *ngFor="let item of filterBu7Table() | slice:((bu7Table.currentPage-1) * 10) : (((bu7Table.currentPage-1) * 10) + 10);let i = index">
<td class="text-center"> <td class="text-center">
...@@ -660,3 +671,33 @@ ...@@ -660,3 +671,33 @@
</div> </div>
</div> </div>
</div> </div>
<div id="sub-department-four-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)] rounded-md">
<div class="ti-modal-header bg-primary !rounded-none !rounded-t-sm">
<h5 class="text-xxl font-bold text-white">
นำเข้าฝ่าย
</h5>
</div>
<div class="ti-modal-body max-h-full overflow-hidden ti-modal-content !rounded-t-none !rounded-b-sm">
<h1 class="mt-2" style="text-align: center;">ไฟล์</h1>
<div class="mt-2 p-2">
<div class="flex rounded-md">
<input #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>
</div>
<div class="flex justify-center mt-2rem mb-1rem space-x-4">
<button type="submit" class="ti-btn ti-btn-secondary" (click)="uploadFile()"
[disabled]="!selectedFile">
อัปโหลด
</button>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
...@@ -4,6 +4,7 @@ import { Bu6Model, MyBu6Model } from 'src/app/shared/model/bu6.model'; ...@@ -4,6 +4,7 @@ import { Bu6Model, MyBu6Model } from 'src/app/shared/model/bu6.model';
import { Bu7Model, MyBu7Model } from 'src/app/shared/model/bu7.model'; import { Bu7Model, MyBu7Model } from 'src/app/shared/model/bu7.model';
import { Bu6Service } from 'src/app/shared/services/bu6.service'; import { Bu6Service } from 'src/app/shared/services/bu6.service';
import { Bu7Service } from 'src/app/shared/services/bu7.service'; import { Bu7Service } from 'src/app/shared/services/bu7.service';
import { FileService } from 'src/app/shared/services/file.service';
interface table { interface table {
currentPage: number, currentPage: number,
...@@ -17,12 +18,17 @@ interface table { ...@@ -17,12 +18,17 @@ interface table {
}) })
export class SubDepartmentFourComponent implements OnInit { export class SubDepartmentFourComponent implements OnInit {
bu7List: Bu7Model[] = [] bu7List: Bu7Model[] = []
bu7ListLoading = false
bu7: Bu7Model = new MyBu7Model({}) bu7: Bu7Model = new MyBu7Model({})
bu7Table: table = { bu7Table: table = {
currentPage: 1, currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1), page: Array.from({ length: 1 }, (_, i) => i + 1),
search: "" search: ""
} }
selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์';
bu7Modal: table = { bu7Modal: table = {
currentPage: 1, currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1), page: Array.from({ length: 1 }, (_, i) => i + 1),
...@@ -39,17 +45,71 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -39,17 +45,71 @@ export class SubDepartmentFourComponent implements OnInit {
constructor(private bu7Service: Bu7Service, constructor(private bu7Service: Bu7Service,
private bu6Service: Bu6Service, private bu6Service: Bu6Service,
private toastr: ToastrService, private toastr: ToastrService,
private cdr: ChangeDetectorRef private cdr: ChangeDetectorRef,
private fileService: FileService
) { } ) { }
ngOnInit(): void { ngOnInit(): void {
this.getBu7List() this.getBu7List()
this.getBu6List() this.getBu6List()
} }
onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์"
}
uploadFile() {
if (!this.selectedFile) {
alert('กรุณาเลือกไฟล์ก่อนอัปโหลด')
return
}
const formData = new FormData();
formData.append('file', this.selectedFile);
this.fileService.upload(formData, 'mbu7').subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getBu7List()
} else {
this.showAlert(response.message, 'error')
}
}, error: error => {
this.showAlert(error.message, 'error')
}
})
}
downloadFile() {
const fileName = 'IMPORT_BU.xlsx'
this.fileService.download(fileName).subscribe({
next: response => {
const url = window.URL.createObjectURL(response);
const a = document.createElement("a");
a.href = url;
a.download = fileName;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, error: error => {
this.showAlert(error.message, 'error')
}
})
}
getBu7List() { getBu7List() {
this.bu7Service.getList().subscribe(response => { this.bu7ListLoading = true
this.bu7Service.getList().subscribe({
next: response => {
this.bu7List = response this.bu7List = response
this.bu7ListLoading = false
this.onBu7TableSearchChange() this.onBu7TableSearchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => {
this.bu7ListLoading = false
this.cdr.detectChanges()
}
}) })
} }
onBu7TableSearchChange() { onBu7TableSearchChange() {
...@@ -85,18 +145,30 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -85,18 +145,30 @@ export class SubDepartmentFourComponent implements OnInit {
x.edesc.includes(this.bu7Modal.search)) x.edesc.includes(this.bu7Modal.search))
} }
addBu7() { addBu7() {
this.bu7Service.post({ ...this.bu7, parent: this.bu6.bu6id }).subscribe((response: any) => { this.bu7Service.post({ ...this.bu7, parent: this.bu6.bu6id }).subscribe({
next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success')
this.getBu7List() this.getBu7List()
this.showSuccessAdd() } else {
this.showAlert(response.message, 'error')
}
}, error: error => {
this.showAlert(error.message, 'error')
} }
}) })
} }
deleteBu7() { deleteBu7() {
this.bu7Service.delete(this.bu7).subscribe((response: any) => { this.bu7Service.delete(this.bu7).subscribe({
next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success')
this.getBu7List() this.getBu7List()
this.showSuccessDelete() } else {
this.showAlert(response.message, 'error')
}
}, error: error => {
this.showAlert(error.message, 'error')
} }
}) })
} }
...@@ -124,23 +196,11 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -124,23 +196,11 @@ export class SubDepartmentFourComponent implements OnInit {
this.bu6 = new MyBu6Model(bu6 || {}) this.bu6 = new MyBu6Model(bu6 || {})
} }
showSuccessAdd() { showAlert(text: string, type: 'success' | 'error') {
this.toastr.success('บันทึกข้อมูลสำเร็จ', 'แจ้งเตือน', { this.toastr[type](text, 'แจ้งเตือน', {
timeOut: 3000, timeOut: 3000,
positionClass: 'toast-top-right', positionClass: 'toast-top-right',
}); })
}
showSuccessEdit() {
this.toastr.success('แก้ไขข้อมูลสำเร็จ', 'แจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
}
showSuccessDelete() {
this.toastr.success('ลบข้อมูลสำเร็จ', 'แจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
} }
} }
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
<div class="flex justify-between"> <div class="flex justify-between">
<div class="flex pr-2"> <div class="flex pr-2">
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"> <button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
data-hs-overlay="#sub-department-one-upload-modal">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
นำเข้าข้อมูล นำเข้าข้อมูล
</button> </button>
<a class="mx-2 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" <a class="mx-2 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"
href="javascript:void(0);"> href="javascript:void(0);" (click)=" downloadFile()">
ดาวน์โหลดตัวอย่างไฟล์ ดาวน์โหลดตัวอย่างไฟล์
</a> </a>
</div> </div>
...@@ -65,14 +66,24 @@ ...@@ -65,14 +66,24 @@
</ng-container> </ng-container>
</tr> </tr>
</thead> </thead>
<tbody *ngIf="!filterBu4Table().length"> <tbody *ngIf="bu4ListLoading">
<tr>
<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"
aria-label="loading">
<span class="sr-only">Loading...</span>
</div>
</td>
</tr>
</tbody>
<tbody *ngIf="!bu4ListLoading&&!filterBu4Table().length">
<tr> <tr>
<td class="text-center" colspan="100%"> <td class="text-center" colspan="100%">
ไม่พบข้อมูล ไม่พบข้อมูล
</td> </td>
</tr> </tr>
</tbody> </tbody>
<tbody *ngIf="filterBu4Table().length"> <tbody *ngIf="!bu4ListLoading&&filterBu4Table().length">
<tr <tr
*ngFor="let item of filterBu4Table() | slice:((bu4Table.currentPage-1) * 10) : (((bu4Table.currentPage-1) * 10) + 10);let i = index"> *ngFor="let item of filterBu4Table() | slice:((bu4Table.currentPage-1) * 10) : (((bu4Table.currentPage-1) * 10) + 10);let i = index">
<td class="text-center"> <td class="text-center">
...@@ -680,3 +691,33 @@ ...@@ -680,3 +691,33 @@
</div> </div>
</div> </div>
</div> </div>
<div id="sub-department-one-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)] rounded-md">
<div class="ti-modal-header bg-primary !rounded-none !rounded-t-sm">
<h5 class="text-xxl font-bold text-white">
นำเข้าฝ่าย
</h5>
</div>
<div class="ti-modal-body max-h-full overflow-hidden ti-modal-content !rounded-t-none !rounded-b-sm">
<h1 class="mt-2" style="text-align: center;">ไฟล์</h1>
<div class="mt-2 p-2">
<div class="flex rounded-md">
<input #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>
</div>
<div class="flex justify-center mt-2rem mb-1rem space-x-4">
<button type="submit" class="ti-btn ti-btn-secondary" (click)="uploadFile()"
[disabled]="!selectedFile">
อัปโหลด
</button>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
...@@ -4,6 +4,7 @@ import { Bu3Model, MyBu3Model } from 'src/app/shared/model/bu3.model'; ...@@ -4,6 +4,7 @@ import { Bu3Model, MyBu3Model } from 'src/app/shared/model/bu3.model';
import { Bu4Model, MyBu4Model } from 'src/app/shared/model/bu4.model'; import { Bu4Model, MyBu4Model } from 'src/app/shared/model/bu4.model';
import { Bu3Service } from 'src/app/shared/services/bu3.service'; import { Bu3Service } from 'src/app/shared/services/bu3.service';
import { Bu4Service } from 'src/app/shared/services/bu4.service'; import { Bu4Service } from 'src/app/shared/services/bu4.service';
import { FileService } from 'src/app/shared/services/file.service';
interface table { interface table {
currentPage: number, currentPage: number,
page: number[], page: number[],
...@@ -16,12 +17,17 @@ interface table { ...@@ -16,12 +17,17 @@ interface table {
}) })
export class SubDepartmentOneComponent implements OnInit { export class SubDepartmentOneComponent implements OnInit {
bu4List: Bu4Model[] = [] bu4List: Bu4Model[] = []
bu4ListLoading = false
bu4: Bu4Model = new MyBu4Model({}) bu4: Bu4Model = new MyBu4Model({})
bu4Table: table = { bu4Table: table = {
currentPage: 1, currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1), page: Array.from({ length: 1 }, (_, i) => i + 1),
search: "" search: ""
} }
selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์';
bu4Modal: table = { bu4Modal: table = {
currentPage: 1, currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1), page: Array.from({ length: 1 }, (_, i) => i + 1),
...@@ -38,17 +44,71 @@ export class SubDepartmentOneComponent implements OnInit { ...@@ -38,17 +44,71 @@ export class SubDepartmentOneComponent implements OnInit {
constructor(private bu4Service: Bu4Service, constructor(private bu4Service: Bu4Service,
private bu3Service: Bu3Service, private bu3Service: Bu3Service,
private toastr: ToastrService, private toastr: ToastrService,
private cdr: ChangeDetectorRef private cdr: ChangeDetectorRef,
private fileService: FileService
) { } ) { }
ngOnInit(): void { ngOnInit(): void {
this.getBu4List() this.getBu4List()
this.getBu3List() this.getBu3List()
} }
onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์"
}
uploadFile() {
if (!this.selectedFile) {
alert('กรุณาเลือกไฟล์ก่อนอัปโหลด')
return
}
const formData = new FormData();
formData.append('file', this.selectedFile);
this.fileService.upload(formData, 'mbu4').subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getBu4List()
} else {
this.showAlert(response.message, 'error')
}
}, error: error => {
this.showAlert(error.message, 'error')
}
})
}
downloadFile() {
const fileName = 'IMPORT_BU.xlsx'
this.fileService.download(fileName).subscribe({
next: response => {
const url = window.URL.createObjectURL(response);
const a = document.createElement("a");
a.href = url;
a.download = fileName;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, error: error => {
this.showAlert(error.message, 'error')
}
})
}
getBu4List() { getBu4List() {
this.bu4Service.getList().subscribe(response => { this.bu4ListLoading = true
this.bu4Service.getList().subscribe({
next: response => {
this.bu4List = response this.bu4List = response
this.bu4ListLoading = false
this.onBu4TableSearchChange() this.onBu4TableSearchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => {
this.bu4ListLoading = false
this.cdr.detectChanges()
}
}) })
} }
onBu4TableSearchChange() { onBu4TableSearchChange() {
...@@ -84,18 +144,30 @@ export class SubDepartmentOneComponent implements OnInit { ...@@ -84,18 +144,30 @@ export class SubDepartmentOneComponent implements OnInit {
x.edesc.includes(this.bu4Modal.search)) x.edesc.includes(this.bu4Modal.search))
} }
addBu4() { addBu4() {
this.bu4Service.post({ ...this.bu4, parent: this.bu3.bu3id }).subscribe((response: any) => { this.bu4Service.post({ ...this.bu4, parent: this.bu3.bu3id }).subscribe({
next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success')
this.getBu4List() this.getBu4List()
this.showSuccess() } else {
this.showAlert(response.message, 'error')
}
}, error: error => {
this.showAlert(error.message, 'error')
} }
}) })
} }
deleteBu4() { deleteBu4() {
this.bu4Service.delete(this.bu4).subscribe((response: any) => { this.bu4Service.delete(this.bu4).subscribe({
next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success')
this.getBu4List() this.getBu4List()
this.showSuccessDelete() } else {
this.showAlert(response.message, 'error')
}
}, error: error => {
this.showAlert(error.message, 'error')
} }
}) })
} }
...@@ -123,23 +195,11 @@ export class SubDepartmentOneComponent implements OnInit { ...@@ -123,23 +195,11 @@ export class SubDepartmentOneComponent implements OnInit {
this.bu3 = new MyBu3Model(bu3 || {}) this.bu3 = new MyBu3Model(bu3 || {})
} }
showSuccess() { showAlert(text: string, type: 'success' | 'error') {
this.toastr.success('บันทึกข้อมูลสำเร็จ', 'เเจ้งเตือน', { this.toastr[type](text, 'แจ้งเตือน', {
timeOut: 3000, timeOut: 3000,
positionClass: 'toast-top-right', positionClass: 'toast-top-right',
}); })
}
showSuccessEdit() {
this.toastr.success('เเก้ไขข้อมูลสำเร็จ', 'เเจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
}
showSuccessDelete() {
this.toastr.success('ลบข้อมูลสำเร็จ', 'เเจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
} }
} }
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
<div class="flex justify-between"> <div class="flex justify-between">
<div class="flex pr-2"> <div class="flex pr-2">
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"> <button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
data-hs-overlay="#sub-department-three-upload-modal">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
นำเข้าข้อมูล นำเข้าข้อมูล
</button> </button>
<a class="mx-2 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" <a class="mx-2 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"
href="javascript:void(0);"> href="javascript:void(0);" (click)="downloadFile()">
ดาวน์โหลดตัวอย่างไฟล์ ดาวน์โหลดตัวอย่างไฟล์
</a> </a>
</div> </div>
...@@ -64,14 +65,24 @@ ...@@ -64,14 +65,24 @@
</ng-container> </ng-container>
</tr> </tr>
</thead> </thead>
<tbody *ngIf="!filterBu6Table().length"> <tbody *ngIf="bu6ListLoading">
<tr>
<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"
aria-label="loading">
<span class="sr-only">Loading...</span>
</div>
</td>
</tr>
</tbody>
<tbody *ngIf="!bu6ListLoading&&!filterBu6Table().length">
<tr> <tr>
<td class="text-center" colspan="100%"> <td class="text-center" colspan="100%">
ไม่พบข้อมูล ไม่พบข้อมูล
</td> </td>
</tr> </tr>
</tbody> </tbody>
<tbody *ngIf="filterBu6Table().length"> <tbody *ngIf="!bu6ListLoading&&filterBu6Table().length">
<tr <tr
*ngFor="let item of filterBu6Table() | slice:((bu6Table.currentPage-1) * 10) : (((bu6Table.currentPage-1) * 10) + 10);let i = index"> *ngFor="let item of filterBu6Table() | slice:((bu6Table.currentPage-1) * 10) : (((bu6Table.currentPage-1) * 10) + 10);let i = index">
<td class="text-center"> <td class="text-center">
...@@ -660,3 +671,33 @@ ...@@ -660,3 +671,33 @@
</div> </div>
</div> </div>
</div> </div>
<div id="sub-department-three-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)] rounded-md">
<div class="ti-modal-header bg-primary !rounded-none !rounded-t-sm">
<h5 class="text-xxl font-bold text-white">
นำเข้าฝ่าย
</h5>
</div>
<div class="ti-modal-body max-h-full overflow-hidden ti-modal-content !rounded-t-none !rounded-b-sm">
<h1 class="mt-2" style="text-align: center;">ไฟล์</h1>
<div class="mt-2 p-2">
<div class="flex rounded-md">
<input #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>
</div>
<div class="flex justify-center mt-2rem mb-1rem space-x-4">
<button type="submit" class="ti-btn ti-btn-secondary" (click)="uploadFile()"
[disabled]="!selectedFile">
อัปโหลด
</button>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
...@@ -4,6 +4,7 @@ import { Bu5Model, MyBu5Model } from 'src/app/shared/model/bu5.model'; ...@@ -4,6 +4,7 @@ import { Bu5Model, MyBu5Model } from 'src/app/shared/model/bu5.model';
import { Bu6Model, MyBu6Model } from 'src/app/shared/model/bu6.model'; import { Bu6Model, MyBu6Model } from 'src/app/shared/model/bu6.model';
import { Bu5Service } from 'src/app/shared/services/bu5.service'; import { Bu5Service } from 'src/app/shared/services/bu5.service';
import { Bu6Service } from 'src/app/shared/services/bu6.service'; import { Bu6Service } from 'src/app/shared/services/bu6.service';
import { FileService } from 'src/app/shared/services/file.service';
interface table { interface table {
currentPage: number, currentPage: number,
...@@ -17,12 +18,17 @@ interface table { ...@@ -17,12 +18,17 @@ interface table {
}) })
export class SubDepartmentThreeComponent implements OnInit { export class SubDepartmentThreeComponent implements OnInit {
bu6List: Bu6Model[] = [] bu6List: Bu6Model[] = []
bu6ListLoading = false
bu6: Bu6Model = new MyBu6Model({}) bu6: Bu6Model = new MyBu6Model({})
bu6Table: table = { bu6Table: table = {
currentPage: 1, currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1), page: Array.from({ length: 1 }, (_, i) => i + 1),
search: "" search: ""
} }
selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์';
bu6Modal: table = { bu6Modal: table = {
currentPage: 1, currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1), page: Array.from({ length: 1 }, (_, i) => i + 1),
...@@ -39,17 +45,71 @@ export class SubDepartmentThreeComponent implements OnInit { ...@@ -39,17 +45,71 @@ export class SubDepartmentThreeComponent implements OnInit {
constructor(private bu6Service: Bu6Service, constructor(private bu6Service: Bu6Service,
private bu5Service: Bu5Service, private bu5Service: Bu5Service,
private toastr: ToastrService, private toastr: ToastrService,
private cdr: ChangeDetectorRef private cdr: ChangeDetectorRef,
private fileService: FileService
) { } ) { }
ngOnInit(): void { ngOnInit(): void {
this.getBu6List() this.getBu6List()
this.getBu5List() this.getBu5List()
} }
onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์"
}
uploadFile() {
if (!this.selectedFile) {
alert('กรุณาเลือกไฟล์ก่อนอัปโหลด')
return
}
const formData = new FormData();
formData.append('file', this.selectedFile);
this.fileService.upload(formData, 'mbu6').subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getBu6List()
} else {
this.showAlert(response.message, 'error')
}
}, error: error => {
this.showAlert(error.message, 'error')
}
})
}
downloadFile() {
const fileName = 'IMPORT_BU.xlsx'
this.fileService.download(fileName).subscribe({
next: response => {
const url = window.URL.createObjectURL(response);
const a = document.createElement("a");
a.href = url;
a.download = fileName;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, error: error => {
this.showAlert(error.message, 'error')
}
})
}
getBu6List() { getBu6List() {
this.bu6Service.getList().subscribe(response => { this.bu6ListLoading = true
this.bu6Service.getList().subscribe({
next: response => {
this.bu6List = response this.bu6List = response
this.bu6ListLoading = false
this.onBu6TableSearchChange() this.onBu6TableSearchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => {
this.bu6ListLoading = false
this.cdr.detectChanges()
}
}) })
} }
onBu6TableSearchChange() { onBu6TableSearchChange() {
...@@ -85,18 +145,30 @@ export class SubDepartmentThreeComponent implements OnInit { ...@@ -85,18 +145,30 @@ export class SubDepartmentThreeComponent implements OnInit {
x.edesc.includes(this.bu6Modal.search)) x.edesc.includes(this.bu6Modal.search))
} }
addBu6() { addBu6() {
this.bu6Service.post({ ...this.bu6, parent: this.bu5.bu5id }).subscribe((response: any) => { this.bu6Service.post({ ...this.bu6, parent: this.bu5.bu5id }).subscribe({
next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success')
this.getBu6List() this.getBu6List()
this.showSuccessAdd() } else {
this.showAlert(response.message, 'error')
}
}, error: error => {
this.showAlert(error.message, 'error')
} }
}) })
} }
deleteBu6() { deleteBu6() {
this.bu6Service.delete(this.bu6).subscribe((response: any) => { this.bu6Service.delete(this.bu6).subscribe({
next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success')
this.getBu6List() this.getBu6List()
this.showSuccessDelete() } else {
this.showAlert(response.message, 'error')
}
}, error: error => {
this.showAlert(error.message, 'error')
} }
}) })
} }
...@@ -124,23 +196,11 @@ export class SubDepartmentThreeComponent implements OnInit { ...@@ -124,23 +196,11 @@ export class SubDepartmentThreeComponent implements OnInit {
this.bu5 = new MyBu5Model(bu5 || {}) this.bu5 = new MyBu5Model(bu5 || {})
} }
showSuccessAdd() { showAlert(text: string, type: 'success' | 'error') {
this.toastr.success('บันทึกข้อมูลสำเร็จ', 'แจ้งเตือน', { this.toastr[type](text, 'แจ้งเตือน', {
timeOut: 3000, timeOut: 3000,
positionClass: 'toast-top-right', positionClass: 'toast-top-right',
}); })
}
showSuccessEdit() {
this.toastr.success('แก้ไขข้อมูลสำเร็จ', 'แจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
}
showSuccessDelete() {
this.toastr.success('ลบข้อมูลสำเร็จ', 'แจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
} }
} }
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
<div class="flex justify-between"> <div class="flex justify-between">
<div class="flex pr-2"> <div class="flex pr-2">
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"> <button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
data-hs-overlay="#sub-department-two-upload-modal">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
นำเข้าข้อมูล นำเข้าข้อมูล
</button> </button>
<a class="mx-2 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" <a class="mx-2 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"
href="javascript:void(0);"> href="javascript:void(0);" (click)="downloadFile()">
ดาวน์โหลดตัวอย่างไฟล์ ดาวน์โหลดตัวอย่างไฟล์
</a> </a>
</div> </div>
...@@ -64,14 +65,24 @@ ...@@ -64,14 +65,24 @@
</ng-container> </ng-container>
</tr> </tr>
</thead> </thead>
<tbody *ngIf="!filterBu5Table().length"> <tbody *ngIf="bu5ListLoading">
<tr>
<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"
aria-label="loading">
<span class="sr-only">Loading...</span>
</div>
</td>
</tr>
</tbody>
<tbody *ngIf="!bu5ListLoading&&!filterBu5Table().length">
<tr> <tr>
<td class="text-center" colspan="100%"> <td class="text-center" colspan="100%">
ไม่พบข้อมูล ไม่พบข้อมูล
</td> </td>
</tr> </tr>
</tbody> </tbody>
<tbody *ngIf="filterBu5Table().length"> <tbody *ngIf="!bu5ListLoading&&filterBu5Table().length">
<tr <tr
*ngFor="let item of filterBu5Table() | slice:((bu5Table.currentPage-1) * 10) : (((bu5Table.currentPage-1) * 10) + 10);let i = index"> *ngFor="let item of filterBu5Table() | slice:((bu5Table.currentPage-1) * 10) : (((bu5Table.currentPage-1) * 10) + 10);let i = index">
<td class="text-center"> <td class="text-center">
...@@ -586,7 +597,7 @@ ...@@ -586,7 +597,7 @@
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);" <a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#sub-department-two-alert-add-modal" (click)="addBu5(); showSuccessAdd()"> data-hs-overlay="#sub-department-two-alert-add-modal" (click)="addBu5()">
บันทึกข้อมูล บันทึกข้อมูล
</a> </a>
</div> </div>
...@@ -671,3 +682,33 @@ ...@@ -671,3 +682,33 @@
</div> </div>
</div> </div>
</div> </div>
<div id="sub-department-two-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)] rounded-md">
<div class="ti-modal-header bg-primary !rounded-none !rounded-t-sm">
<h5 class="text-xxl font-bold text-white">
นำเข้าฝ่าย
</h5>
</div>
<div class="ti-modal-body max-h-full overflow-hidden ti-modal-content !rounded-t-none !rounded-b-sm">
<h1 class="mt-2" style="text-align: center;">ไฟล์</h1>
<div class="mt-2 p-2">
<div class="flex rounded-md">
<input #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>
</div>
<div class="flex justify-center mt-2rem mb-1rem space-x-4">
<button type="submit" class="ti-btn ti-btn-secondary" (click)="uploadFile()"
[disabled]="!selectedFile">
อัปโหลด
</button>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
...@@ -4,6 +4,7 @@ import { Bu4Model, MyBu4Model } from 'src/app/shared/model/bu4.model'; ...@@ -4,6 +4,7 @@ import { Bu4Model, MyBu4Model } from 'src/app/shared/model/bu4.model';
import { Bu5Model, MyBu5Model } from 'src/app/shared/model/bu5.model'; import { Bu5Model, MyBu5Model } from 'src/app/shared/model/bu5.model';
import { Bu4Service } from 'src/app/shared/services/bu4.service'; import { Bu4Service } from 'src/app/shared/services/bu4.service';
import { Bu5Service } from 'src/app/shared/services/bu5.service'; import { Bu5Service } from 'src/app/shared/services/bu5.service';
import { FileService } from 'src/app/shared/services/file.service';
interface table { interface table {
currentPage: number, currentPage: number,
page: number[], page: number[],
...@@ -16,12 +17,17 @@ interface table { ...@@ -16,12 +17,17 @@ interface table {
}) })
export class SubDepartmentTwoComponent implements OnInit { export class SubDepartmentTwoComponent implements OnInit {
bu5List: Bu5Model[] = [] bu5List: Bu5Model[] = []
bu5ListLoading = false
bu5: Bu5Model = new MyBu5Model({}) bu5: Bu5Model = new MyBu5Model({})
bu5Table: table = { bu5Table: table = {
currentPage: 1, currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1), page: Array.from({ length: 1 }, (_, i) => i + 1),
search: "" search: ""
} }
selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์';
bu5Modal: table = { bu5Modal: table = {
currentPage: 1, currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1), page: Array.from({ length: 1 }, (_, i) => i + 1),
...@@ -38,17 +44,71 @@ export class SubDepartmentTwoComponent implements OnInit { ...@@ -38,17 +44,71 @@ export class SubDepartmentTwoComponent implements OnInit {
constructor(private bu5Service: Bu5Service, constructor(private bu5Service: Bu5Service,
private bu4Service: Bu4Service, private bu4Service: Bu4Service,
private toastr: ToastrService, private toastr: ToastrService,
private cdr: ChangeDetectorRef private cdr: ChangeDetectorRef,
private fileService: FileService
) { } ) { }
ngOnInit(): void { ngOnInit(): void {
this.getBu5List() this.getBu5List()
this.getBu4List() this.getBu4List()
} }
onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์"
}
uploadFile() {
if (!this.selectedFile) {
alert('กรุณาเลือกไฟล์ก่อนอัปโหลด')
return
}
const formData = new FormData();
formData.append('file', this.selectedFile);
this.fileService.upload(formData, 'mbu5').subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getBu5List()
} else {
this.showAlert(response.message, 'error')
}
}, error: error => {
this.showAlert(error.message, 'error')
}
})
}
downloadFile() {
const fileName = 'IMPORT_BU.xlsx'
this.fileService.download(fileName).subscribe({
next: response => {
const url = window.URL.createObjectURL(response);
const a = document.createElement("a");
a.href = url;
a.download = fileName;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, error: error => {
this.showAlert(error.message, 'error')
}
})
}
getBu5List() { getBu5List() {
this.bu5Service.getList().subscribe(response => { this.bu5ListLoading = true
this.bu5Service.getList().subscribe({
next: response => {
this.bu5List = response this.bu5List = response
this.bu5ListLoading = false
this.onBu5TableSearchChange() this.onBu5TableSearchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => {
this.bu5ListLoading = false
this.cdr.detectChanges()
}
}) })
} }
onBu5TableSearchChange() { onBu5TableSearchChange() {
...@@ -84,18 +144,30 @@ export class SubDepartmentTwoComponent implements OnInit { ...@@ -84,18 +144,30 @@ export class SubDepartmentTwoComponent implements OnInit {
x.edesc.includes(this.bu5Modal.search)) x.edesc.includes(this.bu5Modal.search))
} }
addBu5() { addBu5() {
this.bu5Service.post({ ...this.bu5, parent: this.bu4.bu4id }).subscribe((response: any) => { this.bu5Service.post({ ...this.bu5, parent: this.bu4.bu4id }).subscribe({
next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success')
this.getBu5List() this.getBu5List()
this.showSuccessAdd() } else {
this.showAlert(response.message, 'error')
}
}, error: error => {
this.showAlert(error.message, 'error')
} }
}) })
} }
deleteBu5() { deleteBu5() {
this.bu5Service.delete(this.bu5).subscribe((response: any) => { this.bu5Service.delete(this.bu5).subscribe({
next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success')
this.getBu5List() this.getBu5List()
this.showSuccessDelete() } else {
this.showAlert(response.message, 'error')
}
}, error: error => {
this.showAlert(error.message, 'error')
} }
}) })
} }
...@@ -123,23 +195,11 @@ export class SubDepartmentTwoComponent implements OnInit { ...@@ -123,23 +195,11 @@ export class SubDepartmentTwoComponent implements OnInit {
this.bu4 = new MyBu4Model(bu4 || {}) this.bu4 = new MyBu4Model(bu4 || {})
} }
showSuccessAdd() { showAlert(text: string, type: 'success' | 'error') {
this.toastr.success('บันทึกข้อมูลสำเร็จ', 'แจ้งเตือน', { this.toastr[type](text, 'แจ้งเตือน', {
timeOut: 3000, timeOut: 3000,
positionClass: 'toast-top-right', positionClass: 'toast-top-right',
}); })
}
showSuccessEdit() {
this.toastr.success('แก้ไขข้อมูลสำเร็จ', 'แจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
}
showSuccessDelete() {
this.toastr.success('ลบข้อมูลสำเร็จ', 'แจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
} }
} }
...@@ -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 { Bu2Model } from '../model/bu2.model'; import { Bu2Model } from '../model/bu2.model';
import { AlertModel } from '../model/alert.model';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
...@@ -17,16 +18,16 @@ export class Bu2Service { ...@@ -17,16 +18,16 @@ export class Bu2Service {
getById(bu2id: string): Observable<Bu2Model> { getById(bu2id: string): Observable<Bu2Model> {
return this.http.get<Bu2Model>(this.urlApi + "/" + bu2id) return this.http.get<Bu2Model>(this.urlApi + "/" + bu2id)
} }
post(body: Bu2Model) { post(body: Bu2Model): Observable<AlertModel> {
return this.http.post(this.urlApi, body) return this.http.post<AlertModel>(this.urlApi, body)
} }
delete(body: Bu2Model) { delete(body: Bu2Model): 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)
} }
} }
...@@ -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 { Bu3Model } from '../model/bu3.model'; import { Bu3Model } from '../model/bu3.model';
import { AlertModel } from '../model/alert.model';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
...@@ -17,16 +18,16 @@ import { Bu3Model } from '../model/bu3.model'; ...@@ -17,16 +18,16 @@ import { Bu3Model } from '../model/bu3.model';
getList(): Observable<Bu3Model[]> { getList(): Observable<Bu3Model[]> {
return this.http.get<Bu3Model[]>(this.urlApi + "/lists") return this.http.get<Bu3Model[]>(this.urlApi + "/lists")
} }
post(body: Bu3Model) { post(body: Bu3Model): Observable<AlertModel> {
return this.http.post(this.urlApi, body) return this.http.post<AlertModel>(this.urlApi, body)
} }
delete(body: Bu3Model) { delete(body: Bu3Model): 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
...@@ -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 { Bu4Model } from '../model/bu4.model'; import { Bu4Model } from '../model/bu4.model';
import { AlertModel } from '../model/alert.model';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
...@@ -17,16 +18,16 @@ export class Bu4Service { ...@@ -17,16 +18,16 @@ export class Bu4Service {
getById(bu4id: string): Observable<Bu4Model> { getById(bu4id: string): Observable<Bu4Model> {
return this.http.get<Bu4Model>(this.urlApi + "/" + bu4id) return this.http.get<Bu4Model>(this.urlApi + "/" + bu4id)
} }
post(body: Bu4Model) { post(body: Bu4Model): Observable<AlertModel> {
return this.http.post(this.urlApi, body) return this.http.post<AlertModel>(this.urlApi, body)
} }
delete(body: Bu4Model) { delete(body: Bu4Model): 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)
} }
} }
...@@ -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 { Bu5Model } from '../model/bu5.model'; import { Bu5Model } from '../model/bu5.model';
import { AlertModel } from '../model/alert.model';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
...@@ -17,16 +18,16 @@ export class Bu5Service { ...@@ -17,16 +18,16 @@ export class Bu5Service {
getById(bu5id: string): Observable<Bu5Model> { getById(bu5id: string): Observable<Bu5Model> {
return this.http.get<Bu5Model>(this.urlApi + "/" + bu5id) return this.http.get<Bu5Model>(this.urlApi + "/" + bu5id)
} }
post(body: Bu5Model) { post(body: Bu5Model): Observable<AlertModel> {
return this.http.post(this.urlApi, body) return this.http.post<AlertModel>(this.urlApi, body)
} }
delete(body: Bu5Model) { delete(body: Bu5Model): 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)
} }
} }
...@@ -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 { Bu6Model } from '../model/bu6.model'; import { Bu6Model } from '../model/bu6.model';
import { AlertModel } from '../model/alert.model';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
...@@ -17,16 +18,16 @@ export class Bu6Service { ...@@ -17,16 +18,16 @@ export class Bu6Service {
getById(bu6id: string): Observable<Bu6Model> { getById(bu6id: string): Observable<Bu6Model> {
return this.http.get<Bu6Model>(this.urlApi + "/" + bu6id) return this.http.get<Bu6Model>(this.urlApi + "/" + bu6id)
} }
post(body: Bu6Model) { post(body: Bu6Model): Observable<AlertModel> {
return this.http.post(this.urlApi, body) return this.http.post<AlertModel>(this.urlApi, body)
} }
delete(body: Bu6Model) { delete(body: Bu6Model): 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)
} }
} }
...@@ -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 { Bu7Model } from '../model/bu7.model'; import { Bu7Model } from '../model/bu7.model';
import { AlertModel } from '../model/alert.model';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
...@@ -17,16 +18,16 @@ export class Bu7Service { ...@@ -17,16 +18,16 @@ export class Bu7Service {
getById(bu7id: string): Observable<Bu7Model> { getById(bu7id: string): Observable<Bu7Model> {
return this.http.get<Bu7Model>(this.urlApi + "/" + bu7id) return this.http.get<Bu7Model>(this.urlApi + "/" + bu7id)
} }
post(body: Bu7Model) { post(body: Bu7Model): Observable<AlertModel> {
return this.http.post(this.urlApi, body) return this.http.post<AlertModel>(this.urlApi, body)
} }
delete(body: Bu7Model) { delete(body: Bu7Model): 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)
} }
} }
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