Merge branch 'master' of https://bitbucket.org/sriramv18/sparqsineedge
This commit is contained in:
parent
9c8cacf18d
commit
40eff8df50
602
ng6-seed/package-lock.json
generated
602
ng6-seed/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -45,7 +45,7 @@
|
||||
"core-js": "^2.6.11",
|
||||
"d3": "^4.9.1",
|
||||
"dragula": "3.7.2",
|
||||
"file-saver": "^2.0.2",
|
||||
"file-saver": "^2.0.5",
|
||||
"firebase": "^6.6.2",
|
||||
"font-awesome": "4.7.0",
|
||||
"hammerjs": "2.0.8",
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
import { ExcelExportDirective } from './excel-export.directive';
|
||||
|
||||
describe('ExcelExportDirective', () => {
|
||||
it('should create an instance', () => {
|
||||
const directive = new ExcelExportDirective();
|
||||
expect(directive).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,19 @@
|
||||
import { Directive, Input, HostListener } from '@angular/core';
|
||||
import { ExcelExportService } from '../excel-export-service/excel-export.service';
|
||||
|
||||
@Directive({
|
||||
selector: '[appExcelExport]'
|
||||
})
|
||||
export class ExcelExportDirective {
|
||||
|
||||
constructor(private excelExportService:ExcelExportService) { }
|
||||
|
||||
@Input('appExcelExport') customers: any[];
|
||||
@Input() fileName: string;
|
||||
|
||||
@HostListener('click', ['$event']) onClick($event) {
|
||||
console.log('clicked: ' + $event);
|
||||
this.excelExportService.exportExcel(this.customers, this.fileName);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ExcelExportService } from './excel-export.service';
|
||||
|
||||
describe('ExcelExportService', () => {
|
||||
beforeEach(() => TestBed.configureTestingModule({}));
|
||||
|
||||
it('should be created', () => {
|
||||
const service: ExcelExportService = TestBed.get(ExcelExportService);
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,28 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import * as FileSaver from 'file-saver';
|
||||
import * as XLSX from 'xlsx';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ExcelExportService {
|
||||
|
||||
constructor() { }
|
||||
|
||||
fileType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8';
|
||||
fileExtension = '.xlsx';
|
||||
|
||||
|
||||
public exportExcel(jsonData: any[], fileName: string): void {
|
||||
|
||||
const ws: XLSX.WorkSheet = XLSX.utils.json_to_sheet(jsonData);
|
||||
const wb: XLSX.WorkBook = { Sheets: { 'data': ws }, SheetNames: ['data'] };
|
||||
const excelBuffer: any = XLSX.write(wb, { bookType: 'xlsx', type: 'array' });
|
||||
this.saveExcelFile(excelBuffer, fileName);
|
||||
}
|
||||
|
||||
private saveExcelFile(buffer: any, fileName: string): void {
|
||||
const data: Blob = new Blob([buffer], {type: this.fileType});
|
||||
FileSaver.saveAs(data, fileName + this.fileExtension);
|
||||
}
|
||||
}
|
||||
@ -29,6 +29,7 @@ import {NotifierModule,NotifierOptions} from 'angular-notifier'
|
||||
import { MatTableExporterModule } from 'mat-table-exporter';
|
||||
import { SmcCreditComponent } from './smc-credit/smc-credit.component';
|
||||
import { SmcRemarksComponent } from './smc-remarks/smc-remarks.component';
|
||||
import { ExcelExportDirective } from './excel-export-directive/excel-export.directive';
|
||||
|
||||
|
||||
const pdCustomNotifierOptions: NotifierOptions = {
|
||||
@ -98,8 +99,8 @@ const pdCustomNotifierOptions: NotifierOptions = {
|
||||
MatDatepickerModule,
|
||||
MatTableExporterModule,MatDialogModule
|
||||
],
|
||||
exports: [MatExpansionModule,SmcRemarksComponent],
|
||||
declarations: [PdMisComponent, SmcCreditComponent, SmcRemarksComponent],
|
||||
exports: [MatExpansionModule,SmcRemarksComponent,ExcelExportDirective],
|
||||
declarations: [PdMisComponent, SmcCreditComponent, SmcRemarksComponent, ExcelExportDirective],
|
||||
providers:[ReportsService,{provide: MAT_DATE_LOCALE, useValue: 'en-GB'},{provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]},
|
||||
{provide: MAT_DATE_FORMATS, useValue: MAT_MOMENT_DATE_FORMATS},],
|
||||
entryComponents:[SmcRemarksComponent]
|
||||
|
||||
@ -4,8 +4,10 @@
|
||||
<div class="ml-xs mr-xs" style="width: 100%;">
|
||||
<mat-card-title><span>MW Credit PD MIS Report </span>
|
||||
|
||||
<button class="btn_export" mat-raised-button color="primary" (click)="exp.exportTable('xlsx',{fileName:'SMC Credit PD MIS Report'})" [disabled]="dataLength == 0 ? true : false || dataLength == -1 ? true : false" >Excel Export</button>
|
||||
<!-- <button class="btn_export" mat-raised-button color="primary" (click)="exp.exportTable('xlsx',{fileName:'SMC Credit PD MIS Report'})" [disabled]="dataLength == 0 ? true : false || dataLength == -1 ? true : false" >Excel Export</button> -->
|
||||
|
||||
<button class="btn_export" mat-raised-button color="primary" [appExcelExport]="exportExcelTableData" fileName="customers" [disabled]="dataLength == 0 ? true : false || dataLength == -1 ? true : false" >Excel Export</button>
|
||||
|
||||
<!-- (click)="ExportTOExcel()" -->
|
||||
</mat-card-title>
|
||||
</div>
|
||||
|
||||
@ -9,6 +9,7 @@ import { SalesPdService } from 'app/sales-pd/services/sales-pd.service';
|
||||
import { ReportsService } from '../reports.service';
|
||||
import {SmcRemarksComponent}from '../smc-remarks/smc-remarks.component';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { ExcelExportService } from '../excel-export-service/excel-export.service';
|
||||
@Component({
|
||||
selector: 'app-smc-credit',
|
||||
templateUrl: './smc-credit.component.html',
|
||||
@ -50,9 +51,11 @@ export class SmcCreditComponent implements OnInit {
|
||||
];
|
||||
expandStatus: boolean=true;
|
||||
|
||||
|
||||
customers: any = [];
|
||||
exportExcelTableData: any;
|
||||
excelExportData: any = [];
|
||||
|
||||
constructor(private reportService:ReportsService,private dialog: MatDialog,private router:Router,private route: ActivatedRoute,private form_builder:FormBuilder,private notifier:NotifierService) {
|
||||
constructor(private excelExportService:ExcelExportService,private reportService:ReportsService,private dialog: MatDialog,private router:Router,private route: ActivatedRoute,private form_builder:FormBuilder,private notifier:NotifierService) {
|
||||
this.reportform = this.form_builder.group({
|
||||
from_date:[null],to_date:[null],officer_name:[null],lender_id:[null]});
|
||||
|
||||
@ -79,6 +82,7 @@ export class SmcCreditComponent implements OnInit {
|
||||
// }
|
||||
this.dataSource.data = this.api_data;
|
||||
this.Loading = false;
|
||||
|
||||
}else{
|
||||
this.dataLength = 0;
|
||||
// this.Loading = true;
|
||||
@ -139,6 +143,11 @@ export class SmcCreditComponent implements OnInit {
|
||||
pageChange(e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
// export() {
|
||||
// this.excelExportService.exportExcel(this.customers, 'customers');
|
||||
// }
|
||||
|
||||
searchPanel(){
|
||||
this.Loading=true;
|
||||
this.reportform.value.from_date=this.pipe.transform(this.reportform.value.from_date,'yyyy-MM-dd')
|
||||
@ -150,6 +159,23 @@ export class SmcCreditComponent implements OnInit {
|
||||
|
||||
this.dataSource.data=res['records'];
|
||||
this.dataLength=res['records'].length;
|
||||
|
||||
this.excelExportData = res['records']
|
||||
console.log(this.excelExportData)
|
||||
// return;
|
||||
this.exportExcelTableData = this.excelExportData.map(val=>{
|
||||
console.log('excelExport',val)
|
||||
return {
|
||||
pd_sno:val.pd_sno,
|
||||
applicant_name:val.applicant_name,
|
||||
type_name:val.type_name,
|
||||
abbr:val.abbr,
|
||||
officer_name:val.officer_name,
|
||||
pd_status:val.pd_status,
|
||||
updatedon:val.updatedon
|
||||
}
|
||||
})
|
||||
|
||||
setTimeout(()=>{
|
||||
console.log(this.exp);
|
||||
})
|
||||
@ -160,6 +186,8 @@ export class SmcCreditComponent implements OnInit {
|
||||
this.scroll_table.nativeElement.scrollIntoView({block:"end"})
|
||||
console.log("Console",this.scroll_table,this.table,this.exp)
|
||||
})
|
||||
|
||||
|
||||
|
||||
if(this.dataLength == 0){
|
||||
console.log("data length",this.dataLength)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user