From a811a121cca284a718eae8aef11656a46028a416 Mon Sep 17 00:00:00 2001 From: tanshu Date: Sun, 10 Jun 2018 16:38:46 +0530 Subject: [PATCH] Added downoad to Raw Material Cost and fixed quantity not showing --- .../raw-material-cost.component.html | 5 +++- .../raw-material-cost.component.ts | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/overlord/src/app/raw-material-cost/raw-material-cost.component.html b/overlord/src/app/raw-material-cost/raw-material-cost.component.html index 2d5480f5..a685763a 100644 --- a/overlord/src/app/raw-material-cost/raw-material-cost.component.html +++ b/overlord/src/app/raw-material-cost/raw-material-cost.component.html @@ -1,6 +1,9 @@ Raw Material Cost +
@@ -66,7 +69,7 @@ Quantity Quantity - {{row.quantityQuantity | number:'1.2-2'}} + {{row.quantity | number:'1.2-2'}} diff --git a/overlord/src/app/raw-material-cost/raw-material-cost.component.ts b/overlord/src/app/raw-material-cost/raw-material-cost.component.ts index 967cd54c..7676cbef 100644 --- a/overlord/src/app/raw-material-cost/raw-material-cost.component.ts +++ b/overlord/src/app/raw-material-cost/raw-material-cost.component.ts @@ -78,4 +78,28 @@ export class RawMaterialCostComponent implements OnInit { finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'), }; } + + exportCsv() { + const data: string[] = []; + if (this.info.id) { + data.push( + 'Name, Group, Quantity, Net, Gross', + ...this.dataSource.data.map(x => x.name + ', ' + x.group + ', ' + x.quantity + ', ' + x.net + ', ' + x.gross) + ); + } else { + data.push( + 'Name, Issue, Sale, RMC', + ...this.dataSource.data.map(x => x.name + ', ' + x.issue + ', ' + x.sale + ', ' + x.rmc), + this.info.footer.name + ', ' + this.info.footer.issue + ', ' + this.info.footer.sale + ', ' + this.info.footer.rmc + ); + } + + const csvData = new Blob([data.join('\n')], {type: 'text/csv;charset=utf-8;'}); + const link = document.createElement('a'); + link.href = window.URL.createObjectURL(csvData); + link.setAttribute('download', 'raw-material-cost.csv'); + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + } }