import{_ as b}from"./ButtonDefault-BIBStZbJ.js";import{u as C}from"./services-C54cnl9l.js";import{s as O}from"./multiselect-DhoC9bwZ.js";import{_ as k}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{E as y,c as x,o as M,a as r,b as _,e as j,t as c,w as p,r as g,x as w,f as u,H as f,s as E}from"./index-CmCGXBst.js";const V={components:{Multiselect:O},props:{data:{type:Object,default:()=>{}}},emits:["modalClose"],setup(d,{emit:a}){const t=C(),o=g(!1),m=g(null);w("emitter");const v=u(()=>t?.DNSmanagerOrdersList),i=u(()=>{const e=v.value;if(!(!e||typeof e!="object"))return Object.keys(e).map(l=>e[l]).find(l=>l.OrderID===d.data?.DNSID)}),S=u(()=>Object.keys(t?.additionalServicesScheme.DNSmanager).map(e=>({...t?.additionalServicesScheme.DNSmanager[e],value:t?.additionalServicesScheme.DNSmanager[e]?.ID,name:t?.additionalServicesScheme.DNSmanager[e]?.Name,cost:t?.additionalServicesScheme.DNSmanager[e]?.CostMonth})).filter(e=>e?.ID==i.value?.SchemeID)),n=u(()=>{const e=S.value[0],l=Object.keys(t?.additionalServicesScheme.DNSmanager).map(s=>({...t?.additionalServicesScheme.DNSmanager[s],value:t?.additionalServicesScheme.DNSmanager[s]?.ID}))?.filter(s=>s?.value?.HardServerID==e?.HardServerID&&s?.IsSchemeChangeable&&s?.ID!==i.value?.SchemeID&&s?.ServersGroupID===d.data?.ServerGroup);return[e,...l].sort((s,I)=>s.SortID-I.SortID).map(s=>({...s,disabled:s.ID==e.ID}))});function h(){o.value=!0,t.DNSmanagerOrderSchemeChange({NewSchemeID:m.value,DNSmanagerOrderID:i.value?.ID}).then(e=>{let{result:l,error:N}=e;l==="SUCCESS"&&a("modalClose"),o.value=!1})}f(()=>{t.fetchAdditionalServiceScheme(d.data?.Code),t.fetchDNSmanagerOrders(),m.value=n.value?.[1]?.value});const D=e=>{e.key==="Enter"&&h()};return f(()=>{document.addEventListener("keyup",D)}),E(()=>{document.removeEventListener("keyup",D)}),{isLoading:o,getDNSSchemes:n,changeScheme:h,selectedPackage:m,getDNSScheme:S}}},L={class:"modal__body"},B={class:"list-item__subtitle"},H={class:"modal__input-row tw-items-center"},P={class:"list-form_col list-form_col--xl"},U={class:"search-field form-field"},G={class:"multiselect-multiple-label"},A={class:"multiselect-option"};function K(d,a,t,o,m,v){const i=y("Multiselect"),S=b;return M(),x("div",L,[a[4]||(a[4]=r("div",{class:"list-item__title"},"Смена тарифного плана",-1)),r("div",B,[a[2]||(a[2]=j(" Текущий тарифный план ",-1)),r("span",null,c(o.getDNSScheme[0]?.name)+"/"+c(o.getDNSScheme[0]?.cost),1)]),r("div",H,[a[3]||(a[3]=r("div",{class:"modal__input-label"},"Новый тарифный план",-1)),r("div",P,[r("div",U,[_(i,{class:"multiselect--white",options:o.getDNSSchemes,type:"text",modelValue:o.selectedPackage,"onUpdate:modelValue":a[0]||(a[0]=n=>o.selectedPackage=n),placeholder:"Поиск"},{singlelabel:p(({value:n})=>[r("div",G,[r("span",null,c(n?.Name)+"/"+c(n?.CostMonth),1)])]),option:p(({option:n})=>[r("div",A,c(n?.Name)+"/"+c(n?.CostMonth),1)]),_:1},8,["options","modelValue"])])])]),_(S,{class:"modal__button",label:"Сменить","is-loading":o.isLoading,onClick:a[1]||(a[1]=n=>o.changeScheme())},null,8,["is-loading"])])}const J=k(V,[["render",K],["__scopeId","data-v-dc912a64"]]);export{J as default};
