import{d as b,V as z,b$ as C,r as g,a4 as p,a as v,l as s,c as P,o as k,aq as O,aa as $,c6 as q,a9 as B,w as K,ab as E,c4 as x,cp as D}from"./index-9PRMimni.js";const R=b({__name:"CustomTable",props:{columns:{default:()=>[]},rowKey:{default:"id"},request:{type:Function,default:()=>!1},params:{default:()=>({})},showPagination:{type:Boolean,default:!0},height:{default:"100%"}},setup(f,{expose:h}){const r=f,{t:c}=z(),m=C(),i=g([]),n=g(!1),u=p(()=>r.columns.map(e=>({...e,align:e.align||"center",resizable:typeof e.resizable>"u"?!0:e.resizable,width:e.width||120,ellipsis:typeof e.ellipsis>"u"?{tooltip:!0}:e.ellipsis}))),t=v({page:1,pageSize:10,itemCount:0,pageSizes:[10,20,30,40,50,80],pageSlot:5,showSizePicker:!0,showQuickJumper:!0,onChange:e=>{t.page=e,l()},onUpdatePageSize:e=>{t.page=1,t.pageSize=e,l()},prefix:e=>`${c("common.total")} ${e.itemCount}`,goto:()=>c("common.goto")}),w=p(()=>{let e=0;return s(u).forEach(a=>{a.width&&(e+=a.width)}),e}),y=p(()=>({loading:s(n),columns:s(u),rowKey:e=>e?.[r.rowKey],data:s(i),striped:!0,bordered:!1,singleLine:!0,remote:!0,scrollX:s(w),...m}));async function l(e){if(r.request){e&&(t.page=1);let a;a={pageNum:t.page,pageSize:t.pageSize},r.showPagination||(a={});try{n.value=!0;const o=await r.request({...a,...r.params});t.itemCount=o?.total||0,i.value=o?.list||[],n.value=!1}catch{n.value=!1,t.itemCount=0,i.value=[]}}}const S=e=>{s(u).forEach(a=>{if(a.sortOrder!==void 0){if(!e){a.sortOrder=!1;return}a.key===e.columnKey?a.sortOrder=e.order:a.sortOrder=!1}}),l()};return h({handleGetData:l}),(e,a)=>{const o=O;return k(),P(o,$({ref:"tableElRef",pagination:e.showPagination?s(t):!1,style:{height:e.height},"virtual-scroll":"","flex-height":""},s(y),{"onUpdate:sorter":S}),q({_:2},[B(Object.keys(e.$slots),d=>({name:d,fn:K(_=>[E(e.$slots,d,x(D(_||{})))])}))]),1040,["pagination","style"])}}});export{R as _};
