Vendor search filter
This commit is contained in:
parent
09a3e56875
commit
f698156061
@ -1,6 +1,6 @@
|
|||||||
import { Component, OnInit, Inject, ViewEncapsulation } from '@angular/core';
|
import { Component, OnInit, Inject, ViewEncapsulation } from '@angular/core';
|
||||||
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
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 { NotifierService } from 'angular-notifier';
|
||||||
import { PdTrigerService } from '../../../pd-service/pd-triger.service';
|
import { PdTrigerService } from '../../../pd-service/pd-triger.service';
|
||||||
// import { AllocationViewMoreComponent } from './../allocation-view-more/allocation-view-more.component';
|
// import { AllocationViewMoreComponent } from './../allocation-view-more/allocation-view-more.component';
|
||||||
@ -18,6 +18,10 @@ export class VendorPdAllocationComponent implements OnInit {
|
|||||||
notifier: NotifierService;
|
notifier: NotifierService;
|
||||||
selectedItem: any;
|
selectedItem: any;
|
||||||
isDisabled: boolean;
|
isDisabled: boolean;
|
||||||
|
searchForm:FormGroup;
|
||||||
|
public submitted = false;
|
||||||
|
cityList: any = [];
|
||||||
|
stateList: any = [];
|
||||||
|
|
||||||
constructor(notifier: NotifierService,
|
constructor(notifier: NotifierService,
|
||||||
private _fb: FormBuilder,
|
private _fb: FormBuilder,
|
||||||
@ -26,11 +30,19 @@ export class VendorPdAllocationComponent implements OnInit {
|
|||||||
@Inject(MAT_DIALOG_DATA) public data: any) {
|
@Inject(MAT_DIALOG_DATA) public data: any) {
|
||||||
console.log(data)
|
console.log(data)
|
||||||
this.notifier = notifier;
|
this.notifier = notifier;
|
||||||
|
|
||||||
|
this.searchForm = this._fb.group(
|
||||||
|
{
|
||||||
|
vendor_name:[null],
|
||||||
|
state: [null],
|
||||||
|
city:[null]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.isDisabled = true;
|
this.isDisabled = true;
|
||||||
this.getVendorList();
|
this.getVendorList();
|
||||||
|
this.getStateCityList();
|
||||||
|
|
||||||
// this._pdAllocationForm = this._fb.group({
|
// this._pdAllocationForm = this._fb.group({
|
||||||
// pd_primary_id: [null],
|
// pd_primary_id: [null],
|
||||||
@ -38,6 +50,7 @@ export class VendorPdAllocationComponent implements OnInit {
|
|||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// convenience getter for easy access to form fields
|
// convenience getter for easy access to form fields
|
||||||
// get readForm() { return this._pdAllocationForm.controls; }
|
// get readForm() { return this._pdAllocationForm.controls; }
|
||||||
// pd officer list
|
// 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 */
|
/** For Popup Close Button */
|
||||||
closeAllocationComponent(): void {
|
closeAllocationComponent(): void {
|
||||||
this.dialogRef.close();
|
this.dialogRef.close();
|
||||||
|
|||||||
@ -10,6 +10,33 @@
|
|||||||
</h2>
|
</h2>
|
||||||
<mat-dialog-content class="mat-typography">
|
<mat-dialog-content class="mat-typography">
|
||||||
<!-- <form [formGroup]="_pdAllocationForm" (submit)="onSubmit()"> -->
|
<!-- <form [formGroup]="_pdAllocationForm" (submit)="onSubmit()"> -->
|
||||||
|
<div [formGroup]="searchForm">
|
||||||
|
<mat-form-field style="width:30%">
|
||||||
|
<input matInput type="text" formControlName="vendor_name" placeholder="Vendor Name" >
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field style="width: 30%">
|
||||||
|
<mat-select placeholder="State" formControlName="state" (selectionChange)="getCityList($event.value,i)">
|
||||||
|
<mat-option *ngFor="let SL of stateList" [value]="SL.state_id">{{SL.name}}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field style="width:30%" *ngIf="searchForm.value.state != '' && searchForm.value.state != null" >
|
||||||
|
<mat-select formControlName="city" placeholder="City">
|
||||||
|
<mat-option *ngFor="let CL of cityList[i]" [value]="CL.city_id">{{CL.city_name}}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
|
||||||
|
<button type="button" mat-raised-button mat-icon-button (click)="onReset()"
|
||||||
|
matTooltip="Reset" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary">
|
||||||
|
<mat-icon>settings_backup_restore</mat-icon>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button type="button" mat-raised-button mat-icon-button (click)="searchItem()"
|
||||||
|
matTooltip="Search" matTooltipPosition="above" class="mr-1 mb-1 hover-icon" color="primary" type="button">
|
||||||
|
<mat-icon>search</mat-icon>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<mat-list role="list" *ngIf="pdOfficerList.length > 0">
|
<mat-list role="list" *ngIf="pdOfficerList.length > 0">
|
||||||
|
|
||||||
@ -37,7 +64,7 @@
|
|||||||
</mat-list>
|
</mat-list>
|
||||||
<mat-list *ngIf="pdOfficerList.length == 0">
|
<mat-list *ngIf="pdOfficerList.length == 0">
|
||||||
<mat-list-item>
|
<mat-list-item>
|
||||||
<p>No PD officer available.</p>
|
<p>No Vendor officer available.</p>
|
||||||
</mat-list-item>
|
</mat-list-item>
|
||||||
</mat-list>
|
</mat-list>
|
||||||
|
|
||||||
|
|||||||
@ -303,7 +303,15 @@ export class PdTrigerService {
|
|||||||
catchError(this.handleError('role', []))
|
catchError(this.handleError('role', []))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
//search vendor list
|
||||||
|
searchListOfvendors(params): Observable<any>{
|
||||||
|
let SearchVendor =
|
||||||
|
{ params: new HttpParams().set('vendor_name', params.vendor_name).set('location', params.city) };
|
||||||
|
return this._http.get<any>(this.apiUrl+'getListOfvendors',SearchVendor)
|
||||||
|
.pipe(
|
||||||
|
catchError(this.handleError('operation', []))
|
||||||
|
)
|
||||||
|
}
|
||||||
// get Vendor List
|
// get Vendor List
|
||||||
getVendorList() {
|
getVendorList() {
|
||||||
return this._http.get<any>(this.apiUrl + 'getListOfvendors')
|
return this._http.get<any>(this.apiUrl + 'getListOfvendors')
|
||||||
|
|||||||
@ -220,7 +220,7 @@ console.log("cog",userData,this.usersData)
|
|||||||
if (this.usersData === undefined) {
|
if (this.usersData === undefined) {
|
||||||
this.AWS.register(userData).subscribe(res => {
|
this.AWS.register(userData).subscribe(res => {
|
||||||
if (res.User.UserStatus != '' && res.User.UserStatus !== undefined && res.User.UserStatus != null) {
|
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.AWS.UserGroup(res,userData).subscribe(res=>{});}
|
||||||
this.users.saveRecords(res, userData).subscribe(res => {
|
this.users.saveRecords(res, userData).subscribe(res => {
|
||||||
data = res;
|
data = res;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user