import{_ as L}from"./basicModal.vue_vue_type_script_setup_true_lang-CsJydKhW.js";import"./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";import{u as V}from"./useModal-CO65vga3.js";import{e as j,a as B,b as U}from"./company-PiwOjwod.js";import{d as q,u as D,V as F,r as _,a4 as N,c as S,o as $,l,w as u,j as n,_ as z,k as A,t as E}from"./index-9PRMimni.js";import{_ as G}from"./TreeSelect-BZh2DeCh.js";const Y=q({__name:"CreateDrawer",props:{title:{},deptList:{}},emits:["change"],setup(b,{expose:y,emit:P}){const v=P,g=b,m=D(),{t:o}=F(),h=()=>({id:null,name:"",code:"",parentId:0,status:1,sort:1}),i=_(null),k=_(!1),x=N(()=>g.deptList),e=_(h()),I={name:[{required:!0,message:o("permission.company.namePlaceholder"),trigger:"blur"}],code:[{required:!0,message:o("permission.company.codePlaceholder"),trigger:"blur"}]},[R,{openModal:w,closeModal:d,setSubLoading:s}]=V({title:g.title,subBtuText:o("common.okText"),cancelText:o("common.cancelText"),width:650});function C(){i.value.validate(r=>{if(r)s(!1),m.error(o("common.editPop.validateFail"));else{const a=e.value.id?o("common.editPop.success"):o("common.addPop.success");e.value.id?j(e.value).then(t=>{m.success(a),v("change"),p(),d(),s(!1)}).catch(()=>{s(!1)}):B(e.value).then(t=>{m.success(a),v("change"),p(),d(),s(!1)}).catch(()=>{s(!1)})}})}function p(){i.value.restoreValidation(),e.value=Object.assign(e.value,h())}function M(r){e.value.id=r,U(r).then(a=>{const t={id:a.id,name:a.name,code:a.code,parentId:a.parentId,status:a.status,sort:a.sort};e.value=Object.assign(e.value,t),k.value=!0})}return y({openModal:w,closeModal:d,getInfo:M}),(r,a)=>{const t=A,f=z,O=G,T=E;return $(),S(l(L),{onRegister:l(R),ref:"modalRef",onOnClose:p,onOnOk:C},{default:u(()=>[n(T,{model:e.value,rules:I,ref_key:"formRef",ref:i,"label-placement":"left","label-width":150},{default:u(()=>[n(f,{label:l(o)("permission.company.name"),path:"name"},{default:u(()=>[n(t,{placeholder:l(o)("permission.company.namePlaceholder"),value:e.value.name,"onUpdate:value":a[0]||(a[0]=c=>e.value.name=c),disabled:e.value.id},null,8,["placeholder","value","disabled"])]),_:1},8,["label"]),n(f,{label:l(o)("permission.company.code"),path:"code"},{default:u(()=>[n(t,{placeholder:l(o)("permission.company.codePlaceholder"),value:e.value.code,"onUpdate:value":a[1]||(a[1]=c=>e.value.code=c)},null,8,["placeholder","value"])]),_:1},8,["label"]),n(f,{label:l(o)("permission.company.higher"),path:"parent"},{default:u(()=>[n(O,{"label-field":"label","value-field":"value","key-field":"value",options:x.value,clearable:"",value:e.value.parentId,"onUpdate:value":a[2]||(a[2]=c=>e.value.parentId=c),placeholder:l(o)("permission.company.higherPlaceholder")},null,8,["options","value","placeholder"])]),_:1},8,["label"])]),_:1},8,["model"])]),_:1},8,["onRegister"])}}});export{Y as _};
