useTable-190f8bb4.js 9.1 KB

1
  1. import{d as ne,ai as c,r as _,z as ge,a,e as j,O as R,D as me,M as fe,i as g,L as he,al as V,y as ye,K as W,_ as oe,B as le,aw as we,bV as be,o as S,c as X,aO as xe,C as ve,w as k,aH as Y,k as D,l as M,t as B,S as A,ay as _e,F as Se,n as Pe,s as ze,g as ke,a$ as re,az as se,ap as Ae,__tla as Le}from"./index-66208f93.js";import{g as I,_ as Oe,__tla as Te}from"./Form-c394334a.js";import{E as Ce,__tla as $e}from"./index-bd81327d.js";import{u as Fe,__tla as je}from"./useForm-aa8c2422.js";import{d as Re}from"./download-20922b56.js";let ie,ce,de,De=Promise.all([(()=>{try{return Le}catch{}})(),(()=>{try{return Te}catch{}})(),(()=>{try{return $e}catch{}})(),(()=>{try{return je}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=_({}),l=_({}),r=j(()=>{const t={...e};return Object.assign(t,a(l)),t}),x=(t,O)=>{var P;const{columns:T}=a(r);for(const C of O||T)for(const $ of t)C.field===$.field?ye(C,$.path,$.value):(P=C.children)!=null&&P.length&&x(t,C.children)},q=_([]),U=t=>{q.value=t};L({setProps:(t={})=>{l.value=Object.assign(a(l),t),n.value=t},setColumn:x,selections:q});const s=j(()=>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));R(()=>a(r).pageSize,t=>{b.value=t}),R(()=>a(r).currentPage,t=>{f.value=t}),R(()=>b.value,t=>{m("update:pageSize",t)}),R(()=>f.value,t=>{m("update:currentPage",t)});const v=j(()=>{const t={...o,...e};return delete t.columns,delete t.data,t}),d=()=>{const{selection:t,reserveSelection:O,align:T,headerAlign:P}=a(r);return t?g(W,{type:"selection",reserveSelection:O,align:T,headerAlign:P,width:"50"},null):void 0},w=()=>{const{align:t,headerAlign:O,expand:T}=a(r);return T?g(W,{type:"expand",align:t,headerAlign:O},{default:P=>I(p,"expand",P)}):void 0},E=t=>{const{columns:O,reserveIndex:T,pageSize:P,currentPage:C,align:$,headerAlign:te,showOverflowTooltip:pe}=a(r);return[w(),d()].concat((t||O).map(i=>{if(i.type==="index")return g(W,{type:"index",index:i.index?i.index:N=>((z,H,G,J)=>{const K=H+1;return z?G*(J-1)+K:K})(T,N,P,C),align:i.align||$,headerAlign:i.headerAlign||te,label:i.label,width:"65px"},null);{const N={...i};return N.children&&delete N.children,g(W,V({showOverflowTooltip:pe,align:$,headerAlign:te},N,{prop:i.field}),{default:z=>{var H;return i.children&&i.children.length?(G=>{const{align:J,headerAlign:K,showOverflowTooltip:ue}=a(r);return G.map(h=>{const Q={...h};return Q.children&&delete Q.children,g(W,V({showOverflowTooltip:ue,align:J,headerAlign:K},Q,{prop:h.field}),{default:F=>{var ae;return h.children&&h.children.length?E(h.children):I(p,h.field,F)||((ae=h==null?void 0:h.formatter)==null?void 0:ae.call(h,F.row,F.column,F.row[h.field],F.$index))||F.row[h.field]},header:I(p,`${h.field}-header`)})})})(i.children):I(p,i.field,z)||((H=i==null?void 0:i.formatter)==null?void 0:H.call(i,z.row,z.column,z.row[i.field],z.$index))||z.row[i.field]},header:()=>I(p,`${i.field}-header`)||i.label})}}))};return()=>me(g("div",null,[g(he,V({ref:u,data:a(r).data,"onSelection-change":U},a(v)),{default:()=>E(),append:()=>I(p,"append")}),a(r).pagination?g(Ce,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]),[[fe,a(r).loading]])}}),[["__scopeId","data-v-b4105caf"],["__file","D:/zx/mall-newfeifan-zx-business/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}=le(),m=e,L=o,u=_(!0),b=j(()=>{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:l}=Fe({model:m.model||{}}),r=async()=>{var s;await((s=a(n))==null?void 0:s.validate(async v=>{if(v){const{getFormData:d}=l,w=await d();L("search",w)}}))},x=async()=>{var d;(d=a(n))==null||d.resetFields();const{getFormData:s}=l,v=await s();L("reset",v)},q=j(()=>({textAlign:m.buttomPosition})),U=()=>{var s;(s=a(n))==null||s.resetFields(),u.value=!a(u)};return(s,v)=>{const d=Pe,w=ze,E=Oe;return S(),X(Se,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)},xe({action:k(()=>[e.layout==="inline"?(S(),X("div",Z,[e.showSearch?(S(),D(w,{key:0,onClick:r},{default:k(()=>[g(d,{class:"mr-5px",icon:"ep:search"}),M(" "+B(a(p)("common.query")),1)]),_:1})):A("",!0),e.showReset?(S(),D(w,{key:1,onClick:x},{default:k(()=>[g(d,{class:"mr-5px",icon:"ep:refresh"}),M(" "+B(a(p)("common.reset")),1)]),_:1})):A("",!0),e.expand?(S(),D(w,{key:2,text:"",onClick:U},{default:k(()=>[M(B(a(p)(a(u)?"common.shrink":"common.expand"))+" ",1),g(d,{icon:a(u)?"ep:arrow-up":"ep:arrow-down"},null,8,["icon"])]),_:1})):A("",!0),Y(s.$slots,"actionMore")])):A("",!0)]),_:2},[ve(Object.keys(s.$slots),t=>({name:t,fn:k(()=>[Y(s.$slots,t)])}))]),1032,["inline","is-col","label-width","schema","onRegister"]),e.layout==="bottom"?(S(),X("div",{key:0,style:_e(a(q))},[e.showSearch?(S(),D(w,{key:0,type:"primary",onClick:r},{default:k(()=>[g(d,{class:"mr-5px",icon:"ep:search"}),M(" "+B(a(p)("common.query")),1)]),_:1})):A("",!0),e.showReset?(S(),D(w,{key:1,onClick:x},{default:k(()=>[g(d,{class:"mr-5px",icon:"ep:refresh-right"}),M(" "+B(a(p)("common.reset")),1)]),_:1})):A("",!0),e.expand?(S(),D(w,{key:2,text:"",onClick:U},{default:k(()=>[M(B(a(p)(a(u)?"common.shrink":"common.expand"))+" ",1),g(d,{icon:a(u)?"ep:arrow-up":"ep:arrow-down"},null,8,["icon"])]),_:1})):A("",!0),Y(s.$slots,"actionMore")],4)):A("",!0)],64)}}}),ie=oe(ee,[["__file","D:/zx/mall-newfeifan-zx-business/src/components/Search/src/Search.vue"]]),{t:y}=le(),de=e=>{const o=ke({pageSize:10,currentPage:1,total:10,tableList:[],params:{...(e==null?void 0:e.defaultParams)||{}},loading:!0,exportLoading:!1,currentRow:null}),p=j(()=>({...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 Ae();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 l=1;n instanceof Array?(l=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))),re.success(y("common.delSuccess")),o.currentPage=(o.total%o.pageSize===l||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 l=await u();l==null||l.setProps(n)},setColumn:async n=>{const l=await u();l==null||l.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,l,r=!0)=>{const x=await u();!l||x!=null&&x.selections.length?r?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):re.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 r;const l=await((r=e==null?void 0:e.exportListApi)==null?void 0:r.call(e,a(p)));l&&Re.excel(l,n)}).finally(()=>{o.exportLoading=!1})}};return e!=null&&e.props&&f.setProps(e.props),{register:(n,l)=>{m.value=n,L.value=l},elTableRef:L,tableObject:o,methods:f,tableMethods:f}}});export{ie as _,De as __tla,ce as a,de as u};