edit pd changes

This commit is contained in:
sriram-at-840620226347 2020-02-14 17:31:14 +05:30
parent 62f0fff6fa
commit 984f90d1fe
3 changed files with 47 additions and 22 deletions

View File

@ -299,7 +299,7 @@ export class AddPdComponent implements OnInit, OnDestroy {
productabbr = '' productabbr = ''
this.subProductList = []; this.subProductList = [];
this._PDtriggerForm.controls['fk_subproduct_id'].setValue(''); this._PDtriggerForm.controls['fk_subproduct_id'].setValue('');
this._PDtriggerForm.controls['fk_pd_type'].setValue(''); // this._PDtriggerForm.controls['fk_pd_type'].setValue('');
this._PDtriggerForm.controls['fk_customer_segment'].setValue(''); this._PDtriggerForm.controls['fk_customer_segment'].setValue('');
this._PDtriggerForm.controls['loan_amount'].setValue(''); this._PDtriggerForm.controls['loan_amount'].setValue('');
} }
@ -549,8 +549,8 @@ export class AddPdComponent implements OnInit, OnDestroy {
if(this.lenderShortName != 'CLIX'){ if(this.lenderShortName != 'CLIX'){
this._PDtriggerForm.controls['fk_pd_type'].setValidators([Validators.required]); // this._PDtriggerForm.controls['fk_pd_type'].setValidators([Validators.required]);
this._PDtriggerForm.controls['fk_pd_type'].updateValueAndValidity(); // this._PDtriggerForm.controls['fk_pd_type'].updateValueAndValidity();
this._PDtriggerForm.controls['fk_customer_segment'].setValidators([Validators.required]); this._PDtriggerForm.controls['fk_customer_segment'].setValidators([Validators.required]);
this._PDtriggerForm.controls['fk_customer_segment'].updateValueAndValidity(); this._PDtriggerForm.controls['fk_customer_segment'].updateValueAndValidity();
@ -608,8 +608,8 @@ export class AddPdComponent implements OnInit, OnDestroy {
this._PDtriggerForm.controls['fk_subproduct_id'].setValue(null); this._PDtriggerForm.controls['fk_subproduct_id'].setValue(null);
} }
this._PDtriggerForm.controls['fk_pd_type'].clearValidators(); // this._PDtriggerForm.controls['fk_pd_type'].clearValidators();
this._PDtriggerForm.controls['fk_pd_type'].updateValueAndValidity(); // this._PDtriggerForm.controls['fk_pd_type'].updateValueAndValidity();
this._PDtriggerForm.controls['fk_customer_segment'].clearValidators(); this._PDtriggerForm.controls['fk_customer_segment'].clearValidators();
this._PDtriggerForm.controls['fk_customer_segment'].updateValueAndValidity(); this._PDtriggerForm.controls['fk_customer_segment'].updateValueAndValidity();
@ -640,11 +640,23 @@ export class AddPdComponent implements OnInit, OnDestroy {
this.validateAllFormFields(this._PDtriggerForm); this.validateAllFormFields(this._PDtriggerForm);
} }
// public findInvalidControls() {
// const invalid = [];
// const controls = this._PDtriggerForm.controls;
// for (const name in controls) {
// if (controls[name].invalid) {
// invalid.push(name);
// }
// }
// return invalid;
// }
// common function for both draft and process pd // common function for both draft and process pd
submitPdDetails(formValue: any, status: string) { submitPdDetails(formValue: any, status: string) {
// console.log('inside the submitPdDetails data'); // console.log('inside the submitPdDetails data');
if (this._PDtriggerForm.invalid) { if (this._PDtriggerForm.invalid) {
// let validate = this.findInvalidControls();
// console.log('validate checking',validate);
this.validateAllFormFields(this._PDtriggerForm); this.validateAllFormFields(this._PDtriggerForm);
this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!'); this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!');
return; return;

View File

@ -21,7 +21,7 @@
</mat-card-header> --> </mat-card-header> -->
<mat-card-content> <mat-card-content>
<mat-form-field style="width: 29%"> <mat-form-field style="width: 29%">
<mat-select placeholder="Lender Name" formControlName="fk_lender_id" (selectionChange)="getContactPerson()"> <mat-select placeholder="Lender Name" formControlName="fk_lender_id" (selectionChange)="getContactPerson();getProCusType($event.value,true)">
<mat-option> <mat-option>
Select Select
</mat-option> </mat-option>

View File

@ -108,17 +108,18 @@ export class EditPdMasterComponent implements OnInit {
} }
// console.log(this.userDetails) // console.log(this.userDetails)
// this.loadFormData(); // this.loadFormData();
this.getProCusType() this.getProCusType(this.userDetails.fk_entity_id,false)
this.sales_and_credit_person.credit_person=[{userid:this.userDetails.userid,user_name:this.userDetails.user_first_name+' '+this.userDetails.user_last_name}] this.sales_and_credit_person.credit_person=[{userid:this.userDetails.userid,user_name:this.userDetails.user_first_name+' '+this.userDetails.user_last_name}]
}) })
} }
getProCusType(){ getProCusType(entity_id,flag?){
console.log("u",this.userDetails) console.log("u",this.userDetails)
this._pd.getEntityPreferences(this.userDetails.fk_entity_id).subscribe(Response=>{ this._pd.getEntityPreferences(entity_id).subscribe(Response=>{
if(Response['dataStatus']){ if(Response['dataStatus']){
this.pdTypeList=Response['records'].pd_types this.pdTypeList=Response['records'].pd_types
this.customerSegmentAllList=Response['records'].customer_segments this.customerSegmentAllList=Response['records'].customer_segments
this.productAllList=Response['records'].products this.productAllList=Response['records'].products
this.productList=this.productAllList
if(this.data.records.fk_product_id){ if(this.data.records.fk_product_id){
// console.log(this.data.fk_product_id) // console.log(this.data.fk_product_id)
// console.log("vv",this.productAllList.filter(val=>val.product_id == this.data.records.fk_product_id).length > 0) // console.log("vv",this.productAllList.filter(val=>val.product_id == this.data.records.fk_product_id).length > 0)
@ -127,8 +128,17 @@ export class EditPdMasterComponent implements OnInit {
} }
} }
this.finInstitutionList=Response['records'].financial_institutions this.finInstitutionList=Response['records'].financial_institutions
if(flag == true){
this._EditPDtriggerForm.controls['fk_product_id'].setValue(Response['records'].default_product);
this._EditPDtriggerForm.controls['fk_subproduct_id'].setValue(Response['records'].default_sub_product);
this._EditPDtriggerForm.controls['fk_customer_segment'].setValue(Response['records'].default_customer_segment);
}else
if(flag ==false){
this.getLenderList();
}
} }
this.getLenderList();
// this.loadFormData(); // this.loadFormData();
}) })
} }
@ -143,7 +153,10 @@ export class EditPdMasterComponent implements OnInit {
let x = this.lenderList.filter(item => item.entity_id == this.data.records.fk_lender_id) let x = this.lenderList.filter(item => item.entity_id == this.data.records.fk_lender_id)
this.lenderBranchList = x[0]['branches']; this.lenderBranchList = x[0]['branches'];
this.lenderShortName = x[0]['short_name'] ; this.lenderShortName = x[0]['short_name'] ;
if(this.userDetails.short_name == 'CHFPL' || this.userDetails.short_name == 'CLIX'){
this.lenderList = data.records.filter(item=> item.short_name == 'CHFPL' || item.short_name == 'CLIX');
console.log('filter lender',this.lenderList);
}
this.filterProductAbbr(x[0]['short_name'],1); this.filterProductAbbr(x[0]['short_name'],1);
} }
} }
@ -204,12 +217,12 @@ export class EditPdMasterComponent implements OnInit {
this._EditPDtriggerForm.controls['fk_customer_segment'].setValue(''); this._EditPDtriggerForm.controls['fk_customer_segment'].setValue('');
this._EditPDtriggerForm.controls['loan_amount'].setValue(''); this._EditPDtriggerForm.controls['loan_amount'].setValue('');
if(this.lenderShortName == "IIB"){ //FOR INDUSLAND BANK // if(this.lenderShortName == "IIB"){ //FOR INDUSLAND BANK
// console.log("entered"); // // console.log("entered");
this._EditPDtriggerForm.controls['fk_product_id'].setValue("3") // this._EditPDtriggerForm.controls['fk_product_id'].setValue("3")
this._EditPDtriggerForm.controls['fk_pd_type'].setValue("1"); // this._EditPDtriggerForm.controls['fk_pd_type'].setValue("1");
this.getSubproductList("3",2) // this.getSubproductList("3",2)
} // }
// console.log("len",lender) // console.log("len",lender)
} }
@ -322,12 +335,12 @@ export class EditPdMasterComponent implements OnInit {
this._EditPDtriggerForm = this._fb.group({ this._EditPDtriggerForm = this._fb.group({
pd_id: [this.data.records.pd_id], pd_id: [this.data.records.pd_id],
fk_lender_id: [{value:this.data.records.fk_lender_id,disabled:true}], fk_lender_id: [{value:this.data.records.fk_lender_id,disabled: this.userDetails.short_name != 'CHFPL' && this.userDetails.short_name != 'CLIX' ? true : false}],
lender_applicant_id: [this.data.records.lender_applicant_id, Validators.compose([Validators.required])], lender_applicant_id: [this.data.records.lender_applicant_id, Validators.compose([Validators.required])],
pd_branch_id:[this.data.records.pd_branch_id, Validators.compose([Validators.required])], pd_branch_id:[this.data.records.pd_branch_id, Validators.compose([Validators.required])],
// pd_contact_person:[this.data.records.pd_contact_person], // pd_contact_person:[this.data.records.pd_contact_person],
lender_sales_person:[this.data.records.lender_sales_person], lender_sales_person:[this.data.records.lender_sales_person],
lender_credit_person:[{value:this.userDetails.userid,disabled:true}], lender_credit_person:[{value:this.userDetails.userid,disabled:false}],
imgc_fin_institute:[this.data.records.imgc_fin_institute], imgc_fin_institute:[this.data.records.imgc_fin_institute],
// pd_contact_mobileno: [this.data.records.pd_contact_mobileno, Validators.compose([Validators.minLength(10),Validators.maxLength(12),Validators.pattern('^[0-9]*$')])], // pd_contact_mobileno: [this.data.records.pd_contact_mobileno, Validators.compose([Validators.minLength(10),Validators.maxLength(12),Validators.pattern('^[0-9]*$')])],
// lender_stdcode: [stdcode, Validators.compose([Validators.minLength(3),Validators.maxLength(5)])], // lender_stdcode: [stdcode, Validators.compose([Validators.minLength(3),Validators.maxLength(5)])],
@ -651,8 +664,8 @@ export class EditPdMasterComponent implements OnInit {
// this._EditPDtriggerForm.controls['imgc_fin_institute'].setValidators([Validators.required]); // this._EditPDtriggerForm.controls['imgc_fin_institute'].setValidators([Validators.required]);
// this._EditPDtriggerForm.controls['imgc_fin_institute'].updateValueAndValidity(); // this._EditPDtriggerForm.controls['imgc_fin_institute'].updateValueAndValidity();
this._EditPDtriggerForm.controls['pd_contact_mobileno'].setValidators([Validators.required]); // this._EditPDtriggerForm.controls['pd_contact_mobileno'].setValidators([Validators.required]);
this._EditPDtriggerForm.controls['pd_contact_mobileno'].updateValueAndValidity(); // this._EditPDtriggerForm.controls['pd_contact_mobileno'].updateValueAndValidity();
this._EditPDtriggerForm.controls['fk_pd_type'].clearValidators(); this._EditPDtriggerForm.controls['fk_pd_type'].clearValidators();
this._EditPDtriggerForm.controls['fk_pd_type'].updateValueAndValidity(); this._EditPDtriggerForm.controls['fk_pd_type'].updateValueAndValidity();