import{a as K}from"./chunk-MLGLFM7E.js";import{a as Y,b as $,c as q,d as H,f as J}from"./chunk-3FOYM5UR.js";import"./chunk-3MQTRQGH.js";import"./chunk-3WHZK6ZQ.js";import{b as W}from"./chunk-AJTKPNL2.js";import{a as V}from"./chunk-F5MI6XGL.js";import"./chunk-K3PQIV7F.js";import"./chunk-SMMIHGJB.js";import{d as G}from"./chunk-7PKMSCVL.js";import"./chunk-WL2OYEJL.js";import"./chunk-RL5BHPLG.js";import{a as j}from"./chunk-RVEFR64E.js";import"./chunk-KGCVL6CP.js";import"./chunk-JSG72ZNQ.js";import"./chunk-JAY45DEO.js";import"./chunk-LINAD4CC.js";import"./chunk-UBQPCB4A.js";import"./chunk-LBZE4AC4.js";import"./chunk-RTVR37QC.js";import"./chunk-ZATDFETU.js";import{I as N,La as O,Ma as r}from"./chunk-QHAVDXDG.js";import{K as R,_ as F,ba as A,na as k}from"./chunk-27KSTDMK.js";import"./chunk-N3BL5TXR.js";import{a as E}from"./chunk-RTL4XZI4.js";import"./chunk-QGNMEQRN.js";import"./chunk-F4GTCTBH.js";import"./chunk-WXQVX7WD.js";import"./chunk-OWZ5YAMH.js";import"./chunk-KXX3UDJ3.js";import"./chunk-PDYJ5OYY.js";import{z as m}from"./chunk-GQAU5ACB.js";import{Bb as o,Ec as f,Ib as P,Jc as w,Lc as U,Mb as L,Nb as S,S as h,Yc as M,ea as p,fd as c,gd as l,hc as u,ic as _,jc as g,kc as T,kd as C,rc as z,sb as I,tc as b,vc as v,ya as x,yd as B,za as y}from"./chunk-ISMRT7VU.js";import"./chunk-GMHSUEGX.js";import"./chunk-M5TX2NVG.js";var Q=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}],X=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:r.Delete,variant:"success"},cancelButton:i("\u041E\u0442\u043C\u0435\u043D\u0430")});var te=i=>({phone:i});function ie(i,D){if(i&1){let e=z();_(0,"wk-button",5),c(1,"translate"),b("clicked",function(){x(e);let n=v();return y(n.openUpsertDialog())}),g()}if(i&2){let e=v();u("icon",e.icons.Plus)("label",l(1,2,"\u041D\u043E\u0432\u044B\u0439 \u043F\u043E\u0441\u0442\u0430\u0432\u0449\u0438\u043A"))}}function ne(i,D){if(i&1&&(w(0),c(1,"phoneFormat")),i&2){let e=D.$implicit;U(" ",l(1,1,e.phoneNumber),`
`)}}var Z=(()=>{class i extends W{get criteria(){return{search:{xin:this.searchValue,name:this.searchValue}}}constructor(e,t,n,s,a,ee){super(a,ee),this._supplierService=e,this._dialogService=t,this._toastService=n,this._localizationService=s,this.icons=r,this.columns=Q(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:d=>this.openUpsertDialog(d)},{text:this._localizationService.getSync("\u0423\u0434\u0430\u043B\u0438\u0442\u044C"),action:d=>this._openDeleteDialog(d.id)}]}ngOnInit(){super.ngOnInit()}getLoadMethod(e){return this._supplierService.getSuppliers(e)}openUpsertDialog(e){let t=this._initUpsertDialog(e);t.canceled.pipe(h(1)).subscribe(()=>t.close()),t.additionalAction.pipe(p(t.closed),m(this.destroyRef)).subscribe(()=>{t.close(),this._openDeleteDialog(e?.id)}),t.submitted.pipe(p(t.closed),m(this.destroyRef)).subscribe(n=>{if(n.markAllAsTouched(),!!n.valid){if(e){this._editSupplier(e.id,n.value,t);return}this._createSupplier(n.value,t)}})}_initUpsertDialog(e){return this._dialogService.open(Y,{data:{id:e?.id,name:e?.name,xin:e?.xin,comment:e?.comment,phoneNumber:e?.phoneNumber},header:e?.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:r.Save},additionalButton:e?.id?{variant:"danger",stylingMode:"outlined",icon:r.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(e,t){e.xin=e.xin?.replace(/\s/g,"")??null,e.phoneNumber=E(e.phoneNumber??"")??null,this._supplierService.createSupplier(e).subscribe(()=>{t.close(),this._toastService.add($(this._localizationService.getSync.bind(this._localizationService))),this.table?.refresh(),this.cdr.detectChanges()})}_editSupplier(e,t,n){t.xin=t.xin?.replace(/\s/g,"")??null,t.phoneNumber=E(t.phoneNumber??"")??null,this._supplierService.editSupplier(t,e).subscribe(()=>{n.close(),this._toastService.add(q(this._localizationService.getSync.bind(this._localizationService))),this.table?.refresh(),this.cdr.detectChanges()})}_openDeleteDialog(e){if(!e)return;let t=this._dialogService.open(null,X(this._localizationService.getSync.bind(this._localizationService)));t.canceled.pipe(h(1)).subscribe(()=>t.close()),t.submitted.pipe(p(t.closed),m(this.destroyRef)).subscribe(()=>{this._deleteSupplier(e),t.close()})}_deleteSupplier(e){e&&this._supplierService.deleteSupplier(e).subscribe(()=>{this._toastService.add(H(this._localizationService.getSync.bind(this._localizationService))),this.cdr.detectChanges()})}static{this.\u0275fac=function(t){return new(t||i)(o(J),o(F),o(k),o(O),o(B),o(A))}}static{this.\u0275cmp=P({type:i,selectors:[["tis-supplier-list"]],features:[L],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(t,n){if(t&1&&(T(0,"tis-subheader",3),c(1,"translate"),S(2,ie,2,4,"ng-template",null,0,C),_(4,"tis-main-layout")(5,"tis-table",4,1),c(7,"translate"),b("changedSearch",function(a){return n.changedSearch(a)}),g()(),S(8,ne,2,3,"ng-template",null,2,C)),t&2){let s=f(3),a=f(9);u("showBackButton",!1)("actionTemplate",s)("title",l(1,14,"\u041F\u043E\u0441\u0442\u0430\u0432\u0449\u0438\u043A\u0438")),I(5),u("allowColumnResizing",!0)("data",n.dataSource)("enablePagination",!0)("enableToolbar",!0)("enableFilters",!1)("menuItems",n.menuItem)("columns",n.columns)("enableContextMenu",!0)("enableSpinner",!0)("customTemplates",M(18,te,a))("searchPlaceholder",l(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:[V,j,R,G,K,N],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-8);margin-bottom:var(--space-vertical-20);justify-content:space-between}.custom-toolbar[_ngcontent-%COMP%]   tis-text-field[_ngcontent-%COMP%]{margin-bottom:0;max-width:390px}
/*# sourceMappingURL=supplier-list.component-EKYMW7GO.css.map */`],changeDetection:0})}}return i})();var Ie=[{path:"",component:Z,pathMatch:"full"},{path:"**",redirectTo:""}];export{Ie as routes};
//# sourceMappingURL=supplier.routes-TKWS7NLO.js.map
