var u=(r,m,c)=>new Promise((x,y)=>{var o=s=>{try{a(c.next(s))}catch(l){y(l)}},n=s=>{try{a(c.throw(s))}catch(l){y(l)}},a=s=>s.done?x(s.value):Promise.resolve(s.value).then(o,n);a((c=c.apply(r,m)).next())});import{d as E,c as P,f as i,n as w,U as d,a2 as v,ad as h,af as C,k as K,a3 as V,V as N,F as U}from"./vue-vendor-CxLCUzY4.js";import{h as D}from"./index-Cy4uayzW.js";import{s as z}from"./depart.user.api-BbJ42Ps1.js";const L=r=>D.get({url:"/sys/sysDepart/queryDepartTreeSync",params:r}),J=r=>D.get({url:"/sys/user/queryByOrgCodeForAddressList",params:r}),Q=r=>D.get({url:"/sys/position/list",params:r}),H=E({__name:"DepartLeftTree",emits:["select","rootTreeData"],setup(r,{expose:m,emit:c}){const x=P("prefixCls"),y=c,o=i(!1),n=i([]),a=i([]),s=i([]),l=i(!1),S=i(null),b=i("");function _(){return u(this,null,function*(){try{o.value=!0,n.value=[];const e=yield L();Array.isArray(e)&&(n.value=e),a.value.length===0&&T()}finally{o.value=!1}})}_();function q(e){return u(this,null,function*(){try{const t=yield L({pid:e.dataRef.id});if(t.length==0)e.dataRef.isLeaf=!0;else if(e.dataRef.children=t,a.value.length>0){let f=[];for(let p of a.value)t.findIndex(g=>g.id===p)!==-1&&f.push(p);f.length>0&&(a.value=[...a.value])}n.value=[...n.value]}catch(t){}return Promise.resolve()})}function T(){let e=n.value[0];e&&(e.isLeaf||(a.value=[e.key]),B())}function B(){return u(this,null,function*(){yield w(),l.value=!0,yield w(),l.value=!1})}function k(e,t){s.value=[e],t&&(S.value=t,y("select",t))}function R(e){return u(this,null,function*(){if(e)try{o.value=!0,n.value=[];let t=yield z({keyWord:e});Array.isArray(t)&&(n.value=t),T()}finally{o.value=!1}else _();b.value=e})}function A(e,t){e.length>0&&s.value[0]!==e[0]?k(e[0],t.selectedNodes[0]):k(s.value[0])}return m({loadRootTreeData:_}),(e,t)=>{const f=d("a-input-search"),p=d("a-tree"),g=d("a-empty"),F=d("a-spin"),O=d("a-card");return v(),h(O,{bordered:!1,style:{height:"100%"}},{default:C(()=>[K(F,{spinning:o.value},{default:C(()=>[K(f,{placeholder:"按部门名称搜索…",style:{"margin-bottom":"10px"},onSearch:R,allowClear:""}),n.value.length>0?(v(),V(U,{key:0},[l.value?N("",!0):(v(),h(p,{key:0,showLine:"",clickRowToExpand:!1,treeData:n.value,selectedKeys:s.value,"load-data":q,expandedKeys:a.value,"onUpdate:expandedKeys":t[0]||(t[0]=j=>a.value=j),onSelect:A},null,8,["treeData","selectedKeys","expandedKeys"]))],64)):(v(),h(g,{key:1,description:"暂无数据"}))]),_:1},8,["spinning"])]),_:1})}}}),X=Object.freeze(Object.defineProperty({__proto__:null,default:H},Symbol.toStringTag,{value:"Module"}));export{X as D,H as _,J as l,Q as p};
