ray-template/js/TablePro-Bvcdca-s.js

2 lines
9.4 KiB
JavaScript

import{P as Z,Q as ee,J as te,G as ae,U as oe,V as ne,I as ue,K as se,W as re,X as le,t as _,Y as ie}from"./hooks-Dx3WCPci.js";import"./currency.js@2.0.4-9OAR_aOO.js";import{d as L}from"./dayjs@1.11.10-C8LoRVP6.js";import"./print-js@1.6.0-BdoEj60G.js";import{a as ce}from"./vue-hooks-plus@2.2.1_vue@3.5.12-CDC3yd1M.js";import"./lodash@4.17.21-Cw59kuJw.js";import"./js-cookie@3.0.5-Z_8Sd105.js";import"./screenfull@5.2.0-DmMZCkhi.js";import"./jsbarcode@3.11.6-DGNGFp02.js";import{l as M,b as e,t as Y,v as V,j as me,f as pe,k as de,F as fe,I as m}from"./@vue_runtime-core@3.5.12-o4JnKqGq.js";import{f as Q,u as ge}from"./utils-CozJMALc.js";import{o as ye}from"./lodash-es@4.17.21-CeZG2a4n.js";import"./instance-nIExQa9a.js";import{M as H}from"./mockjs@1.1.0-CxlURkif.js";import{ah as U,M as J,H as be,ai as Re,c as q,Q as g,N as z,a5 as W,aj as X,am as $,v as ke}from"./naive-ui@2.40.1_vue@3.5.12-DHsO9NF4.js";import{k as E}from"./@vue_reactivity@3.5.12-IcmYCeX3.js";import"./@vueuse_core@11.1.0_vue@3.5.12-DcbFWgSD.js";import"./@vueuse_shared@11.1.0_vue@3.5.12-C48LWOin.js";import"./interactjs@1.10.26-DZL_TZzP.js";import"./call-bind@1.0.7-Cpj98o6Y.js";import"./pinia-plugin-persistedstate@4.1.1_pinia@2.2.4-_Zka_ujQ.js";import"./destr@2.0.3-CVtkxrq9.js";import"./deep-pick-omit@1.2.1-CegYQlcN.js";import"./pinia@2.2.4_typescript@5.2.2_vue@3.5.12-DcSddqfC.js";import"./vue-demi@0.14.10_vue@3.5.12-Dq6ymT-8.js";import"./html-to-image@1.11.11-BOFdlgi9.js";import"./vue-router@4.3.2_vue@3.5.12-DofREeSi.js";import"./vue-i18n@9.13.1_vue@3.5.12-BPgVS6jR.js";import"./@intlify_shared@9.13.1-BxU0OzX2.js";import"./@intlify_core-base@9.13.1-C6DqbPB6.js";import"./@intlify_message-compiler@9.13.1-GrLDMuy_.js";import"./echarts@5.5.0-CezqL3m-.js";import"./zrender@5.5.0-DW8ownf1.js";import"./tslib@2.3.0-BDyQ-Jie.js";import"./@vue_runtime-dom@3.5.12-CgYSV3BI.js";import"./@vue_shared@3.5.12--5_uv9t5.js";import"./axios@1.7.5-C8DqakIB.js";import"./date-fns@3.6.0-q9PkOyxq.js";import"./seemly@0.3.8-DjGKl9dV.js";import"./vueuc@0.4.64_vue@3.5.12-C5OYL2zc.js";import"./evtd@0.2.4-CI_DDEu_.js";import"./@css-render_vue3-ssr@0.15.14_vue@3.5.12-CozsU_5I.js";import"./vooks@0.2.12_vue@3.5.12-fnTfirhD.js";import"./vdirs@0.1.8_vue@3.5.12-C0KV5pCE.js";import"./@juggle_resize-observer@3.4.0-C8OzoCMD.js";import"./css-render@0.15.14-C5toWlUr.js";import"./@emotion_hash@0.8.0-WldOFDRm.js";import"./treemate@0.3.11-DKekKYbv.js";import"./date-fns-tz@3.1.3_date-fns@3.6.0-ztskLDQQ.js";import"./async-validator@4.2.5-DKvM95Vc.js";import"./@css-render_plugin-bem@0.15.14_css-render@0.15.14-Be8eOoM-.js";function Ce(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!V(t)}const he=M({name:"RCollapse",props:Object.assign({},{...Z,open:{type:Boolean,default:!0},cols:{type:Number,default:4}},ee),render(){const{$slots:t,$props:d}=this,{labelPlacement:y,showFeedback:p,...f}=d;return e(ae,Y(f,{labelPlacement:"top",showFeedback:!1}),{default:()=>[e(te,f,Ce(t)?t:{default:()=>[t]})]})}}),Te={...ye(oe,["pagination"]),paginationCount:{type:Number,default:1},onRegister:{type:Function,default:void 0},manual:{type:Boolean,default:!1},request:{type:Function},onTablePaginationUpdate:{type:Function},requestConfig:{type:Object,default:()=>({})},showPagination:{type:Boolean,default:!1},remote:{type:Boolean,default:!0}},Pe=Te;function ve(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!V(t)}const Ee=M({name:"RTablePro",props:Pe,setup(t){const[d,{clearFilters:y,clearSorter:p,downloadCsv:f,filters:l,page:s,scrollTo:k,sort:C,print:F,filter:h}]=ne(),[w,{getPage:D,getPageSize:S,setCallback:B,setItemCount:N,resetPagination:T,getItemCount:n}]=ue(void 0,{prefix:a=>`${a.itemCount}`}),b=me(()=>t.request),A=()=>({getItemCount:n,getPage:D,getPageSize:S}),P=()=>{const{onTablePaginationUpdate:a}=t;a&&Q(a,A())},j=a=>{const r=Object.assign({},t.requestConfig,a),{params:o,formatRangeTime:u}=r;return u!=null&&u.length&&o&&u.forEach(K=>{const{key:v,target:c}=K,i=o[v];if(i&&(c!=null&&c.length)){const[x,R]=i;o[c[0]]=x,o[c[1]]=R}else o[v]=null,o[c[0]]=null,o[c[1]]=null}),Object.assign({},o,{page:D(),pageSize:S()})},G=a=>{var o;T();const r=j(a);(o=b.value)==null||o.call(b,r)},I=a=>{var o;const r=j(a);(o=b.value)==null||o.call(b,r)};return pe(()=>{N(t.paginationCount),B(()=>{const{manual:a}=t;a||I(),P()})}),de(()=>{const{onRegister:a}=t;a&&Q(a,{getTablePagination:A,runTableRequest:G,clearFilters:y,clearSorter:p,downloadCsv:f,filters:l,page:s,scrollTo:k,sort:C,print:F,filter:h,getCurrentTableRequestParams:j})}),{register:d,paginationRef:w}},render(){const{register:t,$props:d,paginationRef:y,$slots:p}=this,{onRegister:f,showPagination:l,...s}=d;return e(se,Y(s,{onRegister:t,pagination:l?y:void 0}),ve(p)?p:{default:()=>[p]})}});function Fe(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!V(t)}const vt=M({name:"TableProDemo",setup(){const{format:t}=ie(),[d,{runTableRequest:y,getCurrentTableRequestParams:p,print:f,downloadCsv:l}]=re(),s=E([]),k=[{type:"selection"},{title:"Name",key:"name"},{title:"Sign Status",key:"statusText"},{title:"Sign Time",key:"signTimeStart",render:a=>t(a.signTimeStart)+" ~ "+t(a.signTimeEnd)},{title:"Age",key:"age"},{title:"Address",key:"address"},{title:"Tags",key:"tags",render:a=>a.tags.map(o=>e(ke,{type:"info",bordered:!1,style:"margin-right: 6px"},Fe(o)?o:{default:()=>[o]}))},{title:"Remark",key:"remark"}],C=E(0),F=E({}),h=E((()=>{const r=[],o=L().valueOf();for(let u=0;u<30;u++)r.push({key:ge(),name:H.Random.cname(),age:u+20,address:H.Random.city(),tags:["nice","developer"],remark:"我是一条很长很长的备注",status:u%2===0?"success":"error",statusText:u%2===0?"在线":"离线",signTimeStart:L(o).add(u*2,"year").valueOf(),signTimeEnd:L(o).add(u+5,"day").valueOf()});return r})()),w=E({pagination:!0,manual:!1}),[D,{checkedRowKeysBind:S,getKeys:B,getRows:N,clearKey:T,clearAll:n,selectKey:b}]=le(s,k,{rowKey:"key",onChange:(a,r,o)=>{}}),A=E(!0),P=a=>a==null,j=a=>new Promise(r=>{const{page:o=1,pageSize:u=10,name:O,status:K,signTimeStart:v,signTimeEnd:c}=a||{};let i=h.value;const x=h.value.length;O&&(i=i.filter(R=>R.name.includes(O))),K&&(i=i.filter(R=>R.status===K)),v&&c&&(i=i.filter(R=>R.signTimeStart>=v&&R.signTimeEnd<=c)),i=i.slice((o-1)*u,o*u),setTimeout(()=>{r({code:0,data:i,total:P(K)&&P(O)&&(P(v)||P(c))?x:i.length,message:"success",page:o,pageSize:u})},1e3)}),{run:G,loading:I}=ce(j,{onSuccess:a=>{const{data:r,total:o}=a;s.value=r,C.value=o}});return{tableDataRef:s,baseColumns:k,itemCountRef:C,loadingGetPersonList:I,runGetPersonList:G,conditionRef:F,radioRef:w,runTableRequest:y,tableProRegister:d,print:f,downloadCsv:l,checkedRowKeysBind:S,checkedRowKeys:D,getKeys:B,getRows:N,clearKey:T,clearAll:n,collapseRef:A,selectKey:b}},render(){const{tableDataRef:t,baseColumns:d,itemCountRef:y,loadingGetPersonList:p,runGetPersonList:f,conditionRef:l,radioRef:s,runTableRequest:k,tableProRegister:C,print:F,downloadCsv:h,checkedRowKeysBind:w,getKeys:D,getRows:S,clearKey:B,clearAll:N,selectKey:T}=this;return e(q,{vertical:!0},{default:()=>[e(he,{open:this.collapseRef},{default:()=>e(fe,null,[e(U,{label:"用户名"},{default:()=>[e(J,{value:l.name,"onUpdate:value":n=>l.name=n,clearable:!0},null)]}),e(U,{label:"状态"},{default:()=>[e(be,{value:l.status,"onUpdate:value":n=>l.status=n,clearable:!0,options:[{label:"成功",value:"success"},{label:"失败",value:"error"}]},null)]}),e(U,{label:"登陆时间"},{default:()=>[e(Re,{type:"datetimerange",value:l.RangeTime,"onUpdate:value":n=>l.RangeTime=n,clearable:!0},null)]}),e(U,{label:"演示折叠的条件框"},{default:()=>[e(J,{readonly:!0,placeholder:"我只是为了占位"},null)]})]),action:()=>e(q,null,{default:()=>[e(g,{type:"primary",onClick:()=>k(),loading:p},{default:()=>[m("查询")]})]}),collapse:n=>n?e(g,{onClick:()=>this.collapseRef=!0,secondary:!0},{default:()=>"受控展开",icon:()=>e(_,{name:"dark",size:"18"},null)}):e(g,{onClick:()=>this.collapseRef=!1,secondary:!0},{default:()=>"受控收起",icon:()=>e(_,{name:"light",size:"18"},null)})}),e(z,{title:"常用高级拓展功能"},{default:()=>[e(q,null,{default:()=>[e(W,{label:"分页"},{default:()=>[e(X,{value:s.pagination,"onUpdate:value":n=>s.pagination=n},{default:()=>[e($,{value:!0},{default:()=>[m("显示分页")]}),e($,{value:!1},{default:()=>[m("隐藏分页")]})]})]}),e(W,{label:"自动更新"},{default:()=>[e(X,{value:s.manual,"onUpdate:value":n=>s.manual=n},{default:()=>[e($,{value:!1},{default:()=>[m("自动更新")]}),e($,{value:!0},{default:()=>[m("取消自动")]})]})]})]})]}),e(z,{title:"useTablePro 部分方法"},{default:()=>[e(q,null,{default:()=>[e(g,{type:"primary",onClick:()=>F()},{default:()=>[m("打印")]}),e(g,{type:"primary",onClick:()=>h()},{default:()=>[m("下载 csv")]})]})]}),e(z,{title:"useCheckedRowKeys 部分方法"},{default:()=>[e(q,null,{default:()=>[e(g,{type:"primary",onClick:()=>{const n=t[1].key;T(n)}},{default:()=>[m("选中第二行")]}),e(g,{type:"primary",onClick:()=>{const n=t[1].key;B(n)}},{default:()=>[m("取消选中第二行")]}),e(g,{type:"primary",onClick:()=>{t==null||t.forEach(n=>T(n.key))}},{default:()=>[m("选中当前页面所有行")]}),e(g,{type:"primary",onClick:()=>{N()}},{default:()=>[m("取消所有已选中行")]})]})]}),e(Ee,{onRegister:C,data:t,columns:d,loading:p,paginationCount:y,request:f,requestConfig:{params:l,formatRangeTime:[{key:"RangeTime",target:["signTimeStart","signTimeEnd"]}]},showPagination:s.pagination,manual:s.manual,rowKey:n=>n.key,checkedRowKeys:this.checkedRowKeys,"onUpdate:checkedRowKeys":n=>this.checkedRowKeys=n,onUpdateCheckedRowKeys:w},null)]})}});export{vt as default};