client-info, other-income form changes : kdk
This commit is contained in:
parent
673ccb490f
commit
27a066b6e8
@ -50,7 +50,7 @@
|
||||
<div>
|
||||
<mat-form-field>
|
||||
<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-form-field>
|
||||
</div>
|
||||
|
||||
@ -63,7 +63,7 @@ export class CurrentLoanComponent implements OnInit {
|
||||
});
|
||||
this.currentLoanForm.controls['loan_details'].setValue(result);
|
||||
} else {
|
||||
control.push(this.createLoanDetail());
|
||||
// control.push(this.createLoanDetail());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<p>Other Income Details</p>
|
||||
<form [formGroup]="otherIncomeForm" class="address">
|
||||
<mat-form-field>
|
||||
<mat-select placeholder="Other Income"
|
||||
<mat-select (selectionChange)="selectedLoanChanges($event)" placeholder="Other Income"
|
||||
formControlName="other_income">
|
||||
<mat-option value="Yes">Yes</mat-option>
|
||||
<mat-option value="No">No</mat-option>
|
||||
|
||||
@ -50,18 +50,22 @@ export class OtherIncomeComponent implements OnInit {
|
||||
console.log('value', value);
|
||||
const control = <FormArray>this.otherIncomeForm.controls['income_details'];
|
||||
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) {
|
||||
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) {
|
||||
result.forEach(val => {
|
||||
control.push(this.createDetail());
|
||||
});
|
||||
this.otherIncomeForm.controls['income_details'].setValue(result);
|
||||
} else {
|
||||
control.push(this.createDetail());
|
||||
// control.push(this.createDetail());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
control.push(this.createDetail());
|
||||
@ -75,6 +79,16 @@ export class OtherIncomeComponent implements OnInit {
|
||||
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() {
|
||||
return this.fb.group({
|
||||
source: ['', Validators.compose([Validators.required])],
|
||||
@ -111,7 +125,11 @@ export class OtherIncomeComponent implements OnInit {
|
||||
records.fk_createdby = this.pdid;
|
||||
records.other_income = this.otherIncomeForm.controls['other_income'].value;
|
||||
records.otherincome_remarks = this.otherIncomeForm.controls['otherincome_remarks'].value;
|
||||
records.income_details = this.otherIncomeForm.controls['income_details'].value;
|
||||
|
||||
if (this.otherIncomeForm.controls['other_income'].value == 'Yes') {
|
||||
records.income_details = this.otherIncomeForm.controls['income_details'].value;
|
||||
}
|
||||
|
||||
console.log('data', records);
|
||||
this._pd.saveForm(records).subscribe(data => {
|
||||
console.log('data', data);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user