import{_ as j,w as D,r as p,Z as q,e as z,$ as I,o as N,c as H,v as r,n as u,y as K,q as g,p as i,t as Z,x as S,aH as A,aI as G,C as Q,s as V,O as W,F as X,J as Y,ak as ee,j as te,D as le}from"./index.8d733f79.js";import{_ as ae}from"./dialogContent.8cf6deaf.js";import{E as oe}from"./el-text.54dc8292.js";import{w as ne}from"./setValue.1d09ba51.js";const se={class:"el-select"},re={class:"el-select__wrapper"},ce=["title"],ie=["onClick"],de={class:"tree-container"},ue={class:"tree-filter"},fe={class:"tree-content"},pe={__name:"orgTree",props:{factoryId:[Number,String],orgId:[Number,String],dialogTitle:{type:String,default:""}},emits:["change","ready"],setup(x,{emit:b}){const c=x,{proxy:k}=le();D(()=>c.factoryId,()=>{o.value={},v.value={}});const E={children:"children",label:"label"},_=p(""),f=p(!1),o=p({}),v=p({}),$=()=>{m.value||(f.value=!0,_.value="",v.value=o.value,setTimeout(()=>{k.$refs.treeRef.setCurrentKey(o.value.id||null)}))},F=(e,t,l)=>e?l.data&&l.data.label&&l.data.label.toUpperCase().includes(e.toUpperCase()):!0,B=()=>{k.$refs.treeRef.filter(_.value)},L=()=>{f.value=!1,o.value=v.value,b("change",o.value)},w=p([]),y=q(()=>{if(c.factoryId){const t=T(w.value).find(l=>l.factoryId===c.factoryId)||[];return O(t.children||[])}return[]}),O=e=>{const t=l=>{const a=[];return l.forEach(n=>{var s;if(n.level===1){const h={...n};(s=n.children)!=null&&s.length&&(h.children=t(h.children)),a.push(h)}}),a};return t(e)},T=(e,t)=>{let l=t||[];return e.forEach(a=>{a.level===0?l.push(a):a.level===5&&(l=T(a.children||[],l))}),l},m=p(!1),R=()=>{m.value=!0,ne({userId:Y.session.getJSON("userInfo").id}).then(e=>{m.value=!1,w.value=e.data||[],c.orgId&&setTimeout(()=>{const t=C(y.value,c.orgId);o.value=t||{}})}).catch(()=>{m.value=!1})},C=(e,t)=>{var a;let l;for(let n=0;n<e.length;n++){const s=e[n];if(s.id===t?l={...s}:(a=s.children)!=null&&a.length&&(l=C(s.children,t)),l)break}return l};D(()=>c.orgId,()=>{if(y.value.length){const e=C(y.value,c.orgId);o.value=e||{}}});const U=e=>{v.value=e},J=()=>{o.value={},v.value={},b("change",o.value)};return z(()=>{R()}),(e,t)=>{const l=I("Loading"),a=ee,n=I("CircleClose"),s=I("arrow-down"),h=te,M=oe,P=ae;return N(),H(X,null,[r("div",se,[r("div",re,[r("div",{class:"selected-container",onClick:$},[u(m)?(N(),K(a,{key:0,class:"is-loading"},{default:g(()=>[i(l)]),_:1})):Z("",!0),r("div",{class:"selected-label",title:u(o).label||"\u5168\u90E8"},S(u(o).label||"\u5168\u90E8"),9,ce),A(r("div",{class:"btn-clear",onClick:Q(J,["stop"])},[i(a,{class:"icon-clear"},{default:g(()=>[i(n)]),_:1})],8,ie),[[G,u(o).label]]),i(a,{class:"el-icon--right"},{default:g(()=>[i(s)]),_:1})])])]),i(P,{modelValue:u(f),"onUpdate:modelValue":t[1]||(t[1]=d=>V(f)?f.value=d:null),title:c.dialogTitle||e.$t("selectTreeNode"),onConfirm:L,onCancel:t[2]||(t[2]=d=>f.value=!1),width:"600"},{main:g(()=>[r("div",de,[r("div",ue,[i(h,{modelValue:u(_),"onUpdate:modelValue":t[0]||(t[0]=d=>V(_)?_.value=d:null),placeholder:e.$t("inputP"),"suffix-icon":"Search",clearable:"",style:{"margin-bottom":"16px"},onInput:B},null,8,["modelValue","placeholder"])]),r("div",fe,[i(M,{ref:"treeRef",class:"filter-tree","node-key":"id",data:u(y),props:E,"default-expand-all":"","check-on-click-node":"","expand-on-click-node":!1,"filter-node-method":F,onNodeClick:U,"highlight-current":""},{default:g(({data:d})=>[r("div",{style:W({cursor:d.level===5?"not-allowed ":""})},S(d.label),5)]),_:1},8,["data"])])])]),_:1},8,["modelValue","title"])],64)}}},ge=j(pe,[["__scopeId","data-v-07eefcdf"]]);export{ge as default};
