Export for daily register working

This commit is contained in:
Amritanshu Agrawal 2024-08-16 11:45:01 +05:30
parent 3b46ac97bc
commit 28c603caee

View File

@ -4,7 +4,6 @@ import { FormGroup, FormArray, FormControl, ReactiveFormsModule, Validators } fr
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatDialog } from '@angular/material/dialog';
import { MatBadgeModule } from '@angular/material/badge';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatIconModule } from '@angular/material/icon';
@ -53,6 +52,7 @@ import { MatTooltipModule } from '@angular/material/tooltip';
MatTooltipModule,
ReactiveFormsModule,
],
providers: [LocalTimePipe],
})
export class MozimoProductRegisterComponent implements OnInit {
@ViewChild(MatPaginator, { static: true }) paginator!: MatPaginator;
@ -84,7 +84,7 @@ export class MozimoProductRegisterComponent implements OnInit {
private route: ActivatedRoute,
private router: Router,
private toCsv: ToCsvService,
private dialog: MatDialog,
private localTimePipe: LocalTimePipe,
private snackBar: MatSnackBar,
public auth: AuthService,
private ser: MozimoProductRegisterService,
@ -205,11 +205,20 @@ export class MozimoProductRegisterComponent implements OnInit {
Opening: 'opening',
Received: 'received',
Sale: 'sale',
Nc: 'nc',
Display: 'display',
Ageing: 'ageing',
Variance: 'variance',
Closing: 'closing',
'Last Edit Date': 'lastEditDate',
};
const d = JSON.parse(JSON.stringify(this.dataSource.data)).map((x: MozimoProductRegisterItem) => ({
x,
}));
const d = JSON.parse(JSON.stringify(this.dataSource.data));
d.forEach(
(x: MozimoProductRegisterItem) =>
(x.lastEditDate = x.lastEditDate ? this.localTimePipe.transform(x.lastEditDate ?? '') : 'Unsaved'),
);
const csvData = new Blob([this.toCsv.toCsv(headers, d)], {
type: 'text/csv;charset=utf-8;',
});