import{$ as e,A as t,B as n,C as r,E as i,M as a,St as o,T as s,X as c,dt as l,ft as u,kt as d,mn as f,t as p,ut as m,w as h}from"./_plugin-vue_export-helper-C0lsYS1a.js";import{i as g,r as _,t as v}from"./GxPagination-DaT0MOF0.js";import{t as y}from"./message-Bn2oVZM9.js";import{t as b}from"./radio-qR85WVAA.js";import{t as x}from"./directive-2hBfY9mU.js";import{n as S}from"./request-B9wfR4zJ.js";var C={class:`sc-table`},w={class:`pagination-wrap`},T={class:`table-main`},E=p(a({__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(a,{expose:f,emit:p}){let E=a,D=p,O=o({page:1,pageSize:10});m(()=>{Object.keys(E?.modelValue).length&&(O.value=E?.modelValue)});let k=o(0),A=o([]),j=o(`暂无数据`),M=o(!1),N=async()=>{j.value=`正在等待后台返回数据，请稍后`,D(`changeTotal`,null),A.value=[],M.value=!0;try{let t={...O.value,...E.query};E.queryTransform&&Object.keys(E.queryTransform).forEach(e=>{let n=e,r=E.queryTransform[e];t[r]=t[n],delete t[n]});var e=await S({url:E.loadUrl,data:t,method:E.method});A.value=e?.data||[],k.value=e?.total||0,D(`changeTotal`,k.value||A.value.length)}catch(e){A.value=[],k.value=0,y({type:`error`,message:e?.message||`数据加载错误！`})}j.value=`暂无数据`,M.value=!1},P=()=>{N()},F=e=>{let t=e.row;return E.radioModeKey&&t[E.radioModeKey]===E.modelValue?`current-row el-table__row--current`:``};function I(e){D(`currentRowChange`,e)}return f({load_Data:N,loadTableData:P}),E.autoLoad&&N(),(o,f)=>{let p=b,m=g,y=x;return c(),i(`div`,C,[r(`div`,w,[u((c(),i(`div`,T,[t(d(_),n({data:A.value},a.tableProps,{"empty-text":j.value,"row-class-name":F}),{default:l(()=>[E.radioModeKey?(c(),h(m,{key:0,label:``,width:`50`},{default:l(({row:e})=>[t(p,{class:`radio-mode`,"model-value":E.modelValue,label:e[E.radioModeKey],onChange:()=>I(e)},null,8,[`model-value`,`label`,`onChange`])]),_:1})):s(``,!0),e(o.$slots,`default`,{},void 0,!0)]),_:3},16,[`data`,`empty-text`])])),[[y,M.value]]),f[2]||=r(`br`,null,null,-1),a.hasPagination?(c(),h(v,{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":f[0]||=e=>O.value.page=e,"current-pageModifiers":{sync:!0},"page-size":O.value.pageSize,"onUpdate:pageSize":f[1]||=e=>O.value.pageSize=e,"page-sizeModifiers":{sync:!0},total:k.value,onSizeChange:N,onCurrentChange:N},null,8,[`current-page`,`page-size`,`total`])):s(``,!0)])])}}}),[[`__scopeId`,`data-v-3ca63fcb`]]);export{E as t};