import{c as y}from"./chunk-DL4FRBQZ.js";import{m as _}from"./chunk-TLX24J4H.js";import{a as g,b as i}from"./chunk-RBR4ZJRC.js";import{Ab as b,I as l,K as d,g as s,gd as w,p as u,rb as a,uc as m,vc as p,wc as f}from"./chunk-ZGECHOBP.js";import{b as n,i as S}from"./chunk-QOJKCMZT.js";import{j as o}from"./chunk-K4ALXBGI.js";S();var v=["table"],I=class h{get criteria(){return this._criteria}get filterData(){return this._filterData}get filters(){return this._filters}set filters(e){this._filters=e}constructor(e,t){this.cdr=e,this.drawerService=t,this.orderBy="id",this.isAscending=!0,this.tableHeight="450px",this._searchSubject=new s,this._warehouseIdSubject=new s,this._accountIdSubject=new s,this._cashboxIdSubject=new s,this._criteria=null}ngOnInit(){this.dataSource=new _({key:"id",cacheRawData:!1,load:e=>o(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 u(this.getLoadMethod(t).pipe(d(1)));return this.table&&(this.table.dataGrid.height=r.data.length>10?this.tableHeight:"100%",this.cdr.markForCheck()),{data:r.data,totalCount:r.count}})}),this._searchSubject.pipe(l(300),i(this)).subscribe(e=>{this.searchValue=e,this.table.refresh()}),this._warehouseIdSubject.pipe(i(this)).subscribe(e=>{this.warehouseId=e,this.table?.refresh()}),this._accountIdSubject.pipe(i(this)).subscribe(e=>{this.accountId=e,this.table?.refresh()}),this._cashboxIdSubject.pipe(i(this)).subscribe(e=>{this.cashboxId=e,this.table?.refresh()})}openFilters(){let e=this.drawerService.open(this.filterComponent,{data:this.filterData,header:"\u0424\u0438\u043B\u044C\u0442\u0440\u044B",submitButton:{label:"\u041F\u0440\u0438\u043C\u0435\u043D\u0438\u0442\u044C",variant:"success"},cancelButton:"\u0421\u0431\u0440\u043E\u0441\u0438\u0442\u044C \u0444\u0438\u043B\u044C\u0442\u0440\u044B"});e.submitted.pipe(i(this)).subscribe(t=>{this.filters=t,e.close(),this.table.refresh(),this.cdr.detectChanges()}),e.canceled.pipe(i(this)).subscribe(()=>{this.filters=null,this.table.refresh(),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||h)(a(w),a(y))}}static{this.\u0275cmp=b({type:h,selectors:[["tis-base-table-view"]],viewQuery:function(t,r){if(t&1&&m(v,5),t&2){let c;p(c=f())&&(r.table=c.first)}},standalone:!1,decls:0,vars:0,template:function(t,r){},encapsulation:2})}};I=n([g()],I);export{I as a};
