You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 1 месец
1
  1. import{a as O}from"./unitManage-104cfe86.js";import{r as p,B as F,b as v,c as E,L as R,h,e as f,f as y,i as B,t as I,d as $,H,F as X,k as q,X as T,C as _}from"./index-dd5fae99.js";const J={class:"unitBox"},Q={class:"left"},W={class:"content"},Y={class:"right"},ee={class:"title"},ae={class:"content"},te={class:"dialog-footer"},le=q({name:"orgTree"}),oe=Object.assign(le,{props:{visible:{type:Boolean,default:!1},showCheckbox:{type:Boolean,default:!1},defaultData:Array,params:{type:Object,default:()=>{}},isPerson:{type:Boolean,default:!1},title:{type:String,default:"单位"},defaultExpandedkeys:{type:Array,default:()=>[]},defaultProps:{type:Object,default:()=>({children:"children",label:"title",value:"key",isLeaf:"isLeaf"})},type:{type:String,default:"UNIT"}},emits:["close","getSelectUnit"],setup(o,{emit:A}){const e=o,P=A,w=()=>{P("close"),V.value=""},S=()=>{P("getSelectUnit",n.value),w()},k=p(""),V=p(""),s=p(),K=async(a,t)=>{var d,i,m,b,g,C,u,x,D,M;if(a.level){let r;if(e.type==="LINE")if(r=await T({...e.params,parentCode:a.data.businessStripCode}),r.data){let c;e.isPerson&&e.showCheckbox?c=r.data.map(l=>({...l,disabled:l.type==="ORGANIZATION",isLeaf:l.type==="MEMBER"})):c=r.data.map(l=>({...l,isLeaf:l.type==="MEMBER"})),t(c)}else t([]);else{let c;(i=(d=a==null?void 0:a.data)==null?void 0:d.children)!=null&&i.length?(e.isPerson&&e.showCheckbox?c=(m=a==null?void 0:a.data)==null?void 0:m.children.map(l=>({...l,disabled:l.type==="ORGANIZATION",isLeaf:l.type==="MEMBER"})):c=(b=a==null?void 0:a.data)==null?void 0:b.children.map(l=>({...l,isLeaf:l.type==="MEMBER"})),t(c)):(r=await O({...e.params,organizationCode:a.data.key}),(C=(g=r.data)==null?void 0:g[0])!=null&&C.children?(e.isPerson&&e.showCheckbox?c=(x=(u=r.data)==null?void 0:u[0])==null?void 0:x.children.map(l=>({...l,disabled:l.type==="ORGANIZATION",isLeaf:l.type==="MEMBER"})):c=(M=(D=r.data)==null?void 0:D[0])==null?void 0:M.children.map(l=>({...l,isLeaf:l.type==="MEMBER"})),t(c)):t([]))}}_(()=>{e.showCheckbox?n.value&&n.value.length?s.value&&s.value.setCheckedNodes(n.value):s.value&&s.value.setCheckedKeys([]):n.value&&n.value.length?s.value&&s.value.setCurrentKey(n.value[0].key):s.value&&s.value.setCurrentKey(null)})};F(()=>e.visible,a=>{a&&_(async()=>{await L(),e.defaultData&&e.defaultData.length?n.value=[...e.defaultData]:(k.value=void 0,n.value=[])})});const U=async()=>{await L(k.value),_(()=>{s.value&&s.value.filter(k.value)})},j=p(!1),z=(a,t)=>!0,n=p([]),G=(a,{checkedKeys:t,checkedNodes:d})=>{e.showCheckbox?t.includes(a[e.defaultProps.value])?n.value.push(a):n.value=n.value.filter(i=>i[e.defaultProps.value]!==a[e.defaultProps.value]):n.value=[a]},Z=(a,t,d)=>{n.value.splice(a,1),_(()=>{e.showCheckbox?s.value&&s.value.setChecked(t,!1):s.value&&s.value.setCurrentKey(null)})},N=p(),L=async a=>{N.value=[];let t;e.type==="LINE"?t=await T({}):t=await O({...e.params,organizationName:!e.isPerson&&a||void 0,employeeName:e.isPerson&&a||void 0,parentCode:void 0});let d;e.isPerson&&e.showCheckbox?d=t.data.map(i=>({...i,disabled:!0})):d=t.data.map(i=>({...i})),N.value=d};return(a,t)=>{const d=v("el-button"),i=v("el-input"),m=v("el-tree"),b=v("el-scrollbar"),g=v("el-tag"),C=v("el-dialog");return E(),R(C,{"model-value":e.visible,title:`选择${o.title}`,width:800,"destroy-on-close":"","before-close":w},{footer:h(()=>[f("span",te,[y(d,{type:"primary",onClick:S},{default:h(()=>t[2]||(t[2]=[B("提交")])),_:1}),y(d,{onClick:w},{default:h(()=>t[3]||(t[3]=[B("关闭")])),_:1})])]),default:h(()=>[f("div",J,[f("div",Q,[t[1]||(t[1]=f("div",{class:"title"},"列表",-1)),f("div",W,[y(i,{modelValue:k.value,"onUpdate:modelValue":t[0]||(t[0]=u=>k.value=u),class:"mb-16",placeholder:"按名称搜索"},{append:h(()=>[y(d,{icon:"Search",onClick:U})]),_:1},8,["modelValue"]),y(b,null,{default:h(()=>[y(m,{ref_key:"treeRef",ref:s,data:N.value,class:"filter-tree","node-key":o.defaultProps.value,"default-checked-keys":e.defaultData&&e.defaultData.length&&e.defaultData.map(u=>u[o.defaultProps.value])||[],"current-node-key":e.defaultData&&e.defaultData.length&&e.defaultData[0][o.defaultProps.value]||void 0,load:K,lazy:"",props:o.defaultProps,"show-checkbox":o.showCheckbox,"check-on-click-node":!o.showCheckbox,"check-strictly":"","highlight-current":!o.showCheckbox,"filter-node-method":z,"default-expand-all":j.value,"default-expanded-keys":o.defaultExpandedkeys,onCheck:G},null,8,["data","node-key","default-checked-keys","current-node-key","props","show-checkbox","check-on-click-node","highlight-current","default-expand-all","default-expanded-keys"])]),_:1})])]),f("div",Y,[f("div",ee,"已选"+I(o.title),1),f("div",ae,[(E(!0),$(X,null,H(n.value,(u,x)=>(E(),R(g,{key:u.key,closable:"",onClose:D=>Z(x,u.key,u.type)},{default:h(()=>[B(I(o.type==="LINE"?u.businessStripName:u.title),1)]),_:2},1032,["onClose"]))),128))])])])]),_:1},8,["model-value","title"])}}});export{oe as _};