import{L as P}from"./bootstrap-vue-next-3DpAa4tb.js";import{_ as S}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{c as r,o as m,a as t,x as N,D as f,b as p,v as c,F as v,i as V,h as A,t as a,w as u}from"./index-CipWZKo_.js";import{_ as $}from"./ClausesKeeper-DVJgfLR3.js";import{_ as O,f as I}from"./BlockBalanceAgreement-2iQbaweR.js";import{u as M}from"./basket-BrgYPkmu.js";import{u as E}from"./contracts-CILh9uSu.js";import{u as R}from"./postings-dJpYnOCG.js";import"./IconClose-ChC2G6HM.js";import"./ButtonDefault-CghIUDY0.js";const T={},j={fill:"none",height:"32",viewBox:"0 0 32 32",width:"32",xmlns:"http://www.w3.org/2000/svg"};function q(g,n){return m(),r("svg",j,n[0]||(n[0]=[t("rect",{fill:"#F7F9FF",height:"31",rx:"3.5",width:"31",x:".5",y:".5"},null,-1),t("path",{d:"M8.5 11h15m-1.665 0v11.667a1.667 1.667 0 0 1-1.667 1.666h-8.333a1.667 1.667 0 0 1-1.667-1.666V11m2.5 0V9.333a1.667 1.667 0 0 1 1.667-1.666h3.333a1.667 1.667 0 0 1 1.667 1.666V11m-5.003 4.167v5m3.336-5v5",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round"},null,-1),t("rect",{height:"31",rx:"3.5",stroke:"#C7D1ED",width:"31",x:".5",y:".5"},null,-1)]))}const z=S(T,[["render",q]]),G=[{key:"ServiceID",label:"Услуга",variant:"td-service"},{key:"OrderID",label:"Номер заказа",variant:"td-service"},{key:"Amount",label:"Период"},{key:"Summ",label:"Сумма"},{key:"controls",label:"Действия",variant:"td-controls"}],H={class:"section"},J={class:"container"},K={key:0,class:"cart-list"},Q={key:0,class:"cart-item"},U={class:"cart-item__subtitle"},W={class:"cart-item__subtitle-name"},X={class:"d-block"},Y={class:"d-block table-td-blue"},Z=["onClick"],tt={class:"total-block"},et={class:"total-block__row"},st={class:"total-block__col"},ot=["onClick"],nt={key:1,class:"notification-field"},at={__name:"Basket",async setup(g){let n,_;const i=M(),b=E(),h=R(),y=N("emitter");y.on("form-cart-invoice",s=>{B(s)}),[n,_]=f(()=>i.fetchBasket()),await n,_(),[n,_]=f(()=>b.fetchContracts()),await n,_(),[n,_]=f(()=>h.fetchServices()),await n,_();function D(s){let e=0;for(let l=0;l<s.length;l++)e=e+Number(s[l]?.Summ);return e}async function w(s){await i.deleteFromBasket({RowsIDs:[s.ID],TableID:"Basket"})==="success"&&(i.basketList=i.basketList[s.ContractID].filter(l=>l.ID!==s.ID))}function C(s,e){y.emit("open-modal",{component:"InvoiceMakeBasket",data:{ItemID:e,ContractPaymentSystems:b.contractsList[e]?.PaymentSystems,ProfileID:b.contractsList[e]?.ProfileID,sum:D(s)}})}function B(s){delete i.basketList[s]}return(s,e)=>{const l=O,L=$,x=z,F=P;return m(),r(v,null,[p(l),t("section",H,[t("div",J,[e[6]||(e[6]=t("div",{class:"section-header"},[t("h1",{class:"section-title"},"Корзина")],-1)),p(L),Object.keys(c(i).basketList).length>0?(m(),r("div",K,[(m(!0),r(v,null,V(c(i).basketList,(d,k)=>(m(),r(v,{key:k},[d&&d.length>0?(m(),r("div",Q,[e[5]||(e[5]=t("div",{class:"cart-item__title"},"Заказ",-1)),t("div",U,[t("div",W,a(c(b).contractsList[k]?.Customer),1)]),p(F,{items:d,fields:c(G),class:"basic-table table-cart"},{"cell(ServiceID)":u(o=>[e[0]||(e[0]=t("span",{class:"td-mobile"},"Услуга",-1)),t("span",X,a(c(h).servicesList[o.item?.ServiceID]?.Name),1),t("span",Y,a(o.item?.Comment),1)]),"cell(OrderID)":u(o=>[e[1]||(e[1]=t("span",{class:"td-mobile"},"Номер заказа",-1)),t("span",null,"№ "+a(o.item?.OrderID),1)]),"cell(Amount)":u(o=>[e[2]||(e[2]=t("span",{class:"td-mobile"},"Период",-1)),t("span",null,a(o.item?.Amount)+" "+a(o.item?.Measure),1)]),"cell(Summ)":u(o=>[e[3]||(e[3]=t("span",{class:"td-mobile"},"Сумма",-1)),t("span",null,a(c(I)(o.item?.Summ)),1)]),"cell(controls)":u(o=>[t("button",{class:"btn-delete btn",onClick:it=>w(o.item)},[p(x)],8,Z)]),_:2},1032,["items","fields"]),t("div",tt,[t("div",et,[e[4]||(e[4]=t("div",{class:"total-block__col"},"Итого",-1)),t("div",st,a(c(I)(D(d))),1)]),t("button",{class:"btn btn--blue btn-default btn--wide",onClick:o=>C(d,k)}," Оплатить заказ ",8,ot)])])):A("",!0)],64))),128))])):(m(),r("div",nt,"Корзина заказов пуста"))])])],64)}}},ft=S(at,[["__scopeId","data-v-2825b14a"]]);export{ft as default};
