useTable-7cfa4dc9.js 9.1 KB

1
  1. import{d as ne,ac as c,r as _,q as ge,a,Y as F,aM as $,z as me,K as fe,f as g,J as he,af as E,s as ye,I as N,_ as oe,h as re,aG as we,bu as be,o as S,c as Q,br as xe,v as ve,w as A,aC as V,x as M,y as q,t as D,a0 as z,ao as _e,F as Se,j as Pe,G as ke,e as Ae,aq as le,by as se,aj as ze,__tla as Le}from"./index-8dc1e40a.js";import{g as I,_ as Te,__tla as Oe}from"./Form-03af17d7.js";import{E as Ce,__tla as je}from"./index-803dbf9a.js";import{u as Re,__tla as Fe}from"./useForm-8c76e04a.js";import{d as $e}from"./download-20922b56.js";let ie,ce,de,Me=Promise.all([(()=>{try{return Le}catch{}})(),(()=>{try{return Oe}catch{}})(),(()=>{try{return je}catch{}})(),(()=>{try{return Fe}catch{}})()]).then(async()=>{let Z,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 t=a(u);m("register",t==null?void 0:t.$parent,u)});const b=_(e.pageSize),f=_(e.currentPage),n=_({}),r=_({}),l=F(()=>{const t={...e};return Object.assign(t,a(r)),t}),x=(t,T)=>{var P;const{columns:O}=a(l);for(const C of T||O)for(const j of t)C.field===j.field?ye(C,j.path,j.value):(P=C.children)!=null&&P.length&&x(t,C.children)},U=_([]),W=t=>{U.value=t};L({setProps:(t={})=>{r.value=Object.assign(a(r),t),n.value=t},setColumn:x,selections:U});const s=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},a(l).pagination));$(()=>a(l).pageSize,t=>{b.value=t}),$(()=>a(l).currentPage,t=>{f.value=t}),$(()=>b.value,t=>{m("update:pageSize",t)}),$(()=>f.value,t=>{m("update:currentPage",t)});const v=F(()=>{const t={...o,...e};return delete t.columns,delete t.data,t}),d=()=>{const{selection:t,reserveSelection:T,align:O,headerAlign:P}=a(l);return t?g(N,{type:"selection",reserveSelection:T,align:O,headerAlign:P,width:"50"},null):void 0},w=()=>{const{align:t,headerAlign:T,expand:O}=a(l);return O?g(N,{type:"expand",align:t,headerAlign:T},{default:P=>I(p,"expand",P)}):void 0},G=t=>{const{columns:T,reserveIndex:O,pageSize:P,currentPage:C,align:j,headerAlign:te,showOverflowTooltip:pe}=a(l);return[w(),d()].concat((t||T).map(i=>{if(i.type==="index")return g(N,{type:"index",index:i.index?i.index:B=>((k,H,J,K)=>{const X=H+1;return k?J*(K-1)+X:X})(O,B,P,C),align:i.align||j,headerAlign:i.headerAlign||te,label:i.label,width:"65px"},null);{const B={...i};return B.children&&delete B.children,g(N,E({showOverflowTooltip:pe,align:j,headerAlign:te},B,{prop:i.field}),{default:k=>{var H;return i.children&&i.children.length?(J=>{const{align:K,headerAlign:X,showOverflowTooltip:ue}=a(l);return J.map(h=>{const Y={...h};return Y.children&&delete Y.children,g(N,E({showOverflowTooltip:ue,align:K,headerAlign:X},Y,{prop:h.field}),{default:R=>{var ae;return h.children&&h.children.length?G(h.children):I(p,h.field,R)||((ae=h==null?void 0:h.formatter)==null?void 0:ae.call(h,R.row,R.column,R.row[h.field],R.$index))||R.row[h.field]},header:I(p,`${h.field}-header`)})})})(i.children):I(p,i.field,k)||((H=i==null?void 0:i.formatter)==null?void 0:H.call(i,k.row,k.column,k.row[i.field],k.$index))||k.row[i.field]},header:()=>I(p,`${i.field}-header`)||i.label})}}))};return()=>me(g("div",null,[g(he,E({ref:u,data:a(l).data,"onSelection-change":W},a(v)),{default:()=>G(),append:()=>I(p,"append")}),a(l).pagination?g(Ce,E({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]),[[fe,a(l).loading]])}}),[["__scopeId","data-v-b4105caf"],["__file","/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-admin/src/components/Table/src/Table.vue"]]),Z={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),b=F(()=>{let s=we(m.schema);if(m.expand&&m.expandField&&!a(u)){const v=be(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:r}=Re({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)},U=F(()=>({textAlign:m.buttomPosition})),W=()=>{var s;(s=a(n))==null||s.resetFields(),u.value=!a(u)};return(s,v)=>{const d=Pe,w=ke,G=Te;return S(),Q(Se,null,[g(G,{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)},xe({action:A(()=>[e.layout==="inline"?(S(),Q("div",Z,[e.showSearch?(S(),M(w,{key:0,onClick:l},{default:A(()=>[g(d,{class:"mr-5px",icon:"ep:search"}),q(" "+D(a(p)("common.query")),1)]),_:1})):z("",!0),e.showReset?(S(),M(w,{key:1,onClick:x},{default:A(()=>[g(d,{class:"mr-5px",icon:"ep:refresh"}),q(" "+D(a(p)("common.reset")),1)]),_:1})):z("",!0),e.expand?(S(),M(w,{key:2,text:"",onClick:W},{default:A(()=>[q(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})):z("",!0),V(s.$slots,"actionMore")])):z("",!0)]),_:2},[ve(Object.keys(s.$slots),t=>({name:t,fn:A(()=>[V(s.$slots,t)])}))]),1032,["inline","is-col","label-width","schema","onRegister"]),e.layout==="bottom"?(S(),Q("div",{key:0,style:_e(a(U))},[e.showSearch?(S(),M(w,{key:0,type:"primary",onClick:l},{default:A(()=>[g(d,{class:"mr-5px",icon:"ep:search"}),q(" "+D(a(p)("common.query")),1)]),_:1})):z("",!0),e.showReset?(S(),M(w,{key:1,onClick:x},{default:A(()=>[g(d,{class:"mr-5px",icon:"ep:refresh-right"}),q(" "+D(a(p)("common.reset")),1)]),_:1})):z("",!0),e.expand?(S(),M(w,{key:2,text:"",onClick:W},{default:A(()=>[q(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})):z("",!0),V(s.$slots,"actionMore")],4)):z("",!0)],64)}}}),ie=oe(ee,[["__file","/Users/RuHu.Xu/Desktop/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}));$(()=>o.currentPage,()=>{f.getList()}),$(()=>o.pageSize,()=>{o.currentPage===1||(o.currentPage=1),f.getList()});const m=_(),L=_(),u=async()=>{await ze();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))),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(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:f.getList()},delList:async(n,r,l=!0)=>{const x=await u();!r||x!=null&&x.selections.length?l?se.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):le.warning(y("common.delNoData"))},exportList:async n=>{o.exportLoading=!0,se.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&&f.setProps(e.props),{register:(n,r)=>{m.value=n,L.value=r},elTableRef:L,tableObject:o,methods:f,tableMethods:f}}});export{ie as _,Me as __tla,ce as a,de as u};