import{_ as B}from"./ButtonDefault-CghIUDY0.js";import{_ as V}from"./ClausesKeeper-DVJgfLR3.js";import{_ as N}from"./BlockBalanceAgreement-2iQbaweR.js";import{u as $,r as g,f as l,g as E,H as L,D as b,c as C,b as p,a as t,h as R,t as c,F as O,am as q,W as M,d as U,o as k}from"./index-CipWZKo_.js";import{u as H}from"./postings-dJpYnOCG.js";import{u as T}from"./services-Dmz4Qt8q.js";import{_ as W}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./IconClose-ChC2G6HM.js";import"./contracts-CILh9uSu.js";const J={class:"additional-service-prolong"},K={class:"container"},X={class:"section-header"},z={class:"section-label"},G={class:"container"},Q={class:"service-prolong__data"},Y={class:"form-field"},Z=["value"],j={class:"form-field"},ee={class:"form-field__label"},te={class:"form-field"},se=["value"],oe={class:"container"},ae={class:"service-prolong__data"},re={class:"total-block"},le={class:"total-block__row total-block__row--big"},ne={class:"total-block__col"},ie={__name:"AdditionalServicesProlong",async setup(ce){let n,i;const F=E(),v=U(),m=H(),f=$(),I=T(),u=g(!1),a=l(()=>Object.values(f?.userOrders).find(s=>s.ID==F.params.id));l(()=>A.value?.find(s=>s.value==a.value?.OrdersFields?.[0]?.Value)?.price),l(()=>P.value?.find(s=>s.value===a.value?.OrdersFields?.[1]?.Value)?.price);const S=g(0),A=l(()=>r.value?.ServicesFields?.[0]?.Options?.split(`
`)?.map(s=>{let e=s.split("=");return{value:e[0],name:e[1],price:e[2]}})),P=l(()=>r.value?.ServicesFields?.[1]?.Options?.split(`
`)?.map(s=>{let e=s.split("=");return{value:e[0],name:e[1],price:e[2]}}));async function D(s){try{const o=(await q.get(`${M}/ServiceOrderPay?OrderID=${s}&JSON=1`)).data,d=h(o);let _=1;return o.AmountPay&&(_=parseInt(o.AmountPay)||1),d}catch(e){return console.error("Ошибка при получении данных о стоимости заказа",e),null}}function h(s){let e=0;for(const o in s)s.hasOwnProperty(o)&&(typeof s[o]=="object"?e+=h(s[o]):o==="Cost"&&!isNaN(s[o])&&(e+=parseFloat(s[o])));return e}function y(){return((parseFloat(r.value?.Cost)||parseFloat(S.value)||0)*1).toFixed(2)}function w(){u.value=!0,I.ServiceOrderPay(a.value?.Code,{AmountPay:"1",ServiceOrderID:a.value?.ID,IsChange:!0},{XMLHttpRequest:"yes"}).then(s=>{let{result:e,error:o}=s;e==="SUCCESS"?v.push(`/AdditionalServices/${a.value?.ID}`):e==="BASKET"&&v.push("/Basket"),u.value=!1})}L(async()=>{if(a.value){const s=a.value.ID,e=await D(s);e!==null&&(S.value=e)}});const r=l(()=>m?.servicesList[a.value?.ServiceID]);return[n,i]=b(()=>f.fetchUserOrders()),await n,i(),[n,i]=b(()=>m.fetchServices()),await n,i(),(s,e)=>{const o=N,d=V,_=B;return k(),C(O,null,[p(o),t("div",J,[t("section",null,[t("div",K,[t("div",X,[e[1]||(e[1]=t("h1",{class:"section-title"},"Оплата заказа дополнительной услуги",-1)),t("div",z,c(r.value?.Name)+" # "+c(a.value?.ID),1)]),p(d)])]),a.value?(k(),C(O,{key:0},[t("section",null,[t("div",G,[t("div",Q,[t("label",Y,[e[2]||(e[2]=t("span",{class:"form-field__label"},"Стоимость заказа",-1)),t("input",{type:"text",placeholder:"0 руб",value:r.value?.Cost+" руб",disabled:""},null,8,Z)]),t("label",j,[t("span",ee,"Количество ("+c(r.value?.Measure)+")",1),e[3]||(e[3]=t("input",{type:"text",placeholder:"0 руб",value:"1",disabled:""},null,-1))]),t("label",te,[e[4]||(e[4]=t("span",{class:"form-field__label"},"Всего к оплате",-1)),t("input",{type:"text",placeholder:"0 руб",value:y()+" руб",disabled:""},null,8,se)])])])]),t("section",null,[t("div",oe,[t("div",ae,[t("div",re,[t("div",le,[e[5]||(e[5]=t("div",{class:"total-block__col"},"Итого",-1)),t("div",ne,c(y()||"0")+" ₽",1)])]),p(_,{class:"btn--wide",label:"Оплатить",onClick:e[0]||(e[0]=x=>w()),"is-loading":u.value},null,8,["is-loading"])])])])],64)):R("",!0)])],64)}}},ye=W(ie,[["__scopeId","data-v-b5b0d8be"]]);export{ye as default};
