From f6981560617901375a640096468397a7e2565883 Mon Sep 17 00:00:00 2001 From: sriram-at-840620226347 Date: Wed, 22 Jul 2020 18:53:20 +0530 Subject: [PATCH] Vendor search filter --- .../VendorPdAllocationComponent.ts | 72 ++++++++++++++++++- .../vendor-pd-allocation.component.html | 29 +++++++- .../pd-service/pd-triger.service.ts | 10 ++- .../users/register/register.component.ts | 2 +- 4 files changed, 109 insertions(+), 4 deletions(-) diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/vendor-pd-allocation/VendorPdAllocationComponent.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/vendor-pd-allocation/VendorPdAllocationComponent.ts index 418ffe083..0aad7bb83 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/vendor-pd-allocation/VendorPdAllocationComponent.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/vendor-pd-allocation/VendorPdAllocationComponent.ts @@ -1,6 +1,6 @@ import { Component, OnInit, Inject, ViewEncapsulation } from '@angular/core'; import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; -import { FormBuilder, FormGroup } from '@angular/forms'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { NotifierService } from 'angular-notifier'; import { PdTrigerService } from '../../../pd-service/pd-triger.service'; // import { AllocationViewMoreComponent } from './../allocation-view-more/allocation-view-more.component'; @@ -18,6 +18,10 @@ export class VendorPdAllocationComponent implements OnInit { notifier: NotifierService; selectedItem: any; isDisabled: boolean; + searchForm:FormGroup; + public submitted = false; + cityList: any = []; + stateList: any = []; constructor(notifier: NotifierService, private _fb: FormBuilder, @@ -26,11 +30,19 @@ export class VendorPdAllocationComponent implements OnInit { @Inject(MAT_DIALOG_DATA) public data: any) { console.log(data) this.notifier = notifier; + + this.searchForm = this._fb.group( + { + vendor_name:[null], + state: [null], + city:[null] + }); } ngOnInit() { this.isDisabled = true; this.getVendorList(); + this.getStateCityList(); // this._pdAllocationForm = this._fb.group({ // pd_primary_id: [null], @@ -38,6 +50,7 @@ export class VendorPdAllocationComponent implements OnInit { // }); } + // convenience getter for easy access to form fields // get readForm() { return this._pdAllocationForm.controls; } // pd officer list @@ -80,6 +93,63 @@ export class VendorPdAllocationComponent implements OnInit { }); } } + + //get State + getStateCityList() { + this._pd.getAllMasterDatas('STATE').subscribe( + data => { + if (data.status == 200) { + this.stateList = data.records.filter(item => item.isactive == 1); + // this.stateData = this.stateList; + } + }); +} + //get city list details based on state id + getCityList(stateID: string,index) { + this._pd.getStateWiseCities(stateID).subscribe(data => { + if (data.status == 200) { + this.cityList[index] = data.records.cities; + // this.cityData[index] = this.cityList[index]; + } + }); + } + + /** To Save/Edited Popup Data */ + searchItem() { + this.submitted = true; + + var searchVendor = this.searchForm.value; + + if(searchVendor.vendor_name == null && searchVendor.city == null){ + this.notifier.notify('warning', 'Please fill the feilds'); + return; + } + + //To Remove The "Null" With Key also + Object.keys(searchVendor).forEach((key) => (searchVendor[key] == null) && delete searchVendor[key]); + + //Add BRANCH data with help Service File + this._pd.searchListOfvendors(searchVendor).subscribe( + dataresult => { + if (dataresult.status == 200) { + console.log(dataresult); + this.pdOfficerList = dataresult.records; + } + else{ + this.pdOfficerList=[]; + this.notifier.notify('warning', 'No Records Found !'); + } + }, error => { + this.dialogRef.close(null); + this.notifier.notify('error', 'Something Went Wrong Try Again.! \t\"' + (error.error_type == 2 ? error.error_status + ' ( ' + error.error_text + ' ) ' : ' ( ' + error.error_text + ' ) ') +'\" Error Occur.!'); + // this.errorMessage = "Something Went Wrong Try Again !"; + }); + } + + onReset(){ + this.searchForm.reset(); + this.getVendorList(); + } /** For Popup Close Button */ closeAllocationComponent(): void { this.dialogRef.close(); diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/vendor-pd-allocation/vendor-pd-allocation.component.html b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/vendor-pd-allocation/vendor-pd-allocation.component.html index f35692e2f..5f3558481 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/vendor-pd-allocation/vendor-pd-allocation.component.html +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/vendor-pd-allocation/vendor-pd-allocation.component.html @@ -10,6 +10,33 @@ +
+ + +     + + + {{SL.name}} + +     + + + {{CL.city_name}} + +     + + +     + + + +
@@ -37,7 +64,7 @@ -

No PD officer available.

+

No Vendor officer available.

diff --git a/ng6-seed/src/app/personal-discussion/pd-service/pd-triger.service.ts b/ng6-seed/src/app/personal-discussion/pd-service/pd-triger.service.ts index 9f4ba477a..74a50890f 100755 --- a/ng6-seed/src/app/personal-discussion/pd-service/pd-triger.service.ts +++ b/ng6-seed/src/app/personal-discussion/pd-service/pd-triger.service.ts @@ -303,7 +303,15 @@ export class PdTrigerService { catchError(this.handleError('role', [])) ) } - + //search vendor list + searchListOfvendors(params): Observable{ + let SearchVendor = + { params: new HttpParams().set('vendor_name', params.vendor_name).set('location', params.city) }; + return this._http.get(this.apiUrl+'getListOfvendors',SearchVendor) + .pipe( + catchError(this.handleError('operation', [])) + ) + } // get Vendor List getVendorList() { return this._http.get(this.apiUrl + 'getListOfvendors') diff --git a/ng6-seed/src/app/settings/users/register/register.component.ts b/ng6-seed/src/app/settings/users/register/register.component.ts index edbaa2c22..4c01f8540 100755 --- a/ng6-seed/src/app/settings/users/register/register.component.ts +++ b/ng6-seed/src/app/settings/users/register/register.component.ts @@ -220,7 +220,7 @@ console.log("cog",userData,this.usersData) if (this.usersData === undefined) { this.AWS.register(userData).subscribe(res => { if (res.User.UserStatus != '' && res.User.UserStatus !== undefined && res.User.UserStatus != null) { - if(userData.role.role_id == 10){ + if(userData.role.role_id == 10 || userData.role.role_id == 21){ this.AWS.UserGroup(res,userData).subscribe(res=>{});} this.users.saveRecords(res, userData).subscribe(res => { data = res;