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.

2 lines
4.8KB

  1. import{a as I}from"./unitManage.45b2919c.js";import{d as F,r as p,L as $,c as v,e as E,I as O,i as h,g as f,h as y,j as P,t as R,f as J,J as q,F as H,M as T,N as x}from"./index.b4f1c826.js";const Q={class:"unitBox"},W={class:"left"},X=f("div",{class:"title"},"\u5217\u8868",-1),Y={class:"content"},ee={class:"right"},ae={class:"title"},te={class:"content"},le={class:"dialog-footer"},se=F({name:"orgTree"}),de=Object.assign(se,{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:"\u5355\u4F4D"},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,B=A,w=()=>{B("close"),V.value=""},S=()=>{B("getSelectUnit",n.value),w()},k=p(""),V=p(""),s=p(),j=async(a,l)=>{var d,i,m,b,g,_,u,C,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(t=>({...t,disabled:t.type==="ORGANIZATION",isLeaf:t.type==="MEMBER"})):c=r.data.map(t=>({...t,isLeaf:t.type==="MEMBER"})),l(c)}else l([]);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(t=>({...t,disabled:t.type==="ORGANIZATION",isLeaf:t.type==="MEMBER"})):c=(b=a==null?void 0:a.data)==null?void 0:b.children.map(t=>({...t,isLeaf:t.type==="MEMBER"})),l(c)):(r=await I({...e.params,organizationCode:a.data.key}),(_=(g=r.data)==null?void 0:g[0])!=null&&_.children?(e.isPerson&&e.showCheckbox?c=(C=(u=r.data)==null?void 0:u[0])==null?void 0:C.children.map(t=>({...t,disabled:t.type==="ORGANIZATION",isLeaf:t.type==="MEMBER"})):c=(M=(D=r.data)==null?void 0:D[0])==null?void 0:M.children.map(t=>({...t,isLeaf:t.type==="MEMBER"})),l(c)):l([]))}}x(()=>{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)})};$(()=>e.visible,a=>{a&&x(async()=>{await L(),e.defaultData&&e.defaultData.length?n.value=[...e.defaultData]:(k.value=void 0,n.value=[])})});const K=async()=>{await L(k.value),x(()=>{s.value&&s.value.filter(k.value)})},U=p(!1),z=(a,l)=>(a,!0),n=p([]),G=(a,{checkedKeys:l,checkedNodes:d})=>{e.showCheckbox?l.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,l,d)=>{n.value.splice(a,1),x(()=>{e.showCheckbox?s.value&&s.value.setChecked(l,!1):s.value&&s.value.setCurrentKey(null)})},N=p(),L=async a=>{N.value=[];let l;e.type==="LINE"?l=await T({}):l=await I({...e.params,organizationName:!e.isPerson&&a||void 0,employeeName:e.isPerson&&a||void 0,parentCode:void 0});let d;e.isPerson&&e.showCheckbox?d=l.data.map(i=>({...i,disabled:!0})):d=l.data.map(i=>({...i})),N.value=d};return(a,l)=>{const d=v("el-button"),i=v("el-input"),m=v("el-tree"),b=v("el-scrollbar"),g=v("el-tag"),_=v("el-dialog");return E(),O(_,{"model-value":e.visible,title:`\u9009\u62E9${o.title}`,width:800,"destroy-on-close":"","before-close":w},{footer:h(()=>[f("span",le,[y(d,{type:"primary",onClick:S},{default:h(()=>[P("\u63D0\u4EA4")]),_:1}),y(d,{onClick:w},{default:h(()=>[P("\u5173\u95ED")]),_:1})])]),default:h(()=>[f("div",Q,[f("div",W,[X,f("div",Y,[y(i,{modelValue:k.value,"onUpdate:modelValue":l[0]||(l[0]=u=>k.value=u),class:"mb-16",placeholder:"\u6309\u540D\u79F0\u641C\u7D22"},{append:h(()=>[y(d,{icon:"Search",onClick:K})]),_: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:j,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":U.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",ee,[f("div",ae,"\u5DF2\u9009"+R(o.title),1),f("div",te,[(E(!0),J(H,null,q(n.value,(u,C)=>(E(),O(g,{key:u.key,closable:"",onClose:D=>Z(C,u.key,u.type)},{default:h(()=>[P(R(o.type==="LINE"?u.businessStripName:u.title),1)]),_:2},1032,["onClose"]))),128))])])])]),_:1},8,["model-value","title"])}}});export{de as _};