1import{a as x}from"./chunk-YXVUJTQ4.js";import{Gh as $,Kc as S,Lc as A,Pa as D,mf as k,nf as g,of as f,rb as R,sb as d,ub as h}from"./chunk-B6OB7OHB.js";import{$ as m,L as p,Ma as F,_c as C,ad as L,f as v,ga as u,la as w,ma as n,nd as M,wb as c}from"./chunk-OOA2NBWP.js";import{a as l,b as y}from"./chunk-2W3Q6YC6.js";var P=class{search;endDate=new Date;iniDate=new Date;constructor(t="",e){this.search=t,this.iniDate.setMonth(this.endDate.getMonth()-1),e&&Object.assign(this,e)}};var _=class o{filterDateChanges=new F;filters=c(new P);_unsubscribeAll$=new v;_activatedRoute=n(D);_headerService=n(f);_menuService=n(g);init(){let{queryParamMap:t}=this._activatedRoute;t.pipe(p(1)).subscribe(e=>{let a=new Date,r=new Date;if(a.setMonth(a.getMonth()-1),e?.get("search")?.length||e?.get("iniDate")?.length||e?.get("endDate")?.length){this.filters().iniDate=e.get("iniDate")?new Date(e.get("iniDate")):a,this.filters().endDate=e.get("endDate")?new Date(e.get("endDate")):r;let{iniDate:s,endDate:i}=this.filters();this._headerService.updateCurrentRouteParams({iniDate:s,endDate:i})}})}destroy(){this._unsubscribeAll$.next(),this._unsubscribeAll$.complete()}setDeliveriesFilter(t){this.filters.update(e=>(Object.assign(t,e),e)),this._headerService.updateCurrentRouteParams(this.filters())}setFilters(t){this.filters.update(e=>Object.assign(e,t)),this._headerService.updateCurrentRouteParams(t),this._menuService.navigateTo("spare-parts",t).catch(()=>0)}setDatesFilter(t){this.filters.update(e=>
1(e.iniDate=t.iniDate,e.endDate=t.endDate,e)),this._headerService.updateCurrentRouteParams(this.filters()),this.filterDateChanges.emit(t)}static \u0275fac=function(e){return new(e||o)};static \u0275prov=u({token:o,factory:o.\u0275fac,providedIn:"root"})};var b=class o{constructor(t,e){this._translateService=t;this.removeLeadingZerosPipe=e}downloadXLSX(t){let e=[this._translateService.instant("Status"),this._translateService.instant("Customer.Order"),this._translateService.instant("Spare.Parts.Order"),this._translateService.instant("Position"),this._translateService.instant("Spare.Parts.Delivery"),"Material",this._translateService.instant("Quantity"),this._translateService.instant("dispatchDate"),this._translateService.instant("Spare.Parts.Delivery.Consignee"),this._translateService.instant("Spare.Parts.Delivery.Address"),this._translateService.instant("Tracking"),this._translateService.instant("Tracking.Url")],a=t.map(i=>[i.status,i.customerOrder,i.order,i.orderPosition,`${i.delivery} - ${this.removeLeadingZerosPipe.transform(String(i.deliveryPosition))}`,`${i.materialCode} - ${i.materialDescription}`,i.quantity,this.formatDate(i.dispatchDate),`${this.removeLeadingZerosPipe.transform(i.deliveryConsignee)} - ${i.deliveryConsigneeName}`,i.deliveryAddress,i.trackingId,{v:`${i.operator}${i.trackingId}`,l:{Target:`${i.operator}${i.trackingId}`},t:"s"}]),r=d.book_new(),s=d.sheet_add_aoa(r,[e]);d.sheet_add_aoa(s,a,{origin:"A2"}),s["!cols"]=this.getColumnMinSize(a,e),d.book_append_sheet(r,s,this._translateService.instant("Spare.Parts.Deliveries.List")),R(r,`deliveries_list_${new Date().toLocaleDateString()}.xlsx`)}getColumnMinSize(t,e){let a=t[0]?.length,r=[];for(let s=0;s<a;s++)r.push(Math.max(...t.map(i=>i[s]?.toString()?.length)));return r.forEach((s,i)=>{r[i]=Math.max(r[i],e[i]?.length)+2}),r.map(s=>({wch:s}))}formatDate(t){return M(t,"dd/MM/yyyy","en-US")}static \u0275fac=function(e){return new(e||o)(w(h),w(S))};static \u0275prov=u({token:o,factory:o.\u0275fac,providedIn:"root"})};var I=["delivery","customerOrder"],j=class{filters;isLoading=c(!0);viewMode;deliveriesAll=c([]);deliveriesFiltered;deliveriesToDisplay=c([]);showItemsScroll=c(15);_sparePartApiService=n(x);_translateService=n(h);_feedbackService=n(k);_headerService=n(f);_activatedRoute=n(D);_unsubscribeAll$=new v;_menuService=n(g);_filtersDeliveriesService=n(_);removeLeadingZerosPipe=new S;utilsOrders=new b(n(h),this.removeLeadingZerosPipe);_searchFilterService=n($);constructor(){this._headerService.download.pipe(m(this._unsubscribeAll$)).subscribe(()=>this.exportDeliveries()),this._filtersDeliveriesService.filterDateChanges.pipe(m(this._unsubscribeAll$)).subscribe(t=>{this.filterByDate(t)}),this.filters=this._filtersDeliveriesService.filters,this.viewMode=C(()=>this._headerService.header()?.getSelectedChangeView()?.value??0),this.deliveriesFiltered=C(()=>{let t=this.deliveriesAll().map(e=>e.props);return this._searchFilterService.filter(t,this.filters().search,I)}),this._headerService.header().enableFilters(!0),L(()=>{this._headerService.header().setFiltersComponent(()=>import("./chunk-B5RREUVZ.js").then(e=>e.FiltersDeliveriesComponent));let t=this._headerService.header().getCurrentBreadcrumb()?.route?.queryParams?.search??"";this.filters.update(e=>y(l({},e),{search:t}))},{allowSignalWrites:!0})}init(){let{queryParamMap:t}=this._activatedRoute;t.pipe(p(1)).subscribe(e=>{let a=new Date,r=new Date;if(a.setMonth(a.getMonth()-1),e?.get("iniDate")?.length||e?.get("endDate")?.length){let s={search:e?.get("search")??null,iniDate:e.get("iniDate")?new Date(e.get("iniDate")):a,endDate:e.get("endDate")?new Date(e.get("endDate")):r};this.filters.update(i=>l(l({},i),s)),this._headerService.updateCurrentRouteParams(s)}else this._headerService.updateCurrentRouteParams({search:null,iniDate:a,endDate:r})})}destroy(){this._unsubscribeAll$.next(),this._unsubscribeAll$.complete(),this._filtersDeliveriesService.destroy()}setFilters(t){this.filters.update(e=>l(l({},e),t)),this._headerService.updateCurrentRouteParams(t),this._menuService.navigateTo("spare-parts/",t).catch(()=>0)}onScroll(){this.showItemsScroll.update(t=>t+10)}setPreviewItems(t){this.showItemsScroll()<t&&this.showItemsScroll.set(t)}getDeliveriesList(t="",e=""){this.isLoading.set(!0);let{iniDate:a,endDate:r}=this.buildParams();this._sparePartApiService.getDeliveriesByOrderPosition(t,e,a,r).then(s=>this.handleData(s)).catch(()=>this.handleError()).finally(()=>this.isLoading.set(!1))}exportDeliveries(){if(this.viewMode()===1){let e=new A().transform(this.deliveriesToDisplay(),this.filters().search,I);e.length?this.utilsOrders.downloadXLSX(e):this._feedbackService.message("ExportExcelNoSelection","warning")}}filterByDate(t){this._menuService.navigateTo("spare-parts/",t).then(()=>this.getDeliveriesList()).catch(()=>0)}buildParams(){let{queryParamMap:t}=this._activatedRoute;t.pipe(m(this._unsubscribeAll$)).subscribe(r=>{r?.get("iniDate")&&r?.get("endDate")&&this.filters.update(s=>y(l({},s),{iniDate:new Date(r.get("iniDate")),endDate:new Date(r.get("endDate"))}))});let{iniDate:e,endDate:a}=this.filters();return{iniDate:e,endDate:a}}handleData(t){this.deliveriesAll.set(t)}handleError(){let t=this._translateService.instant("SpareParts"),a=["ThereWasAnError.Loa
1ding",{item:this._translateService.instant("Item.List",{item:t}).toLowerCase()}];this._feedbackService.message(a,"error")}};export{_ as a,j as b};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.