import{a as J}from"./chunk-IDKT5PCT.js";import{c as H}from"./chunk-NXFRFRZF.js";import{a as q}from"./chunk-TIU2IJHG.js";import{a as Q}from"./chunk-QYJGZ7EQ.js";import{a as K,b as X,c as Y,d as Z,f as ee}from"./chunk-TOWCQIUF.js";import"./chunk-AE2SE5YA.js";import"./chunk-TFYURWU4.js";import{a as $}from"./chunk-FBUBZ6AE.js";import"./chunk-VFX53AYF.js";import"./chunk-AMCGKSO5.js";import"./chunk-JAY45DEO.js";import"./chunk-LINAD4CC.js";import"./chunk-ZVQ5RRLK.js";import"./chunk-ZBHD2A5S.js";import{b as G,e as W,f as c}from"./chunk-XJK5B3XJ.js";import{Ia as O,La as V,Ya as j,oa as k}from"./chunk-NKXT7PF4.js";import"./chunk-QVBHH5C3.js";import{a as N,b as m}from"./chunk-IGFM5CCE.js";import{a as P}from"./chunk-FTPWLRQ4.js";import"./chunk-CC7H2Q52.js";import"./chunk-FWAWZDGH.js";import"./chunk-WUNNKW5D.js";import"./chunk-IFY4UZPR.js";import"./chunk-7R42RYQZ.js";import"./chunk-PLVHWZTL.js";import"./chunk-PDYJ5OYY.js";import"./chunk-7WGMNLRJ.js";import"./chunk-YMOV4UGM.js";import{ua as A}from"./chunk-TDUJNOEU.js";import{Db as T,Ec as y,Hb as z,Ib as v,Jc as U,K as _,Lc as B,Yc as F,dc as u,ec as f,fc as C,fd as l,gc as M,gd as s,kd as I,lb as w,nc as E,tc as D,ua as g,va as b,vc as x,wb as a,zd as R}from"./chunk-I3FGJX2C.js";import"./chunk-AKP2VPKK.js";import"./chunk-ML3VIXIY.js";import{d as L,n as ne}from"./chunk-INB5GR2I.js";import"./chunk-B7YGBANW.js";ne();var te=i=>[{caption:i("\u041F\u043E\u0441\u0442\u0430\u0432\u0449\u0438\u043A"),dataField:"name",width:"35%",minWidth:200},{caption:i("\u041D\u043E\u043C\u0435\u0440 \u0442\u0435\u043B\u0435\u0444\u043E\u043D\u0430"),dataField:"phone",showDashIfEmpty:!0,width:"20%",minWidth:140,isCustom:!0},{caption:i("\u0418\u0418\u041D/\u0411\u0418\u041D"),dataField:"xin",width:"20%",minWidth:140,showDashIfEmpty:!0},{caption:i("\u0411\u0430\u043B\u0430\u043D\u0441, \u20B8"),dataField:"balance",alignment:"right",numericPrecision:2,width:"25%",minWidth:140}],ie=i=>({header:i("\u0423\u0434\u0430\u043B\u0435\u043D\u0438\u0435 \u043F\u043E\u0441\u0442\u0430\u0432\u0449\u0438\u043A\u0430"),text:i("\u0412\u044B \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u043E \u0445\u043E\u0442\u0438\u0442\u0435 \u0443\u0434\u0430\u043B\u0438\u0442\u044C \u043F\u043E\u0441\u0442\u0430\u0432\u0449\u0438\u043A\u0430?"),submitButton:{label:i("\u0414\u0430, \u0443\u0434\u0430\u043B\u0438\u0442\u044C"),icon:c.Delete,variant:"success"},cancelButton:i("\u041E\u0442\u043C\u0435\u043D\u0430")});var oe=i=>({phone:i});function re(i,t){if(i&1){let e=E();f(0,"wk-button",5),l(1,"translate"),D("clicked",function(){g(e);let r=x();return b(r.openUpsertDialog())}),C()}if(i&2){let e=x();u("icon",e.icons.Plus)("label",s(1,2,"\u041D\u043E\u0432\u044B\u0439 \u043F\u043E\u0441\u0442\u0430\u0432\u0449\u0438\u043A"))}}function ae(i,t){if(i&1&&(U(0),l(1,"phoneFormat")),i&2){let e=t.$implicit;B(" ",s(1,1,e.phoneNumber),`
`)}}var o,h=(o=class extends H{get criteria(){return{search:{xin:this.searchValue,name:this.searchValue}}}constructor(t,e,n,r,p,d){super(p,d),this._supplierService=t,this._dialogService=e,this._toastService=n,this._localizationService=r,this.icons=c,this.columns=te(this._localizationService.getSync.bind(this._localizationService)),this.menuItem=[{text:this._localizationService.getSync("\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C"),action:S=>this.openUpsertDialog(S)},{text:this._localizationService.getSync("\u0423\u0434\u0430\u043B\u0438\u0442\u044C"),action:S=>this._openDeleteDialog(S.id)}]}ngOnInit(){super.ngOnInit()}getLoadMethod(t){return this._supplierService.getSuppliers(t)}openUpsertDialog(t){let e=this._initUpsertDialog(t);e.canceled.pipe(_(1)).subscribe(()=>e.close()),e.additionalAction.pipe(m(e)).subscribe(()=>{e.close(),this._openDeleteDialog(t?.id)}),e.submitted.pipe(m(e)).subscribe(n=>{if(n.markAllAsTouched(),!!n.valid){if(t){this._editSupplier(t.id,n.value,e);return}this._createSupplier(n.value,e)}})}_initUpsertDialog(t){return this._dialogService.open(K,{data:{id:t?.id,name:t?.name,xin:t?.xin,comment:t?.comment,phoneNumber:t?.phoneNumber},header:t?.id?this._localizationService.getSync("\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435 \u043F\u043E\u0441\u0442\u0430\u0432\u0449\u0438\u043A\u0430"):this._localizationService.getSync("\u041D\u043E\u0432\u044B\u0439 \u043F\u043E\u0441\u0442\u0430\u0432\u0449\u0438\u043A"),cancelButton:this._localizationService.getSync("\u041E\u0442\u043C\u0435\u043D\u0430"),submitButton:{label:this._localizationService.getSync("\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C"),variant:"success",icon:c.Save},additionalButton:t?.id?{variant:"danger",stylingMode:"outlined",icon:c.Delete,label:this._localizationService.getSync("\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u043F\u043E\u0441\u0442\u0430\u0432\u0449\u0438\u043A\u0430")}:void 0})}_createSupplier(t,e){t.xin=t.xin?.replace(/\s/g,"")??null,t.phoneNumber=P(t.phoneNumber??"")??null,this._supplierService.createSupplier(t).subscribe(()=>{e.close(),this._toastService.add(X(this._localizationService.getSync.bind(this._localizationService))),this.table?.refresh(),this.cdr.detectChanges()})}_editSupplier(t,e,n){e.xin=e.xin?.replace(/\s/g,"")??null,e.phoneNumber=P(e.phoneNumber??"")??null,this._supplierService.editSupplier(e,t).subscribe(()=>{n.close(),this._toastService.add(Y(this._localizationService.getSync.bind(this._localizationService))),this.table?.refresh(),this.cdr.detectChanges()})}_openDeleteDialog(t){if(!t)return;let e=this._dialogService.open(null,ie(this._localizationService.getSync.bind(this._localizationService)));e.canceled.pipe(_(1)).subscribe(()=>e.close()),e.submitted.pipe(m(e)).subscribe(()=>{this._deleteSupplier(t),e.close()})}_deleteSupplier(t){t&&this._supplierService.deleteSupplier(t).subscribe(()=>{this._toastService.add(Z(this._localizationService.getSync.bind(this._localizationService))),this.cdr.detectChanges()})}},o.\u0275fac=function(e){return new(e||o)(a(ee),a(O),a(j),a(W),a(R),a(V))},o.\u0275cmp=T({type:o,selectors:[["tis-supplier-list"]],features:[z],decls:10,vars:20,consts:[["headerActions",""],["table",""],["phoneNumber",""],[1,"header",3,"showBackButton","actionTemplate","title"],[3,"changedSearch","allowColumnResizing","data","enablePagination","enableToolbar","enableFilters","menuItems","columns","enableContextMenu","enableSpinner","customTemplates","searchPlaceholder"],["token","new-cupplier",3,"clicked","icon","label"]],template:function(e,n){if(e&1){let r=E();M(0,"tis-subheader",3),l(1,"translate"),v(2,re,2,4,"ng-template",null,0,I),f(4,"tis-main-layout")(5,"tis-table",4,1),l(7,"translate"),D("changedSearch",function(d){return g(r),b(n.changedSearch(d))}),C()(),v(8,ae,2,3,"ng-template",null,2,I)}if(e&2){let r=y(3),p=y(9);u("showBackButton",!1)("actionTemplate",r)("title",s(1,14,"\u041F\u043E\u0441\u0442\u0430\u0432\u0449\u0438\u043A\u0438")),w(5),u("allowColumnResizing",!0)("data",n.dataSource)("enablePagination",!0)("enableToolbar",!0)("enableFilters",!1)("menuItems",n.menuItem)("columns",n.columns)("enableContextMenu",!0)("enableSpinner",!0)("customTemplates",F(18,oe,p))("searchPlaceholder",s(7,16,"\u041F\u043E\u0438\u0441\u043A \u043F\u043E \u043D\u0430\u0438\u043C\u0435\u043D\u043E\u0432\u0430\u043D\u0438\u044E \u0438\u043B\u0438 \u0411\u0418\u041D"))}},dependencies:[A,q,Q,k,$,J,G],styles:[`[_nghost-%COMP%]{display:flex;flex-direction:column;min-height:100%}.header[_ngcontent-%COMP%]{top:0;position:sticky;z-index:10}.custom-toolbar[_ngcontent-%COMP%]{display:flex;gap:var(--space-horizontal-s);margin-bottom:var(--space-vertical-xl);justify-content:space-between}.custom-toolbar[_ngcontent-%COMP%]   tis-text-field[_ngcontent-%COMP%]{margin-bottom:0;max-width:390px}
/*# sourceMappingURL=supplier-list.component-S7Q4CFRG.css.map */`],changeDetection:0}),o);h=L([N()],h);var ze=[{path:"",component:h,pathMatch:"full"},{path:"**",redirectTo:""}];export{ze as routes};
//# sourceMappingURL=supplier.routes-2SFR5RJO.js.map
