1 |
- import{d as ae,ar as c,r as _,b as pe,a,e as $,w as R,k as ue,Y as ge,f as g,X as me,m as J,N as he,W as I,P as ne,cM as fe,b3 as ye,o as P,c as K,aX as we,Q as be,A,aN as V,C as M,D as N,E as W,a2 as z,aG as xe,F as ve,_ as _e,J as Pe,x as Se,bj as oe,bk as re,n as ke,__tla as Ae}from"./index-f65577b8.js";import{g as B,_ as ze,__tla as Le}from"./Form-45e955df.js";import{E as Oe,__tla as Te}from"./index-1896261a.js";import{_ as Ce}from"./_plugin-vue_export-helper-1b428a4d.js";import{u as je,__tla as Fe}from"./useForm-5a0107aa.js";import{d as $e}from"./download-20922b56.js";let le,se,ie,Re=Promise.all([(()=>{try{return Ae}catch{}})(),(()=>{try{return Le}catch{}})(),(()=>{try{return Te}catch{}})(),(()=>{try{return Fe}catch{}})()]).then(async()=>{let Z,y;se=Ce(ae({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:L}){const u=_();pe(()=>{const t=a(u);m("register",t==null?void 0:t.$parent,u)});const b=_(e.pageSize),h=_(e.currentPage),n=_({}),r=_({}),l=$(()=>{const t={...e};return Object.assign(t,a(r)),t}),x=(t,O)=>{var S;const{columns:T}=a(l);for(const C of O||T)for(const j of t)C.field===j.field?he(C,j.path,j.value):(S=C.children)!=null&&S.length&&x(t,C.children)},q=_([]),E=t=>{q.value=t};L({setProps:(t={})=>{r.value=Object.assign(a(r),t),n.value=t},setColumn:x,selections:q});const s=$(()=>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(l).pagination));R(()=>a(l).pageSize,t=>{b.value=t}),R(()=>a(l).currentPage,t=>{h.value=t}),R(()=>b.value,t=>{m("update:pageSize",t)}),R(()=>h.value,t=>{m("update:currentPage",t)});const v=$(()=>{const t={...o,...e};return delete t.columns,delete t.data,t}),d=()=>{const{selection:t,reserveSelection:O,align:T,headerAlign:S}=a(l);return t?g(I,{type:"selection",reserveSelection:O,align:T,headerAlign:S,width:"50"},null):void 0},w=()=>{const{align:t,headerAlign:O,expand:T}=a(l);return T?g(I,{type:"expand",align:t,headerAlign:O},{default:S=>B(p,"expand",S)}):void 0},U=t=>{const{columns:O,reserveIndex:T,pageSize:S,currentPage:C,align:j,headerAlign:ee,showOverflowTooltip:ce}=a(l);return[w(),d()].concat((t||O).map(i=>{if(i.type==="index")return g(I,{type:"index",index:i.index?i.index:D=>((k,X,Q,Y)=>{const G=X+1;return k?Q*(Y-1)+G:G})(T,D,S,C),align:i.align||j,headerAlign:i.headerAlign||ee,label:i.label,width:"65px"},null);{const D={...i};return D.children&&delete D.children,g(I,J({showOverflowTooltip:ce,align:j,headerAlign:ee},D,{prop:i.field}),{default:k=>{var X;return i.children&&i.children.length?(Q=>{const{align:Y,headerAlign:G,showOverflowTooltip:de}=a(l);return Q.map(f=>{const H={...f};return H.children&&delete H.children,g(I,J({showOverflowTooltip:de,align:Y,headerAlign:G},H,{prop:f.field}),{default:F=>{var te;return f.children&&f.children.length?U(f.children):B(p,f.field,F)||((te=f==null?void 0:f.formatter)==null?void 0:te.call(f,F.row,F.column,F.row[f.field],F.$index))||F.row[f.field]},header:B(p,`${f.field}-header`)})})})(i.children):B(p,i.field,k)||((X=i==null?void 0:i.formatter)==null?void 0:X.call(i,k.row,k.column,k.row[i.field],k.$index))||k.row[i.field]},header:()=>B(p,`${i.field}-header`)||i.label})}}))};return()=>ue(g("div",null,[g(me,J({ref:u,data:a(l).data,"onSelection-change":E},a(v)),{default:()=>U(),append:()=>B(p,"append")}),a(l).pagination?g(Oe,J({pageSize:b.value,"onUpdate:pageSize":t=>b.value=t,currentPage:h.value,"onUpdate:currentPage":t=>h.value=t,class:"float-right mb-15px mt-15px"},a(s)),null):void 0]),[[ge,a(l).loading]])}}),[["__scopeId","data-v-ade6697d"]]),Z={key:0},le=ae({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}=ne(),m=e,L=o,u=_(!0),b=$(()=>{let s=fe(m.schema);if(m.expand&&m.expandField&&!a(u)){const v=ye(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:h,elFormRef:n,methods:r}=je({model:m.model||{}}),l=async()=>{var s;await((s=a(n))==null?void 0:s.validate(async v=>{if(v){const{getFormData:d}=r,w=await d();L("search",w)}}))},x=async()=>{var d;(d=a(n))==null||d.resetFields();const{getFormData:s}=r,v=await s();L("reset",v)},q=$(()=>({textAlign:m.buttomPosition})),E=()=>{var s;(s=a(n))==null||s.resetFields(),u.value=!a(u)};return(s,v)=>{const d=_e,w=Pe,U=ze;return P(),K(ve,null,[g(U,{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(h)},we({action:A(()=>[e.layout==="inline"?(P(),K("div",Z,[e.showSearch?(P(),M(w,{key:0,onClick:l},{default:A(()=>[g(d,{class:"mr-5px",icon:"ep:search"}),N(" "+W(a(p)("common.query")),1)]),_:1})):z("",!0),e.showReset?(P(),M(w,{key:1,onClick:x},{default:A(()=>[g(d,{class:"mr-5px",icon:"ep:refresh"}),N(" "+W(a(p)("common.reset")),1)]),_:1})):z("",!0),e.expand?(P(),M(w,{key:2,text:"",onClick:E},{default:A(()=>[N(W(a(p)(a(u)?"common.shrink":"common.expand"))+" ",1),g(d,{icon:a(u)?"ep:arrow-up":"ep:arrow-down"},null,8,["icon"])]),_:1})):z("",!0),V(s.$slots,"actionMore")])):z("",!0)]),_:2},[be(Object.keys(s.$slots),t=>({name:t,fn:A(()=>[V(s.$slots,t)])}))]),1032,["inline","is-col","label-width","schema","onRegister"]),e.layout==="bottom"?(P(),K("div",{key:0,style:xe(a(q))},[e.showSearch?(P(),M(w,{key:0,type:"primary",onClick:l},{default:A(()=>[g(d,{class:"mr-5px",icon:"ep:search"}),N(" "+W(a(p)("common.query")),1)]),_:1})):z("",!0),e.showReset?(P(),M(w,{key:1,onClick:x},{default:A(()=>[g(d,{class:"mr-5px",icon:"ep:refresh-right"}),N(" "+W(a(p)("common.reset")),1)]),_:1})):z("",!0),e.expand?(P(),M(w,{key:2,text:"",onClick:E},{default:A(()=>[N(W(a(p)(a(u)?"common.shrink":"common.expand"))+" ",1),g(d,{icon:a(u)?"ep:arrow-up":"ep:arrow-down"},null,8,["icon"])]),_:1})):z("",!0),V(s.$slots,"actionMore")],4)):z("",!0)],64)}}}),{t:y}=ne(),ie=e=>{const o=Se({pageSize:10,currentPage:1,total:10,tableList:[],params:{...(e==null?void 0:e.defaultParams)||{}},loading:!0,exportLoading:!1,currentRow:null}),p=$(()=>({...o.params,pageSize:o.pageSize,pageNo:o.currentPage}));R(()=>o.currentPage,()=>{h.getList()}),R(()=>o.pageSize,()=>{o.currentPage===1||(o.currentPage=1),h.getList()});const m=_(),L=_(),u=async()=>{await ke();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 r=1;n instanceof Array?(r=n.length,await Promise.all(n.map(async l=>{await((e==null?void 0:e.delListApi)&&(e==null?void 0:e.delListApi(l)))}))):await((e==null?void 0:e.delListApi)&&(e==null?void 0:e.delListApi(n))),oe.success(y("common.delSuccess")),o.currentPage=(o.total%o.pageSize===r||o.pageSize===1)&&o.currentPage>1?o.currentPage-1:o.currentPage,await h.getList()},h={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 r=await u();r==null||r.setProps(n)},setColumn:async n=>{const r=await u();r==null||r.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:h.getList()},delList:async(n,r,l=!0)=>{const x=await u();!r||x!=null&&x.selections.length?l?re.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):oe.warning(y("common.delNoData"))},exportList:async n=>{o.exportLoading=!0,re.confirm(y("common.exportMessage"),y("common.confirmTitle"),{confirmButtonText:y("common.ok"),cancelButtonText:y("common.cancel"),type:"warning"}).then(async()=>{var l;const r=await((l=e==null?void 0:e.exportListApi)==null?void 0:l.call(e,a(p)));r&&$e.excel(r,n)}).finally(()=>{o.exportLoading=!1})}};return e!=null&&e.props&&h.setProps(e.props),{register:(n,r)=>{m.value=n,L.value=r},elTableRef:L,tableObject:o,methods:h,tableMethods:h}}});export{le as _,Re as __tla,se as a,ie as u};
|