address form : ps

This commit is contained in:
venbatechnologies@gmail.com 2019-03-01 10:08:14 +05:30
parent 4022528604
commit 6dcf363ad6
4 changed files with 418 additions and 257 deletions

View File

@ -21,138 +21,158 @@
<div fxLayout="row wrap">
<div fxFlex="100">
<mat-card style="min-height: 550px;">
<mat-card-content>
<div fxLayout="row wrap">
<div formArrayName="addresses">
<div *ngFor="let item of addressForm.controls.addresses['controls']; let i=index">
<mat-card-header>
<p>Address Details #{{i+1}}</p>
</mat-card-header>
<mat-card-content class="matcard" [formGroup]="item">
<div fxLayout="row wrap">
<div fxFlex="100">
<mat-form-field style="width: 96%">
<input matInput placeholder="Address" formControlName="address"
oninput="this.value = this.value.toUpperCase()" required
autocomplete="off">
</mat-form-field>
</div>
<div fxFlex="100">
<mat-form-field style="width: 96%">
<input matInput placeholder="Address" formControlName="address" oninput="this.value = this.value.toUpperCase()"
required autocomplete="off">
</mat-form-field>
</div>
<div fxFlex="100" fxLayout="nowrap">
<mat-form-field style="width: 32%">
<mat-select placeholder="State" formControlName="state"
(selectionChange)="getcityList($event.target.value,i)">
<mat-option>Select</mat-option>
<mat-option *ngFor="let SL of stateData" [value]="SL.state_id">{{SL.name}}</mat-option>
</mat-select>
</mat-form-field>
<div fxFlex="100" fxLayout="nowrap">
<mat-form-field style="width: 32%">
<mat-select placeholder="State" formControlName="state"
(selectionChange)="getcityList($event.target.value)">
<mat-option>Select</mat-option>
<mat-option *ngFor="let SL of stateData" [value]="SL.state_id">{{SL.name}}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 32%">
<mat-select placeholder="City" formControlName="city">
<mat-option> Select </mat-option>
<mat-option *ngFor="let CL of cityData[i]" [value]="CL.city_id">{{CL.city_name}}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 32%">
<mat-select placeholder="City" formControlName="city">
<mat-option> Select </mat-option>
<mat-option *ngFor="let CL of cityData" [value]="CL.city_id">{{CL.city_name}}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 24%">
<mat-select placeholder="Pincode" formControlName="pincode">
<mat-option>Select</mat-option>
<mat-option *ngFor="let PL of pincodeData[i]" [value]="PL.pincode_id">{{PL.pincode}}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 24%">
<mat-select placeholder="Pincode" formControlName="pincode">
<mat-option>Select</mat-option>
<mat-option *ngFor="let PL of pincodeData" [value]="PL.pincode_id">{{PL.pincode}}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 24%" *ngIf="item.get('pincode').value == 1">
<input matInput autocomplete="off" placeholder="Specify Pincode *"
formControlName="pincode_others" (keypress)="keyPress($event)">
<!-- <mat-error *ngIf="!addressForm.controls['pincode_others'].valid">Pincode
Required</mat-error> -->
</mat-form-field>
<mat-form-field style="width: 24%" *ngIf="addressForm.controls['pincode'].value == 1">
<input matInput autocomplete="off" placeholder="Specify Pincode *"
formControlName="pincode_others" (keypress)="keyPress($event)">
<mat-error *ngIf="!addressForm.controls['pincode_others'].valid">Pincode
Required</mat-error>
</mat-form-field>
</div>
</div>
<div fxFlex="100">
<mat-form-field style="width: 46%;">
<mat-select placeholder="Address Type" formControlName="address_type"
required (selectionChange)="selectedAddressType($event.source.triggerValue,i)">
<mat-option>Select</mat-option>
<mat-option value="{{m_addressType.address_type_id}}"
*ngFor="let m_addressType of addressData">{{m_addressType.address_type}}
</mat-option>
</mat-select>
</mat-form-field>
<div fxFlex="100">
<mat-form-field style="width: 46%;">
<mat-select placeholder="Address Type" formControlName="address_type"
required (selectionChange)="selectedAddressType($event.source.triggerValue)">
<mat-option>Select</mat-option>
<mat-option value="{{m_addressType.address_type_id}}" *ngFor="let m_addressType of addressData">{{m_addressType.address_type}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 46%;" *ngIf="item.get('address_type').value == 1">
<input matInput placeholder="Specify Address Type *"
formControlName="address_type_others" autocomplete="off"
(change)="selectedAddressType($event.target.value,i)">
<!-- <mat-error *ngIf="!addressForm.controls['address_type_others'].valid">Address Type Required</mat-error> -->
</mat-form-field>
<mat-form-field style="width: 46%;" *ngIf="addressForm.controls['address_type'].value == 1">
<input matInput placeholder="Specify Address Type *" formControlName="address_type_others"
autocomplete="off" (change)="selectedAddressType($event.target.value)">
<mat-error *ngIf="!addressForm.controls['address_type_others'].valid">Address Type Required</mat-error>
</mat-form-field>
</div>
</div>
<div fxFlex="100">
<mat-form-field style="width: 46%;">
<mat-select placeholder="Locality" formControlName="locality"
required>
<mat-option>Select</mat-option>
<mat-option value="{{m_locality.locality_id}}" *ngFor="let m_locality of localityData">{{m_locality.locality_name}}
</mat-option>
</mat-select>
</mat-form-field>
<div fxFlex="100">
<mat-form-field style="width: 46%;">
<mat-select placeholder="Locality" formControlName="locality" required>
<mat-option>Select</mat-option>
<mat-option value="{{m_locality.locality_id}}" *ngFor="let m_locality of localityData">{{m_locality.locality_name}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 46%;" *ngIf="addressForm.controls.locality.value == 1">
<input matInput placeholder="Specify Locality *" formControlName="locality_others"
autocomplete="off">
<!-- autofocus -->
<mat-error *ngIf="!addressForm.controls['locality_others'].valid">Locality Required</mat-error>
</mat-form-field>
<mat-form-field style="width: 46%;" *ngIf="item.get('locality').value == 1">
<input matInput placeholder="Specify Locality *"
formControlName="locality_others" autocomplete="off">
<!-- autofocus -->
<!-- <mat-error *ngIf="!addressForm.controls['locality_others'].valid">Locality Required</mat-error> -->
</mat-form-field>
<mat-form-field style="width: 46%;" *ngIf="addressForm.controls.locality.value == 5">
<input matInput placeholder="Specify the MixUse *" formControlName="locality_mixuse"
autocomplete="off">
<mat-error *ngIf="!addressForm.controls['locality_mixuse'].valid">MixUse
Required</mat-error>
</mat-form-field>
</div>
<mat-form-field style="width: 46%;" *ngIf="item.get('locality').value == 5">
<input matInput placeholder="Specify the MixUse *"
formControlName="locality_mixuse" autocomplete="off">
<!-- <mat-error *ngIf="!addressForm.controls['locality_mixuse'].valid">MixUse
Required</mat-error> -->
</mat-form-field>
</div>
<div fxFlex="100">
<mat-form-field style="width: 46%;">
<mat-select placeholder="Approach to PD Location" formControlName="pd_location"
required>
<mat-option>Select</mat-option>
<mat-option value="{{data.pd_location_approach_id}}" *ngFor="let data of locationdata">{{data.description}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 46%;">
<mat-select placeholder="Comment on Locality" formControlName="comment_locality"
required>
<mat-option>Select</mat-option>
<mat-option value="{{data.comments_on_locality_id}}" *ngFor="let data of commentData">{{data.rating}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
<div fxFlex="100" fxLayout="nowrap">
<mat-form-field style="width: 46%;">
<input matInput [placeholder]="placeholderName" formControlName="estimated_area"
(keypress)="keyPress($event)">
</mat-form-field>
<mat-form-field style="width: 46%;">
<mat-select placeholder="Unit of Measurement" formControlName="uom">
<mat-option>Select</mat-option>
<mat-option value="{{uom.uom_id}}" *ngFor="let uom of uomData">{{uom.name}}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 24%;" *ngIf="addressForm.controls['uom'].value == 1 ">
<input matInput placeholder="Specify UOM *" formControlName="uom_others"
autocomplete="off">
<mat-error *ngIf="!addressForm.controls['uom_others'].valid">UOM
Required</mat-error>
</mat-form-field>
</div>
<div fxFlex="100">
<mat-form-field style="width: 46%;">
<mat-select placeholder="Approach to PD Location"
formControlName="pd_location" required>
<mat-option>Select</mat-option>
<mat-option value="{{data.pd_location_approach_id}}" *ngFor="let data of locationdata">{{data.description}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 46%;">
<mat-select placeholder="Comment on Locality" formControlName="comment_locality"
required>
<mat-option>Select</mat-option>
<mat-option value="{{data.comments_on_locality_id}}" *ngFor="let data of commentData">{{data.rating}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
<div fxFlex="100" fxLayout="nowrap">
<mat-form-field style="width: 46%;">
<input matInput [placeholder]="placeholderName[i] ? placeholderName[i] : 'Estimated area of the (Address Type)'" formControlName="estimated_area"
(keypress)="keyPress($event)">
</mat-form-field>
<mat-form-field style="width: 46%;">
<mat-select placeholder="Unit of Measurement" formControlName="uom">
<mat-option>Select</mat-option>
<mat-option value="{{uom.uom_id}}" *ngFor="let uom of uomData">{{uom.name}}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 24%;" *ngIf="item.get('uom').value == 1 ">
<input matInput placeholder="Specify UOM *" formControlName="uom_others"
autocomplete="off">
<!-- <mat-error *ngIf="!addressForm.controls['uom_others'].valid">UOM
Required</mat-error> -->
</mat-form-field>
</div>
</div>
<!-- <button type="button" matTooltip="Add More Address Details" class="mr-1 mb-1 hover-icon" matTooltipPosition="above" mat-raised-button mat-icon-button *ngIf="i==0"
(click)="addAddresses()"
color="primary" style="float: right;">
<mat-icon>add</mat-icon>
</button>
<button type="button" matTooltip="Delete" class="mr-1 mb-1 hover-icon" matTooltipPosition="above" mat-raised-button mat-icon-button *ngIf="i>0"
(click)="removeAddresses(i)"
style="float: right;">
<mat-icon>delete</mat-icon>
</button> -->
</mat-card-content>
</div>
</mat-card-content>
</div>
</mat-card>
</div>
</div>

View File

@ -33,15 +33,15 @@ export class AddressComponent implements OnInit {
//@Input() pdid: number;
pdid: number;
form_id: number;
pdAddress: string;
pdState: any;
pdCity: any;
pdPincode: any;
pdOtherPincode: any;
// pdAddress: string;
// pdState: any;
// pdCity: any;
// pdPincode: any;
// pdOtherPincode: any;
CustSegAbbr: any;
loadDataStatus: boolean = true;
placeholderName: any = 'Estimated area of the (Address Type)';
placeholderName: any = [];
/**Array declaration Of Dropdown */
locationdata: any = [];
@ -53,21 +53,23 @@ export class AddressComponent implements OnInit {
cityData: any = [];
uomData: any = [];
addressesList: any = [];
otherPincodeFlag:any = [];
/**Declaration of FormField Variables */
private notifier: NotifierService;
public addressForm: FormGroup;
public address: AbstractControl;
public addressType: AbstractControl;
public state: AbstractControl;
public city: AbstractControl;
public pincode: AbstractControl;
public locality: AbstractControl;
public pdLocation: AbstractControl;
public commentLocality: AbstractControl;
public estArea: AbstractControl;
public uom: AbstractControl;
// public address: AbstractControl;
// public addressType: AbstractControl;
// public state: AbstractControl;
// public city: AbstractControl;
// public pincode: AbstractControl;
// public locality: AbstractControl;
// public pdLocation: AbstractControl;
// public commentLocality: AbstractControl;
// public estArea: AbstractControl;
// public uom: AbstractControl;
/**Constructor of the class */
constructor(private el: ElementRef, notifier: NotifierService,
@ -85,26 +87,18 @@ export class AddressComponent implements OnInit {
this.lender_applicant_id = this.pd_all_details.pdmaster_details.lender_applicant_id;
this.subproduct_abbr = this.pd_all_details.pdmaster_details.subproduct_abbr;
this.customer_segment_abbr = this.pd_all_details.pdmaster_details.customer_segment_abbr;
console.log('this.pd_all_details',this.pd_all_details);
let CSAbbrSearch = this.pd_all_details.pdmaster_details.customer_segment_abbr.search("-");
this.CustSegAbbr = this.pd_all_details.pdmaster_details.customer_segment_abbr.substr(0, CSAbbrSearch);
this.notifier = notifier;
this.pdAddress = this.pd_all_details.pdmaster_details.addressline1;
this.pdState = this.pd_all_details.pdmaster_details.fk_state;
this.getCityAndPincodeDetails(this.pdState);
this.pdCity = this.pd_all_details.pdmaster_details.fk_city;
this.pdPincode = this.pd_all_details.pdmaster_details.pincode_id;
console.log('this.pdPincode', this.pdPincode);
this.pdOtherPincode = this.pdPincode == 1 ? this.pd_all_details.pdmaster_details.other_pincode : '';
console.log('this.pdOtherPincode', this.pdOtherPincode);
}
/**Init Fns of the class */
ngOnInit() {
this.initAddressForm();
this.getMasterDetails('PDLOCATIONAPPROACH', 1);
this.getMasterDetails('COMMENTSONLOCALITY', 2);
this.getMasterDetails('UOM', 3);
@ -112,70 +106,148 @@ export class AddressComponent implements OnInit {
this.getMasterDetails('ADDRESSTYPE', 5);
this.getMasterDetails('STATE', 6);
this.initAddressForm();
let params: any = {};
params.pd_id = this.pdid;
params.pd_form_id = '5';
this._pd.retriveForm(params).subscribe(data => {
const control = <FormArray>this.addressForm.controls['addresses'];
if (data.status == 200) {
if (data.records.addresses.length == 0) {
control.push(this.createAddresses(null));
// this.loadPDAddressesDetails();
} else {
data.records.addresses.forEach((datas,index) => {
let obj = {
'address': datas.address,
'address_type': datas.address_type,
'address_type_others': datas.address_type_others,
'state': datas.state,
'city': datas.city,
'pincode': datas.pincode,
'pincode_others': datas.pincode_others,
'locality': datas.locality,
'locality_others': datas.locality_others,
'locality_mixuse': datas.locality_mixuse,
'pd_location': datas.pd_location,
'comment_locality': datas.comment_locality,
'estimated_area': datas.estimated_area,
'uom': datas.uom,
'uom_others': datas.uom_others
}
this.getCityAndPincodeDetails(datas.state,index);
this.getOtherPincode(datas.pincode,index);
let selectedAddressType = this.addressData.filter(element => element.address_type_id == datas.address_type)[0];
this.selectedAddressType(selectedAddressType.address_type,index);
if (datas.address_type == 1) {
this.selectedAddressType(datas.address_type_others,index);
}
control.push(this.createAddresses(obj));
});
}
this.addressForm.controls.address.setValue(data.records.address);
this.addressForm.controls.state.setValue(data.records.state);
// this.addressForm.controls.address.setValue(data.records.address);
// this.addressForm.controls.state.setValue(data.records.state);
if (data.records.state != '') {
this.getCityAndPincodeDetails(data.records.state);
this.addressForm.controls.city.setValue(data.records.city);
this.addressForm.controls.pincode.setValue(data.records.pincode);
if (data.records.pincode == 1) {
this.addressForm.controls.pincode_others.setValue(data.records.pincode_others);
this.addressForm.controls.pincode_others.setValidators([Validators.required]);
this.addressForm.controls.pincode_others.updateValueAndValidity();
}
}
// if (data.records.state != '') {
// this.getCityAndPincodeDetails(data.records.state);
// this.addressForm.controls.city.setValue(data.records.city);
// this.addressForm.controls.pincode.setValue(data.records.pincode);
// if (data.records.pincode == 1) {
// this.addressForm.controls.pincode_others.setValue(data.records.pincode_others);
// this.addressForm.controls.pincode_others.setValidators([Validators.required]);
// this.addressForm.controls.pincode_others.updateValueAndValidity();
// }
// }
this.addressForm.controls.pd_location.setValue(data.records.pd_location);
this.addressForm.controls.address_type.setValue(data.records.address_type);
// this.addressForm.controls.pd_location.setValue(data.records.pd_location);
// this.addressForm.controls.address_type.setValue(data.records.address_type);
let selectedAddressType = this.addressData.filter(element => element.address_type_id == data.records.address_type)[0];
this.selectedAddressType(selectedAddressType.address_type);
// let selectedAddressType = this.addressData.filter(element => element.address_type_id == data.records.address_type)[0];
// this.selectedAddressType(selectedAddressType.address_type);
if (data.records.address_type == 1) {
this.addressForm.controls.address_type_others.setValue(data.records.address_type_others);
this.addressForm.controls.address_type_others.setValidators([Validators.required]);
this.addressForm.controls.address_type_others.updateValueAndValidity();
this.selectedAddressType(data.records.address_type_others);
}
// if (data.records.address_type == 1) {
// this.addressForm.controls.address_type_others.setValue(data.records.address_type_others);
// this.addressForm.controls.address_type_others.setValidators([Validators.required]);
// this.addressForm.controls.address_type_others.updateValueAndValidity();
// this.selectedAddressType(data.records.address_type_others);
// }
this.addressForm.controls.comment_locality.setValue(data.records.comment_locality);
// this.addressForm.controls.comment_locality.setValue(data.records.comment_locality);
this.addressForm.controls.locality.setValue(data.records.locality);
// this.addressForm.controls.locality.setValue(data.records.locality);
if (data.records.locality == 1) {
this.addressForm.controls.locality_others.setValue(data.records.locality_others);
this.addressForm.controls.locality_others.setValidators([Validators.required]);
this.addressForm.controls.locality_others.updateValueAndValidity();
}
if (data.records.locality == 5) {
this.addressForm.controls.locality_mixuse.setValue(data.records.locality_mixuse);
this.addressForm.controls.locality_mixuse.setValidators([Validators.required])
this.addressForm.controls.locality_mixuse.updateValueAndValidity();
}
// if (data.records.locality == 1) {
// this.addressForm.controls.locality_others.setValue(data.records.locality_others);
// this.addressForm.controls.locality_others.setValidators([Validators.required]);
// this.addressForm.controls.locality_others.updateValueAndValidity();
// }
// if (data.records.locality == 5) {
// this.addressForm.controls.locality_mixuse.setValue(data.records.locality_mixuse);
// this.addressForm.controls.locality_mixuse.setValidators([Validators.required])
// this.addressForm.controls.locality_mixuse.updateValueAndValidity();
// }
// this.addressForm.controls.estimated_area.setValue(data.records.estimated_area);
// this.addressForm.controls.uom.setValue(data.records.uom);
// if (data.records.uom == 1) {
// this.addressForm.controls.uom_others.setValue(data.records.uom_others);
// this.addressForm.controls.uom_others.setValidators([Validators.required])
// this.addressForm.controls.uom_others.updateValueAndValidity();
// }
this.addressForm.controls.estimated_area.setValue(data.records.estimated_area);
this.addressForm.controls.uom.setValue(data.records.uom);
if (data.records.uom == 1) {
this.addressForm.controls.uom_others.setValue(data.records.uom_others);
this.addressForm.controls.uom_others.setValidators([Validators.required])
this.addressForm.controls.uom_others.updateValueAndValidity();
}
this.addressForm.controls.address_form_remark.setValue(data.records.address_form_remark);
}
else{
this.loadPDAddressesDetails();
}
// else {
// control.push(this.createAddresses(null));
// }
});
}
loadPDAddressesDetails(){
const control = <FormArray>this.addressForm.controls['addresses'];
this._pd.getAddressesDetails(this.pdid).subscribe(
data => {
if (data.status == 200) {
this.addressesList = data.records;
if (this.addressesList.length > 0) {
this.addressesList.forEach((val,index)=>{
let obj = {
'address': val.addressline,
'address_type': '',
'address_type_others': '',
'state': val.fk_state,
'city': val.fk_city,
'pincode': val.pincode,
'pincode_others': val.other_pincode,
'locality': '',
'locality_others': '',
'locality_mixuse': '',
'pd_location': '',
'comment_locality': '',
'estimated_area': '',
'uom': '',
'uom_others': ''
}
this.getCityAndPincodeDetails(val.fk_state,index);
this.getOtherPincode(val.pincode,index);
control.push(this.createAddresses(obj));
});
}
// else{
// control.push(this.createAddresses(null));
// }
}
// else{
// control.push(this.createAddresses(null));
// }
});
}
// getM_Address_Type() {
// this._pd.getAllMasterDatas('ADDRESSTYPE').subscribe(
// data => {
@ -192,13 +264,52 @@ export class AddressComponent implements OnInit {
/** Address Form ELements */
public initAddressForm(): void {
this.addressForm = this.fb.group({
address: [this.pdAddress != '' ? this.pdAddress : '', Validators.compose([Validators.required])],
addresses: this.fb.array([]),
address_form_remark: ['']
});
// this.address = this.addressForm.controls['address'];
// this.state = this.addressForm.controls['state'];
// this.city = this.addressForm.controls['city'];
// this.pincode = this.addressForm.controls['pincode'];
// this.addressType = this.addressForm.controls['address_type'];
// this.locality = this.addressForm.controls['locality'];
// this.pdLocation = this.addressForm.controls['pd_location'];
// this.commentLocality = this.addressForm.controls['comment_locality'];
// this.estArea = this.addressForm.controls['estimated_area'];
// this.uom = this.addressForm.controls['uom'];
}
/** FOR Adress */
createAddresses(AddressDetails): FormGroup {
if(AddressDetails != null){
return this.fb.group({
address: [AddressDetails.address, Validators.compose([Validators.required])],
address_type: [AddressDetails.address_type, Validators.compose([Validators.required])],
address_type_others: [AddressDetails.address_type_others],
state: [AddressDetails.state],
city: [AddressDetails.city],
pincode: [AddressDetails.pincode],/** ,Validators.compose([Validators.minLength(6),Validators.maxLength(6)]) */
pincode_others: [AddressDetails.pincode_others, Validators.compose([Validators.minLength(6), Validators.maxLength(6)])],
locality: [AddressDetails.locality, Validators.compose([Validators.required])],
locality_others: [AddressDetails.locality_others],
locality_mixuse: [AddressDetails.locality_mixuse],
pd_location: [AddressDetails.pd_location, Validators.compose([Validators.required])],
comment_locality: [AddressDetails.comment_locality, Validators.compose([Validators.required])],
estimated_area: [AddressDetails.estimated_area],
uom: [AddressDetails.uom],
uom_others: [AddressDetails.uom_others]
});
}
else{
return this.fb.group({
address: ['', Validators.compose([Validators.required])],
address_type: ['', Validators.compose([Validators.required])],
address_type_others: [''],
state: [this.pdState != '' ? this.pdState : ''],
city: [this.pdCity != '' ? this.pdCity : ''],
pincode: [this.pdPincode != '' ? this.pdPincode : ''],/** ,Validators.compose([Validators.minLength(6),Validators.maxLength(6)]) */
pincode_others: [this.pdOtherPincode != '' ? this.pdOtherPincode : '', Validators.compose([Validators.minLength(6), Validators.maxLength(6)])],
state: [''],
city: [''],
pincode: [''],
pincode_others: ['', Validators.compose([Validators.minLength(6), Validators.maxLength(6)])],
locality: ['', Validators.compose([Validators.required])],
locality_others: [''],
locality_mixuse: [''],
@ -206,22 +317,20 @@ export class AddressComponent implements OnInit {
comment_locality: ['', Validators.compose([Validators.required])],
estimated_area: [''],
uom: [''],
uom_others: [''],
address_form_remark: ['']
//additional_premises: this.fb.array([])
uom_others: ['']
});
this.address = this.addressForm.controls['address'];
this.state = this.addressForm.controls['state'];
this.city = this.addressForm.controls['city'];
this.pincode = this.addressForm.controls['pincode'];
this.addressType = this.addressForm.controls['address_type'];
this.locality = this.addressForm.controls['locality'];
this.pdLocation = this.addressForm.controls['pd_location'];
this.commentLocality = this.addressForm.controls['comment_locality'];
this.estArea = this.addressForm.controls['estimated_area'];
this.uom = this.addressForm.controls['uom'];
}
}
}
// addAddresses() {
// const address_control = <FormArray>this.addressForm.controls['addresses'];
// address_control.push(this.createAddresses(null));
// }
// removeAddresses(index: number) {
// const address_control = <FormArray>this.addressForm.controls['addresses'];
// address_control.removeAt(index);
// }
/** To Get Dropdown Data For Address Form */
getMasterDetails(table: string, type: number) {
@ -252,88 +361,119 @@ export class AddressComponent implements OnInit {
/** To Get City And Pincode Data For Address Form
* Param 'stateID' -> selected StateId
*/
getCityAndPincodeDetails(stateID: string) {
getCityAndPincodeDetails(stateID: string,index) {
this._pd.getStateWiseCities(stateID).subscribe(data => {
if (data.status == 200) {
this.cityData = data.records.cities;
this.pincodeData = data.records.pincode;
this.cityData[index] = data.records.cities;
this.pincodeData[index] = data.records.pincode;
}
});
}
getOtherPincode(e,i){ this.otherPincodeFlag[i] = e == 1 ? true : false;}
/** TO Save Address Forms Details*/
onSubmit() {
// let addressesArrayValues = this.addressForm.controls.addresses.value;
// console.log(this.addressForm.controls.addresses);
// return;
// addressesArrayValues.forEach(data => {
// data.address_type.value == 1
// ? this.addressForm.controls['address_type_others'].setValidators([Validators.required])
// : this.addressForm.controls['address_type_others'].clearValidators();
// this.addressForm.controls['address_type_others'].updateValueAndValidity();
this.addressForm.controls.address_type.value == 1
? this.addressForm.controls['address_type_others'].setValidators([Validators.required])
: this.addressForm.controls['address_type_others'].clearValidators();
this.addressForm.controls['address_type_others'].updateValueAndValidity();
// data.controls.locality.value == 1
// ? this.addressForm.controls['locality_others'].setValidators([Validators.required])
// : this.addressForm.controls['locality_others'].clearValidators();
// this.addressForm.controls['locality_others'].updateValueAndValidity();
this.addressForm.controls.locality.value == 1
? this.addressForm.controls['locality_others'].setValidators([Validators.required])
: this.addressForm.controls['locality_others'].clearValidators();
this.addressForm.controls['locality_others'].updateValueAndValidity();
// data.controls.pincode.value == 1
// ? this.addressForm.controls['pincode_others'].setValidators([Validators.required])
// : this.addressForm.controls['pincode_others'].clearValidators();
// this.addressForm.controls['pincode_others'].updateValueAndValidity();
this.addressForm.controls.pincode.value == 1
? this.addressForm.controls['pincode_others'].setValidators([Validators.required])
: this.addressForm.controls['pincode_others'].clearValidators();
this.addressForm.controls['pincode_others'].updateValueAndValidity();
// data.controls.locality.value == 5
// ? this.addressForm.controls['locality_mixuse'].setValidators([Validators.required])
// : this.addressForm.controls['locality_mixuse'].clearValidators();
// this.addressForm.controls['locality_mixuse'].updateValueAndValidity();
this.addressForm.controls.locality.value == 5
? this.addressForm.controls['locality_mixuse'].setValidators([Validators.required])
: this.addressForm.controls['locality_mixuse'].clearValidators();
this.addressForm.controls['locality_mixuse'].updateValueAndValidity();
// data.controls.uom.value == 1
// ? this.addressForm.controls['uom_others'].setValidators([Validators.required])
// : this.addressForm.controls['uom_others'].clearValidators();
// this.addressForm.controls['uom_others'].updateValueAndValidity();
// });
// this.addressForm.controls.address_type.value == 1
// ? this.addressForm.controls['address_type_others'].setValidators([Validators.required])
// : this.addressForm.controls['address_type_others'].clearValidators();
// this.addressForm.controls['address_type_others'].updateValueAndValidity();
this.addressForm.controls.uom.value == 1
? this.addressForm.controls['uom_others'].setValidators([Validators.required])
: this.addressForm.controls['uom_others'].clearValidators();
this.addressForm.controls['uom_others'].updateValueAndValidity();
// this.addressForm.controls.locality.value == 1
// ? this.addressForm.controls['locality_others'].setValidators([Validators.required])
// : this.addressForm.controls['locality_others'].clearValidators();
// this.addressForm.controls['locality_others'].updateValueAndValidity();
// this.addressForm.controls.pincode.value == 1
// ? this.addressForm.controls['pincode_others'].setValidators([Validators.required])
// : this.addressForm.controls['pincode_others'].clearValidators();
// this.addressForm.controls['pincode_others'].updateValueAndValidity();
// this.addressForm.controls.locality.value == 5
// ? this.addressForm.controls['locality_mixuse'].setValidators([Validators.required])
// : this.addressForm.controls['locality_mixuse'].clearValidators();
// this.addressForm.controls['locality_mixuse'].updateValueAndValidity();
// this.addressForm.controls.uom.value == 1
// ? this.addressForm.controls['uom_others'].setValidators([Validators.required])
// : this.addressForm.controls['uom_others'].clearValidators();
// this.addressForm.controls['uom_others'].updateValueAndValidity();
if (!this.addressForm.valid) {
this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!');
return;
}
// if(this.address.value.bussiness_activity_remark == ''){
// this.notifier.notify('warning', 'Fill Remark!');
// return;
// }
if(this.addressForm.value.bussiness_activity_remark == ''){
this.notifier.notify('warning', 'Fill Remark!');
return;
}
let records: any = {};
records.address = this.address.value;
records.state = this.state.value;
records.city = this.city.value;
records.address_type = this.addressType.value;
records.addresses = this.addressForm.controls.addresses.value;
// records.address = this.address.value;
// records.state = this.state.value;
// records.city = this.city.value;
// records.address_type = this.addressType.value;
records.address_type_others = this.addressType.value == 1 ?
this.addressForm.controls.address_type_others.value : '';
// records.address_type_others = this.addressType.value == 1 ?
// this.addressForm.controls.address_type_others.value : '';
records.locality = this.locality.value;
records.locality_others = this.locality.value == 1 ?
this.addressForm.controls.locality_others.value : '';
// records.locality = this.locality.value;
// records.locality_others = this.locality.value == 1 ?
// this.addressForm.controls.locality_others.value : '';
records.locality_mixuse = this.locality.value == 5 ?
this.addressForm.controls.locality_mixuse.value : '';
// records.locality_mixuse = this.locality.value == 5 ?
// this.addressForm.controls.locality_mixuse.value : '';
records.pincode = this.pincode.value;
records.pincode_others = this.pincode.value == 1 ?
this.addressForm.controls.pincode_others.value : '';
// records.pincode = this.pincode.value;
// records.pincode_others = this.pincode.value == 1 ?
// this.addressForm.controls.pincode_others.value : '';
records.pd_location = this.pdLocation.value;
records.comment_locality = this.commentLocality.value;
// records.pd_location = this.pdLocation.value;
// records.comment_locality = this.commentLocality.value;
records.address_form_remark = this.addressForm.controls.address_form_remark.value;
records.estimated_area = this.estArea.value;
// records.estimated_area = this.estArea.value;
records.uom = this.uom.value;
records.uom_others = records.uom == 1 ?
this.addressForm.controls.uom_others.value : '';
// records.uom = this.uom.value;
// records.uom_others = records.uom == 1 ?
// this.addressForm.controls.uom_others.value : '';
records.pdid = this.pdid;
records.formid = '5';
// records.fk_createdby = '250';
// console.log(JSON.stringify(records));
this._pd.saveForm(records).subscribe(data => {
if (data.status == 200) {
@ -352,9 +492,9 @@ export class AddressComponent implements OnInit {
/** For PlaceHolder
* selected AddressType is concate with label */
selectedAddressType(e: any) {
console.log(e);
this.placeholderName = 'Estimated area of the ' + e;
selectedAddressType(e: any,i) {
this.placeholderName[i] = 'Estimated area of the ' + e;
}

View File

@ -135,6 +135,7 @@ export class FinancialInfoComponent implements OnInit {
let retriveData = value.records;
if(value.records.is_financial_statements == 'yes'){
this.isDisplay = true;
/** Backend Data of Asper Statement */
let result = Object.keys(value.records.date_per_financial).map(function(key) {
return value.records.date_per_financial[key];

View File

@ -66,7 +66,7 @@ export class PdTrigerService {
/* To get addresses From T_PD_ADDRESS table.,
* Used In 1) edit pd trigger component
* 2)
* 2) Address Form
*/
getAddressesDetails(pdID): Observable<any> {
return this._http.post<any>(this.apiUrl + 'getPDAddress', { "pd_id": pdID })