import{r as d,n as m,D as u}from"./vue.1RczIYhx.js";import{h as p}from"./elementPlus.CSBdF9Zt.js";function h(l){const r=d({data:[],total:0,page:1,limit:15,loading:!1});async function t(e,s){typeof e=="object"&&e.currentPage&&e.pageSize?(r.value.page=e.currentPage,r.value.limit=e.pageSize):(r.value.page=e,r.value.limit=s),await l()}return{tableOptions:r,handlePageChange:t}}async function E(l,r,t){const e=(a,i)=>u(a)?a.value[i]:a[i],s=(a,i,f)=>{u(a)?a.value[i]=f:a[i]=f},n=()=>e(t,"pagerConfig")?e(t,"pagerConfig"):{total:e(t,"total")||0,page:e(t,"page")||1,limit:e(t,"limit")||15},o=a=>{if(e(t,"pagerConfig")){const i=n();s(t,"pagerConfig",{...i,total:a})}else s(t,"total",a)},g=a=>{e(t,"loading")!==void 0&&s(t,"loading",a)},c=n();r={...r,page:c.page,limit:c.limit};try{g(!0);const a=await l(r);let i=Array.isArray(a.data)?a.data:[a.data];return s(t,"data",i),o(a.total),{success:!0,data:i,code:a.code,msg:a.msg}}catch(a){return p.error("Table Error"),{success:!1,error:a}}finally{g(!1),await m(),window.dispatchEvent(new Event("resize"))}}export{E as a,h as u};
