import{d as te,as as c,r as S,b as se,a,ad as R,w as $,P as le,Z as ce,k as g,Y as de,m as V,cT as pe,X as W,H as ue,J as ae,aS as ge,bS as me,o as P,c as G,bA as fe,i as he,B as z,j as K,g as B,O as M,D,h as L,aB as we,F as ye,U as be,V as xe,A as ve,di as ne,b9 as oe,aF as Se}from"./index-CHTXMeh8.js";import{g as I}from"./Form.vue_vue_type_style_index_0_scoped_09f6ff61_lang-B0myO5Ey.js";import{E as Pe}from"./index-DVe591HI.js";import{_ as Ae}from"./Form-DWU3hFR9.js";import{u as ke}from"./useForm-CEk1zgLl.js";import{d as ze}from"./download-e0EdwhTv.js";const Le=ue(te({name:"Table",props:{pageSize:c.number.def(10),currentPage:c.number.def(1),selection:c.bool.def(!1),showOverflowTooltip:c.bool.def(!0),columns:{type:Array,default:()=>[]},expand:c.bool.def(!1),pagination:{type:Object,default:()=>{}},reserveSelection:c.bool.def(!1),loading:c.bool.def(!1),reserveIndex:c.bool.def(!1),align:c.string.validate(e=>["left","center","right"].includes(e)).def("center"),headerAlign:c.string.validate(e=>["left","center","right"].includes(e)).def("center"),data:{type:Array,default:()=>[]}},emits:["update:pageSize","update:currentPage","register"],setup(e,{attrs:o,slots:p,emit:m,expose:O}){const u=S();se(()=>{const t=a(u);m("register",t==null?void 0:t.$parent,u)});const b=S(e.pageSize),f=S(e.currentPage),n=S({}),i=S({}),r=R(()=>{const t={...e};return Object.assign(t,a(i)),t}),x=(t,T)=>{var A;const{columns:_}=a(r);for(const C of T||_)for(const j of t)C.field===j.field?pe(C,j.path,j.value):(A=C.children)!=null&&A.length&&x(t,C.children)},q=S([]),U=t=>{q.value=t};O({setProps:(t={})=>{i.value=Object.assign(a(i),t),n.value=t},setColumn:x,selections:q});const s=R(()=>Object.assign({small:!1,background:!0,pagerCount:document.body.clientWidth<992?5:7,layout:"total, sizes, prev, pager, next, jumper",pageSizes:[10,20,30,50,100],disabled:!1,hideOnSinglePage:!1,total:10},a(r).pagination));$(()=>a(r).pageSize,t=>{b.value=t}),$(()=>a(r).currentPage,t=>{f.value=t}),$(()=>b.value,t=>{m("update:pageSize",t)}),$(()=>f.value,t=>{m("update:currentPage",t)});const v=R(()=>{const t={...o,...e};return delete t.columns,delete t.data,t}),d=()=>{const{selection:t,reserveSelection:T,align:_,headerAlign:A}=a(r);return t?g(W,{type:"selection",reserveSelection:T,align:_,headerAlign:A,width:"50"},null):void 0},w=()=>{const{align:t,headerAlign:T,expand:_}=a(r);return _?g(W,{type:"expand",align:t,headerAlign:T},{default:A=>I(p,"expand",A)}):void 0},E=t=>{const{columns:T,reserveIndex:_,pageSize:A,currentPage:C,align:j,headerAlign:Q,showOverflowTooltip:ie}=a(r);return[w(),d()].concat((t||T).map(l=>{if(l.type==="index")return g(W,{type:"index",index:l.index?l.index:N=>((k,H,X,Y)=>{const J=H+1;return k?X*(Y-1)+J:J})(_,N,A,C),align:l.align||j,headerAlign:l.headerAlign||Q,label:l.label,width:"65px"},null);{const N={...l};return N.children&&delete N.children,g(W,V({showOverflowTooltip:ie,align:j,headerAlign:Q},N,{prop:l.field}),{default:k=>{var H;return l.children&&l.children.length?(X=>{const{align:Y,headerAlign:J,showOverflowTooltip:re}=a(r);return X.map(h=>{const Z={...h};return Z.children&&delete Z.children,g(W,V({showOverflowTooltip:re,align:Y,headerAlign:J},Z,{prop:h.field}),{default:F=>{var ee;return h.children&&h.children.length?E(h.children):I(p,h.field,F)||((ee=h==null?void 0:h.formatter)==null?void 0:ee.call(h,F.row,F.column,F.row[h.field],F.$index))||F.row[h.field]},header:I(p,`${h.field}-header`)})})})(l.children):I(p,l.field,k)||((H=l==null?void 0:l.formatter)==null?void 0:H.call(l,k.row,k.column,k.row[l.field],k.$index))||k.row[l.field]},header:()=>I(p,`${l.field}-header`)||l.label})}}))};return()=>le(g("div",null,[g(de,V({ref:u,data:a(r).data,"onSelection-change":U},a(v)),{default:()=>E(),append:()=>I(p,"append")}),a(r).pagination?g(Pe,V({pageSize:b.value,"onUpdate:pageSize":t=>b.value=t,currentPage:f.value,"onUpdate:currentPage":t=>f.value=t,class:"float-right mb-15px mt-15px"},a(s)),null):void 0]),[[ce,a(r).loading]])}}),[["__scopeId","data-v-1ee0f9ba"]]),Oe={key:0},Te=te({name:"Search",__name:"Search",props:{schema:{type:Array,default:()=>[]},isCol:c.bool.def(!1),labelWidth:c.oneOfType([String,Number]).def("auto"),layout:c.string.validate(e=>["inline","bottom"].includes(e)).def("inline"),buttomPosition:c.string.validate(e=>["left","center","right"].includes(e)).def("center"),showSearch:c.bool.def(!0),showReset:c.bool.def(!0),expand:c.bool.def(!1),expandField:c.string.def(""),inline:c.bool.def(!0),model:{type:Object,default:()=>({})}},emits:["search","reset"],setup(e,{emit:o}){const{t:p}=ae(),m=e,O=o,u=S(!0),b=R(()=>{let s=ge(m.schema);if(m.expand&&m.expandField&&!a(u)){const v=me(s,d=>d.field===m.expandField);if(v>-1){const d=s.length;s.splice(v+1,d)}}return m.layout==="inline"&&(s=s.concat([{field:"action",formItemProps:{labelWidth:"0px"}}])),s}),{register:f,elFormRef:n,methods:i}=ke({model:m.model||{}}),r=async()=>{var s;await((s=a(n))==null?void 0:s.validate(async v=>{if(v){const{getFormData:d}=i,w=await d();O("search",w)}}))},x=async()=>{var d;(d=a(n))==null||d.resetFields();const{getFormData:s}=i,v=await s();O("reset",v)},q=R(()=>({textAlign:m.buttomPosition})),U=()=>{var s;(s=a(n))==null||s.resetFields(),u.value=!a(u)};return(s,v)=>{const d=be,w=xe,E=Ae;return P(),G(ye,null,[g(E,{inline:e.inline,"is-col":e.isCol,"is-custom":!1,"label-width":e.labelWidth,schema:a(b),class:"-mb-15px","hide-required-asterisk":"",onRegister:a(f)},fe({action:z(()=>[e.layout==="inline"?(P(),G("div",Oe,[e.showSearch?(P(),B(w,{key:0,onClick:r},{default:z(()=>[g(d,{class:"mr-5px",icon:"ep:search"}),M(" "+D(a(p)("common.query")),1)]),_:1})):L("",!0),e.showReset?(P(),B(w,{key:1,onClick:x},{default:z(()=>[g(d,{class:"mr-5px",icon:"ep:refresh"}),M(" "+D(a(p)("common.reset")),1)]),_:1})):L("",!0),e.expand?(P(),B(w,{key:2,text:"",onClick:U},{default:z(()=>[M(D(a(p)(a(u)?"common.shrink":"common.expand"))+" ",1),g(d,{icon:a(u)?"ep:arrow-up":"ep:arrow-down"},null,8,["icon"])]),_:1})):L("",!0),K(s.$slots,"actionMore")])):L("",!0)]),_:2},[he(Object.keys(s.$slots),t=>({name:t,fn:z(()=>[K(s.$slots,t)])}))]),1032,["inline","is-col","label-width","schema","onRegister"]),e.layout==="bottom"?(P(),G("div",{key:0,style:we(a(q))},[e.showSearch?(P(),B(w,{key:0,type:"primary",onClick:r},{default:z(()=>[g(d,{class:"mr-5px",icon:"ep:search"}),M(" "+D(a(p)("common.query")),1)]),_:1})):L("",!0),e.showReset?(P(),B(w,{key:1,onClick:x},{default:z(()=>[g(d,{class:"mr-5px",icon:"ep:refresh-right"}),M(" "+D(a(p)("common.reset")),1)]),_:1})):L("",!0),e.expand?(P(),B(w,{key:2,text:"",onClick:U},{default:z(()=>[M(D(a(p)(a(u)?"common.shrink":"common.expand"))+" ",1),g(d,{icon:a(u)?"ep:arrow-up":"ep:arrow-down"},null,8,["icon"])]),_:1})):L("",!0),K(s.$slots,"actionMore")],4)):L("",!0)],64)}}}),{t:y}=ae(),_e=e=>{const o=ve({pageSize:10,currentPage:1,total:10,tableList:[],params:{...(e==null?void 0:e.defaultParams)||{}},loading:!0,exportLoading:!1,currentRow:null}),p=R(()=>({...o.params,pageSize:o.pageSize,pageNo:o.currentPage}));$(()=>o.currentPage,()=>{f.getList()}),$(()=>o.pageSize,()=>{o.currentPage===1||(o.currentPage=1),f.getList()});const m=S(),O=S(),u=async()=>{await Se();const n=a(m);return n||console.error("The table is not registered. Please use the register method to register"),n},b=async n=>{let i=1;n instanceof Array?(i=n.length,await Promise.all(n.map(async r=>{await((e==null?void 0:e.delListApi)&&(e==null?void 0:e.delListApi(r)))}))):await((e==null?void 0:e.delListApi)&&(e==null?void 0:e.delListApi(n))),ne.success(y("common.delSuccess")),o.currentPage=(o.total%o.pageSize===i||o.pageSize===1)&&o.currentPage>1?o.currentPage-1:o.currentPage,await f.getList()},f={getList:async()=>{o.loading=!0;const n=await(e==null?void 0:e.getListApi(a(p)).finally(()=>{o.loading=!1}));n&&(o.tableList=n.list,o.total=n.total??0)},setProps:async(n={})=>{const i=await u();i==null||i.setProps(n)},setColumn:async n=>{const i=await u();i==null||i.setColumn(n)},getSelections:async()=>{const n=await u();return(n==null?void 0:n.selections)||[]},setSearchParams:n=>{o.params=Object.assign(o.params,{pageSize:o.pageSize,pageNo:1,...n}),o.currentPage!==1?o.currentPage=1:f.getList()},delList:async(n,i,r=!0)=>{const x=await u();!i||x!=null&&x.selections.length?r?oe.confirm(y("common.delMessage"),y("common.confirmTitle"),{confirmButtonText:y("common.ok"),cancelButtonText:y("common.cancel"),type:"warning"}).then(async()=>{await b(n)}):await b(n):ne.warning(y("common.delNoData"))},exportList:async n=>{o.exportLoading=!0,oe.confirm(y("common.exportMessage"),y("common.confirmTitle"),{confirmButtonText:y("common.ok"),cancelButtonText:y("common.cancel"),type:"warning"}).then(async()=>{var r;const i=await((r=e==null?void 0:e.exportListApi)==null?void 0:r.call(e,a(p)));i&&ze.excel(i,n)}).finally(()=>{o.exportLoading=!1})}};return e!=null&&e.props&&f.setProps(e.props),{register:(n,i)=>{m.value=n,O.value=i},elTableRef:O,tableObject:o,methods:f,tableMethods:f}};export{Te as _,Le as a,_e as u};
|