useTable-8fd32e7f.js 9.1 KB

1
  1. import{d as ne,p as c,r as _,B as me,a,b as F,aS as $,C as ge,N as fe,i as m,M as he,ai as E,x as ye,L as U,_ as oe,n as re,as as we,cb as xe,o as S,c as V,cw as be,k as ve,w as A,aJ as Y,l as M,j as B,t as D,a2 as z,av as _e,F as Se,v as Pe,J as ke,f as Ae,ax as le,cc as se,am as ze,__tla as Le}from"./index-af173888.js";import{g as N,_ as Te,__tla as Oe}from"./Form-1c876ba3.js";import{E as Ce,__tla as je}from"./index-54b8f773.js";import{u as Re,__tla as Fe}from"./useForm-b52f5b9f.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:g,expose:L}){const u=_();me(()=>{const t=a(u);g("register",t==null?void 0:t.$parent,u)});const x=_(e.pageSize),f=_(e.currentPage),n=_({}),r=_({}),l=F(()=>{const t={...e};return Object.assign(t,a(r)),t}),b=(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&&b(t,C.children)},W=_([]),q=t=>{W.value=t};L({setProps:(t={})=>{r.value=Object.assign(a(r),t),n.value=t},setColumn:b,selections:W});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=>{x.value=t}),$(()=>a(l).currentPage,t=>{f.value=t}),$(()=>x.value,t=>{g("update:pageSize",t)}),$(()=>f.value,t=>{g("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?m(U,{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?m(U,{type:"expand",align:t,headerAlign:T},{default:P=>N(p,"expand",P)}):void 0},H=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 m(U,{type:"index",index:i.index?i.index:I=>((k,J,G,K)=>{const X=J+1;return k?G*(K-1)+X:X})(O,I,P,C),align:i.align||j,headerAlign:i.headerAlign||te,label:i.label,width:"65px"},null);{const I={...i};return I.children&&delete I.children,m(U,E({showOverflowTooltip:pe,align:j,headerAlign:te},I,{prop:i.field}),{default:k=>{var J;return i.children&&i.children.length?(G=>{const{align:K,headerAlign:X,showOverflowTooltip:ue}=a(l);return G.map(h=>{const Q={...h};return Q.children&&delete Q.children,m(U,E({showOverflowTooltip:ue,align:K,headerAlign:X},Q,{prop:h.field}),{default:R=>{var ae;return h.children&&h.children.length?H(h.children):N(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:N(p,`${h.field}-header`)})})})(i.children):N(p,i.field,k)||((J=i==null?void 0:i.formatter)==null?void 0:J.call(i,k.row,k.column,k.row[i.field],k.$index))||k.row[i.field]},header:()=>N(p,`${i.field}-header`)||i.label})}}))};return()=>ge(m("div",null,[m(he,E({ref:u,data:a(l).data,"onSelection-change":q},a(v)),{default:()=>H(),append:()=>N(p,"append")}),a(l).pagination?m(Ce,E({pageSize:x.value,"onUpdate:pageSize":t=>x.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(),g=e,L=o,u=_(!0),x=F(()=>{let s=we(g.schema);if(g.expand&&g.expandField&&!a(u)){const v=xe(s,d=>d.field===g.expandField);if(v>-1){const d=s.length;s.splice(v+1,d)}}return g.layout==="inline"&&(s=s.concat([{field:"action",formItemProps:{labelWidth:"0px"}}])),s}),{register:f,elFormRef:n,methods:r}=Re({model:g.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)}}))},b=async()=>{var d;(d=a(n))==null||d.resetFields();const{getFormData:s}=r,v=await s();L("reset",v)},W=F(()=>({textAlign:g.buttomPosition})),q=()=>{var s;(s=a(n))==null||s.resetFields(),u.value=!a(u)};return(s,v)=>{const d=Pe,w=ke,H=Te;return S(),V(Se,null,[m(H,{inline:e.inline,"is-col":e.isCol,"is-custom":!1,"label-width":e.labelWidth,schema:a(x),class:"-mb-15px","hide-required-asterisk":"",onRegister:a(f)},be({action:A(()=>[e.layout==="inline"?(S(),V("div",Z,[e.showSearch?(S(),M(w,{key:0,onClick:l},{default:A(()=>[m(d,{class:"mr-5px",icon:"ep:search"}),B(" "+D(a(p)("common.query")),1)]),_:1})):z("",!0),e.showReset?(S(),M(w,{key:1,onClick:b},{default:A(()=>[m(d,{class:"mr-5px",icon:"ep:refresh"}),B(" "+D(a(p)("common.reset")),1)]),_:1})):z("",!0),e.expand?(S(),M(w,{key:2,text:"",onClick:q},{default:A(()=>[B(D(a(p)(a(u)?"common.shrink":"common.expand"))+" ",1),m(d,{icon:a(u)?"ep:arrow-up":"ep:arrow-down"},null,8,["icon"])]),_:1})):z("",!0),Y(s.$slots,"actionMore")])):z("",!0)]),_:2},[ve(Object.keys(s.$slots),t=>({name:t,fn:A(()=>[Y(s.$slots,t)])}))]),1032,["inline","is-col","label-width","schema","onRegister"]),e.layout==="bottom"?(S(),V("div",{key:0,style:_e(a(W))},[e.showSearch?(S(),M(w,{key:0,type:"primary",onClick:l},{default:A(()=>[m(d,{class:"mr-5px",icon:"ep:search"}),B(" "+D(a(p)("common.query")),1)]),_:1})):z("",!0),e.showReset?(S(),M(w,{key:1,onClick:b},{default:A(()=>[m(d,{class:"mr-5px",icon:"ep:refresh-right"}),B(" "+D(a(p)("common.reset")),1)]),_:1})):z("",!0),e.expand?(S(),M(w,{key:2,text:"",onClick:q},{default:A(()=>[B(D(a(p)(a(u)?"common.shrink":"common.expand"))+" ",1),m(d,{icon:a(u)?"ep:arrow-up":"ep:arrow-down"},null,8,["icon"])]),_:1})):z("",!0),Y(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 g=_(),L=_(),u=async()=>{await ze();const n=a(g);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(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 b=await u();!r||b!=null&&b.selections.length?l?se.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,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)=>{g.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};