diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.html index 98a1ddd7e..88d691015 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.html @@ -1,13 +1,14 @@

-
- {{pageTitle}} -
-
- -
+
+ {{pageTitle}} +
+
+ +

- + @@ -17,58 +18,173 @@ - - + + +
+ + + + {{person.name}} + + + +
+
+
Residence Details
+ + + + + + + + + + + + + + + + + + + + + {{ownerShip.name}} + + + + + + + + + + + +
+
+ + + +
+ +
+
+
+ +
+ + + + + + + + {{relation.name}} + + + + + + +
+
+ + + + {{earnings.type}} + + + +
+
+ + + + + {{segment.name}} + + + + + + + + + + + + +
+
+ + + + {{occupation.name}} + + + + + + + + + +
+
+
+
+
+ + + + + + +
+
+ - - -
- - - -
-
-
-
- -
-
-
-
- Nivi SKM - -
- -
-
-
-
-
-
-
-
- -
-
-
-
- Nivi SKM - -
- -
-
-
-
-
-
-
-
- -
-
-
-
- Nivi SKM - -
- -
-
-
-
-
-
-
-
- -
-
-
-
- Nivi SKM - -
- -
-
-
-
-
-
-
-
- -
-
-
-
- Nivi SKM - -
- -
-
-
-
-
-
-
-
- -
-
-
-
- Nivi SKM - -
- -
-
-
-
-
- -
- -
-
- -
- + + + + + +
+
+
+
+ +
+
+
+
+ Nivi SKM + +
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ Nivi SKM + +
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ Nivi SKM + +
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ Nivi SKM + +
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ Nivi SKM + +
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ Nivi SKM + +
+ +
+
+
+
+
+ +
+ +
+
+ + +
-
- - Remarks - - -
-
+
+ + Remarks + + +
+
- +
- + - + @@ -311,7 +390,7 @@

Family Details

