ray-template/js/TablePro-DyGNxTE3.js

2 lines
9.3 KiB
JavaScript

import{O,P as I,F as U,I as G,Q as $,U as L,H as z,J as M,V as _,W as H,r as q,X as J}from"./hooks-DeCbIFFS.js";import"./currency.js@2.0.4-9OAR_aOO.js";import"./print-js@1.6.0-BdoEj60G.js";import{a as Q}from"./vue-hooks-plus@2.2.1_vue@3.4.38-DdMBTcyt.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{d as A,u as W}from"./utils-DGuZdIHQ.js";import{o as X}from"./lodash-es@4.17.21-BALnwRTu.js";import"./instance-B5j64X7o.js";import{M as K}from"./mockjs@1.1.0-CxlURkif.js";import"./@vueuse_core@10.9.0_vue@3.4.38-Cp_qoKMZ.js";import"./@vueuse_shared@10.9.0_vue@3.4.38-BTLxKjPf.js";import"./interactjs@1.10.26-DZL_TZzP.js";import"./call-bind@1.0.7-Cpj98o6Y.js";import"./pinia-plugin-persistedstate@3.2.1_pinia@2.1.7-RV7uh3T-.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-core@3.4.38-f9XU7P4m.js";import"./@vue_reactivity@3.4.38-CmXFqMGn.js";import"./@vue_shared@3.4.38-D8qfpBTH.js";function Y(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!Vue.isVNode(e)}const Z=Vue.defineComponent({name:"RCollapse",props:Object.assign({},{...O,open:{type:Boolean,default:!0},cols:{type:Number,default:4}},I),render(){const{$slots:e,$props:d}=this,{labelPlacement:p,showFeedback:c,...m}=d;return Vue.createVNode(U,Vue.mergeProps(m,{labelPlacement:"top",showFeedback:!1}),{default:()=>[Vue.createVNode(G,m,Y(e)?e:{default:()=>[e]})]})}}),ee={...X($,["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}},te=ee;function ae(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!Vue.isVNode(e)}const ue=Vue.defineComponent({name:"RTablePro",props:te,setup(e){const[d,{clearFilters:p,clearSorter:c,downloadCsv:m,filters:i,page:n,scrollTo:g,sort:N,print:b,filter:y}]=L(),[T,{getPage:k,getPageSize:P,setCallback:h,setItemCount:F,resetPagination:v,getItemCount:u}]=z(void 0,{prefix:t=>`${t.itemCount}`}),V=Vue.computed(()=>e.request),w=()=>({getItemCount:u,getPage:k,getPageSize:P}),R=()=>{const{onTablePaginationUpdate:t}=e;t&&A(t,w())},E=t=>{const r=Object.assign({},e.requestConfig,t),{params:a,formatRangeTime:o}=r;return o!=null&&o.length&&a&&o.forEach(B=>{const{key:C,target:l}=B,s=a[C];if(s&&(l!=null&&l.length)){const[j,f]=s;a[l[0]]=j,a[l[1]]=f}else a[C]=null,a[l[0]]=null,a[l[1]]=null}),Object.assign({},a,{page:k(),pageSize:P()})},x=t=>{var a;v();const r=E(t);(a=V.value)==null||a.call(V,r)},S=t=>{var a;const r=E(t);(a=V.value)==null||a.call(V,r)};return Vue.watchEffect(()=>{F(e.paginationCount),h(()=>{const{manual:t}=e;t||S(),R()})}),Vue.onMounted(()=>{const{onRegister:t}=e;t&&A(t,{getTablePagination:w,runTableRequest:x,clearFilters:p,clearSorter:c,downloadCsv:m,filters:i,page:n,scrollTo:g,sort:N,print:b,filter:y,getCurrentTableRequestParams:E})}),{register:d,paginationRef:T}},render(){const{register:e,$props:d,paginationRef:p,$slots:c}=this,{onRegister:m,showPagination:i,...n}=d;return Vue.createVNode(M,Vue.mergeProps(n,{onRegister:e,pagination:i?p:void 0}),ae(c)?c:{default:()=>[c]})}});function oe(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!Vue.isVNode(e)}const Fe=Vue.defineComponent({name:"TableProDemo",setup(){const{format:e}=J(),[d,{runTableRequest:p,getCurrentTableRequestParams:c,print:m,downloadCsv:i}]=_(),n=Vue.ref([]),g=[{type:"selection"},{title:"Name",key:"name"},{title:"Sign Status",key:"statusText"},{title:"Sign Time",key:"signTimeStart",render:t=>e(t.signTimeStart)+" ~ "+e(t.signTimeEnd)},{title:"Age",key:"age"},{title:"Address",key:"address"},{title:"Tags",key:"tags",render:t=>t.tags.map(a=>Vue.createVNode(naive.NTag,{type:"info",bordered:!1,style:"margin-right: 6px"},oe(a)?a:{default:()=>[a]}))},{title:"Remark",key:"remark"}],N=Vue.ref(0),b=Vue.ref({}),y=Vue.ref((()=>{const r=[],a=dayjs().valueOf();for(let o=0;o<30;o++)r.push({key:W(),name:K.Random.cname(),age:o+20,address:K.Random.city(),tags:["nice","developer"],remark:"我是一条很长很长的备注",status:o%2===0?"success":"error",statusText:o%2===0?"在线":"离线",signTimeStart:dayjs(a).add(o*2,"year").valueOf(),signTimeEnd:dayjs(a).add(o+5,"day").valueOf()});return r})()),T=Vue.ref({pagination:!0,manual:!1}),[k,{checkedRowKeysBind:P,getKeys:h,getRows:F,clearKey:v,clearAll:u,selectKey:V}]=H(n,g,{rowKey:"key",onChange:(t,r,a)=>{}}),w=Vue.ref(!0),R=t=>t==null,E=t=>new Promise(r=>{const{page:a=1,pageSize:o=10,name:D,status:B,signTimeStart:C,signTimeEnd:l}=t||{};let s=y.value;const j=y.value.length;D&&(s=s.filter(f=>f.name.includes(D))),B&&(s=s.filter(f=>f.status===B)),C&&l&&(s=s.filter(f=>f.signTimeStart>=C&&f.signTimeEnd<=l)),s=s.slice((a-1)*o,a*o),setTimeout(()=>{r({code:0,data:s,total:R(B)&&R(D)&&(R(C)||R(l))?j:s.length,message:"success",page:a,pageSize:o})},1e3)}),{run:x,loading:S}=Q(E,{onSuccess:t=>{const{data:r,total:a}=t;n.value=r,N.value=a}});return{tableDataRef:n,baseColumns:g,itemCountRef:N,loadingGetPersonList:S,runGetPersonList:x,conditionRef:b,radioRef:T,runTableRequest:p,tableProRegister:d,print:m,downloadCsv:i,checkedRowKeysBind:P,checkedRowKeys:k,getKeys:h,getRows:F,clearKey:v,clearAll:u,collapseRef:w,selectKey:V}},render(){const{tableDataRef:e,baseColumns:d,itemCountRef:p,loadingGetPersonList:c,runGetPersonList:m,conditionRef:i,radioRef:n,runTableRequest:g,tableProRegister:N,print:b,downloadCsv:y,checkedRowKeysBind:T,getKeys:k,getRows:P,clearKey:h,clearAll:F,selectKey:v}=this;return Vue.createVNode(naive.NFlex,{vertical:!0},{default:()=>[Vue.createVNode(Z,{open:this.collapseRef},{default:()=>Vue.createVNode(Vue.Fragment,null,[Vue.createVNode(naive.NFormItemGi,{label:"用户名"},{default:()=>[Vue.createVNode(naive.NInput,{value:i.name,"onUpdate:value":u=>i.name=u,clearable:!0},null)]}),Vue.createVNode(naive.NFormItemGi,{label:"状态"},{default:()=>[Vue.createVNode(naive.NSelect,{value:i.status,"onUpdate:value":u=>i.status=u,clearable:!0,options:[{label:"成功",value:"success"},{label:"失败",value:"error"}]},null)]}),Vue.createVNode(naive.NFormItemGi,{label:"登陆时间"},{default:()=>[Vue.createVNode(naive.NDatePicker,{type:"datetimerange",value:i.RangeTime,"onUpdate:value":u=>i.RangeTime=u,clearable:!0},null)]}),Vue.createVNode(naive.NFormItemGi,{label:"演示折叠的条件框"},{default:()=>[Vue.createVNode(naive.NInput,{readonly:!0,placeholder:"我只是为了占位"},null)]})]),action:()=>Vue.createVNode(naive.NFlex,null,{default:()=>[Vue.createVNode(naive.NButton,{type:"primary",onClick:()=>g(),loading:c},{default:()=>[Vue.createTextVNode("查询")]})]}),collapse:u=>u?Vue.createVNode(naive.NButton,{onClick:()=>this.collapseRef=!0,secondary:!0},{default:()=>"受控展开",icon:()=>Vue.createVNode(q,{name:"dark",size:"18"},null)}):Vue.createVNode(naive.NButton,{onClick:()=>this.collapseRef=!1,secondary:!0},{default:()=>"受控收起",icon:()=>Vue.createVNode(q,{name:"light",size:"18"},null)})}),Vue.createVNode(naive.NCard,{title:"常用高级拓展功能"},{default:()=>[Vue.createVNode(naive.NFlex,null,{default:()=>[Vue.createVNode(naive.NFormItem,{label:"分页"},{default:()=>[Vue.createVNode(naive.NRadioGroup,{value:n.pagination,"onUpdate:value":u=>n.pagination=u},{default:()=>[Vue.createVNode(naive.NRadioButton,{value:!0},{default:()=>[Vue.createTextVNode("显示分页")]}),Vue.createVNode(naive.NRadioButton,{value:!1},{default:()=>[Vue.createTextVNode("隐藏分页")]})]})]}),Vue.createVNode(naive.NFormItem,{label:"自动更新"},{default:()=>[Vue.createVNode(naive.NRadioGroup,{value:n.manual,"onUpdate:value":u=>n.manual=u},{default:()=>[Vue.createVNode(naive.NRadioButton,{value:!1},{default:()=>[Vue.createTextVNode("自动更新")]}),Vue.createVNode(naive.NRadioButton,{value:!0},{default:()=>[Vue.createTextVNode("取消自动")]})]})]})]})]}),Vue.createVNode(naive.NCard,{title:"useTablePro 部分方法"},{default:()=>[Vue.createVNode(naive.NFlex,null,{default:()=>[Vue.createVNode(naive.NButton,{type:"primary",onClick:()=>b()},{default:()=>[Vue.createTextVNode("打印")]}),Vue.createVNode(naive.NButton,{type:"primary",onClick:()=>y()},{default:()=>[Vue.createTextVNode("下载 csv")]})]})]}),Vue.createVNode(naive.NCard,{title:"useCheckedRowKeys 部分方法"},{default:()=>[Vue.createVNode(naive.NFlex,null,{default:()=>[Vue.createVNode(naive.NButton,{type:"primary",onClick:()=>{const u=e[1].key;v(u)}},{default:()=>[Vue.createTextVNode("选中第二行")]}),Vue.createVNode(naive.NButton,{type:"primary",onClick:()=>{const u=e[1].key;h(u)}},{default:()=>[Vue.createTextVNode("取消选中第二行")]}),Vue.createVNode(naive.NButton,{type:"primary",onClick:()=>{e==null||e.forEach(u=>v(u.key))}},{default:()=>[Vue.createTextVNode("选中当前页面所有行")]}),Vue.createVNode(naive.NButton,{type:"primary",onClick:()=>{F()}},{default:()=>[Vue.createTextVNode("取消所有已选中行")]})]})]}),Vue.createVNode(ue,{onRegister:N,data:e,columns:d,loading:c,paginationCount:p,request:m,requestConfig:{params:i,formatRangeTime:[{key:"RangeTime",target:["signTimeStart","signTimeEnd"]}]},showPagination:n.pagination,manual:n.manual,rowKey:u=>u.key,checkedRowKeys:this.checkedRowKeys,"onUpdate:checkedRowKeys":u=>this.checkedRowKeys=u,onUpdateCheckedRowKeys:T},null)]})}});export{Fe as default};