city issue fixed

This commit is contained in:
surya 2022-03-18 19:50:32 +05:30
parent 5d04b39ead
commit e67fbc9eb3

View File

@ -15,6 +15,7 @@ import { takeUntil } from 'rxjs/operators';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { MatDialog } from '@angular/material'; import { MatDialog } from '@angular/material';
import { ExcelUploadDialogComponent } from './excel-upload-dialog/excel-upload-dialog.component'; import { ExcelUploadDialogComponent } from './excel-upload-dialog/excel-upload-dialog.component';
import { log } from 'console';
@Component({ @Component({
selector: 'app-add-pd', selector: 'app-add-pd',
templateUrl: './add-pd.component.html', templateUrl: './add-pd.component.html',
@ -84,6 +85,7 @@ export class AddPdComponent implements OnInit, OnDestroy {
prod_seg: any; prod_seg: any;
usertype: string; usertype: string;
range: any; range: any;
pincodedata: any;
constructor(notifier: NotifierService, private _fb: FormBuilder, private route: ActivatedRoute, constructor(notifier: NotifierService, private _fb: FormBuilder, private route: ActivatedRoute,
private router: Router, private _pd: PdTrigerService, private _aws: AwsService, private ListPdComponent: ListPdComponent, private router: Router, private _pd: PdTrigerService, private _aws: AwsService, private ListPdComponent: ListPdComponent,
private titleCase : TitleCasePipe,private userService:UserService,private matDialog:MatDialog) { private titleCase : TitleCasePipe,private userService:UserService,private matDialog:MatDialog) {
@ -407,9 +409,11 @@ export class AddPdComponent implements OnInit, OnDestroy {
//get city list details based on state id //get city list details based on state id
getCityList(stateID: string,index) { getCityList(stateID: string,index) {
console.log(stateID)
this.getvendor(stateID) this.getvendor(stateID)
this._pd.getStateWiseCities(stateID).subscribe(data => { this._pd.getStateWiseCities(stateID).subscribe(data => {
if (data.status == 200) { if (data.status == 200) {
console.log(data.records)
this.cityList[index] = data.records.cities; this.cityList[index] = data.records.cities;
this.pincodeList[index] = data.records.pincode; this.pincodeList[index] = data.records.pincode;
this.cityData[index]=this.cityList[index] this.cityData[index]=this.cityList[index]
@ -587,7 +591,8 @@ export class AddPdComponent implements OnInit, OnDestroy {
this.lengthCheckToaddMore = 1; this.lengthCheckToaddMore = 1;
} }
} }
getPincode(e,i){ this.pincodeflag[i] = e == 1 ? true : false;} getPincode(e,i){ this.pincodeflag[i] = e == 1 ? true : false;
console.log(e , i)}
// save pd in draft // save pd in draft
saveDraftPD(formValue: any, status: string) { saveDraftPD(formValue: any, status: string) {
//alert('Inside The Draft PD'); //alert('Inside The Draft PD');
@ -794,7 +799,7 @@ export class AddPdComponent implements OnInit, OnDestroy {
control_address.get('pincode').enable() control_address.get('pincode').enable()
// this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!'); // this.notifier.notify('warning', 'Please Fill All Mandatory Fields.!');
} }
else if(formValue.addresses[0].pincode == undefined ) else if(formValue.addresses[0].pincode == undefined && formValue.addresses[0].pincode == "")
{ {
let control_address = this._PDtriggerForm.get('addresses')['controls'][0] as FormArray let control_address = this._PDtriggerForm.get('addresses')['controls'][0] as FormArray
control_address.get('pincode').enable() control_address.get('pincode').enable()
@ -1326,10 +1331,13 @@ searchFun(control:any,i:number,option){
// control_address.get('fk_state') // control_address.get('fk_state')
// control_address.get('fk_city') // control_address.get('fk_city')
// control_address.get('pincode') // control_address.get('pincode')
console.log('jkhjjjhguhg')
control_address.get('addressline1').disable() control_address.get('addressline1').disable()
control_address.get('fk_state').disable() control_address.get('fk_state').disable()
control_address.get('fk_city').disable() control_address.get('fk_city').disable()
control_address.get('pincode').disable() control_address.get('pincode').disable()
let pincode = control_address.get('pincode');
console.log(pincode);
this.choosed_address.setValidators(Validators.required) this.choosed_address.setValidators(Validators.required)
} }
@ -1341,9 +1349,8 @@ searchFun(control:any,i:number,option){
} }
}) })
} }
onChangeSelectedAddress(value) { onChangeSelectedAddress(value) {
console.log(value)
let state=value.state; let state=value.state;
this.getvendor(state) this.getvendor(state)
if(value) { if(value) {
@ -1351,9 +1358,31 @@ searchFun(control:any,i:number,option){
console.log(control_address); console.log(control_address);
control_address.get('addressline1').setValue(value.addressline) control_address.get('addressline1').setValue(value.addressline)
control_address.get('fk_state').setValue(value.state) control_address.get('fk_state').setValue(value.state)
this.getCityList(value.state,0);
control_address.get('fk_city').setValue(value.city) control_address.get('fk_city').setValue(value.city)
control_address.get('pincode').setValue(value.pincode) this.getCityList(value.state,0);
this._pd.getStateWiseCities(value.state).subscribe(data => {
if (data.status == 200) {
this.pincodedata = data.records.pincode;
console.log( this.pincodedata )
let pincode_is_avai = this.pincodedata.filter(t=>t.pincode_id ==value.pincode);
let length=pincode_is_avai.length;
console.log( length )
if(length==0)
{
control_address.get('pincode').enable()
control_address.get('pincode').setValue("")
}
else
{
control_address.get('pincode').setValue(value.pincode)
}
}
});
} }
} }
changePDTypeSlideValue(event) { changePDTypeSlideValue(event) {