--> - - + --> \ No newline at end of file diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.ts index 510290b23..86a235c49 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/family-details/family-details.component.ts @@ -34,18 +34,24 @@ export class FamilyDetailsComponent implements OnInit { pdid : string; form_id : number; - public currentLoanForm: FormGroup; private notifier: NotifierService; public familyForm: FormGroup; - // public person: AbstractControl; - // public personOther: AbstractControl; - public members: AbstractControl; - public residence: AbstractControl; - public years: AbstractControl; - public ownership: AbstractControl; - public ownershipOther: AbstractControl; - public rent: AbstractControl; + 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 = []; @@ -68,7 +74,7 @@ export class FamilyDetailsComponent implements OnInit { this.getMasterDetails('OCCUPATIONMEMBERS',2); //this.getMasterDetails('PERSONSMET',3); this.getMasterDetails('RESIDENCEOWNERSHIP',4); - this.getMasterDetails('CUSTOMERSEGMENT',5) + this.getMasterDetails('CUSTOMERSEGMENT',5); this.initFamilyForm(); let params: any = {}; params.pd_id = this.pdid; @@ -77,131 +83,118 @@ export class FamilyDetailsComponent implements OnInit { const control = this.familyForm.controls['nonEarningMembers']; const value = this.familyForm.controls['earningMembers']; if (data.status == 200) { - var result = Object.keys(data.records.non_earning_members).map(function (key) { - return data.records.non_earning_members[key]; - }); - var earning = Object.keys(data.records.earning_members).map(function (key) { - return data.records.earning_members[key]; - }); - // this.familyForm.controls.person.setValue(data.records.person_met); - // if (data.records.person_met_other) { - // this.familyForm.controls.personOther.setValue(data.records.person_met_other); - // } - this.familyForm.controls.members.setValue(data.records.family_members); - this.familyForm.controls.years.setValue(data.records.no_of_years); - this.familyForm.controls.ownership.setValue(data.records.ownership); + 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); - - if (data.records.ownership_others) { - this.familyForm.controls.ownershipOther.setValue(data.records.ownership_others); - } - this.familyForm.controls.rent.setValue(data.records.what_rent); - if (result.length == 0) { - control.push(this.createNonMembers()); - } else { - result.forEach(datas => { - control.push(this.createNonMembers()); - }); - this.familyForm.controls.nonEarningMembers.setValue(result); - } - if (earning.length == 0) { - value.push(this.createMembers()); - } else { - earning.forEach(datas => { - value.push(this.createMembers()); - }); - this.familyForm.controls.earningMembers.setValue(earning); - } - this.familyForm.controls.residence.setValue(data.records.residence); + this.generateFamilyMembersDetailsGetData(data.records.family_members_details); } else { - value.push(this.createMembers()); - control.push(this.createNonMembers()); + // 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 = this.familyForm.controls['family_members_details']; + control.push(this.initgenerateFamilyMembersDetailsGet(val)); + } + } + } + + onSearchChange(e):void { + e.preventDefault(); + } public initFamilyForm(): void { this.familyForm = this.fb.group({ - // person: ['', Validators.compose([Validators.required])], + selected_person: ['', Validators.compose([Validators.required])], // personOther: [''], - members: ['', Validators.compose([Validators.required])], - residence: ['', Validators.compose([Validators.required])], - years: ['', Validators.compose([Validators.required])], - ownership: ['', Validators.compose([Validators.required])], + // members: ['', 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: [''], - earningMembers: this.fb.array([]), - nonEarningMembers: this.fb.array([]), + + total_number_of_family_members: ['', Validators.compose([Validators.min(1), Validators.max(20)])], + + family_members_details: this.fb.array([]), + // earningMembers: this.fb.array([]), + // nonEarningMembers: this.fb.array([]), family_details_form_remark: [''] }); - // this.person = this.familyForm.controls['person']; - // this.personOther = this.familyForm.controls['personOther']; - this.members = this.familyForm.controls['members']; - this.residence = this.familyForm.controls['residence']; - this.years = this.familyForm.controls['years']; - this.ownership = this.familyForm.controls['ownership']; - this.ownershipOther = this.familyForm.controls['ownershipOther']; - this.rent = this.familyForm.controls['rent']; - } - createMembers(): FormGroup { - return this.fb.group({ - earning_member_name : ['', Validators.compose([Validators.required])], - earning_member_age : ['', Validators.compose([Validators.required])], - relation: ['', Validators.compose([Validators.required])], - segment: ['', Validators.compose([Validators.required])], - income: ['', Validators.compose([Validators.required])], - employer_name: ['', Validators.compose([Validators.required])], - }); - } - createNonMembers(): FormGroup { - return this.fb.group({ - non_earning_member_name : ['', Validators.compose([Validators.required])], - non_earning_member_age : ['', Validators.compose([Validators.required])], - relationship: ['', Validators.compose([Validators.required])], - occupation: ['', Validators.compose([Validators.required])], - retired: [''], - others_occupation : [''] - }); } - addearningMembers() { - - const control = this.familyForm.controls['earningMembers']; - //this.earnMemberArrCount = control.length; - if(control.length == this.familyForm.controls['members'].value) - { + 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 = 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 { - }else{ - control.push(this.createMembers()); - //console.log('Add earn member',this.familyForm.controls['members'].value); } - - // console.log(this.earnMemberArrCount); - // console.log(this.nonEarnMemberArrCount); } - addMembers() { - const control = this.familyForm.controls['nonEarningMembers']; - this.count++; - // this.nonEarnMemberArrCount = control.length; - // console.log(this.earnMemberArrCount); - // console.log(this.nonEarnMemberArrCount); - // if(control.length == this.familyForm.controls['members'].value) - // { + + 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([])], + }) + } - // }else{ - // control.push(this.createNonMembers()); - // } - - - } - deleteEarningMembers(index) { - const control = this.familyForm.controls['earningMembers']; - control.removeAt(index); - } - deleteMembers(index) { - const control = this.familyForm.controls['nonEarningMembers']; - control.removeAt(index); - } // get all master details getMasterDetails(table:string,type:number){ this._pd.getAllMasterDatas(table).subscribe( @@ -231,43 +224,10 @@ export class FamilyDetailsComponent implements OnInit { if (!this.familyForm.valid) { return; } - let records: any = {}; - records.no_of_years = this.years.value; - if (this.ownership.value == 4) { - records.ownership_others = this.ownershipOther.value; - } - records.ownership = this.ownership.value; - records.residence = this.residence.value; - if (this.ownership.value == 3) { - records.what_rent = this.rent.value; - } - // if (this.person.value == 8) { - // records.person_met_other = this.personOther.value; - // } - //records.person_met = this.person.value; - records.family_members = this.members.value; - records.earning_members = this.familyForm.controls['earningMembers'].value; - // filter re conditions - let non_earning_members_filter = this.familyForm.controls['nonEarningMembers'].value.map(function(obj) { - - console.log(obj.occupation); - if(obj.occupation==3){ - return obj; - } - else{ - obj.retired=''; - return obj; - } - if(obj.occupation==9){ - return obj; - } - else{ - obj.others_occupation=''; - return obj; - } - }); - records.non_earning_members = non_earning_members_filter; - records.family_details_form_remark = this.familyForm.controls['family_details_form_remark'].value; + 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'; @@ -277,25 +237,25 @@ export class FamilyDetailsComponent implements OnInit { 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); - } - }); - } + // 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]/; + // /** 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(); - } - } + // let inputChar = String.fromCharCode(event.charCode); + // if (event.keyCode != 8 && !pattern.test(inputChar)) { + // event.preventDefault(); + // } + // } }