import{d as U,h as u,Y as $,r as n,o as b,f as A,w as l,b as r,aE as H,H as K,a as R,a2 as T,l as E,E as q,_ as M}from"./index.e3896b23.js";import{u as P,a as S,b as j}from"./orgs.0a892ff5.js";const I={class:"popover-pop-body"},Y=E("\u53D6\u6D88"),z=E("\u786E\u5B9A"),G=U({__name:"add-or-update",emits:["refreshDataList"],setup(J,{expose:C,emit:V}){const s=u(!1),m=u([]),c=u(),d=u(),_=u(),e=$({id:"",name:"",pid:"",parentName:"",sort:0}),F=o=>{s.value=!0,e.id="",d.value&&d.value.resetFields(),o?k(o):i(),y()},y=()=>P().then(o=>{m.value=o.data}),k=o=>{S(o).then(t=>{if(Object.assign(e,t.data),e.pid=="0")return i();c.value.setCurrentKey(e.pid)})},i=()=>{e.pid="0",e.parentName="\u4E00\u7EA7\u673A\u6784"},D=o=>{e.pid=o.id,e.parentName=o.name,_.value.hide()},N=u({name:[{required:!0,message:"\u5FC5\u586B\u9879\u4E0D\u80FD\u4E3A\u7A7A",trigger:"blur"}],parentName:[{required:!0,message:"\u5FC5\u586B\u9879\u4E0D\u80FD\u4E3A\u7A7A",trigger:"blur"}]}),f=()=>{d.value.validate(o=>{if(!o)return!1;j(e).then(()=>{q.success({message:"\u64CD\u4F5C\u6210\u529F",duration:500,onClose:()=>{s.value=!1,V("refreshDataList")}})})})};return C({init:F}),(o,t)=>{const g=n("el-input"),p=n("el-form-item"),h=n("svg-icon"),x=n("el-tree"),L=n("el-popover"),O=n("el-input-number"),B=n("el-form"),v=n("el-button"),w=n("el-dialog");return b(),A(w,{modelValue:s.value,"onUpdate:modelValue":t[7]||(t[7]=a=>s.value=a),title:e.id?"\u4FEE\u6539":"\u65B0\u589E","close-on-click-modal":!1,draggable:""},{footer:l(()=>[r(v,{onClick:t[5]||(t[5]=a=>s.value=!1)},{default:l(()=>[Y]),_:1}),r(v,{type:"primary",onClick:t[6]||(t[6]=a=>f())},{default:l(()=>[z]),_:1})]),default:l(()=>[r(B,{ref_key:"dataFormRef",ref:d,model:e,rules:N.value,"label-width":"120px",onKeyup:t[4]||(t[4]=T(a=>f(),["enter"]))},{default:l(()=>[r(p,{prop:"name",label:"\u540D\u79F0"},{default:l(()=>[r(g,{modelValue:e.name,"onUpdate:modelValue":t[0]||(t[0]=a=>e.name=a),placeholder:"\u540D\u79F0"},null,8,["modelValue"])]),_:1}),r(p,{prop:"parentName",label:"\u4E0A\u7EA7\u673A\u6784",class:"org-list"},{default:l(()=>[r(L,{ref_key:"orgListPopover",ref:_,placement:"bottom-start",trigger:"click",width:400,"popper-class":"popover-pop"},{reference:l(()=>[r(g,{modelValue:e.parentName,"onUpdate:modelValue":t[2]||(t[2]=a=>e.parentName=a),readonly:!0,placeholder:"\u4E0A\u7EA7\u673A\u6784"},{suffix:l(()=>[e.pid!=="0"?(b(),A(h,{key:0,icon:"icon-close-circle",onClick:t[1]||(t[1]=H(a=>i(),["stop"]))})):K("",!0)]),_:1},8,["modelValue"])]),default:l(()=>[R("div",I,[r(x,{ref_key:"orgListTree",ref:c,data:m.value,props:{label:"name",children:"children"},"node-key":"id","highlight-current":!0,"expand-on-click-node":!1,accordion:"",onCurrentChange:D},null,8,["data"])])]),_:1},512)]),_:1}),r(p,{prop:"sort",label:"\u6392\u5E8F"},{default:l(()=>[r(O,{modelValue:e.sort,"onUpdate:modelValue":t[3]||(t[3]=a=>e.sort=a),"controls-position":"right",min:0,label:"\u6392\u5E8F"},null,8,["modelValue"])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["modelValue","title"])}}});const X=M(G,[["__scopeId","data-v-90d2d3fe"]]);export{X as default};
