Added downoad to Raw Material Cost and fixed quantity not showing
This commit is contained in:
parent
8996516978
commit
a811a121cc
@ -1,6 +1,9 @@
|
||||
<mat-card>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Raw Material Cost</mat-card-title>
|
||||
<button mat-button mat-icon-button *ngIf="dataSource.data.length" (click)="exportCsv()">
|
||||
<mat-icon>save_alt</mat-icon>
|
||||
</button>
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<form [formGroup]="form" fxLayout="column">
|
||||
@ -66,7 +69,7 @@
|
||||
<!-- Quantity Column -->
|
||||
<ng-container matColumnDef="quantity">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header class="right">Quantity Quantity</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row" class="right">{{row.quantityQuantity | number:'1.2-2'}}</mat-cell>
|
||||
<mat-cell *matCellDef="let row" class="right">{{row.quantity | number:'1.2-2'}}</mat-cell>
|
||||
<mat-footer-cell *matFooterCellDef></mat-footer-cell>
|
||||
</ng-container>
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user