address : ps

This commit is contained in:
venbatechnologies@gmail.com 2018-12-15 18:24:00 +05:30
parent 47aba2af71
commit a39d8af38e
2 changed files with 120 additions and 60 deletions

View File

@ -22,7 +22,7 @@
<mat-form-field> <mat-form-field>
<!-- <input matInput placeholder="Name" formControlName="name_ans" type="text" required> --> <!-- <input matInput placeholder="Name" formControlName="name_ans" type="text" required> -->
<input matInput placeholder="Address" formControlName="address" required> <input matInput placeholder="Address" formControlName="address" required autocomplete="off">
</mat-form-field> </mat-form-field>
@ -35,7 +35,7 @@
</mat-form-field> </mat-form-field>
<mat-form-field *ngIf="addressForm.controls['address_type'].value == 12"> <mat-form-field *ngIf="addressForm.controls['address_type'].value == 12">
<input matInput placeholder="Address Type Others" formControlName="address_type_others"> <input matInput placeholder="Address Type Others" formControlName="address_type_others" autocomplete="off">
</mat-form-field> </mat-form-field>
<mat-form-field> <mat-form-field>
@ -48,7 +48,7 @@
<mat-form-field *ngIf="addressForm.controls.locality.value == 'Others'"> <mat-form-field *ngIf="addressForm.controls.locality.value == 'Others'">
<input matInput placeholder="Specify Locality" <input matInput placeholder="Specify Locality"
formControlName="locality_others"> formControlName="locality_others" autocomplete="off">
</mat-form-field> </mat-form-field>
<mat-form-field style="width: 30%"> <mat-form-field style="width: 30%">
@ -87,11 +87,11 @@
</mat-form-field> </mat-form-field>
<mat-form-field *ngIf="addressForm.controls['address_ownership'].value == 4 " style="width: 38%"> <mat-form-field *ngIf="addressForm.controls['address_ownership'].value == 4 " style="width: 38%">
<input matInput placeholder="Specify Other Ownership" formControlName="other_ownership"> <input matInput placeholder="Specify Other Ownership" formControlName="other_ownership" autocomplete="off">
</mat-form-field> </mat-form-field>
<mat-form-field *ngIf="addressForm.controls['address_ownership'].value == 3 " style="width: 38%"> <mat-form-field *ngIf="addressForm.controls['address_ownership'].value == 3 " style="width: 38%">
<input matInput placeholder="What is the monthly rent paid?" formControlName="rent_amt"> <input matInput placeholder="What is the monthly rent paid?" formControlName="rent_amt" autocomplete="off">
</mat-form-field> </mat-form-field>
<mat-form-field style="width: 42%"> <mat-form-field style="width: 42%">
@ -102,35 +102,33 @@
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<mat-form-field *ngIf="addressForm.controls['bussiness_activity'].value == 'yes'" style="width: 100%"> <!-- <mat-form-field *ngIf="addressForm.controls['bussiness_activity'].value == 'yes'" style="width: 100%">
<!-- <mat-select placeholder="Bussiness Type" formControlName="bussiness_address_type"> <!-- <mat-select placeholder="Bussiness Type" formControlName="bussiness_address_type">
<mat-option value="{{m_addressType.address_type_id}}" <mat-option value="{{m_addressType.address_type_id}}"
*ngFor="let m_addressType of addressData">{{m_addressType.address_type}} *ngFor="let m_addressType of addressData">{{m_addressType.address_type}}
</mat-option> </mat-option>
</mat-select> --> </mat-select> -->
<mat-select placeholder="Type of Premises" formControlName="bussiness_address_type" multiple> <!-- --<mat-select placeholder="Type of Premises" formControlName="bussiness_address_type" multiple>
<mat-option *ngFor="let m_addressType of addressData" [value]="m_addressType.address_type_id" (onSelectionChange)="SelectedPremises($event)" > {{m_addressType.address_type}} </mat-option> <mat-option *ngFor="let m_addressType of addressData" [value]="m_addressType.address_type_id" (onSelectionChange)="SelectedPremises($event)" > {{m_addressType.address_type}} </mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field> -->
<mat-form-field *ngIf="PremisesOtherFlag == true" style="width: 40%"> <mat-form-field *ngIf="PremisesOtherFlag == true" style="width: 40%">
<input matInput placeholder="Specify Other Premises Type" formControlName="bussiness_address_type_others"> <input matInput placeholder="Specify Other Premises Type" formControlName="bussiness_address_type_others" autocomplete="off">
</mat-form-field> </mat-form-field>
<mat-card formArrayName="premises"> <span formArrayName="additional_premises">
<div <div
*ngFor="let item of addressForm.controls.premises['controls']; let i = index;" [formGroupName]="i"> *ngFor="let item of addressForm.controls.additional_premises['controls']; let i = index;" [formGroupName]="i">
<p>{{i+1}} . {{PremisesLabel[i]}}</p>
<mat-card-header>
<mat-card-title>{{i+1}} . {{PremisesLabel[i]}}</mat-card-title>
</mat-card-header>
<mat-card-content>
<mat-form-field style="width: 40%;"> <mat-form-field style="width: 40%;">
<input matInput placeholder="Number Of Additional Units" <input matInput placeholder="Number Of Additional Units"
formControlName="no_of_additional_units"> formControlName="no_of_additional_units" autocomplete="off">
</mat-form-field> </mat-form-field>
<mat-form-field *ngIf="item.get('no_of_additional_units').value > 2" style="width: 40%;"> <mat-form-field *ngIf="item.get('no_of_additional_units').value > 2" style="width: 40%;">
<mat-select placeholder="City" formControlName="premises_city"> <!--multiple (selectionChange)="relationChanged($event)"> --> <mat-select placeholder="City" formControlName="premises_city" multiple > <!-- (selectionChange)="relationChanged($event)"> -->
<mat-option *ngFor="let CL of cityData" [value]="CL.city_id"> <mat-option *ngFor="let CL of cityData" [value]="CL.city_id">
{{CL.name}} {{CL.name}}
</mat-option> </mat-option>
@ -148,18 +146,17 @@
<!-- <mat-form-field *ngIf="addressForm.controls['premises_ownership'].value == 4 "> --> <!-- <mat-form-field *ngIf="addressForm.controls['premises_ownership'].value == 4 "> -->
<mat-form-field *ngIf="item.get('premises_ownership').value == 4" style="width: 40%;"> <mat-form-field *ngIf="item.get('premises_ownership').value == 4" style="width: 40%;">
<input matInput placeholder="Specify Other Ownership" formControlName="premises_ownership_others"> <input matInput placeholder="Specify Other Ownership" formControlName="premises_ownership_others" autocomplete="off">
</mat-form-field> </mat-form-field>
<mat-form-field *ngIf="item.get('premises_ownership').value == 3" style="width: 40%;"> <mat-form-field *ngIf="item.get('premises_ownership').value == 3" style="width: 40%;">
<input matInput placeholder="What is the monthly rent paid?" formControlName="premises_rent_amt"> <input matInput placeholder="What is the monthly rent paid?" formControlName="premises_rent_amt" autocomplete="off">
</mat-form-field> </mat-form-field>
<mat-form-field> <mat-form-field>
<input matInput placeholder="Remarks" <input matInput placeholder="Remarks"
formControlName="premises_remarks" style="width: 65%;"> formControlName="premises_remarks" style="width: 65%;" autocomplete="off">
</mat-form-field> </mat-form-field>
</mat-card-content>
</div> </div>
</mat-card> </span>
<!--- Don't Remove To replace atlast of the PD Completion and creating new form (Neighbourhood check) -- <!--- Don't Remove To replace atlast of the PD Completion and creating new form (Neighbourhood check) --
<mat-card> <mat-card>
<mat-card-header> <mat-card-header>

