import{_ as O}from"./BlueButton.vue_vue_type_script_setup_true_lang-CY8chwQm.js";import{_ as D}from"./ClausesKeeper-CyJ_9bTp.js";import{_ as B}from"./BlockBalanceAgreement-396E9Da8.js";import{u as A,r as y,g as x,l as N,x as k,o as C,c as S,b as u,a as e,t as n,w as P,i as F,F as V,y as j,W as E,e as $,j as L,f as R}from"./index-Bb2UEb_P.js";import{u as q}from"./services-DEZoSah0.js";import{_ as M}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./HtmlContent-DrkJBX3e.js";import"./IconCloseCircle-ctElXVvc.js";import"./clauses-Bhz_DuFa.js";import"./index-Dax_IkAt.js";import"./ButtonDefault-CzWpVlv6.js";import"./common-U_VzDrmL.js";const T={key:0,class:"tw-px-4 md:tw-px-8"},U={class:"tw-text-gray-500 tw-mt-2"},K={class:"tw-max-w-96"},W={class:"tw-mt-4"},H={class:"form-field"},J=["value"],X={class:"form-field"},z={class:"form-field__label"},G={class:"form-field"},Q=["value"],Y={class:"tw-mt-4"},Z={class:"tw-flex tw-justify-between tw-items-center tw-gap-4 tw-text-lg"},tt={__name:"AdditionalServicesOrderPayId",async setup(et){let c,d;const g=L(),p=$(),_=A(),m=q(),i=y(!1),o=x(()=>Object.values(_?.userOrders).find(s=>s.ID==g.params.id)),f=y(0);async function I(s){try{const r=(await j.get(`${E}/ServiceOrderPay`,{params:{OrderID:s,JSON:1}})).data;return v(r)}catch(t){return console.error("Ошибка при получении данных о стоимости заказа",t),null}}function v(s){let t=0;for(const[r,a]of Object.entries(s))a!==null&&typeof a=="object"?t+=v(a):r==="Cost"&&!isNaN(a)&&(t+=parseFloat(a));return t}function w(){return((parseFloat(l.value?.Cost)||parseFloat(f.value)||0)*1).toFixed(2)}async function b(){i.value=!0;const{result:s}=await m.serviceOrderPay(o.value?.Code,{AmountPay:"1",ServiceOrderID:o.value?.ID,IsChange:!0},{XMLHttpRequest:"yes"});s==="SUCCESS"?p.push(`/AdditionalServices/${o.value?.ID}`):s==="BASKET"&&p.push("/Basket"),i.value=!1}N(async()=>{if(o.value){const s=o.value.ID,t=await I(s);t!==null&&(f.value=t)}});const l=x(()=>m.ServicesList?.[o.value?.ServiceID]);return[c,d]=k(()=>_.fetchUserOrders()),await c,d(),(s,t)=>{const r=B,a=D,h=O;return C(),S(V,null,[u(r,{"contract-id":o.value?.ContractID},null,8,["contract-id"]),o.value?(C(),S("div",T,[t[6]||(t[6]=e("h1",{class:"tw-text-2xl sm:tw-text-4xl"},"Оплата заказа дополнительной услуги",-1)),e("div",U,n(l.value?.Name)+" # "+n(o.value?.ID),1),u(a),e("div",K,[e("div",W,[e("label",H,[t[1]||(t[1]=e("span",{class:"form-field__label"},"Стоимость заказа",-1)),e("input",{type:"text",placeholder:"0 руб",value:l.value?.Cost+" руб",disabled:""},null,8,J)]),e("label",X,[e("span",z,"Количество ("+n(l.value?.Measure)+")",1),t[2]||(t[2]=e("input",{type:"text",placeholder:"0 руб",value:"1",disabled:""},null,-1))]),e("label",G,[t[3]||(t[3]=e("span",{class:"form-field__label"},"Всего к оплате",-1)),e("input",{type:"text",placeholder:"0 руб",value:w()+" руб",disabled:""},null,8,Q)])]),e("div",Y,[e("div",Z,[t[4]||(t[4]=e("div",null,"Итого",-1)),e("div",null,n(w()||"0")+" ₽",1)]),u(h,{class:"tw-mt-4 tw-w-full",loading:i.value,onClick:t[0]||(t[0]=st=>b())},{default:P(()=>t[5]||(t[5]=[R(" Оплатить ",-1)])),_:1,__:[5]},8,["loading"])])])])):F("",!0)],64)}}},ft=M(tt,[["__scopeId","data-v-f0f17da6"]]);export{ft as default};
