import{c as v}from"./chunk-TNAVBFSM.js";import{d as _}from"./chunk-GPCBDOQR.js";import{a as y}from"./chunk-D2E2EQ56.js";import{a as w,b as s}from"./chunk-XVWHZ5TH.js";import{Bb as m,J as u,L as d,g as i,gd as g,la as b,p as l,sb as a,vc as f,wc as p,xc as S}from"./chunk-LEOKSAW2.js";import{d as o,n as I}from"./chunk-HE7HQ6LI.js";import{j as n}from"./chunk-K4ALXBGI.js";I();var x=["table"],C=class c{get criteria(){return this._criteria}get filterData(){return this._filterData}get translate(){return this.localizationService.getSync.bind(this.localizationService)}get filters(){return this._filters}set filters(e){this._filters=e}constructor(e,t){this.cdr=e,this.drawerService=t,this.localizationService=b(_),this.orderBy="id",this.isAscending=!0,this.tableHeight="450px",this.disableDynamicTableHeight=!1,this.filterSubmitted=new i,this.filterCanceled=new i,this._searchSubject=new i,this._warehouseIdSubject=new i,this._accountIdSubject=new i,this._cashboxIdSubject=new i,this._criteria=null}ngOnInit(){this.dataSource=new y({key:"id",cacheRawData:!1,load:e=>n(this,null,function*(){let t={criteria:this.criteria??null,skip:e.skip??0,take:e.take??100,orderBy:this.orderBy,isAscending:this.isAscending},r=yield l(this.getLoadMethod(t).pipe(d(1)));return this.table&&!this.disableDynamicTableHeight&&(this.table.dataGrid.height=r.data.length>10?this.tableHeight:"100%",this.cdr.markForCheck()),{data:r.data,totalCount:r.count}})}),this._searchSubject.pipe(u(300),s(this)).subscribe(e=>{this.searchValue=e,this.table.refresh()}),this._warehouseIdSubject.pipe(s(this)).subscribe(e=>{this.warehouseId=e,this.table?.refresh()}),this._accountIdSubject.pipe(s(this)).subscribe(e=>{this.accountId=e,this.table?.refresh()}),this._cashboxIdSubject.pipe(s(this)).subscribe(e=>{this.cashboxId=e,this.table?.refresh()})}openFilters(){let e=this.drawerService.open(this.filterComponent,{data:this.filterData,header:this.localizationService.getSync("\u0424\u0438\u043B\u044C\u0442\u0440\u044B"),submitButton:{label:this.localizationService.getSync("\u041F\u0440\u0438\u043C\u0435\u043D\u0438\u0442\u044C"),variant:"success"},cancelButton:this.localizationService.getSync("\u0421\u0431\u0440\u043E\u0441\u0438\u0442\u044C \u0444\u0438\u043B\u044C\u0442\u0440\u044B")});e.submitted.pipe(s(this)).subscribe(t=>{this.previousFilters=this.filters,this.filters=t,e.close(),this.table.refresh(),this.filterSubmitted.next(t),this.cdr.detectChanges()}),e.canceled.pipe(s(this)).subscribe(()=>{this.previousFilters=this.filters,this.filters=null,this.table.refresh(),this.filterCanceled.next(),this.cdr.detectChanges()})}changedSearch(e){this._searchSubject.next(e)}changedWarehouse(e,t){this._warehouseIdSubject.next(e),t&&t.router.navigate([],{relativeTo:t.route,queryParams:{warehouseId:e},queryParamsHandling:"merge"})}changedAccount(e,t){this._accountIdSubject.next(e),t&&t.router.navigate([],{relativeTo:t.route,queryParams:{accountId:e},queryParamsHandling:"merge"})}changedCashbox(e,t){this._cashboxIdSubject.next(e),t&&t.router.navigate([],{relativeTo:t.route,queryParams:{cashboxId:e},queryParamsHandling:"merge"})}static{this.\u0275fac=function(t){return new(t||c)(a(g),a(v))}}static{this.\u0275cmp=m({type:c,selectors:[["tis-base-table-view"]],viewQuery:function(t,r){if(t&1&&f(x,5),t&2){let h;p(h=S())&&(r.table=h.first)}},decls:0,vars:0,template:function(t,r){},encapsulation:2})}};C=o([w()],C);export{C as a};