View File

@ -50,12 +50,10 @@ export class AddressComponent implements OnInit {
ownerShipData:any = []; ownerShipData:any = [];
cityData:any = []; cityData:any = [];
z = 0; z = 0;
formPremisesArray: any = []; formPremisesArray: any = [];
relativeNames2: any = []; formPremisesCityArray: any = [];
//neighbourStatusData:any=["Yes","No"]; //neighbourStatusData:any=["Yes","No"];
//applicantOwnerData:any=["Yes","No","Dont Know"]; //applicantOwnerData:any=["Yes","No","Dont Know"];
@ -96,13 +94,15 @@ export class AddressComponent implements OnInit {
this.getMasterDetails('RESIDENCEOWNERSHIP',6); this.getMasterDetails('RESIDENCEOWNERSHIP',6);
this.getMasterDetails('CITY',7); this.getMasterDetails('CITY',7);
this.initAddressForm(); this.initAddressForm();
let params: any = {}; let params: any = {};
params.pd_id = this.pdid; params.pd_id = this.pdid;
params.pd_form_id = '5'; params.pd_form_id = '5';
this._pd.retriveForm(params).subscribe(data => { this._pd.retriveForm(params).subscribe(data => {
console.log('data', data); console.log('data', data);
//const control = <FormArray>this.addressForm.controls['neighbourhood']; //const control = <FormArray>this.addressForm.controls['neighbourhood'];
const control = <FormArray>this.addressForm.controls['premises']; const additionalPremisesControl = <FormArray>this.addressForm.controls['additional_premises'];
if(data.status == 200) { if(data.status == 200) {
// var result = Object.keys(data.records.neighbourhood).map(function (key) { // var result = Object.keys(data.records.neighbourhood).map(function (key) {
// return data.records.neighbourhood[key]; // return data.records.neighbourhood[key];
@ -111,6 +111,7 @@ export class AddressComponent implements OnInit {
this.addressForm.controls.address.setValue(data.records.address); this.addressForm.controls.address.setValue(data.records.address);
this.addressForm.controls.pd_location.setValue(data.records.pd_location); this.addressForm.controls.pd_location.setValue(data.records.pd_location);
this.addressForm.controls.address_type.setValue(data.records.address_type); this.addressForm.controls.address_type.setValue(data.records.address_type);
if(data.records.address_type == 12) { if(data.records.address_type == 12) {
this.addressForm.controls.address_type_others.setValue(data.records.address_type_others); this.addressForm.controls.address_type_others.setValue(data.records.address_type_others);
} }
@ -122,16 +123,17 @@ export class AddressComponent implements OnInit {
this.addressForm.controls.other_ownership.setValue(data.records.other_ownership); this.addressForm.controls.other_ownership.setValue(data.records.other_ownership);
this.addressForm.controls.rent_amt.setValue(data.records.rent_amt); this.addressForm.controls.rent_amt.setValue(data.records.rent_amt);
this.addressForm.controls.bussiness_activity.setValue(data.records.bussiness_activity); this.addressForm.controls.bussiness_activity.setValue(data.records.bussiness_activity);
if(data.records.bussiness_activity == 'yes') { if(data.records.bussiness_activity == 'yes') {
let selectedMembers = Object.keys(data.records.bussiness_address_type).map(function (key) { let selectedPremisesDBData = Object.keys(data.records.bussiness_address_type).map(function (key) {
return data.records.bussiness_address_type[key]; return data.records.bussiness_address_type[key];
}); });
let enduse: any = []; let enduse: any = [];
let existPremises: any =[]; let existPremises: any =[];
selectedMembers.forEach(val => { selectedPremisesDBData.forEach(val => {
enduse.push(val.premises); enduse.push(val.premises_types);
existPremises.push(val); existPremises.push(val);
}); });
@ -139,19 +141,65 @@ export class AddressComponent implements OnInit {
this.addressForm.controls.bussiness_address_type.setValue(enduse); this.addressForm.controls.bussiness_address_type.setValue(enduse);
var result = Object.keys(data.records.premises).map(function (key) { var additionalPremisesResult = Object.keys(data.records.additional_premises).map(function (key) {
return data.records.premises[key]; return data.records.additional_premises[key];
}); });
if (result.length == 0) { // let cityenduse: any = [];
control.push(this.createPremises()); // let existcity: any =[];
} else {
result.forEach(datas => { // additionalPremisesResult.forEach(val => {
control.push(this.createPremises()); // cityenduse.push(val.premises_types);
// existcity.push(val);
// });
// this.formPremisesCityArray = existcity;
additionalPremisesResult.forEach((val,index)=>
{
console.log(val);
let cityenduse: any = [];
let existcity: any =[];
if(val.premises_city != ''){
this.formPremisesCityArray = [];
val.premises_city.forEach(option => {
// cityenduse.push(option);
// existcity.push(val);
//this.formPremisesCityArray.push({additional_premises_city: option});
//this.addressForm.controls.additional_premises.value[index].premises_city = cityenduse;
console.log(option);
}); });
//console.log(cityenduse);
//this.formPremisesCityArray = existcity;
}
});
if (additionalPremisesResult.length == 0) {
additionalPremisesControl.push(this.createPremises());
} else {
let cityenduse: any = [];
let existcity: any =[];
additionalPremisesResult.forEach(datas => {
if(datas.premises_city != ''){
cityenduse.push(datas.additional_premises_city);
existcity.push(datas);
}
additionalPremisesControl.push(this.createPremises());
});
this.formPremisesCityArray = existcity;
console.log(cityenduse);
console.log(existcity);
this.addressForm.controls['additional_premises'].setValue(additionalPremisesResult);
} }
this.addressForm.controls['premises'].setValue(result);
if(data.records.bussiness_address_type == 12) { if(data.records.bussiness_address_type == 12) {
this.addressForm.controls.bussiness_address_type_others.setValue(data.records.bussiness_address_type_others); this.addressForm.controls.bussiness_address_type_others.setValue(data.records.bussiness_address_type_others);
@ -191,7 +239,7 @@ export class AddressComponent implements OnInit {
bussiness_activity:[''], bussiness_activity:[''],
bussiness_address_type:[''], bussiness_address_type:[''],
bussiness_address_type_others: [''], bussiness_address_type_others: [''],
premises: this.fb.array([]) additional_premises: this.fb.array([])
}); });
this.address = this.addressForm.controls['address']; this.address = this.addressForm.controls['address'];
this.addressType = this.addressForm.controls['address_type']; this.addressType = this.addressForm.controls['address_type'];
@ -297,32 +345,47 @@ export class AddressComponent implements OnInit {
records.bussiness_address_type_others = this.addressForm.controls.bussiness_address_type_others.value; records.bussiness_address_type_others = this.addressForm.controls.bussiness_address_type_others.value;
} }
} }
this.addressForm.controls.additional_premises.value.forEach((val,index)=>
{
console.log(val);
records.premises = this.addressForm.controls.premises.value; if(val.premises_city != ''){
this.formPremisesCityArray = [];
val.premises_city.forEach(option => {
this.formPremisesCityArray.push({additional_premises_city: option});
this.addressForm.controls.additional_premises.value[index].premises_city = this.formPremisesCityArray;
// console.log(val);
});
}
console.log(this.addressForm.controls.premises.value);
});
records.additional_premises = this.addressForm.controls.additional_premises.value;
// console.log(this.formPremisesCityArray);
// console.log(this.addressForm.controls.premises.value);
records.pdid = this.pdid; records.pdid = this.pdid;
records.formid = '5'; records.formid = '5';
// records.fk_createdby = '250'; // records.fk_createdby = '250';
console.log('params', records); console.log('params', records);
this._pd.saveForm(records).subscribe(data => { this._pd.saveForm(records).subscribe(data => {
console.log('data', data); console.log('data', data);
this.notifier.notify('success', 'Saved Successfully.'); this.notifier.notify('success', 'Saved Successfully.');
}, error => { }, error => {
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
}); });
} }
relationChanged(event) { // relationChanged(event) {
this.relativeNames2 = []; // this.formPremisesCityArray = [];
event.value.forEach(option => { // event.value.forEach(option => {
this.relativeNames2.push({city: option}); // this.formPremisesCityArray.push({city: option});
}); // });
} // }
SelectedPremises($event){ SelectedPremises($event){
console.log('event',$event);
let premisesData = $event.source.value; let premisesData = $event.source.value;
@ -335,7 +398,7 @@ export class AddressComponent implements OnInit {
//console.log(this.formPremisesArray); //console.log(this.formPremisesArray);
this.formPremisesArray.push({premises: $event.source.value}); this.formPremisesArray.push({premises_types: $event.source.value});
//console.log(this.formPremisesArray); //console.log(this.formPremisesArray);
@ -351,7 +414,7 @@ export class AddressComponent implements OnInit {
this.z++; this.z++;
const control = <FormArray>this.addressForm.controls['premises']; const control = <FormArray>this.addressForm.controls['additional_premises'];
control.push(this.createPremises()); control.push(this.createPremises());
@ -366,7 +429,7 @@ export class AddressComponent implements OnInit {
this.PremisesOtherFlag = false; this.PremisesOtherFlag = false;
} }
const control = <FormArray>this.addressForm.controls['neighbourhood']; const control = <FormArray>this.addressForm.controls['additional_premises'];
control.removeAt(this.z); control.removeAt(this.z);
this.z--; this.z--;
//let index = this.selectedSegmentDatas.indexOf(CustomerSegmentName.name); //let index = this.selectedSegmentDatas.indexOf(CustomerSegmentName.name);