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