import{a as J}from"./chunk-ELNHEHXE.js";import{a as H}from"./chunk-TUAL6EZO.js";import{a as q}from"./chunk-NLXRVFDY.js";import{a as Q}from"./chunk-P7KQ7LX4.js";import{a as K,b as X,c as Y,d as Z,f as ee}from"./chunk-OVRXJXIY.js";import"./chunk-GC3TETVU.js";import"./chunk-SDJJWUKM.js";import"./chunk-SMMIHGJB.js";import{a as $}from"./chunk-EJEVRE4J.js";import"./chunk-SYE2YM6F.js";import"./chunk-5T6TZLDM.js";import"./chunk-SMAIR2YP.js";import"./chunk-JAY45DEO.js";import"./chunk-LINAD4CC.js";import"./chunk-LBZE4AC4.js";import"./chunk-ZBAZR7FK.js";import{b as G,e as W,f as c}from"./chunk-Y5ITWXM5.js";import{Ha as O,Ka as V,Xa as j,ma as k}from"./chunk-NNMVEAHQ.js";import{a as N,b as m}from"./chunk-KXDO3JYP.js";import"./chunk-CC7H2Q52.js";import{a as P}from"./chunk-LUCOJAXQ.js";import"./chunk-HQUUBXQJ.js";import"./chunk-RTKDH4JU.js";import"./chunk-IFY4UZPR.js";import"./chunk-UU4K5RCK.js";import"./chunk-JBWPPKX4.js";import"./chunk-7N232KV6.js";import"./chunk-PDYJ5OYY.js";import"./chunk-NDLDFKR2.js";import{$c as l,Cb as T,Dc as U,Fc as B,Gb as z,Hb as v,K as _,Sc as F,Ue as A,ad as s,bc as u,cc as f,dc as C,ec as M,ed as I,kb as w,lc as E,nc as D,pc as x,sd as R,ta as g,ua as b,vb as a,yc as y}from"./chunk-PVUKHE45.js";import"./chunk-AKP2VPKK.js";import"./chunk-GVXHDKBW.js";import{d as L,n as ne}from"./chunk-VD6R3735.js";import"./chunk-MZPAXKJS.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-H63CCBBU.js.map
