import{u as e}from"./useCreate-b3492f2b.js";import{u as a}from"./useShow-ca493df3.js";import{d as l,f as r,k as t,p as o,R as n,r as m,K as p,J as d,o as i,j as u,w as s,a as c,e as _,b as f,t as b}from"./index-018fb6dd.js";const V={class:"flex justify-end"},v=l({__name:"create",props:{primary:String|Number,api:String},emits:["close"],setup(l,{emit:v}){const y=l,{formData:g,form:U,loading:h,submitForm:j,close:w,beforeCreate:S,beforeUpdate:k}=e(y.api,y.primary);g.value.sort=1,S.value=()=>{g.value.parent_id=x(g.value.parent_id)},k.value=()=>{g.value.parent_id=x(g.value.parent_id)};const x=e=>void 0===e?0:e[e.length-1];if(y.primary){const{afterShow:e}=a(y.api,y.primary,g);e.value=e=>{const a=r(e);a.parent_id=a.parent_id?[a.parent_id]:0,a.data_range||(a.data_range=null),e.value=a}}const C=t();return o((()=>{n.get(y.api).then((e=>{C.value=e.data.data})),w((()=>{v("close")}))})),(e,a)=>{const l=m("el-cascader"),t=m("el-form-item"),o=m("el-input"),n=m("el-input-number"),v=m("el-button"),y=m("el-form"),w=p("loading");return d((i(),u(y,{model:r(g),"label-width":"120px",ref_key:"form",ref:U,class:"pr-4"},{default:s((()=>[c(t,{label:"父级部门",prop:"parent_id"},{default:s((()=>[c(l,{options:C.value,name:"parent_id",modelValue:r(g).parent_id,"onUpdate:modelValue":a[0]||(a[0]=e=>r(g).parent_id=e),clearable:"",props:{value:"id",label:"department_name",checkStrictly:!0},class:"w-full"},null,8,["options","modelValue"])])),_:1}),c(t,{label:"部门名称",prop:"department_name",rules:[{required:!0,message:"部门名称必须填写"}]},{default:s((()=>[c(o,{modelValue:r(g).department_name,"onUpdate:modelValue":a[1]||(a[1]=e=>r(g).department_name=e),name:"department_name",clearable:""},null,8,["modelValue"])])),_:1}),c(t,{label:"部门联系人",prop:"principal"},{default:s((()=>[c(o,{modelValue:r(g).principal,"onUpdate:modelValue":a[2]||(a[2]=e=>r(g).principal=e),name:"principal",clearable:""},null,8,["modelValue"])])),_:1}),c(t,{label:"手机号",prop:"mobile"},{default:s((()=>[c(o,{modelValue:r(g).mobile,"onUpdate:modelValue":a[3]||(a[3]=e=>r(g).mobile=e),name:"mobile",clearable:""},null,8,["modelValue"])])),_:1}),c(t,{label:"邮箱",prop:"email"},{default:s((()=>[c(o,{modelValue:r(g).email,"onUpdate:modelValue":a[4]||(a[4]=e=>r(g).email=e),name:"email",clearable:""},null,8,["modelValue"])])),_:1}),c(t,{label:"排序",prop:"sort"},{default:s((()=>[c(n,{modelValue:r(g).sort,"onUpdate:modelValue":a[5]||(a[5]=e=>r(g).sort=e),name:"sort",min:1},null,8,["modelValue"])])),_:1}),_("div",V,[c(v,{type:"primary",onClick:a[6]||(a[6]=e=>r(j)(r(U)))},{default:s((()=>[f(b(e.$t("system.confirm")),1)])),_:1})])])),_:1},8,["model"])),[[w,r(h)]])}}});export{v as _};
