import{_ as $}from"./ButtonDefault-BIBStZbJ.js";import{_ as w}from"./BlockSelectProfile-DJR_O1cX.js";import{_ as R}from"./SimpleCheckbox-BAAxXipX.js";import{_ as F}from"./ClausesKeeper-CTja-fCz.js";import{_ as M}from"./BlockBalanceAgreement-qtspRQ_B.js";import{u as O}from"./contracts-P7YPBhEI.js";import{ao as U,r as d,f as u,H as D,s as j,m as A,d as K,D as H,c as f,b as s,a as n,w as J,E as q,F as v,i as z,x as G,g as Q,o as c,e as W,C as X,h as Y}from"./index-CmCGXBst.js";import{_ as Z}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./multiselect-DhoC9bwZ.js";import"./IconClose-B_k4TzXM.js";const ee={class:"section"},te={class:"container"},oe={class:"tw-mb-4"},ae={class:"form"},ne={class:"container-limited"},le={__name:"ContractCreateContract",async setup(se){let k,C;const y=U(),i=O(),m=K();Q();const P=G("emitter"),_=d(!1),r=d("Natural"),o=d(null),T=u(()=>y.data),a=u(()=>i?.profileList),p=u(()=>Object.keys(a.value).map(e=>{if(a.value[e].TemplateID==="Natural"||a.value[e].TemplateID==="Juridical"||a.value[e].TemplateID==="Individual"||a.value[e].TemplateID==="NaturalPartner")return{value:a.value[e].ID,name:a.value[e].Name,contractID:a.value[e].ContractID}}).filter(e=>e.contractID===0)),I=e=>{e.key==="Enter"&&e.ctrlKey&&!V.value&&b()},V=u(()=>o.value===null||o.value===void 0);D(()=>{document.addEventListener("keyup",I)}),j(()=>{document.removeEventListener("keyup",I)});function b(){_.value=!0,i.contractMake({ProfileID:o.value,TypeID:r.value}).then(e=>{e.status==="success"&&(P.emit("open-modal",{component:"SuccessContract",data:"Договор успешно создан!"}),m.push("/Contracts")),_.value=!1})}function g(){o.value=p.value?.[0]?.value||null}return A(r,()=>{g()}),D(()=>{p.value.length<1&&m.push(`/ProfileMake?ProfileEmpty=true&Redirect=${m.options.history.state.back}`),g()}),[k,C]=H(()=>i.fetchProfiles()),await k,C(),(e,t)=>{const h=M,E=q("router-link"),S=F,L=R,N=w,x=$;return c(),f(v,null,[s(h),n("section",ee,[n("div",te,[n("div",oe,[s(E,{to:"/Contracts",class:"section-label"},{default:J(()=>t[2]||(t[2]=[W("Мои договора",-1)])),_:1,__:[2]}),t[3]||(t[3]=n("h1",{class:"section-title"},"Создать договор",-1))]),s(S),t[4]||(t[4]=n("div",{class:"section-header"},[n("h2",{class:"section-block_title"},"Шаблон")],-1)),n("form",ae,[(c(!0),f(v,null,z(T.value?.Contracts?.Types,l=>(c(),f(v,{key:l?.ProfileTemplateID},[l?.ProfileTemplateID!==""?(c(),X(L,{key:0,label:l?.Name,value:l?.ProfileTemplateID,modelValue:r.value,"onUpdate:modelValue":t[0]||(t[0]=B=>r.value=B)},null,8,["label","value","modelValue"])):Y("",!0)],64))),128))]),n("div",ne,[s(N,{title:"Использовать профиль",items:p.value,modelValue:o.value,"onUpdate:modelValue":t[1]||(t[1]=l=>o.value=l)},null,8,["items","modelValue"]),s(x,{onClick:b,disabled:o.value===null||o.value===void 0,"is-loading":_.value,label:"Зарегистрировать"},null,8,["disabled","is-loading"])])])])],64)}}},ke=Z(le,[["__scopeId","data-v-f0b24fba"]]);export{ke as default};
