import{a as Q}from"./chunk-JPNJN7BT.js";import{a as $}from"./chunk-5J2NAU6E.js";import{a as z}from"./chunk-DV3DSI3N.js";import{a as G}from"./chunk-YGRCRXXK.js";import{a as q,b as H,c as J,d as K,f as X}from"./chunk-UAB2HPHM.js";import"./chunk-LZ6JCNZ4.js";import{a as W}from"./chunk-WH5RBXYQ.js";import"./chunk-HBSPKYMF.js";import"./chunk-I3R3BWDT.js";import"./chunk-DCREHIGF.js";import"./chunk-ZVQ5RRLK.js";import"./chunk-R7MAHTDS.js";import{e as s}from"./chunk-2MNVXWEX.js";import{Ma as O,Pa as V,_a as j,ta as k}from"./chunk-YFBLRBP4.js";import{a as N,b as p}from"./chunk-VXSBHXCN.js";import{a as x}from"./chunk-B6U47PXC.js";import"./chunk-CC7H2Q52.js";import"./chunk-ZAOXB7JK.js";import"./chunk-RESH3J2M.js";import"./chunk-DC6G5OHZ.js";import"./chunk-JUPKAJPM.js";import"./chunk-PDYJ5OYY.js";import"./chunk-Z2AWIQRI.js";import{ua as B}from"./chunk-3OWC7J4L.js";import{$c as y,Bb as L,Cd as A,Fb as w,Gb as S,Gc as D,L as d,Lc as M,Nc as U,fc as u,gc as b,hc as g,ic as T,id as F,jd as R,nb as P,nd as v,pc as f,tb as a,vc as C,wa as h,xa as _,xc as E}from"./chunk-C2QKZJOP.js";import"./chunk-AKP2VPKK.js";import"./chunk-ML3VIXIY.js";import{d as I,n as ee}from"./chunk-INB5GR2I.js";import"./chunk-B7YGBANW.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:s.Delete,variant:"success"},cancelButton:"\u041E\u0442\u043C\u0435\u043D\u0430"};var te=o=>({phone:o});function ie(o,t){if(o&1){let e=f();b(0,"wk-button",5),C("clicked",function(){h(e);let r=E();return _(r.openUpsertDialog())}),g()}if(o&2){let e=E();u("icon",e.icons.Plus)}}function ne(o,t){if(o&1&&(M(0),F(1,"phoneFormat")),o&2){let e=t.$implicit;U(" ",R(1,1,e.phoneNumber),`
`)}}var n,m=(n=class extends Q{get criteria(){return{search:{xin:this.searchValue,name:this.searchValue}}}constructor(t,e,i,r,c){super(r,c),this._supplierService=t,this._dialogService=e,this._toastService=i,this.icons=s,this.columns=Y,this.menuItem=[{text:"\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C",action:l=>this.openUpsertDialog(l)},{text:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C",action:l=>this._openDeleteDialog(l.id)}]}ngOnInit(){super.ngOnInit()}getLoadMethod(t){return this._supplierService.getSuppliers(t)}openUpsertDialog(t){let e=this._initUpsertDialog(t);e.canceled.pipe(d(1)).subscribe(()=>e.close()),e.additionalAction.pipe(p(e)).subscribe(()=>{e.close(),this._openDeleteDialog(t?.id)}),e.submitted.pipe(p(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(q,{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:s.Save},additionalButton:t?.id?{variant:"danger",stylingMode:"outlined",icon:s.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=x(t.phoneNumber??"")??null,this._supplierService.createSupplier(t).subscribe(()=>{e.close(),this._toastService.add(H),this.table?.refresh(),this.cdr.detectChanges()})}_editSupplier(t,e,i){e.xin=e.xin?.replace(/\s/g,"")??null,e.phoneNumber=x(e.phoneNumber??"")??null,this._supplierService.editSupplier(e,t).subscribe(()=>{i.close(),this._toastService.add(J),this.table?.refresh(),this.cdr.detectChanges()})}_openDeleteDialog(t){if(!t)return;let e=this._dialogService.open(null,Z);e.canceled.pipe(d(1)).subscribe(()=>e.close()),e.submitted.pipe(p(e)).subscribe(()=>{this._deleteSupplier(t),e.close()})}_deleteSupplier(t){t&&this._supplierService.deleteSupplier(t).subscribe(()=>{this._toastService.add(K),this.cdr.detectChanges()})}},n.\u0275fac=function(e){return new(e||n)(a(X),a(O),a(j),a(A),a(V))},n.\u0275cmp=L({type:n,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 r=f();T(0,"tis-subheader",3),S(1,ie,1,1,"ng-template",null,0,v),b(3,"tis-main-layout")(4,"tis-table",4,1),C("changedSearch",function(l){return h(r),_(i.changedSearch(l))}),g()(),S(6,ne,2,3,"ng-template",null,2,v)}if(e&2){let r=D(2),c=D(7);u("showBackButton",!1)("actionTemplate",r),P(4),u("allowColumnResizing",!0)("data",i.dataSource)("enablePagination",!0)("enableToolbar",!0)("enableFilters",!1)("menuItems",i.menuItem)("columns",i.columns)("enableContextMenu",!0)("enableSpinner",!0)("customTemplates",y(12,te,c))}},dependencies:[B,z,G,k,W,$],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}),n);m=I([N()],m);var Pe=[{path:"",component:m,pathMatch:"full"},{path:"**",redirectTo:""}];export{Pe as routes};
//# sourceMappingURL=supplier.routes-UED6XVAN.js.map
