Added downoad to Raw Material Cost and fixed quantity not showing

This commit is contained in:
tanshu
2018-06-10 16:38:46 +05:30
parent 8996516978
commit a811a121cc
2 changed files with 28 additions and 1 deletions
@@ -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);
}
}