Переписала фильтрацию в списке заказов

This commit is contained in:
Luba Kaysina 2022-06-30 10:49:03 +04:00
parent 917eb7416a
commit 35fa921b20
3 changed files with 32 additions and 5 deletions

View File

@ -23,8 +23,8 @@
</tr> </tr>
<tr style="position:sticky !important; top: 55px"> <tr style="position:sticky !important; top: 55px">
<th></th> <th></th>
<th><p-columnFilter type="text" field="status_h"></p-columnFilter></th> <th><p-columnFilter type="text" field="status_h" [matchModeOptions]="matchModeOptions" [matchMode]="'custom-contains'"></p-columnFilter></th>
<th><p-columnFilter type="text" field="address.name"></p-columnFilter></th> <th><p-columnFilter type="text" field="address.name" [matchModeOptions]="matchModeOptions" [matchMode]="'custom-contains'"></p-columnFilter></th>
<th></th> <th></th>
<th></th> <th></th>
<th></th> <th></th>
@ -53,7 +53,7 @@
<ng-template #order_v> <ng-template #order_v>
<div> <div>
<button (click)="listOrders()">К списку заказов</button> <button (click)="listOrders()">К списку</button>
<h1>Заказ: {{order[0].id}}</h1> <h1>Заказ: {{order[0].id}}</h1>
<p-table [value]="order"> <p-table [value]="order">
<ng-template pTemplate="header"> <ng-template pTemplate="header">

View File

@ -5,7 +5,7 @@ import { MessageService } from "primeng/api";
import { Order, Products, Delivery_address, Notification, Refund } from "src/app/interface/data"; import { Order, Products, Delivery_address, Notification, Refund } from "src/app/interface/data";
import { ClientsComponent } from "../clients/clients.component"; import { ClientsComponent } from "../clients/clients.component";
import { ToastModule } from 'primeng/toast'; import { ToastModule } from 'primeng/toast';
import { ConfirmationService } from 'primeng/api'; import { ConfirmationService, FilterService, FilterMatchMode, SelectItem } from 'primeng/api';
/*import { SwPush, NewsletterService } from '@angular/service-worker*/ /*import { SwPush, NewsletterService } from '@angular/service-worker*/
@ -33,6 +33,7 @@ export class OrdersComponent implements OnInit {
public sumRef0: any = 0; public sumRef0: any = 0;
public sumRef1: any = 0; public sumRef1: any = 0;
public sumRef2: any = 0; public sumRef2: any = 0;
public matchModeOptions!: SelectItem[];
public statuses = [ public statuses = [
@ -58,7 +59,8 @@ export class OrdersComponent implements OnInit {
private jsonRpcService: JsonrpcService, private jsonRpcService: JsonrpcService,
private messageService: MessageService, private messageService: MessageService,
private clientsComponent: ClientsComponent, private clientsComponent: ClientsComponent,
private confirmationService: ConfirmationService private confirmationService: ConfirmationService,
private filterService: FilterService
) { ) {
} }
@ -73,7 +75,27 @@ export class OrdersComponent implements OnInit {
setInterval(() => this.getOrders(), 60000); setInterval(() => this.getOrders(), 60000);
this.chooseName = this.jsonRpcService.ClientChooseName; this.chooseName = this.jsonRpcService.ClientChooseName;
} }
const customFilterName = "custom-contains";
this.filterService.register(customFilterName, (value: any, filter: any): boolean => {
if (filter === undefined || filter === null || filter.trim() === '') {
return true;
}
if (value === undefined || value === null) {
return false;
}
let det = value.toString()
let det2 = det.toLowerCase()
return det2.includes(filter.toString()) || det.includes(filter.toString());
});
this.matchModeOptions = [
{ label: 'Содержит', value: customFilterName },
{ label: 'Равно', value: FilterMatchMode.EQUALS },
{ label: 'Начинается с', value: FilterMatchMode.STARTS_WITH },
];
} }
notif() { notif() {

View File

@ -94,6 +94,11 @@ export class TerminalsComponent implements OnInit {
setTimeout(() => document.getElementsByTagName("input")[1].value = division_id, 100); setTimeout(() => document.getElementsByTagName("input")[1].value = division_id, 100);
this.jsonRpcService.changeId = id; this.jsonRpcService.changeId = id;
this.getAreas() this.getAreas()
for (let i = 0; i < this.areas.length; i++) {
if (this.areas[i].name == area_types) {
this.areas[i].selected = true
}
}
} }
updateTerminal() { updateTerminal() {