import{a as q}from"./chunk-ITK25TXJ.js";import{a as $}from"./chunk-WNNN6P4L.js";import{a as z}from"./chunk-W64NXVAR.js";import{a as G}from"./chunk-OVHB4I7R.js";import{a as H,b as J,c as K,d as Q,f as X}from"./chunk-A7WY7WDA.js";import"./chunk-TYKPZAY3.js";import"./chunk-JST3XJCU.js";import{b as W}from"./chunk-OBPOQHIL.js";import"./chunk-LAQWHNKH.js";import"./chunk-YC7GTVSG.js";import"./chunk-2O23XSGQ.js";import"./chunk-K4ARG2G6.js";import"./chunk-QIDUJNWO.js";import"./chunk-LDWSFHA3.js";import"./chunk-KSOO7RKS.js";import"./chunk-JTYOM5WI.js";import{a as v}from"./chunk-CM25G6VJ.js";import"./chunk-NIGRN2AN.js";import"./chunk-WSL3XVPI.js";import"./chunk-QQGYKLKF.js";import"./chunk-3VQS547U.js";import"./chunk-YO44C22F.js";import"./chunk-KOXD6BDO.js";import"./chunk-UELRRTSS.js";import{a}from"./chunk-QV3XX5C6.js";import{Aa as k,Qa as O,Ta as V,ab as j}from"./chunk-JTDXTMDS.js";import{a as N,b as u}from"./chunk-NSGLSIBS.js";import"./chunk-6VC7H3CZ.js";import{ya as R}from"./chunk-QSMHDGIB.js";import{$c as D,Ab as P,Ac as y,Cc as M,Eb as w,Fb as _,K as m,Oc as U,Tb as c,Wc as F,Xc as A,cc as S,dc as b,ec as T,gd as B,ic as g,mb as L,oc as f,pc as C,rb as r,wa as d,xa as h,zc as E}from"./chunk-QMYHTLAJ.js";import"./chunk-FK6H3RFT.js";import"./chunk-53LFMTPK.js";import{d as I,n as ee}from"./chunk-HE7HQ6LI.js";import"./chunk-K4ALXBGI.js";ee();var Y=[{caption:"\u041F\u043E\u0441\u0442\u0430\u0432\u0449\u0438\u043A",dataField:"name",width:"35%",minWidth:200},{caption:"\u041D\u043E\u043C\u0435\u0440 \u0442\u0435\u043B\u0435\u0444\u043E\u043D\u0430",dataField:"phone",showDashIfEmpty:!0,width:"20%",minWidth:140,isCustom:!0},{caption:"\u0418\u0418\u041D/\u0411\u0418\u041D",dataField:"xin",width:"20%",minWidth:140,showDashIfEmpty:!0},{caption:"\u0411\u0430\u043B\u0430\u043D\u0441, \u20B8",dataField:"balance",alignment:"right",numericPrecision:2,width:"25%",minWidth:140}],Z={header:"\u0423\u0434\u0430\u043B\u0435\u043D\u0438\u0435 \u043F\u043E\u0441\u0442\u0430\u0432\u0449\u0438\u043A\u0430",text:"\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:"\u0414\u0430, \u0443\u0434\u0430\u043B\u0438\u0442\u044C",icon:a.Delete,variant:"success"},cancelButton:"\u041E\u0442\u043C\u0435\u043D\u0430"};var te=n=>({phone:n});function ie(n,t){if(n&1){let e=g();S(0,"wk-button",5),f("clicked",function(){d(e);let o=C();return h(o.openUpsertDialog())}),b()}if(n&2){let e=C();c("icon",e.icons.Plus)}}function ne(n,t){if(n&1&&(y(0),F(1,"phoneFormat")),n&2){let e=t.$implicit;M(" ",A(1,1,e.phoneNumber),`
`)}}var p=class x extends ${get criteria(){return{search:{xin:this.searchValue,name:this.searchValue}}}constructor(t,e,i,o,l){super(o,l),this._supplierService=t,this._dialogService=e,this._toastService=i,this.icons=a,this.columns=Y,this.menuItem=[{text:"\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C",action:s=>this.openUpsertDialog(s)},{text:"\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(m(1)).subscribe(()=>e.close()),e.additionalAction.pipe(u(e)).subscribe(()=>{e.close(),this._openDeleteDialog(t?.id)}),e.submitted.pipe(u(e)).subscribe(i=>{if(i.markAllAsTouched(),!!i.valid){if(t){this._editSupplier(t.id,i.value,e);return}this._createSupplier(i.value,e)}})}_initUpsertDialog(t){return this._dialogService.open(H,{data:{id:t?.id,name:t?.name,xin:t?.xin,comment:t?.comment,phoneNumber:t?.phoneNumber},header:t?.id?"\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435 \u043F\u043E\u0441\u0442\u0430\u0432\u0449\u0438\u043A\u0430":"\u041D\u043E\u0432\u044B\u0439 \u043F\u043E\u0441\u0442\u0430\u0432\u0449\u0438\u043A",cancelButton:"\u041E\u0442\u043C\u0435\u043D\u0430",submitButton:{label:"\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C",variant:"success",icon:a.Save},additionalButton:t?.id?{variant:"danger",stylingMode:"outlined",icon:a.Delete,label:"\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=v(t.phoneNumber??"")??null,this._supplierService.createSupplier(t).subscribe(()=>{e.close(),this._toastService.add(J),this.table?.refresh(),this.cdr.detectChanges()})}_editSupplier(t,e,i){e.xin=e.xin?.replace(/\s/g,"")??null,e.phoneNumber=v(e.phoneNumber??"")??null,this._supplierService.editSupplier(e,t).subscribe(()=>{i.close(),this._toastService.add(K),this.table?.refresh(),this.cdr.detectChanges()})}_openDeleteDialog(t){if(!t)return;let e=this._dialogService.open(null,Z);e.canceled.pipe(m(1)).subscribe(()=>e.close()),e.submitted.pipe(u(e)).subscribe(()=>{this._deleteSupplier(t),e.close()})}_deleteSupplier(t){t&&this._supplierService.deleteSupplier(t).subscribe(()=>{this._toastService.add(Q),this.cdr.detectChanges()})}static{this.\u0275fac=function(e){return new(e||x)(r(X),r(O),r(j),r(B),r(V))}}static{this.\u0275cmp=P({type:x,selectors:[["tis-supplier-list"]],features:[w],decls:8,vars:14,consts:[["headerActions",""],["table",""],["phoneNumber",""],["title","\u041F\u043E\u0441\u0442\u0430\u0432\u0449\u0438\u043A\u0438",1,"header",3,"showBackButton","actionTemplate"],["searchPlaceholder","\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",3,"changedSearch","allowColumnResizing","data","enablePagination","enableToolbar","enableFilters","menuItems","columns","enableContextMenu","enableSpinner","customTemplates"],["token","new-cupplier","label","\u041D\u043E\u0432\u044B\u0439 \u043F\u043E\u0441\u0442\u0430\u0432\u0449\u0438\u043A",3,"clicked","icon"]],template:function(e,i){if(e&1){let o=g();T(0,"tis-subheader",3),_(1,ie,1,1,"ng-template",null,0,D),S(3,"tis-main-layout")(4,"tis-table",4,1),f("changedSearch",function(s){return d(o),h(i.changedSearch(s))}),b()(),_(6,ne,2,3,"ng-template",null,2,D)}if(e&2){let o=E(2),l=E(7);c("showBackButton",!1)("actionTemplate",o),L(4),c("allowColumnResizing",!0)("data",i.dataSource)("enablePagination",!0)("enableToolbar",!0)("enableFilters",!1)("menuItems",i.menuItem)("columns",i.columns)("enableContextMenu",!0)("enableSpinner",!0)("customTemplates",U(12,te,l))}},dependencies:[R,z,G,k,W,q],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}"],changeDetection:0})}};p=I([N()],p);var Le=[{path:"",component:p,pathMatch:"full"},{path:"**",redirectTo:""}];export{Le as routes};
