import{z as e,J as a,bs as s,K as l}from"./index.js?v=1723125373998";import{g as t}from"./data.js?v=1723125373998";import{l as o,ah as i,ai as n,k as u,ad as p,j as r,r as d,ak as g,f,P as c,w as m,S as v,U as y,V as w,D as h,L as S,W as x,t as P,n as z}from"./vue.js?v=1723125373998";import{_ as k}from"./Skeleton.js?v=1723125373998";import{N as j}from"./DataTable.js?v=1723125373998";const b=o({__name:"index",props:i({data:{default:()=>[]},rowKey:{default:"id"},loading:{type:Boolean,default:!1},loadingNum:{default:10},isPage:{type:Boolean,default:!1},columns:{default:()=>[]},rowProps:{},storeKey:{}},{page:{default:()=>({page:1,pageSize:10})},pageModifiers:{}}),emits:["update:page"],setup(o){const i=o,b=n(o,"page"),K=u((()=>{const{storeKey:e}=i;return e?"".concat(e,"-page"):""})),{t:_}=p(),{columns:N,data:T}=r(i),$=()=>s(P(N.value)),B=d($()),C=$(),{rowKey:D}=i,E=e(D)?e=>e[D]:D,J=d([]),L=g(),U=f({style:{width:"100%"},showSizePicker:!0,showQuickJumper:!0,pageSizes:[10,20,50,100],prefix:()=>{var e;return null==(e=L.pagePrefix)?void 0:e.call(L)},suffix:e=>c("span",{class:"text-13px text-default"},[_("Public.Table.Total",{total:e.itemCount})]),onChange:e=>{b.value.page=e},onUpdatePageSize:e=>{b.value.page=1,b.value.pageSize=e,K.value&&a(K.value,String(e))}});(()=>{if(K.value){const e=l(K.value);e&&(b.value.pageSize=t(e))}})();const M=u((()=>({...U,page:b.value.page,pageSize:b.value.pageSize})));return m((()=>T.value),(e=>{i.loading||(J.value=e)}),{deep:!0}),m((()=>i.loading),(e=>{if(e){if(B.value.forEach((e=>{"selection"!==e.type&&(e.ellipsis&&delete e.ellipsis,e.render=()=>c(k,null,null))})),0===T.value.length)for(let a=0;a<i.loadingNum;a++){const e={};e.id=a,J.value.push(e)}}else J.value=[],z((()=>{B.value.forEach(((e,a)=>{if("selection"===e.type)return;const s=C[a];s.ellipsis&&(e.ellipsis=s.ellipsis),e.render=s.render})),J.value=T.value}))}),{immediate:!0}),m((()=>i.columns),(()=>{B.value=$(),C.splice(0,C.length),C.push(...$())}),{deep:!0}),(e,a)=>{const s=j;return v(),y(s,S(e.$attrs,{"row-key":x(E),data:x(J),columns:x(B),pagination:!!e.isPage&&x(M),"row-props":e.rowProps}),{empty:w((()=>[h(e.$slots,"empty")])),default:w((()=>[h(e.$slots,"pagePrefix")])),_:3},16,["row-key","data","columns","pagination","row-props"])}}});function K(e){const a=d([]),s=f({data:[],total:0,loading:!1}),l=d(e);return{keys:a,table:s,columns:l,setLoading:(e,a=!0)=>{a&&(s.loading=e)}}}export{b as _,K as u};
