var T=Object.defineProperty;var x=Object.getOwnPropertySymbols;var V=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var b=(n,a,e)=>a in n?T(n,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[a]=e,y=(n,a)=>{for(var e in a||(a={}))V.call(a,e)&&b(n,e,a[e]);if(x)for(var e of x(a))j.call(a,e)&&b(n,e,a[e]);return n};var C=(n,a,e)=>new Promise((s,u)=>{var v=r=>{try{m(e.next(r))}catch(t){u(t)}},h=r=>{try{m(e.throw(r))}catch(t){u(t)}},m=r=>r.done?s(r.value):Promise.resolve(r.value).then(v,h);m((e=e.apply(n,a)).next())});import{h as q,f as D,g as z}from"./index-2a45336b.js";import{u as G}from"./useForm-269e95cd.js";import{c as H}from"./lodash-es-7cb071db.js";import{a as I,b as f,o as J,c as K,w as _,e as i,u as o}from"./ant-design-vue-710243d9.js";import"./tinymce-3184e0f1.js";import"./echarts-ca5d9323.js";import"./cropper-47c8e461.js";import"./qrcode-bec2257a.js";import"./jschardet-bd496279.js";const te={__name:"EditDepartmentDialog",emits:["ok"],setup(n,{expose:a,emit:e}){const{modal:s,showModal:u,hideModal:v,showLoading:h,hideLoading:m}=q(),{formRecord:r,formData:t,formRef:k,formRules:E,resetForm:R}=G(),g=I("取消");function F(){u({type:"create",title:"新建部门"})}function L(d={}){u({type:"edit",title:"编辑部门"}),r.value=d,t.value=H(d)}function M(){k.value.validateFields().then(d=>C(this,null,function*(){try{h();const l=y({},d);let c=null;switch(s.value.type){case"create":c=yield D.common.create(l).catch(()=>{throw new Error});break;case"edit":c=yield D.common.update(l).catch(()=>{throw new Error});break}m(),z("http.code.success")===(c==null?void 0:c.code)&&(v(),e("ok"))}catch(l){m()}})).catch(()=>{m()})}function U(){v()}function B(){R(),g.value="取消",m()}return a({handleCreate:F,handleEdit:L}),(d,l)=>{const c=f("a-input"),w=f("a-form-item"),O=f("a-tree-select"),A=f("a-form"),N=f("a-modal");return J(),K(N,{open:o(s).open,title:o(s).title,width:480,"confirm-loading":o(s).confirmLoading,"after-close":B,"cancel-text":g.value,onOk:M,onCancel:U},{default:_(()=>[i(A,{ref_key:"formRef",ref:k,model:o(t),rules:o(E),"label-col":{style:{width:"90px"}}},{default:_(()=>[i(w,{label:"部门名称",name:"name"},{default:_(()=>[i(c,{value:o(t).name,"onUpdate:value":l[0]||(l[0]=p=>o(t).name=p)},null,8,["value"])]),_:1}),i(w,{label:"上级部门",name:"parent_id"},{default:_(()=>[i(O,{value:o(t).parent_id,"onUpdate:value":l[1]||(l[1]=p=>o(t).parent_id=p)},null,8,["value"])]),_:1}),i(w,{label:"部门负责人",name:"name"},{default:_(()=>[i(c,{value:o(t).name,"onUpdate:value":l[2]||(l[2]=p=>o(t).name=p)},null,8,["value"])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["open","title","confirm-loading","cancel-text"])}}};export{te as default};
