From 96a1bbc17748b29d9fb1612d43b2caecf182275d Mon Sep 17 00:00:00 2001 From: saravanakumarkandasami Date: Fri, 14 Jun 2019 13:37:13 +0530 Subject: [PATCH] clix changes : ps --- src/pages/input/input.html | 4 +- src/pages/input/input.ts | 138 +++++++++++++++++++++++++++---------- 2 files changed, 102 insertions(+), 40 deletions(-) diff --git a/src/pages/input/input.html b/src/pages/input/input.html index a9b31ff..3e5afe2 100755 --- a/src/pages/input/input.html +++ b/src/pages/input/input.html @@ -67,8 +67,8 @@ - - + + -- diff --git a/src/pages/input/input.ts b/src/pages/input/input.ts index 73f2afa..b6d19d2 100755 --- a/src/pages/input/input.ts +++ b/src/pages/input/input.ts @@ -39,6 +39,7 @@ export class InputPage { users: any; pdforms:FormGroup; items: FormArray; +productAllList : any = []; proname:any = []; subproname:any=[]; customeSeg:any=[]; @@ -59,16 +60,19 @@ btnaccess:boolean = false; stateVal: any=[]; cityListVal: any=[]; pincodeListVal: any=[]; - - + lenderID:any; + productabbr:any; + isSubproductShown: boolean = true; + constructor(public navCtrl: NavController, public navParams: NavParams,public fb:FormBuilder,public pddetails:PdtriggerProvider,public shared:CognitoServiceProvider,public aws:AwsServiceProvider,public camera:Camera,public toast:ToastProvider, public qustCat:QuestionCategoryProvider,public constant:ConstantsProvider) { + this.shared.refresh(); this.pddrops(); this.pdforms = this.fb.group({ - pd_branch_id:['',Validators.compose([Validators.required])], + pd_branch_id:['',Validators.compose([Validators.required])], lenAppID:['',Validators.compose([Validators.required])], - proName:[''], + proName:[this.lenderID != 12 ? '' : Validators.compose([Validators.required])], subProName:[''], customeSeg:[''], pdType:[''], @@ -112,7 +116,7 @@ btnaccess:boolean = false; } initAddress(){ return this.fb.group({ - add1:[''], + add1:[this.lenderID != 12 ? '' : Validators.compose([Validators.required])], state:[''], city:[''], pincode:[''], @@ -140,9 +144,9 @@ btnaccess:boolean = false; } initPersonCoApplicant(){ return this.fb.group({ - applicant_title_name:[''], - mainappname:[''], - mainappcompany:[''], + applicant_title_name:[''], + mainappname:[this.lenderID != 12 ? '' : Validators.compose([Validators.required])], + mainappcompany:[this.lenderID != 12 ? '' : Validators.compose([Validators.required])], mainappphone:[''], mainapplandline:[''], applicant_stdcode:[''], @@ -182,18 +186,19 @@ inWords(event){ let userid = this.aws.getlocale(); this.aws.getuserprofile(userid).subscribe(res=> { + console.log('this.users',res); this.users = res; if(this.users.dataStatus == true) { this.users = this.users.records[0]; } - // console.log("Entity Id",this.users.fk_entity_id); + this.lenderID = this.users.fk_entity_id; //console.log("Entity branch",this.users.fk_entity_id[]) - this.qustCat.getLenderDetailsById(this.users.fk_entity_id).subscribe(res=>{ + this.qustCat.getLenderDetailsById(this.users.fk_entity_id).subscribe(res=>{ this.branchList=res['records'].branch_details.filter(val=>val.isactive==1) - // console.log("entity by Id",this.branchList); - }) + + }) }) this.qustCat.getcommondrop('TITLES').subscribe(res=>{ @@ -214,16 +219,40 @@ inWords(event){ this.proname = res; if(this.proname.dataStatus == true) { - this.proname = this.proname.records; - } + if(this.lenderID == 12){ + let getProductAbbr = this.proname.records.map(dval => dval.product_abbr); + let ClixProductAbbr = ['BL','LAEP']; + let FilteredAbbr: any = []; + FilteredAbbr = ClixProductAbbr.map(x => { + let findIndex = getProductAbbr.indexOf(x); + return this.proname.records[findIndex]; + }); + this.proname = FilteredAbbr.length > 0 ? FilteredAbbr : this.proname.records; + } + else{ + this.proname = this.proname.records; + } + } }) + /**customer segment */ this.pddetails.getcustomerseg().subscribe(res=> { + console.log(res); this.customeSeg = res; if(this.customeSeg.dataStatus == true) { - this.customeSeg = this.customeSeg.records; + if(this.lenderID == 12){ + // let filtered = this.customeSeg.filter(s => (s.customer_segment).includes('Self')); + // this.customeSeg = filtered; + this.customeSeg = this.customeSeg.records; + } + else{ + this.customeSeg = this.customeSeg.records; + } + + + } }) @@ -259,16 +288,50 @@ inWords(event){ } - getsubproduct(subprodcutdata) - { - this.subproname = this.proname.filter(product=>product.product_id == subprodcutdata)[0]; - this.subproname = this.subproname.subproducts; - this.subproname = this.subproname.filter(item => item.is_others == 0); - /**customer segment */ - this.customerSegmentList = (subprodcutdata != '4')?this.customeSeg:this.customeSeg.filter(s => (s.customer_segment).includes('Self')); - if(subprodcutdata != '4'){this.pdforms.controls['subProName'].setValue(null)} + getsubproduct(selectedProductID) + { + if(selectedProductID !== undefined && selectedProductID !== null && selectedProductID !== '') { + this.subproname = this.proname.filter(product=>product.product_id == selectedProductID)[0]; + this.productabbr = this.subproname.product_abbr; + this.subproname = this.subproname.subproducts; + this.subproname = this.subproname.filter(item => item.is_others == 0); + } + else{ + this.productabbr = '' + this.subproname = []; + + this.pdforms.controls['subProName'].setValue(''); + this.pdforms.controls['pdType'].setValue(''); + this.pdforms.controls['customeSeg'].setValue(''); + this.pdforms.controls['loanAmt'].setValue(''); + } - + /**customer segment */ + switch(this.productabbr){ + case 'BL' : + console.log(1); + this.customerSegmentList = this.customeSeg.filter(s => (s.customer_segment).includes('Self')); + this.pdforms.controls['subProName'].setValue(null); + this.isSubproductShown = false; + break; + case 'LAEP': + console.log(2); + this.customerSegmentList = this.customeSeg.filter(s => (s.customer_segment).includes('Self')); + this.pdforms.controls['subProName'].setValue(null) + this.isSubproductShown = false; + break; + default: + console.log(3); + this.customerSegmentList = this.customeSeg; + this.isSubproductShown = true; + break; + } + + if(this.lenderID == 12 && this.productabbr != ''){ + this.pdforms.controls['pdType'].setValue('1'); + this.pdforms.controls['customeSeg'].setValue('5'); + this.pdforms.controls['loanAmt'].setValue(0); + } } createItem(): FormGroup { return this.fb.group({ @@ -354,18 +417,16 @@ inWords(event){ { console.log(pddata); this.btnaccess = true; - + if(this.pdforms.invalid) { + this.toast.lenderappmessage("Please Fill all the Fields marked with '*' ") + } this.pddocdata.forEach((items,index) => { - - // console.log(217,(items)); - if(items.Name !='' && items.Name != null && items.Name !== undefined) - { - - }else - { + if(items.Name !='' && items.Name != null && items.Name !== undefined){} + else{ this.pddocdata[index] = {'image':items.image,'Name':'DocNames-'+index+1}; } }); + let lender_landline_no; let applicant_landline_no; @@ -381,7 +442,7 @@ inWords(event){ lender_landline_no = ''; } - // console.log('226',this.pddocdata); + let pdstatus:any; if(pddata.address_field[0].add1 !='' && pddata.address_field[0].city !='' && pddata.customeSeg !='' && pddata.lenAppID !='' && pddata.loanAmt !='' && pddata.mainappcompany !='' && pddata.mainappname !='' && pddata.mainappphone !='' && pddata.pdType !='' && pddata.pdcontactperson !='' && pddata.pdcontectno !='' && pddata.address_field[0].pincode !='' && pddata.proName !='' && pddata.address_field[0].state !='' && pddata.subProName !='') { @@ -389,20 +450,23 @@ inWords(event){ }else{ pdstatus = "DRAFT"; } + let proname = pddata.proName; let subprodcut = pddata.subProName; let pdtype = pddata.pdType; let customeSeg = pddata.customeSeg; var addres:any; + if(pddata.address_field[0].add1!=''){ addres=pddata.address_field[0].add1.toUpperCase(); } let state = pddata.address_field[0].state; let city = pddata.address_field[0].city; + let pdDetailsData = { 'fk_lender_id':this.users.fk_entity_id, - 'pd_branch_id':pddata.pd_branch_id, + 'pd_branch_id':pddata.pd_branch_id, 'fk_entity_billing_id':'', 'lender_applicant_id':pddata.lenAppID, 'pd_date_of_initiation':'', @@ -449,7 +513,7 @@ inWords(event){ let pd_applicant_details:any =[ { 'applicant_title_name':pddata.applicant_title_name, - 'company_name': pddata.mainappcompany, + 'company_name': pddata.mainappcompany, 'applicant_name':pddata.mainappname, 'mobile_no':pddata.mainappphone, 'landline':applicant_landline_no, @@ -474,7 +538,7 @@ inWords(event){ } let values={ 'applicant_title_name':datas.applicant_title_name, - 'company_name': datas.mainappcompany, + 'company_name': datas.mainappcompany, 'applicant_name':datas.mainappname, 'mobile_no':datas.mainappphone, 'landline':coapplicant_landline_no, @@ -521,8 +585,6 @@ inWords(event){ this.toast.lenderappmessage('something went wrong Try Again'); } }); - - } searchFun(control,index,option){ console.log(control,option);