client-info, other-income form changes : kdk

This commit is contained in:
dineshkumarkannan 2018-11-17 16:29:53 +05:30
parent 673ccb490f
commit 27a066b6e8
4 changed files with 25 additions and 7 deletions

View File

@ -50,7 +50,7 @@
<div> <div>
<mat-form-field> <mat-form-field>
<mat-select (selectionChange)="selectedFreqPurchase($event)" placeholder="Select Frequency of Purchase" formControlName="frequency_of_purchase"> <mat-select (selectionChange)="selectedFreqPurchase($event)" placeholder="Select Frequency of Purchase" formControlName="frequency_of_purchase">
<mat-option *ngFor="let feq of m_freqOfPurchase" [value]="feq.id">{{ feq.name }}</mat-option> <mat-option *ngFor="let feq of m_freqOfPurchase" [value]="feq.frequency_id">{{ feq.name }}</mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
</div> </div>

View File

@ -63,7 +63,7 @@ export class CurrentLoanComponent implements OnInit {
}); });
this.currentLoanForm.controls['loan_details'].setValue(result); this.currentLoanForm.controls['loan_details'].setValue(result);
} else { } else {
control.push(this.createLoanDetail()); // control.push(this.createLoanDetail());
} }
} }
} else { } else {

View File

@ -21,7 +21,7 @@
<p>Other Income Details</p> <p>Other Income Details</p>
<form [formGroup]="otherIncomeForm" class="address"> <form [formGroup]="otherIncomeForm" class="address">
<mat-form-field> <mat-form-field>
<mat-select placeholder="Other Income" <mat-select (selectionChange)="selectedLoanChanges($event)" placeholder="Other Income"
formControlName="other_income"> formControlName="other_income">
<mat-option value="Yes">Yes</mat-option> <mat-option value="Yes">Yes</mat-option>
<mat-option value="No">No</mat-option> <mat-option value="No">No</mat-option>

View File

@ -50,18 +50,22 @@ export class OtherIncomeComponent implements OnInit {
console.log('value', value); console.log('value', value);
const control = <FormArray>this.otherIncomeForm.controls['income_details']; const control = <FormArray>this.otherIncomeForm.controls['income_details'];
if (value.status == 200) { if (value.status == 200) {
this.otherIncomeForm.controls['other_income'].setValue(value.records.other_income);
this.otherIncomeForm.controls['otherincome_remarks'].setValue(value.records.otherincome_remarks);
if (value.records.other_income == 'Yes') {
var result = Object.keys(value.records.income_details).map(function(key) { var result = Object.keys(value.records.income_details).map(function(key) {
return value.records.income_details[key]; return value.records.income_details[key];
}); });
this.otherIncomeForm.controls['other_income'].setValue(value.records.other_income);
this.otherIncomeForm.controls['otherincome_remarks'].setValue(value.records.otherincome_remarks);
if (result.length > 0) { if (result.length > 0) {
result.forEach(val => { result.forEach(val => {
control.push(this.createDetail()); control.push(this.createDetail());
}); });
this.otherIncomeForm.controls['income_details'].setValue(result); this.otherIncomeForm.controls['income_details'].setValue(result);
} else { } else {
control.push(this.createDetail()); // control.push(this.createDetail());
}
} }
} else { } else {
control.push(this.createDetail()); control.push(this.createDetail());
@ -75,6 +79,16 @@ export class OtherIncomeComponent implements OnInit {
income_details: this.fb.array([]) income_details: this.fb.array([])
}); });
} }
selectedLoanChanges(e): void {
if (e.value == 'Yes') {
const control = <FormArray>this.otherIncomeForm.controls['income_details'];
control.push(this.createDetail());
} else if (e.value == 'No') {
const arr = <FormArray>this.otherIncomeForm.controls.income_details;
arr.removeAt(0);
}
}
createDetail() { createDetail() {
return this.fb.group({ return this.fb.group({
source: ['', Validators.compose([Validators.required])], source: ['', Validators.compose([Validators.required])],
@ -111,7 +125,11 @@ export class OtherIncomeComponent implements OnInit {
records.fk_createdby = this.pdid; records.fk_createdby = this.pdid;
records.other_income = this.otherIncomeForm.controls['other_income'].value; records.other_income = this.otherIncomeForm.controls['other_income'].value;
records.otherincome_remarks = this.otherIncomeForm.controls['otherincome_remarks'].value; records.otherincome_remarks = this.otherIncomeForm.controls['otherincome_remarks'].value;
if (this.otherIncomeForm.controls['other_income'].value == 'Yes') {
records.income_details = this.otherIncomeForm.controls['income_details'].value; records.income_details = this.otherIncomeForm.controls['income_details'].value;
}
console.log('data', records); console.log('data', records);
this._pd.saveForm(records).subscribe(data => { this._pd.saveForm(records).subscribe(data => {
console.log('data', data); console.log('data', data);