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