import{_ as N}from"./ButtonDefault-CzWpVlv6.js";import{_ as h}from"./InputSelect.vue_vue_type_script_setup_true_lang-DDGr1dhD.js";import{_ as B}from"./SimpleCheckbox-DxdM8U6J.js";import{_ as $}from"./ClausesKeeper-CyJ_9bTp.js";import{_ as j}from"./BlockBalanceAgreement-396E9Da8.js";import{u as A}from"./index-Dax_IkAt.js";import{am as M,r as p,x as R,g as I,v as O,o as n,c as u,b as l,a,w as q,F as g,h as E,d as F,e as U,j as K,A as z,f as G,m as H}from"./index-Bb2UEb_P.js";import{_ as J}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./IconChevronDown-NfcUpI8U.js";import"./HtmlContent-DrkJBX3e.js";import"./IconCloseCircle-ctElXVvc.js";import"./clauses-Bhz_DuFa.js";import"./common-U_VzDrmL.js";const Q={class:"tw-px-4 md:tw-px-8"},W={class:"tw-mb-4"},X={class:"form"},Y={key:0,class:"tw-max-w-[722px]"},Z={class:"tw-flex md:tw-items-center tw-flex-col md:tw-flex-row tw-gap-4 tw-mt-4"},ee={class:"tw-w-full"},te={key:1},oe={__name:"ContractMake",async setup(ae){let f,_;const x=M(),o=A(),d=U(),v=K(),D=z("emitter"),c=p(!1),s=p("Natural"),i=p(null);[f,_]=R(()=>o.fetchProfiles()),await f,_();const m=I(()=>{const t=Object.values(o.contractsList).find(e=>e.TypeID==="NaturalPartner");return Object.values(x.data?.Contracts?.Types||{}).filter(e=>e.ProfileTemplateID).filter(e=>e.ProfileTemplateID==="NaturalPartner"?!t:!0)}),w=I(()=>Object.keys(o.profileList).filter(t=>o.profileList[t].TemplateID===s.value&&o.profileList[t].ContractID===0).map(t=>({value:o.profileList[t].ID,name:`#${String(o.profileList[t].ID).padStart(5,"0")} / ${o.profileList[t].Name}`})));async function T(){c.value=!0,(await o.contractMake({ProfileID:i.value,TypeID:s.value})).status==="success"&&(D.emit("open-modal",{component:"SuccessContract",data:"Договор успешно создан!"}),d.push("/Contracts")),c.value=!1}function b(){d.push(`/ProfileMake?CreateContract=true&TemplateID=${s.value}`)}return O(m,()=>{v.query.TemplateID?s.value=v.query.TemplateID:s.value=m.value[0]?.ProfileTemplateID||null},{immediate:!0}),(t,e)=>{const k=j,P=F("RouterLink"),y=$,L=B,S=h,C=N;return n(),u(g,null,[l(k),a("div",Q,[a("div",W,[l(P,{to:"/Contracts",class:"section-label"},{default:q(()=>e[2]||(e[2]=[G(" Мои договора ",-1)])),_:1,__:[2]}),e[3]||(e[3]=a("h1",{class:"tw-mt-4"},"Создать договор",-1))]),l(y),a("form",X,[(n(!0),u(g,null,E(m.value,r=>(n(),H(L,{key:r.ProfileTemplateID,modelValue:s.value,"onUpdate:modelValue":e[0]||(e[0]=V=>s.value=V),label:r.Name,value:r.ProfileTemplateID},null,8,["modelValue","label","value"]))),128))]),w.value.length>0?(n(),u("div",Y,[a("div",Z,[e[4]||(e[4]=a("div",{class:"tw-w-64"},"Использовать профиль",-1)),a("div",ee,[l(S,{modelValue:i.value,"onUpdate:modelValue":e[1]||(e[1]=r=>i.value=r),options:w.value,placeholder:"Выбрать профиль"},null,8,["modelValue","options"])])]),l(C,{disabled:!i.value,"is-loading":c.value,label:"Зарегистрировать",class:"tw-mt-4",onClick:T},null,8,["disabled","is-loading"])])):(n(),u("div",te,[e[5]||(e[5]=a("p",null,"Нет доступных профилей для выбранного типа договора.",-1)),l(C,{label:"Создать профиль",class:"tw-w-64 tw-mt-4",onClick:b})]))])],64)}}},we=J(oe,[["__scopeId","data-v-ad3c15ac"]]);export{we as default};
