import{r as U,a7 as B}from"./index.CL7yl-Wb.js";import{a as P,r as u,_ as L,w as N,aj as r,J as f,o as g,K as C,b as D,S as d,M as E,c as K,R as j,a9 as q}from"./vue.D1BjjNmv.js";import{_ as A}from"./_plugin-vue_export-helper.DlAUqK2U.js";const F={class:"option"},I=P({__name:"index",props:{modelValue:{},tableConfig:{url:null,label:null,value:null,isTree:!1,lazy:!0,load:()=>{},data:[],isMultiple:!1,treeProps:{children:"children",hasChildren:"hasChildren"},columns:[]},displayLabel:{}},emits:["update:modelValue"],setup(y,{emit:v}){const a=y,_=v,V=u(),s=u(),w=u(),b=u(void 0),c=u(),l=L({page:1,limit:10,total:0}),x=t=>{w.value=t;const{tableConfig:e}=a,i=t.map(n=>n[e.value]);s.value=t.map(n=>n[e.label]),_("update:modelValue",i)},k=t=>{const{tableConfig:e}=a;!e.isMultiple&&t&&(s.value=[t[e.label]],_("update:modelValue",t[e.value]))},m=async()=>{const t=a.tableConfig.url,e={page:l.page,limit:l.limit,search:b.value},{data:i,page:n,limit:p,total:h}=await U({url:t,params:e});l.page=n,l.limit=p,l.total=h,a.tableConfig.data===void 0||a.tableConfig.data.length===0?a.tableConfig.isTree?c.value=B.toArrayTree(i,{parentKey:"parent",key:"id",children:"children"}):c.value=i:c.value=a.tableConfig.data},z=t=>{t&&m()},S=t=>{l.page=t,m()};return N(()=>a.displayLabel,t=>{const{tableConfig:e}=a,i=t?t.map(n=>n[e.label]):null;s.value=i},{immediate:!0}),(t,e)=>{const i=r("el-button"),n=r("el-input"),p=r("el-table-column"),h=r("el-table"),T=r("el-pagination"),M=r("el-select");return g(),f(M,{"popper-class":"popperClass",class:"tableSelector",multiple:"",onRemoveTag:t.removeTag,modelValue:s.value,"onUpdate:modelValue":e[3]||(e[3]=o=>s.value=o),placeholder:"请选择",onVisibleChange:z},{empty:C(()=>[D("div",F,[d(n,{style:{"margin-bottom":"10px"},modelValue:b.value,"onUpdate:modelValue":e[0]||(e[0]=o=>b.value=o),clearable:"",placeholder:"请输入关键词",onChange:m,onClear:m},{append:C(()=>[d(i,{type:"primary",icon:"Search"})]),_:1},8,["modelValue"]),d(h,{ref_key:"tableRef",ref:V,data:c.value,size:"mini",border:"","row-key":"id",lazy:a.tableConfig.lazy,load:a.tableConfig.load,"tree-props":a.tableConfig.treeProps,style:{width:"400px"},"max-height":"200",height:"200","highlight-current-row":!a.tableConfig.isMultiple,onSelectionChange:x,onCurrentChange:k},{default:C(()=>[a.tableConfig.isMultiple?(g(),f(p,{key:0,fixed:"",type:"selection",width:"55"})):E("",!0),d(p,{fixed:"",type:"index",label:"#",width:"50"}),(g(!0),K(j,null,q(a.tableConfig.columns,(o,R)=>(g(),f(p,{prop:o.prop,label:o.label,width:o.width,key:R},null,8,["prop","label","width"]))),128))]),_:1},8,["data","lazy","load","tree-props","highlight-current-row"]),d(T,{style:{"margin-top":"10px"},background:"","current-page":l.page,"onUpdate:currentPage":e[1]||(e[1]=o=>l.page=o),"page-size":l.limit,"onUpdate:pageSize":e[2]||(e[2]=o=>l.limit=o),layout:"prev, pager, next",total:l.total,onCurrentChange:S},null,8,["current-page","page-size","total"])])]),_:1},8,["onRemoveTag","modelValue"])}}}),H=A(I,[["__scopeId","data-v-dd0b29a1"]]);export{H as t};
