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