useTable-56d8260a.js 9.1 KB

1
  1. import{d as ne,ag as c,r as _,l as ge,a as t,K as F,L as R,x as me,I as fe,f as g,H as he,aj as K,s as ye,G as N,_ as oe,h as re,a$ as we,ba as xe,o as P,c as V,aZ as be,q as ve,w as A,aE as X,v as D,n as I,t as M,P as k,au as _e,F as Pe,j as Se,C as ze,e as Ae,aw as le,bg as ie,an as ke,__tla as Le}from"./index-e3afde76.js";import{g as q,_ as Te,__tla as Oe}from"./Form-81a434c2.js";import{E as Ce,__tla as je}from"./index-2d20a7ff.js";import{u as $e,__tla as Fe}from"./useForm-3e38077d.js";import{d as Re}from"./download-20922b56.js";let se,ce,de,De=Promise.all([(()=>{try{return Le}catch{}})(),(()=>{try{return Oe}catch{}})(),(()=>{try{return je}catch{}})(),(()=>{try{return Fe}catch{}})()]).then(async()=>{let Y,ee,y;ce=oe(ne({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=_();ge(()=>{const a=t(u);m("register",a==null?void 0:a.$parent,u)});const x=_(e.pageSize),f=_(e.currentPage),n=_({}),r=_({}),l=F(()=>{const a={...e};return Object.assign(a,t(r)),a}),b=(a,T)=>{var S;const{columns:O}=t(l);for(const C of T||O)for(const j of a)C.field===j.field?ye(C,j.path,j.value):(S=C.children)!=null&&S.length&&b(a,C.children)},W=_([]),E=a=>{W.value=a};L({setProps:(a={})=>{r.value=Object.assign(t(r),a),n.value=a},setColumn:b,selections:W});const i=F(()=>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},t(l).pagination));R(()=>t(l).pageSize,a=>{x.value=a}),R(()=>t(l).currentPage,a=>{f.value=a}),R(()=>x.value,a=>{m("update:pageSize",a)}),R(()=>f.value,a=>{m("update:currentPage",a)});const v=F(()=>{const a={...o,...e};return delete a.columns,delete a.data,a}),d=()=>{const{selection:a,reserveSelection:T,align:O,headerAlign:S}=t(l);return a?g(N,{type:"selection",reserveSelection:T,align:O,headerAlign:S,width:"50"},null):void 0},w=()=>{const{align:a,headerAlign:T,expand:O}=t(l);return O?g(N,{type:"expand",align:a,headerAlign:T},{default:S=>q(p,"expand",S)}):void 0},U=a=>{const{columns:T,reserveIndex:O,pageSize:S,currentPage:C,align:j,headerAlign:ae,showOverflowTooltip:pe}=t(l);return[w(),d()].concat((a||T).map(s=>{if(s.type==="index")return g(N,{type:"index",index:s.index?s.index:B=>((z,G,Z,J)=>{const H=G+1;return z?Z*(J-1)+H:H})(O,B,S,C),align:s.align||j,headerAlign:s.headerAlign||ae,label:s.label,width:"65px"},null);{const B={...s};return B.children&&delete B.children,g(N,K({showOverflowTooltip:pe,align:j,headerAlign:ae},B,{prop:s.field}),{default:z=>{var G;return s.children&&s.children.length?(Z=>{const{align:J,headerAlign:H,showOverflowTooltip:ue}=t(l);return Z.map(h=>{const Q={...h};return Q.children&&delete Q.children,g(N,K({showOverflowTooltip:ue,align:J,headerAlign:H},Q,{prop:h.field}),{default:$=>{var te;return h.children&&h.children.length?U(h.children):q(p,h.field,$)||((te=h==null?void 0:h.formatter)==null?void 0:te.call(h,$.row,$.column,$.row[h.field],$.$index))||$.row[h.field]},header:q(p,`${h.field}-header`)})})})(s.children):q(p,s.field,z)||((G=s==null?void 0:s.formatter)==null?void 0:G.call(s,z.row,z.column,z.row[s.field],z.$index))||z.row[s.field]},header:()=>q(p,`${s.field}-header`)||s.label})}}))};return()=>me(g("div",null,[g(he,K({ref:u,data:t(l).data,"onSelection-change":E},t(v)),{default:()=>U(),append:()=>q(p,"append")}),t(l).pagination?g(Ce,K({pageSize:x.value,"onUpdate:pageSize":a=>x.value=a,currentPage:f.value,"onUpdate:currentPage":a=>f.value=a,class:"float-right mb-15px mt-15px"},t(i)),null):void 0]),[[fe,t(l).loading]])}}),[["__scopeId","data-v-b4105caf"],["__file","D:/zx/mall-newfeifan-zx-admin/src/components/Table/src/Table.vue"]]),Y={key:0},ee=ne({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}=re(),m=e,L=o,u=_(!0),x=F(()=>{let i=we(m.schema);if(m.expand&&m.expandField&&!t(u)){const v=xe(i,d=>d.field===m.expandField);if(v>-1){const d=i.length;i.splice(v+1,d)}}return m.layout==="inline"&&(i=i.concat([{field:"action",formItemProps:{labelWidth:"0px"}}])),i}),{register:f,elFormRef:n,methods:r}=$e({model:m.model||{}}),l=async()=>{var i;await((i=t(n))==null?void 0:i.validate(async v=>{if(v){const{getFormData:d}=r,w=await d();L("search",w)}}))},b=async()=>{var d;(d=t(n))==null||d.resetFields();const{getFormData:i}=r,v=await i();L("reset",v)},W=F(()=>({textAlign:m.buttomPosition})),E=()=>{var i;(i=t(n))==null||i.resetFields(),u.value=!t(u)};return(i,v)=>{const d=Se,w=ze,U=Te;return P(),V(Pe,null,[g(U,{inline:e.inline,"is-col":e.isCol,"is-custom":!1,"label-width":e.labelWidth,schema:t(x),class:"-mb-15px","hide-required-asterisk":"",onRegister:t(f)},be({action:A(()=>[e.layout==="inline"?(P(),V("div",Y,[e.showSearch?(P(),D(w,{key:0,onClick:l},{default:A(()=>[g(d,{class:"mr-5px",icon:"ep:search"}),I(" "+M(t(p)("common.query")),1)]),_:1})):k("",!0),e.showReset?(P(),D(w,{key:1,onClick:b},{default:A(()=>[g(d,{class:"mr-5px",icon:"ep:refresh"}),I(" "+M(t(p)("common.reset")),1)]),_:1})):k("",!0),e.expand?(P(),D(w,{key:2,text:"",onClick:E},{default:A(()=>[I(M(t(p)(t(u)?"common.shrink":"common.expand"))+" ",1),g(d,{icon:t(u)?"ep:arrow-up":"ep:arrow-down"},null,8,["icon"])]),_:1})):k("",!0),X(i.$slots,"actionMore")])):k("",!0)]),_:2},[ve(Object.keys(i.$slots),a=>({name:a,fn:A(()=>[X(i.$slots,a)])}))]),1032,["inline","is-col","label-width","schema","onRegister"]),e.layout==="bottom"?(P(),V("div",{key:0,style:_e(t(W))},[e.showSearch?(P(),D(w,{key:0,type:"primary",onClick:l},{default:A(()=>[g(d,{class:"mr-5px",icon:"ep:search"}),I(" "+M(t(p)("common.query")),1)]),_:1})):k("",!0),e.showReset?(P(),D(w,{key:1,onClick:b},{default:A(()=>[g(d,{class:"mr-5px",icon:"ep:refresh-right"}),I(" "+M(t(p)("common.reset")),1)]),_:1})):k("",!0),e.expand?(P(),D(w,{key:2,text:"",onClick:E},{default:A(()=>[I(M(t(p)(t(u)?"common.shrink":"common.expand"))+" ",1),g(d,{icon:t(u)?"ep:arrow-up":"ep:arrow-down"},null,8,["icon"])]),_:1})):k("",!0),X(i.$slots,"actionMore")],4)):k("",!0)],64)}}}),se=oe(ee,[["__file","D:/zx/mall-newfeifan-zx-admin/src/components/Search/src/Search.vue"]]),{t:y}=re(),de=e=>{const o=Ae({pageSize:10,currentPage:1,total:10,tableList:[],params:{...(e==null?void 0:e.defaultParams)||{}},loading:!0,exportLoading:!1,currentRow:null}),p=F(()=>({...o.params,pageSize:o.pageSize,pageNo:o.currentPage}));R(()=>o.currentPage,()=>{f.getList()}),R(()=>o.pageSize,()=>{o.currentPage===1||(o.currentPage=1),f.getList()});const m=_(),L=_(),u=async()=>{await ke();const n=t(m);return n||console.error("The table is not registered. Please use the register method to register"),n},x=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))),le.success(y("common.delSuccess")),o.currentPage=(o.total%o.pageSize===r||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(t(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:f.getList()},delList:async(n,r,l=!0)=>{const b=await u();!r||b!=null&&b.selections.length?l?ie.confirm(y("common.delMessage"),y("common.confirmTitle"),{confirmButtonText:y("common.ok"),cancelButtonText:y("common.cancel"),type:"warning"}).then(async()=>{await x(n)}):await x(n):le.warning(y("common.delNoData"))},exportList:async n=>{o.exportLoading=!0,ie.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,t(p)));r&&Re.excel(r,n)}).finally(()=>{o.exportLoading=!1})}};return e!=null&&e.props&&f.setProps(e.props),{register:(n,r)=>{m.value=n,L.value=r},elTableRef:L,tableObject:o,methods:f,tableMethods:f}}});export{se as _,De as __tla,ce as a,de as u};