| 1 |
- var o=(r,y,l)=>new Promise((s,i)=>{var g=n=>{try{u(l.next(n))}catch(f){i(f)}},w=n=>{try{u(l.throw(n))}catch(f){i(f)}},u=n=>n.done?s(n.value):Promise.resolve(n.value).then(g,w);u((l=l.apply(r,y)).next())});import{c as T}from"./index-XQEkcq4y.js";import{l as b,b as x}from"./element-plus-B-YefleC.js";import{r as d,w as v,u as a,j as M,n as P}from"./vue-chunks-COp0tDkU.js";const{t:p}=T(),B=r=>{const{immediate:y=!0}=r,l=d(!1),s=d(1),i=d(10),g=d(0),w=d([]);let u=!1;v(()=>s.value,()=>{u||m.getList(),u=!1}),v(()=>i.value,()=>{a(s)===1||(s.value=1,u=!0),m.getList()}),M(()=>{y&&m.getList()});const n=d(),f=d(),L=(e,t)=>{n.value=e,f.value=a(t)},h=()=>o(void 0,null,function*(){yield P();const e=a(n);return e||console.error("The table is not registered. Please use the register method to register"),e}),m={getList:()=>o(void 0,null,function*(){l.value=!0;try{const e=yield r==null?void 0:r.fetchDataApi();e&&(w.value=e.list,g.value=e.total||0)}catch(e){}finally{l.value=!1}}),setProps:(...t)=>o(void 0,[...t],function*(e={}){const c=yield h();c==null||c.setProps(e)}),setColumn:e=>o(void 0,null,function*(){const t=yield h();t==null||t.setColumn(e)}),addColumn:(e,t)=>o(void 0,null,function*(){const c=yield h();c==null||c.addColumn(e,t)}),delColumn:e=>o(void 0,null,function*(){const t=yield h();t==null||t.delColumn(e)}),getElTableExpose:()=>o(void 0,null,function*(){return yield h(),a(f)}),refresh:()=>{m.getList()},delList:e=>o(void 0,null,function*(){const{fetchDelApi:t}=r;if(!t){console.warn("fetchDelApi is undefined");return}b.confirm(p("common.delMessage"),p("common.delWarning"),{confirmButtonText:p("common.delOk"),cancelButtonText:p("common.delCancel"),type:"warning"}).then(()=>o(void 0,null,function*(){if(yield t()){x.success(p("common.delSuccess"));const C=a(g)%a(i)===e||a(i)===1?a(s)>1?a(s)-1:a(s):a(s);s.value=C,m.getList()}}))})};return{tableRegister:L,tableMethods:m,tableState:{currentPage:s,pageSize:i,total:g,dataList:w,loading:l}}};export{B as u};
|