import{a as P,_ as q}from"./index-sxX6oYqj.js";/* empty css                   *//* empty css                        */import{r as D}from"./request-yGlVfSRy.js";import{x as E,o as K,r as k,A as B,y as S}from"./element-plus-xvP3-5Ws.js";import{d as N,b as s,H as j,M as y,O as _,X as R,V as h,Y as b,a1 as w,W as C,T as U,u as L,N as c,P as O}from"./vue-ChXMuCsz.js";const A={class:"sc-table"},F={class:"pagination-wrap"},H={class:"table-main"},I=N({__name:"Data_Table",props:{modelValue:{default:{}},query:{default:{}},loadUrl:{},autoLoad:{type:Boolean,default:!0},method:{default:"post"},tableProps:{default:{}},hasPagination:{type:Boolean,default:!0},radioModeKey:{},queryTransform:{}},emits:["changeTotal","currentRowChange"],setup(m,{expose:T,emit:z}){const e=m,p=z,o=s({page:1,pageSize:10});j(()=>{Object.keys(e?.modelValue).length&&(o.value=e?.modelValue)});const u=s(0),r=s([]),g=s("暂无数据"),f=s(!1),n=async()=>{g.value="正在等待后台返回数据，请稍后",p("changeTotal",null),r.value=[],f.value=!0;try{const a={...o.value,...e.query};e.queryTransform&&Object.keys(e.queryTransform).forEach(d=>{const i=d,v=e.queryTransform[d];a[v]=a[i],delete a[i]});var t=await D({url:e.loadUrl,data:a,method:e.method});r.value=t?.data||[],u.value=t?.total||0,p("changeTotal",u.value||r.value.length)}catch(a){r.value=[],u.value=0,K({type:"error",message:a?.message||"数据加载错误！"})}g.value="暂无数据",f.value=!1},x=()=>{n()},M=t=>{const a=t.row;return e.radioModeKey&&a[e.radioModeKey]===e.modelValue?"current-row el-table__row--current":""};function V(t){p("currentRowChange",t)}return T({load_Data:n,loadTableData:x}),e.autoLoad&&n(),(t,a)=>{const d=B,i=k,v=E;return c(),y("div",A,[_("div",F,[R((c(),y("div",H,[w(L(S),U({data:r.value},m.tableProps,{"empty-text":g.value,"row-class-name":M}),{default:C(()=>[e.radioModeKey?(c(),h(i,{key:0,label:"",width:"50"},{default:C(({row:l})=>[w(d,{class:"radio-mode","model-value":e.modelValue,label:l[e.radioModeKey],onChange:()=>V(l)},null,8,["model-value","label","onChange"])]),_:1})):b("",!0),O(t.$slots,"default",{},void 0,!0)]),_:3},16,["data","empty-text"])])),[[v,f.value]]),a[2]||(a[2]=_("br",null,null,-1)),m.hasPagination?(c(),h(P,{key:0,style:{"justify-content":"end"},"page-sizes":[10,20,30,40],layout:"total,prev, pager, next, sizes,jumper","current-page":o.value.page,"onUpdate:currentPage":a[0]||(a[0]=l=>o.value.page=l),"current-pageModifiers":{sync:!0},"page-size":o.value.pageSize,"onUpdate:pageSize":a[1]||(a[1]=l=>o.value.pageSize=l),"page-sizeModifiers":{sync:!0},total:u.value,onSizeChange:n,onCurrentChange:n},null,8,["current-page","page-size","total"])):b("",!0)])])}}}),Q=q(I,[["__scopeId","data-v-3ca63fcb"]]);export{Q as D};
