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