other family details changes : kdk
This commit is contained in:
parent
12f806dbab
commit
3651a582bd
@ -1,4 +1,4 @@
|
||||
<form class="address" [formGroup]="familyForm">
|
||||
<!--<form class="address" [formGroup]="familyForm">
|
||||
<h2 mat-dialog-title class="paragraph_change">
|
||||
<div fxFlex="70" align="left" style="padding: 10px !important;">
|
||||
{{pageTitle}}
|
||||
@ -255,11 +255,11 @@
|
||||
</mat-dialog-actions>
|
||||
|
||||
</form>
|
||||
<notifier-container></notifier-container>
|
||||
<notifier-container></notifier-container>-->
|
||||
|
||||
|
||||
|
||||
<!--<h2 mat-dialog-title class="paragraph_change">
|
||||
<h2 mat-dialog-title class="paragraph_change">
|
||||
<div fxFlex="70" align="left" style="padding: 10px !important;">
|
||||
{{pageTitle}}
|
||||
</div>
|
||||
@ -532,4 +532,4 @@
|
||||
</mat-dialog-actions>
|
||||
|
||||
</form>
|
||||
<notifier-container></notifier-container>-->
|
||||
<notifier-container></notifier-container>
|
||||
|
||||
@ -1,269 +1,3 @@
|
||||
import {
|
||||
Component,
|
||||
OnInit,
|
||||
Inject,
|
||||
Input, Output
|
||||
} from '@angular/core';
|
||||
|
||||
import {
|
||||
FormBuilder,
|
||||
FormGroup,
|
||||
Validators,
|
||||
FormArray, FormControl, AbstractControl,
|
||||
} from '@angular/forms';
|
||||
|
||||
import { NotifierService } from 'angular-notifier';
|
||||
|
||||
import {
|
||||
MatDialog,
|
||||
MatDialogRef,
|
||||
MAT_DIALOG_DATA
|
||||
} from '@angular/material';
|
||||
/** Service */
|
||||
import { PdTrigerService } from '../../../../../pd-service/pd-triger.service';
|
||||
import {ActivatedRoute, Router} from "@angular/router";
|
||||
|
||||
@Component({
|
||||
selector: 'app-family-details',
|
||||
templateUrl: './family-details.component.html',
|
||||
styleUrls: ['./family-details.component.scss']
|
||||
})
|
||||
export class FamilyDetailsComponent implements OnInit {
|
||||
//@Input() pdid: number;
|
||||
pageTitle: string ="Other Family Details";
|
||||
pdid : string;
|
||||
form_id : number;
|
||||
|
||||
private notifier: NotifierService;
|
||||
public familyForm: FormGroup;
|
||||
public selectPerson;
|
||||
// selectPerson = [{
|
||||
// name : 'person 1',
|
||||
// id : 111
|
||||
// }, {
|
||||
// name : 'person 2',
|
||||
// id : 222
|
||||
// }];
|
||||
|
||||
earningStatus = [{
|
||||
type: 'Earning',
|
||||
id: 1
|
||||
}, {
|
||||
type: 'Non Earning',
|
||||
id: 2
|
||||
}]
|
||||
|
||||
relationData: any = [];
|
||||
occupationData: any = [];
|
||||
//personMetData: any = [];
|
||||
ownerShipData: any = [];
|
||||
customerSegData: any = [];
|
||||
// earnMemberArrCount :any ;
|
||||
// nonEarnMemberArrCount :any ;
|
||||
count : number;
|
||||
constructor(notifier: NotifierService, private fb: FormBuilder, private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private _pd: PdTrigerService,
|
||||
@Inject(MAT_DIALOG_DATA) public pd_all_details: any) {
|
||||
console.log(pd_all_details);
|
||||
this.selectPerson = this.pd_all_details.pdapplicants_detials;
|
||||
this.pdid = this.pd_all_details.pdmaster_details.pd_id;
|
||||
this.form_id = 6;
|
||||
this.notifier = notifier;
|
||||
}
|
||||
ngOnInit() {
|
||||
this.getMasterDetails('RELATIONSHIPS',1);
|
||||
this.getMasterDetails('OCCUPATIONMEMBERS',2);
|
||||
//this.getMasterDetails('PERSONSMET',3);
|
||||
this.getMasterDetails('RESIDENCEOWNERSHIP',4);
|
||||
this.getMasterDetails('CUSTOMERSEGMENT',5);
|
||||
this.initFamilyForm();
|
||||
let params: any = {};
|
||||
params.pd_id = this.pdid;
|
||||
params.pd_form_id = '6';
|
||||
this._pd.retriveForm(params).subscribe(data => {
|
||||
const control = <FormArray>this.familyForm.controls['nonEarningMembers'];
|
||||
const value = <FormArray>this.familyForm.controls['earningMembers'];
|
||||
if (data.status == 200) {
|
||||
this.familyForm.controls.selected_person.setValue(data.records.selected_person);
|
||||
this.familyForm.controls.residence_place.setValue(data.records.residence_place);
|
||||
this.familyForm.controls.residence_city.setValue(data.records.residence_city);
|
||||
this.familyForm.controls.residence_state.setValue(data.records.residence_state);
|
||||
this.familyForm.controls.residence_pin.setValue(data.records.residence_pin);
|
||||
this.familyForm.controls.residence_No_of_years.setValue(data.records.residence_No_of_years);
|
||||
this.familyForm.controls.residence_ownership.setValue(data.records.residence_ownership);
|
||||
this.familyForm.controls.ownershipOther.setValue(data.records.ownershipOther);
|
||||
this.familyForm.controls.rent.setValue(data.records.rent);
|
||||
this.familyForm.controls.total_number_of_family_members.setValue(data.records.total_number_of_family_members);
|
||||
this.familyForm.controls.family_details_form_remark.setValue(data.records.family_details_form_remark);
|
||||
this.generateFamilyMembersDetailsGetData(data.records.family_members_details);
|
||||
} else {
|
||||
// value.push(this.createMembers());
|
||||
// control.push(this.createNonMembers());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
initgenerateFamilyMembersDetailsGet(val): FormGroup {
|
||||
return this.fb.group({
|
||||
family_member_name : [val.family_member_name, Validators.compose([])],
|
||||
family_member_relationship : [val.family_member_relationship, Validators.compose([])],
|
||||
family_member_age : [val.family_member_age, Validators.compose([])],
|
||||
family_member_earning_status : [val.family_member_earning_status, Validators.compose([])],
|
||||
earning_segment: [val.earning_segment, Validators.compose([])],
|
||||
earning_gross_income_per_month: [val.earning_gross_income_per_month, Validators.compose([])],
|
||||
earning_name_of_the_employer_or_business: [val.earning_name_of_the_employer_or_business, Validators.compose([])],
|
||||
earning_number_of_years_in_employment_or_business: [val.earning_number_of_years_in_employment_or_business, Validators.compose([])],
|
||||
non_earning_occupation: [val.non_earning_occupation, Validators.compose([])],
|
||||
non_earning_if_others: [val.non_earning_if_others, Validators.compose([])],
|
||||
non_earning_if_retired_from: [val.non_earning_if_retired_from, Validators.compose([])],
|
||||
})
|
||||
}
|
||||
|
||||
generateFamilyMembersDetailsGetData(data) {
|
||||
var result = Object.keys(data).map(function (key) {
|
||||
return data[key];
|
||||
});
|
||||
if (result.length > 0) {
|
||||
for (let val of result) {
|
||||
const control = <FormArray>this.familyForm.controls['family_members_details'];
|
||||
control.push(this.initgenerateFamilyMembersDetailsGet(val));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onSearchChange(e):void {
|
||||
e.preventDefault();
|
||||
}
|
||||
public initFamilyForm(): void {
|
||||
this.familyForm = this.fb.group({
|
||||
selected_person: ['', Validators.compose([Validators.required])],
|
||||
residence_place: ['', Validators.compose([])],
|
||||
residence_city: ['', Validators.compose([])],
|
||||
residence_state: ['', Validators.compose([])],
|
||||
residence_pin: ['', Validators.compose([])],
|
||||
residence_No_of_years: ['', Validators.compose([])],
|
||||
residence_ownership: ['', Validators.compose([])],
|
||||
ownershipOther: [''],
|
||||
rent: [''],
|
||||
total_number_of_family_members: ['', Validators.compose([Validators.min(1), Validators.max(20)])],
|
||||
family_members_details: this.fb.array([]),
|
||||
family_details_form_remark: ['']
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
getNumberOfFamilyMemberDetails(){
|
||||
// alert(this.familyForm.controls.total_number_of_family_members.valid);
|
||||
if(this.familyForm.controls.total_number_of_family_members.valid){
|
||||
let totalMem = this.familyForm.get('total_number_of_family_members').value;
|
||||
const control = <FormArray>this.familyForm.controls.family_members_details;
|
||||
if(totalMem > control.length) {
|
||||
let len = totalMem - control.length;
|
||||
for(let i = 0; i < len; i++){
|
||||
control.push(this.generateFamilyMembersDetailsGet());
|
||||
}
|
||||
} else if (totalMem < control.length) {
|
||||
// control.controls.slice(0, totalMem);
|
||||
control.controls = [];
|
||||
for(let i = 0; i < totalMem; i++){
|
||||
control.push(this.generateFamilyMembersDetailsGet());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
generateFamilyMembersDetailsGet(): FormGroup {
|
||||
return this.fb.group({
|
||||
family_member_name : ['', Validators.compose([])],
|
||||
family_member_relationship : ['', Validators.compose([])],
|
||||
family_member_age : ['', Validators.compose([])],
|
||||
family_member_earning_status : ['', Validators.compose([])],
|
||||
earning_segment: ['', Validators.compose([])],
|
||||
earning_gross_income_per_month: ['', Validators.compose([])],
|
||||
earning_name_of_the_employer_or_business: ['', Validators.compose([])],
|
||||
earning_number_of_years_in_employment_or_business: ['', Validators.compose([])],
|
||||
non_earning_occupation: ['', Validators.compose([])],
|
||||
non_earning_if_others: ['', Validators.compose([])],
|
||||
non_earning_if_retired_from: ['', Validators.compose([])],
|
||||
})
|
||||
}
|
||||
|
||||
// get all master details
|
||||
getMasterDetails(table:string,type:number){
|
||||
this._pd.getAllMasterDatas(table).subscribe(
|
||||
data => {
|
||||
if (data.status == 200) {
|
||||
if(type==1){
|
||||
this.relationData=data.records.filter(item => item.isactive == 1);
|
||||
}
|
||||
else if(type==2){
|
||||
this.occupationData=data.records.filter(item => item.isactive == 1);
|
||||
}
|
||||
// else if(type==3){
|
||||
// this.personMetData=data.records.filter(item => item.isactive == 1);
|
||||
// }
|
||||
else if(type==4){
|
||||
this.ownerShipData=data.records.filter(item => item.isactive == 1);
|
||||
}
|
||||
else if(type==5){
|
||||
this.customerSegData=data.records.filter(item => item.isactive == 1);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
submitFamily() {
|
||||
if (!this.familyForm.valid) {
|
||||
return;
|
||||
}
|
||||
var records = this.familyForm.value;
|
||||
//To Remove The "Null" With Key also
|
||||
Object.keys(records).forEach((key) => (records[key] == null) && delete records[key]);
|
||||
// records.other_family_details = answerFormValues;
|
||||
records.pdid = this.pdid;
|
||||
records.formid = '6';
|
||||
// records.fk_createdby = '251';
|
||||
this._pd.saveForm(records).subscribe(data => {
|
||||
this.notifier.notify('success', 'Saved Successfully.');
|
||||
}, error => {
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
});
|
||||
}
|
||||
// validateAllFormFields(formGroup: FormGroup) {
|
||||
// Object.keys(formGroup.controls).forEach(field => {
|
||||
// const control = formGroup.get(field);
|
||||
// if (control instanceof FormControl) {
|
||||
// control.markAsTouched({onlySelf: true});
|
||||
// } else if (control instanceof FormGroup) {
|
||||
// this.validateAllFormFields(control);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// /** On Key Press Event For Age */
|
||||
// keyPress(event: any) {
|
||||
// const pattern = /[0-9]/;
|
||||
|
||||
// let inputChar = String.fromCharCode(event.charCode);
|
||||
// if (event.keyCode != 8 && !pattern.test(inputChar)) {
|
||||
// event.preventDefault();
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// =================== other family details multiple add
|
||||
|
||||
// import {
|
||||
// Component,
|
||||
// OnInit,
|
||||
@ -343,7 +77,7 @@ export class FamilyDetailsComponent implements OnInit {
|
||||
// //this.getMasterDetails('PERSONSMET',3);
|
||||
// this.getMasterDetails('RESIDENCEOWNERSHIP',4);
|
||||
// this.getMasterDetails('CUSTOMERSEGMENT',5);
|
||||
// this.initFamilyFormDetails();
|
||||
// this.initFamilyForm();
|
||||
// let params: any = {};
|
||||
// params.pd_id = this.pdid;
|
||||
// params.pd_form_id = '6';
|
||||
@ -351,19 +85,18 @@ export class FamilyDetailsComponent implements OnInit {
|
||||
// const control = <FormArray>this.familyForm.controls['nonEarningMembers'];
|
||||
// const value = <FormArray>this.familyForm.controls['earningMembers'];
|
||||
// if (data.status == 200) {
|
||||
// this.initFamilyForm(data.records);
|
||||
// // this.familyForm.controls.selected_person.setValue(data.records.selected_person);
|
||||
// // this.familyForm.controls.residence_place.setValue(data.records.residence_place);
|
||||
// // this.familyForm.controls.residence_city.setValue(data.records.residence_city);
|
||||
// // this.familyForm.controls.residence_state.setValue(data.records.residence_state);
|
||||
// // this.familyForm.controls.residence_pin.setValue(data.records.residence_pin);
|
||||
// // this.familyForm.controls.residence_No_of_years.setValue(data.records.residence_No_of_years);
|
||||
// // this.familyForm.controls.residence_ownership.setValue(data.records.residence_ownership);
|
||||
// // this.familyForm.controls.ownershipOther.setValue(data.records.ownershipOther);
|
||||
// // this.familyForm.controls.rent.setValue(data.records.rent);
|
||||
// // this.familyForm.controls.total_number_of_family_members.setValue(data.records.total_number_of_family_members);
|
||||
// // this.familyForm.controls.family_details_form_remark.setValue(data.records.family_details_form_remark);
|
||||
// // this.generateFamilyMembersDetailsGetData(data.records.family_members_details);
|
||||
// this.familyForm.controls.selected_person.setValue(data.records.selected_person);
|
||||
// this.familyForm.controls.residence_place.setValue(data.records.residence_place);
|
||||
// this.familyForm.controls.residence_city.setValue(data.records.residence_city);
|
||||
// this.familyForm.controls.residence_state.setValue(data.records.residence_state);
|
||||
// this.familyForm.controls.residence_pin.setValue(data.records.residence_pin);
|
||||
// this.familyForm.controls.residence_No_of_years.setValue(data.records.residence_No_of_years);
|
||||
// this.familyForm.controls.residence_ownership.setValue(data.records.residence_ownership);
|
||||
// this.familyForm.controls.ownershipOther.setValue(data.records.ownershipOther);
|
||||
// this.familyForm.controls.rent.setValue(data.records.rent);
|
||||
// this.familyForm.controls.total_number_of_family_members.setValue(data.records.total_number_of_family_members);
|
||||
// this.familyForm.controls.family_details_form_remark.setValue(data.records.family_details_form_remark);
|
||||
// this.generateFamilyMembersDetailsGetData(data.records.family_members_details);
|
||||
// } else {
|
||||
// // value.push(this.createMembers());
|
||||
// // control.push(this.createNonMembers());
|
||||
@ -402,60 +135,8 @@ export class FamilyDetailsComponent implements OnInit {
|
||||
// onSearchChange(e):void {
|
||||
// e.preventDefault();
|
||||
// }
|
||||
// public initFamilyFormDetails(): void {
|
||||
// public initFamilyForm(): void {
|
||||
// this.familyForm = this.fb.group({
|
||||
// family_details: this.fb.array([]),
|
||||
// family_details_form_remark: ['']
|
||||
// })
|
||||
// }
|
||||
|
||||
// public noRecordsFound: Boolean = false;
|
||||
|
||||
// public initFamilyForm(records): void {
|
||||
// // let data = [...records];
|
||||
// let recordss = {
|
||||
// "selected_person":"95",
|
||||
// "residence_place":"check ",
|
||||
// "residence_city":"check ",
|
||||
// "residence_state":"check ",
|
||||
// "residence_pin":"123456",
|
||||
// "residence_No_of_years":"2",
|
||||
// "residence_ownership":"1",
|
||||
// "ownershipOther":"",
|
||||
// "rent":"",
|
||||
// "total_number_of_family_members":"2",
|
||||
// "family_members_details":{
|
||||
// "1":{
|
||||
// "family_member_name":"name",
|
||||
// "family_member_relationship":"1",
|
||||
// "family_member_age":"21",
|
||||
// "family_member_earning_status":"1",
|
||||
// "earning_segment":"1",
|
||||
// "earning_gross_income_per_month":"12000",
|
||||
// "earning_name_of_the_employer_or_business":"check",
|
||||
// "earning_number_of_years_in_employment_or_business":"2",
|
||||
// "non_earning_occupation":"",
|
||||
// "non_earning_if_others":"",
|
||||
// "non_earning_if_retired_from":""
|
||||
// },
|
||||
// "2":{
|
||||
// "family_member_name":"chekc ",
|
||||
// "family_member_relationship":"2",
|
||||
// "family_member_age":"31",
|
||||
// "family_member_earning_status":"2",
|
||||
// "earning_segment":"",
|
||||
// "earning_gross_income_per_month":"",
|
||||
// "earning_name_of_the_employer_or_business":"",
|
||||
// "earning_number_of_years_in_employment_or_business":"",
|
||||
// "non_earning_occupation":"9",
|
||||
// "non_earning_if_others":"others check ",
|
||||
// "non_earning_if_retired_from":""
|
||||
// }
|
||||
// },
|
||||
// "family_details_form_remark":"check remark"
|
||||
// };
|
||||
// if(recordss === null) {
|
||||
// this.fb.group({
|
||||
// selected_person: ['', Validators.compose([Validators.required])],
|
||||
// residence_place: ['', Validators.compose([])],
|
||||
// residence_city: ['', Validators.compose([])],
|
||||
@ -466,47 +147,17 @@ export class FamilyDetailsComponent implements OnInit {
|
||||
// ownershipOther: [''],
|
||||
// rent: [''],
|
||||
// total_number_of_family_members: ['', Validators.compose([Validators.min(1), Validators.max(20)])],
|
||||
// family_members_details: this.fb.array([this.addFamilyMemberDetails()]),
|
||||
// });
|
||||
// } else {
|
||||
// let formData: FormGroup = this.fb.group({
|
||||
// selected_person: ['1', Validators.compose([Validators.required])],
|
||||
// residence_place: ['as', Validators.compose([])],
|
||||
// residence_city: ['as', Validators.compose([])],
|
||||
// residence_state: ['sa', Validators.compose([])],
|
||||
// residence_pin: ['sa', Validators.compose([])],
|
||||
// residence_No_of_years: ['sa', Validators.compose([])],
|
||||
// residence_ownership: ['s', Validators.compose([])],
|
||||
// ownershipOther: ['s'],
|
||||
// rent: ['as'],
|
||||
// total_number_of_family_members: ['1', Validators.compose([Validators.min(1), Validators.max(20)])],
|
||||
// family_members_details: this.fb.array([]),
|
||||
// family_details_form_remark: ['']
|
||||
// });
|
||||
|
||||
// const control = <FormArray>this.familyForm.controls['family_details'];
|
||||
// control.push(formData);
|
||||
// console.log(this.familyForm.value);
|
||||
// }
|
||||
// this.noRecordsFound = true;
|
||||
// }
|
||||
|
||||
// addFamilyMemberDetails(): void {
|
||||
|
||||
// }
|
||||
|
||||
// addMoreApplicantFamilyDetails(e): void {
|
||||
// e.stopPropagation();
|
||||
// this.initFamilyForm('chck');
|
||||
// }
|
||||
|
||||
// getNumberOfFamilyMemberDetails(inx){
|
||||
// // alert(inx);
|
||||
// let formData = <FormArray>this.familyForm.controls['family_details']['controls'][inx].controls;
|
||||
// // alert(formData['total_number_of_family_members'].value);
|
||||
// getNumberOfFamilyMemberDetails(){
|
||||
// // alert(this.familyForm.controls.total_number_of_family_members.valid);
|
||||
// if(formData['total_number_of_family_members'].valid){
|
||||
// let totalMem = formData['total_number_of_family_members'].value;
|
||||
// const control = <FormArray>this.familyForm.controls['family_details']['controls'][inx].controls.family_members_details;
|
||||
// if(this.familyForm.controls.total_number_of_family_members.valid){
|
||||
// let totalMem = this.familyForm.get('total_number_of_family_members').value;
|
||||
// const control = <FormArray>this.familyForm.controls.family_members_details;
|
||||
// if(totalMem > control.length) {
|
||||
// let len = totalMem - control.length;
|
||||
// for(let i = 0; i < len; i++){
|
||||
@ -576,12 +227,11 @@ export class FamilyDetailsComponent implements OnInit {
|
||||
// records.pdid = this.pdid;
|
||||
// records.formid = '6';
|
||||
// // records.fk_createdby = '251';
|
||||
// console.log(JSON.stringify(records));
|
||||
// // this._pd.saveForm(records).subscribe(data => {
|
||||
// // this.notifier.notify('success', 'Saved Successfully.');
|
||||
// // }, error => {
|
||||
// // this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
// // });
|
||||
// this._pd.saveForm(records).subscribe(data => {
|
||||
// this.notifier.notify('success', 'Saved Successfully.');
|
||||
// }, error => {
|
||||
// this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
// });
|
||||
// }
|
||||
// // validateAllFormFields(formGroup: FormGroup) {
|
||||
// // Object.keys(formGroup.controls).forEach(field => {
|
||||
@ -605,3 +255,408 @@ export class FamilyDetailsComponent implements OnInit {
|
||||
// // }
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// =================== other family details multiple add
|
||||
|
||||
import {
|
||||
Component,
|
||||
OnInit,
|
||||
Inject,
|
||||
Input, Output
|
||||
} from '@angular/core';
|
||||
|
||||
import {
|
||||
FormBuilder,
|
||||
FormGroup,
|
||||
Validators,
|
||||
FormArray, FormControl, AbstractControl,
|
||||
} from '@angular/forms';
|
||||
|
||||
import { NotifierService } from 'angular-notifier';
|
||||
|
||||
import {
|
||||
MatDialog,
|
||||
MatDialogRef,
|
||||
MAT_DIALOG_DATA
|
||||
} from '@angular/material';
|
||||
/** Service */
|
||||
import { PdTrigerService } from '../../../../../pd-service/pd-triger.service';
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
|
||||
@Component({
|
||||
selector: 'app-family-details',
|
||||
templateUrl: './family-details.component.html',
|
||||
styleUrls: ['./family-details.component.scss']
|
||||
})
|
||||
export class FamilyDetailsComponent implements OnInit {
|
||||
//@Input() pdid: number;
|
||||
pageTitle: string = "Other Family Details";
|
||||
pdid: string;
|
||||
form_id: number;
|
||||
|
||||
private notifier: NotifierService;
|
||||
public familyForm: FormGroup;
|
||||
public selectPerson;
|
||||
// selectPerson = [{
|
||||
// name : 'person 1',
|
||||
// id : 111
|
||||
// }, {
|
||||
// name : 'person 2',
|
||||
// id : 222
|
||||
// }];
|
||||
|
||||
earningStatus = [{
|
||||
type: 'Earning',
|
||||
id: 1
|
||||
}, {
|
||||
type: 'Non Earning',
|
||||
id: 2
|
||||
}]
|
||||
|
||||
relationData: any = [];
|
||||
occupationData: any = [];
|
||||
//personMetData: any = [];
|
||||
ownerShipData: any = [];
|
||||
customerSegData: any = [];
|
||||
// earnMemberArrCount :any ;
|
||||
// nonEarnMemberArrCount :any ;
|
||||
count: number;
|
||||
constructor(notifier: NotifierService, private fb: FormBuilder, private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private _pd: PdTrigerService,
|
||||
@Inject(MAT_DIALOG_DATA) public pd_all_details: any) {
|
||||
console.log(pd_all_details);
|
||||
this.selectPerson = this.pd_all_details.pdapplicants_detials;
|
||||
this.pdid = this.pd_all_details.pdmaster_details.pd_id;
|
||||
this.form_id = 6;
|
||||
this.notifier = notifier;
|
||||
}
|
||||
ngOnInit() {
|
||||
this.getMasterDetails('RELATIONSHIPS', 1);
|
||||
this.getMasterDetails('OCCUPATIONMEMBERS', 2);
|
||||
//this.getMasterDetails('PERSONSMET',3);
|
||||
this.getMasterDetails('RESIDENCEOWNERSHIP', 4);
|
||||
this.getMasterDetails('CUSTOMERSEGMENT', 5);
|
||||
this.initFamilyFormDetails();
|
||||
let params: any = {};
|
||||
params.pd_id = this.pdid;
|
||||
params.pd_form_id = '6';
|
||||
this._pd.retriveForm(params).subscribe(data => {
|
||||
const control = <FormArray>this.familyForm.controls['nonEarningMembers'];
|
||||
const value = <FormArray>this.familyForm.controls['earningMembers'];
|
||||
if (data.status == 200) {
|
||||
this.initFamilyForm(data.records.family_details);
|
||||
// this.familyForm.controls.selected_person.setValue(data.records.selected_person);
|
||||
// this.familyForm.controls.residence_place.setValue(data.records.residence_place);
|
||||
// this.familyForm.controls.residence_city.setValue(data.records.residence_city);
|
||||
// this.familyForm.controls.residence_state.setValue(data.records.residence_state);
|
||||
// this.familyForm.controls.residence_pin.setValue(data.records.residence_pin);
|
||||
// this.familyForm.controls.residence_No_of_years.setValue(data.records.residence_No_of_years);
|
||||
// this.familyForm.controls.residence_ownership.setValue(data.records.residence_ownership);
|
||||
// this.familyForm.controls.ownershipOther.setValue(data.records.ownershipOther);
|
||||
// this.familyForm.controls.rent.setValue(data.records.rent);
|
||||
// this.familyForm.controls.total_number_of_family_members.setValue(data.records.total_number_of_family_members);
|
||||
this.familyForm.controls.family_details_form_remark.setValue(data.records.family_details_form_remark);
|
||||
// this.generateFamilyMembersDetailsGetData(data.records.family_members_details);
|
||||
} else {
|
||||
// value.push(this.createMembers());
|
||||
// control.push(this.createNonMembers());
|
||||
this.initFamilyForm(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
initgenerateFamilyMembersDetailsGet(val): FormGroup {
|
||||
return this.fb.group({
|
||||
family_member_name: [val.family_member_name, Validators.compose([])],
|
||||
family_member_relationship: [val.family_member_relationship, Validators.compose([])],
|
||||
family_member_age: [val.family_member_age, Validators.compose([])],
|
||||
family_member_earning_status: [val.family_member_earning_status, Validators.compose([])],
|
||||
earning_segment: [val.earning_segment, Validators.compose([])],
|
||||
earning_gross_income_per_month: [val.earning_gross_income_per_month, Validators.compose([])],
|
||||
earning_name_of_the_employer_or_business: [val.earning_name_of_the_employer_or_business, Validators.compose([])],
|
||||
earning_number_of_years_in_employment_or_business: [val.earning_number_of_years_in_employment_or_business, Validators.compose([])],
|
||||
non_earning_occupation: [val.non_earning_occupation, Validators.compose([])],
|
||||
non_earning_if_others: [val.non_earning_if_others, Validators.compose([])],
|
||||
non_earning_if_retired_from: [val.non_earning_if_retired_from, Validators.compose([])],
|
||||
})
|
||||
}
|
||||
|
||||
generateFamilyMembersDetailsGetData(data) {
|
||||
var result = Object.keys(data).map(function (key) {
|
||||
return data[key];
|
||||
});
|
||||
if (result.length > 0) {
|
||||
for (let val of result) {
|
||||
const control = <FormArray>this.familyForm.controls['family_members_details'];
|
||||
control.push(this.initgenerateFamilyMembersDetailsGet(val));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onSearchChange(e): void {
|
||||
e.preventDefault();
|
||||
}
|
||||
public initFamilyFormDetails(): void {
|
||||
this.familyForm = this.fb.group({
|
||||
family_details: this.fb.array([]),
|
||||
family_details_form_remark: ['']
|
||||
})
|
||||
}
|
||||
|
||||
public noRecordsFound: Boolean = false;
|
||||
|
||||
public initFamilyForm(records): void {
|
||||
// let data = [...records];
|
||||
// let recordss = [
|
||||
// {
|
||||
// "selected_person":"51",
|
||||
// "residence_place":"as",
|
||||
// "residence_city":"as",
|
||||
// "residence_state":"sa",
|
||||
// "residence_pin":"sa",
|
||||
// "residence_No_of_years":12,
|
||||
// "residence_ownership":"1",
|
||||
// "ownershipOther":"s",
|
||||
// "rent":"as",
|
||||
// "total_number_of_family_members":2,
|
||||
// "family_members_details":[
|
||||
// {
|
||||
// "family_member_name":"ce",
|
||||
// "family_member_relationship":"2",
|
||||
// "family_member_age":"12",
|
||||
// "family_member_earning_status":"1",
|
||||
// "earning_segment":"6",
|
||||
// "earning_gross_income_per_month":"12",
|
||||
// "earning_name_of_the_employer_or_business":"21",
|
||||
// "earning_number_of_years_in_employment_or_business":"12",
|
||||
// "non_earning_occupation":null,
|
||||
// "non_earning_if_others":null,
|
||||
// "non_earning_if_retired_from":null
|
||||
// },
|
||||
// {
|
||||
// "family_member_name":"csdcs",
|
||||
// "family_member_relationship":"2",
|
||||
// "family_member_age":"21",
|
||||
// "family_member_earning_status":"1",
|
||||
// "earning_segment":"4",
|
||||
// "earning_gross_income_per_month":"as",
|
||||
// "earning_name_of_the_employer_or_business":"as",
|
||||
// "earning_number_of_years_in_employment_or_business":"sa",
|
||||
// "non_earning_occupation":"",
|
||||
// "non_earning_if_others":"",
|
||||
// "non_earning_if_retired_from":""
|
||||
// }
|
||||
// ]
|
||||
// },
|
||||
// {
|
||||
// "selected_person":"51",
|
||||
// "residence_place":"as",
|
||||
// "residence_city":"as",
|
||||
// "residence_state":"sa",
|
||||
// "residence_pin":"sa",
|
||||
// "residence_No_of_years":13,
|
||||
// "residence_ownership":"2",
|
||||
// "ownershipOther":"s",
|
||||
// "rent":"as",
|
||||
// "total_number_of_family_members":"1",
|
||||
// "family_members_details":[
|
||||
// {
|
||||
// "family_member_name":"dinesh",
|
||||
// "family_member_relationship":"4",
|
||||
// "family_member_age":"26",
|
||||
// "family_member_earning_status":"2",
|
||||
// "earning_segment":"",
|
||||
// "earning_gross_income_per_month":"",
|
||||
// "earning_name_of_the_employer_or_business":"",
|
||||
// "earning_number_of_years_in_employment_or_business":"",
|
||||
// "non_earning_occupation":"2",
|
||||
// "non_earning_if_others":"",
|
||||
// "non_earning_if_retired_from":""
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
// ];
|
||||
if (records === null) {
|
||||
let formData: FormGroup = this.fb.group({
|
||||
selected_person: ['', Validators.compose([Validators.required])],
|
||||
residence_place: ['', Validators.compose([])],
|
||||
residence_city: ['', Validators.compose([])],
|
||||
residence_state: ['', Validators.compose([])],
|
||||
residence_pin: ['', Validators.compose([])],
|
||||
residence_No_of_years: ['', Validators.compose([])],
|
||||
residence_ownership: ['', Validators.compose([])],
|
||||
ownershipOther: [''],
|
||||
rent: [''],
|
||||
total_number_of_family_members: ['', Validators.compose([Validators.min(1), Validators.max(20)])],
|
||||
family_members_details: this.fb.array([]),
|
||||
});
|
||||
const control = <FormArray>this.familyForm.controls['family_details'];
|
||||
control.push(formData);
|
||||
} else {
|
||||
for (let val of records) {
|
||||
let formData: FormGroup = this.fb.group({
|
||||
selected_person: [val.selected_person, Validators.compose([Validators.required])],
|
||||
residence_place: [val.residence_place, Validators.compose([])],
|
||||
residence_city: [val.residence_city, Validators.compose([])],
|
||||
residence_state: [val.residence_state, Validators.compose([])],
|
||||
residence_pin: [val.residence_pin, Validators.compose([])],
|
||||
residence_No_of_years: [val.residence_No_of_years, Validators.compose([])],
|
||||
residence_ownership: [val.residence_ownership, Validators.compose([])],
|
||||
ownershipOther: [val.ownershipOther || null],
|
||||
rent: [val.rent || null],
|
||||
total_number_of_family_members: [val.total_number_of_family_members, Validators.compose([Validators.min(1), Validators.max(20)])],
|
||||
family_members_details: this.fb.array([]),
|
||||
});
|
||||
const control = <FormArray>this.familyForm.controls['family_details'];
|
||||
control.push(formData);
|
||||
let inx = control.length - 1;
|
||||
this.addFamilyMemberDetailsWithData(inx, val.family_members_details);
|
||||
console.log(control);
|
||||
}
|
||||
|
||||
}
|
||||
this.noRecordsFound = true;
|
||||
}
|
||||
|
||||
addFamilyMemberDetailsWithData(inx, val): void {
|
||||
const control = <FormArray>this.familyForm.controls['family_details']['controls'][inx].controls.family_members_details;
|
||||
for (let vals of val) {
|
||||
let datas = this.fb.group({
|
||||
family_member_name: [vals.family_member_name || null, Validators.compose([])],
|
||||
family_member_relationship: [vals.family_member_relationship || null, Validators.compose([])],
|
||||
family_member_age: [vals.family_member_age || null, Validators.compose([])],
|
||||
family_member_earning_status: [vals.family_member_earning_status || null, Validators.compose([])],
|
||||
earning_segment: [vals.earning_segment || null, Validators.compose([])],
|
||||
earning_gross_income_per_month: [vals.earning_gross_income_per_month || null, Validators.compose([])],
|
||||
earning_name_of_the_employer_or_business: [vals.earning_name_of_the_employer_or_business || null, Validators.compose([])],
|
||||
earning_number_of_years_in_employment_or_business: [vals.earning_number_of_years_in_employment_or_business || null, Validators.compose([])],
|
||||
non_earning_occupation: [vals.non_earning_occupation || null, Validators.compose([])],
|
||||
non_earning_if_others: [vals.non_earning_if_others || null, Validators.compose([])],
|
||||
non_earning_if_retired_from: [vals.non_earning_if_retired_from || null, Validators.compose([])],
|
||||
});
|
||||
control.push(datas);
|
||||
}
|
||||
}
|
||||
|
||||
addFamilyMemberDetails() {
|
||||
|
||||
}
|
||||
|
||||
addMoreApplicantFamilyDetails(e): void {
|
||||
e.stopPropagation();
|
||||
this.initFamilyForm('chck');
|
||||
}
|
||||
|
||||
getNumberOfFamilyMemberDetails(inx) {
|
||||
// alert(inx);
|
||||
let formData = <FormArray>this.familyForm.controls['family_details']['controls'][inx].controls;
|
||||
// alert(formData['total_number_of_family_members'].value);
|
||||
// alert(this.familyForm.controls.total_number_of_family_members.valid);
|
||||
if (formData['total_number_of_family_members'].valid) {
|
||||
let totalMem = formData['total_number_of_family_members'].value;
|
||||
const control = <FormArray>this.familyForm.controls['family_details']['controls'][inx].controls.family_members_details;
|
||||
if (totalMem > control.length) {
|
||||
let len = totalMem - control.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
control.push(this.generateFamilyMembersDetailsGet());
|
||||
}
|
||||
} else if (totalMem < control.length) {
|
||||
// control.controls.slice(0, totalMem);
|
||||
control.controls = [];
|
||||
for (let i = 0; i < totalMem; i++) {
|
||||
control.push(this.generateFamilyMembersDetailsGet());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
generateFamilyMembersDetailsGet(): FormGroup {
|
||||
return this.fb.group({
|
||||
family_member_name: ['', Validators.compose([])],
|
||||
family_member_relationship: ['', Validators.compose([])],
|
||||
family_member_age: ['', Validators.compose([])],
|
||||
family_member_earning_status: ['', Validators.compose([])],
|
||||
earning_segment: ['', Validators.compose([])],
|
||||
earning_gross_income_per_month: ['', Validators.compose([])],
|
||||
earning_name_of_the_employer_or_business: ['', Validators.compose([])],
|
||||
earning_number_of_years_in_employment_or_business: ['', Validators.compose([])],
|
||||
non_earning_occupation: ['', Validators.compose([])],
|
||||
non_earning_if_others: ['', Validators.compose([])],
|
||||
non_earning_if_retired_from: ['', Validators.compose([])],
|
||||
})
|
||||
}
|
||||
|
||||
// get all master details
|
||||
getMasterDetails(table: string, type: number) {
|
||||
this._pd.getAllMasterDatas(table).subscribe(
|
||||
data => {
|
||||
if (data.status == 200) {
|
||||
if (type == 1) {
|
||||
this.relationData = data.records.filter(item => item.isactive == 1);
|
||||
}
|
||||
else if (type == 2) {
|
||||
this.occupationData = data.records.filter(item => item.isactive == 1);
|
||||
}
|
||||
// else if(type==3){
|
||||
// this.personMetData=data.records.filter(item => item.isactive == 1);
|
||||
// }
|
||||
else if (type == 4) {
|
||||
this.ownerShipData = data.records.filter(item => item.isactive == 1);
|
||||
}
|
||||
else if (type == 5) {
|
||||
this.customerSegData = data.records.filter(item => item.isactive == 1);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
submitFamily() {
|
||||
if (!this.familyForm.valid) {
|
||||
return;
|
||||
}
|
||||
var records = this.familyForm.value;
|
||||
//To Remove The "Null" With Key also
|
||||
Object.keys(records).forEach((key) => (records[key] == null) && delete records[key]);
|
||||
// records.other_family_details = answerFormValues;
|
||||
records.pdid = this.pdid;
|
||||
records.formid = '6';
|
||||
// records.fk_createdby = '251';
|
||||
console.log(JSON.stringify(records));
|
||||
this._pd.saveForm(records).subscribe(data => {
|
||||
this.notifier.notify('success', 'Saved Successfully.');
|
||||
}, error => {
|
||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||
});
|
||||
}
|
||||
// validateAllFormFields(formGroup: FormGroup) {
|
||||
// Object.keys(formGroup.controls).forEach(field => {
|
||||
// const control = formGroup.get(field);
|
||||
// if (control instanceof FormControl) {
|
||||
// control.markAsTouched({onlySelf: true});
|
||||
// } else if (control instanceof FormGroup) {
|
||||
// this.validateAllFormFields(control);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// /** On Key Press Event For Age */
|
||||
// keyPress(event: any) {
|
||||
// const pattern = /[0-9]/;
|
||||
|
||||
// let inputChar = String.fromCharCode(event.charCode);
|
||||
// if (event.keyCode != 8 && !pattern.test(inputChar)) {
|
||||
// event.preventDefault();
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user