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