-downloads
-subscribe project
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
<!-- <app-main-dashboard></app-main-dashboard> -->
|
||||
<app-main-manager></app-main-manager>
|
||||
<app-main-manager (documentDownload)="OnDownloadPrjDoc($event)"></app-main-manager>
|
||||
|
||||
@@ -62,7 +62,46 @@ export class MainManagerContentComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
OnDownloadPrjDoc(value: any): void {
|
||||
let uri = `/api/ttc/projectdownload`;
|
||||
let param = {
|
||||
prjseq: value
|
||||
}
|
||||
|
||||
// isBlob = true
|
||||
this.generalService.getRequest(uri, param, true).subscribe({
|
||||
next: (blob: Blob) => {
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `เอกสาร_โครงการ_${value}.zip`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
window.URL.revokeObjectURL(url);
|
||||
|
||||
const mockResult = {
|
||||
code: '200',
|
||||
message: 'Download Successful',
|
||||
message_th: 'ดาวน์โหลดเอกสารสำเร็จเรียบร้อย'
|
||||
};
|
||||
// this.generalService.trowApi(mockResult);
|
||||
},
|
||||
error: (error: any) => {
|
||||
if (error.status === 404) {
|
||||
// แจ้งเตือนเฉพาะเจาะจง
|
||||
this.generalService.trowApi({
|
||||
code: '404',
|
||||
message: 'No documents found',
|
||||
message_th: 'ไม่พบเอกสารแนบของโครงการนี้'
|
||||
});
|
||||
} else {
|
||||
// Error อื่นๆ (500, etc.)
|
||||
this.generalService.trowApi(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// OnSetupDashboard(value: any, setupFirst: boolean): void {
|
||||
// const uri = '/api/web/accountingSetup';
|
||||
|
||||
Reference in New Issue
Block a user