diff --git a/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.html b/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.html index ce7513af8..340bb94c7 100644 --- a/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.html +++ b/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.html @@ -1,164 +1,196 @@ -
- -
-
-
- -
PD Details
- -
- - - - - - {{LL.lender_hierarchy}} - - You must include a Pick up Lender Name. - - - - - - - - You must include Lender Applicant Id. - - - - - - {{PL.name}} - - - - - - - - - {{SPL.name}} - - - - - - - {{CSL.name}} - - - - - - - {{PDL.type_name}} - - - - - - - - - - + + +
+
+
+ +
PD Details
+ +
+ - - - + + + + {{LL.lender_hierarchy}} + + You must include a Pick up Lender Name. + + + + + + + + You must include Lender Applicant Id. + + + + + + {{PL.name}} + + + - - - - - - ` - {{CL.name}} - - - - - - - - {{SL.name}} - - - - - - - -
- -
-
-
-
-
- -
Main Applicant Details
- - - - - - - - - - - - - - - - - - -
-
-
-
-
- - -
{{PDtriggerForm.controls.items.controls[i].controls.label.value}} {{i+1}}
-
- - - - - - + + + + + {{SPL.name}} + + + + + + + {{CSL.name}} + + + + + + + {{PDL.type_name}} + + + + + + + + + + + + + + + + + + + + + ` + {{CL.name}} + + + + + + + + {{SL.name}} + + + + + + +
-
-
+ + +
+
+
+
+ +
Main Applicant Details
+ + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + +
{{PDtriggerForm.controls.items.controls[i].controls.label.value}} {{i+1}}
+
+ + + + + + +
+
+
+
+
+ +
+ + + + + + +
- -
- - - - -
-
- - - - - -
- - - + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + \ No newline at end of file diff --git a/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.ts b/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.ts index ffc9a5490..859a3f9b7 100644 --- a/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.ts +++ b/ng6-seed/src/app/pd-triger/add-pd/add-pd.component.ts @@ -2,6 +2,7 @@ import { Component, OnInit, ViewEncapsulation } from '@angular/core'; import { FormBuilder, FormGroup, Validators, FormControl, FormArray } from '@angular/forms'; import { CustomValidators } from 'ng2-validation'; import { PdTrigerService } from '../pd-service/pd-triger.service'; +import { AwsService } from '../../AwsService/aws.service'; @Component({ selector: 'app-add-pd', @@ -25,10 +26,14 @@ export class AddPdComponent implements OnInit { // Dynamic co applicant createWithLongContent = false; dynamicCoApplicant = []; - constructor(private _fb: FormBuilder, - private _pd: PdTrigerService) { } + constructor(private _fb: FormBuilder, + private _pd: PdTrigerService, private _aws:AwsService) { } + public totalfiles: Array =[]; + public totalFileName = []; + public lengthCheckToaddMore =0; ngOnInit() { + this.PDtriggerForm = this._fb.group({ fk_lender_id: [null, Validators.compose([Validators.required])], lender_applicant_id: [null, Validators.compose([Validators.required])], @@ -36,7 +41,7 @@ export class AddPdComponent implements OnInit { fk_subproduct_id: [null, Validators.compose([Validators.required])], fk_pd_type: [null, Validators.compose([Validators.required])], fk_customer_segment: [null, Validators.compose([Validators.required])], - loan_amount: [null], + loan_amount: [null, Validators.compose([Validators.required])], applicant_name: [null, Validators.compose([Validators.required])], mobile_no: [null, Validators.compose([Validators.required])], email: [null, Validators.compose([Validators.required, CustomValidators.email])], @@ -45,8 +50,9 @@ export class AddPdComponent implements OnInit { addressline3: [null], fk_city: [null, Validators.compose([Validators.required])], fk_state: [null, Validators.compose([Validators.required])], -   pincode : [null], - items: this._fb.array([]) +   pincode : [null, Validators.compose([Validators.required])], + items: this._fb.array([]), + documents: this._fb.array([]) }); this._pd.getAllMasterDatas('CITY') @@ -142,11 +148,132 @@ this._pd.getAllMasterDatas('PDTYPE') this.items.push(this.createItem()); } } - submitPdDetails() { - if(this.PDtriggerForm.valid){ - var my_array = this.PDtriggerForm.value; - Object.keys(my_array).forEach((key) => ( my_array[key] == null) && delete my_array[key]); + + addMoreDocs() { + if(this.totalfiles.length!=0){ + + + if( this.documents.value[0].doc_name != "" && ((this.lengthCheckToaddMore) === (this.totalfiles.length)) ) + { + this.documents.insert(0, this.generateDocuments()) + this.lengthCheckToaddMore=this.lengthCheckToaddMore+1; } } + else if(this.totalfiles.length===0 && this.lengthCheckToaddMore===0){ + this.documents.insert(0, this.generateDocuments()) + this.lengthCheckToaddMore=this.lengthCheckToaddMore+1; + } + } + generateDocuments(): FormGroup { + return this._fb.group({ + doc_name: [null, Validators.compose([Validators.required])], + documentFile : [null, Validators.compose([Validators.required])], + }); + } + get documents(): FormArray { + return this.PDtriggerForm.get('documents') as FormArray; + }; + + removeItem(index: number) { + this.totalfiles.splice(index,1); + this.totalFileName.splice(index,1); + this.documents.removeAt(index); + this.lengthCheckToaddMore=this.lengthCheckToaddMore-1; + } + + public fileSelectionEvent(fileInput: any,oldIndex:number) { + + + if (fileInput.target.files && fileInput.target.files[0]) { + var reader = new FileReader(); + reader.onload = (event: any) => { + } + + if(oldIndex==0) + { + this.totalfiles.unshift((fileInput.target.files[0])) + this.totalFileName.unshift(fileInput.target.files[0].name) + } + else + { + this.totalfiles[oldIndex]=(fileInput.target.files[0]); + this.totalFileName[oldIndex]=fileInput.target.files[0].name + } + + reader.readAsDataURL(fileInput.target.files[0]); + } + + if(this.totalfiles.length == 1) + { + this.lengthCheckToaddMore=1; + } + } + submitPdDetails(formValue: any) { + if(this.PDtriggerForm.valid){ + // let my_array = this.PDtriggerForm.value; + // Object.keys(my_array).forEach((key) => ( my_array[key] == null) && delete my_array[key]); + let pd_details:any={ + "fk_lender_id":formValue.fk_lender_id, + "lender_applicant_id":formValue.lender_applicant_id, + "fk_product_id":formValue.fk_product_id.product_id, + "fk_subproduct_id":formValue.fk_subproduct_id.subproduct_id, + "fk_pd_type":formValue.fk_pd_type, + "fk_customer_segment":formValue.fk_customer_segment, + "loan_amount":formValue.loan_amount, + "addressline1":formValue.addressline1, + "addressline2":formValue.addressline2, + "addressline3":formValue.addressline3, + "fk_city":formValue.fk_city.city_id, + "fk_state":formValue.fk_state.state_id, + "pincode ":formValue.pincode , + "fk_createdby" : this._aws.getlocale(), + "createdon": new Date().toJSON().slice(0,19).replace('T',' ') + }; + let pd_applicant_details : any=[{ + "applicant_name":formValue.applicant_name, + "email":formValue.email, + "mobile_no":formValue.mobile_no, + "applicant_type":1, + "relationship":"", + }]; + formValue.items.forEach((itemElement, itemIndex) => { + let obj1 = { + "applicant_name":itemElement.coapplicantName, + "relationship":itemElement.relationship, + "email":"", + "mobile_no":"", + "applicant_type":0, + } + pd_applicant_details.push(obj1) + }); + + // docs details + let pd_form: FormData = new FormData(); + + for(let j=0;jthis.totalfiles[j]) + } + + //reverseFileNames=this.totalFileName.reverse(); + + let AllFilesObj= [] + + formValue.documents.forEach((element, index) => { + // let eachObj= + // { + // 'doc_name' : element.doc_name, + // 'file_name' : this.totalFileName[index] + // } + AllFilesObj.push(element.doc_name); + }); + pd_form.append("pd_details",JSON.stringify(pd_details)) + pd_form.append("pd_applicant_details",JSON.stringify(pd_applicant_details)) + pd_form.append("pd_document_titles",JSON.stringify(AllFilesObj)) + + this._pd.addPdDetails(pd_form).subscribe(); + } + } } diff --git a/ng6-seed/src/app/pd-triger/pd-service/pd-triger.service.ts b/ng6-seed/src/app/pd-triger/pd-service/pd-triger.service.ts index e0139e295..f5048b551 100644 --- a/ng6-seed/src/app/pd-triger/pd-service/pd-triger.service.ts +++ b/ng6-seed/src/app/pd-triger/pd-service/pd-triger.service.ts @@ -32,6 +32,12 @@ export class PdTrigerService { catchError(this.handleError('role', [])) ) } + addPdDetails(pdForm: any): Observable { + return this._http.post(this.apiUrl+"triggerNewPD", pdForm) + .pipe( + catchError(this.handleError('operation', [])) + ) + } private handleError(operation = 'operation', result?: T) { return (error: any): Observable => { diff --git a/ng6-seed/src/app/pd-triger/pd-triger.module.ts b/ng6-seed/src/app/pd-triger/pd-triger.module.ts index 2e161ca0a..4bbf56394 100644 --- a/ng6-seed/src/app/pd-triger/pd-triger.module.ts +++ b/ng6-seed/src/app/pd-triger/pd-triger.module.ts @@ -8,7 +8,7 @@ import { MatRadioModule, MatButtonModule,MatTableModule,MatPaginatorModule, MatProgressBarModule,MatDialogModule, MatSortModule, - MatToolbarModule,MatSelectModule } from '@angular/material'; + MatToolbarModule,MatSelectModule, MatListModule } from '@angular/material'; import {MatSlideToggleModule} from '@angular/material/slide-toggle'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload'; @@ -39,7 +39,7 @@ import { PdTrigerService } from './pd-service/pd-triger.service'; FlexLayoutModule, NgxDatatableModule, FormsModule,MatSlideToggleModule, - MatSelectModule, + MatSelectModule, MatListModule, ReactiveFormsModule, FileUploadModule, TreeModule,