vue-export-table 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vue-export-table.cjs +1 -1
- package/dist/vue-export-table.css +1 -1
- package/dist/vue-export-table.js +100 -105
- package/dist/vue-export-table.umd.js +1 -1
- package/dist/vue-export-table.vue2.cjs +1 -1
- package/dist/vue-export-table.vue2.js +64 -64
- package/dist/vue-export-table.vue2.umd.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),p=require("vue-demi");function D(n){const a=p.reactive({});function l(){n.forEach(o=>{o.defaultValue!==void 0?a[o.name]=o.defaultValue:a[o.name]=o.type==="rangePicker"?[]:void 0})}l();function u(){const o={};return Object.keys(a).forEach(s=>{const i=a[s];if(i!=null&&i!==""){if(Array.isArray(i)&&i.length===0)return;o[s]=i}}),o}function m(){l()}function h(o,s){a[o]=s}return{filters:a,onSearch:u,onReset:m,setFilter:h}}function T(n=10){const a=p.ref(1),l=p.ref(n),u=p.computed(()=>({current:a.value,pageSize:l.value}));function m(o,s){a.value=o,s!==l.value&&(l.value=s,a.value=1)}function h(){a.value=1}return{currentPage:a,pageSize:l,pagination:u,onPageChange:m,resetPage:h}}function U(n,a){const l=p.ref(n.enabled??n.interval>0),u=p.ref(n.interval);let m=null;function h(){o(),!(!l.value||n.interval<=0)&&(u.value=n.interval,m=setInterval(()=>{u.value-=1,u.value<=0&&(u.value=n.interval,a())},1e3))}function o(){m&&(clearInterval(m),m=null)}function s(g){l.value=g??!l.value,l.value?h():(o(),u.value=n.interval)}function i(){l.value&&(u.value=n.interval)}function v(){n.pauseOnHidden&&(document.hidden?o():l.value&&h())}return p.onMounted(()=>{l.value&&n.interval>0&&(h(),n.pauseOnHidden&&document.addEventListener("visibilitychange",v))}),p.onUnmounted(()=>{o(),document.removeEventListener("visibilitychange",v)}),{enabled:l,countdown:u,toggle:s,resetCountdown:i}}function q(n){const a=p.ref(!1),l=p.ref([]),u=p.ref(0),{filters:m,onSearch:h,onReset:o,setFilter:s}=D(n.queryFields??[]),{currentPage:i,pageSize:v,pagination:g,onPageChange:_,resetPage:C}=T(n.pageSize??10),k=n.autoRefresh??{interval:0,enabled:!1},{enabled:V,countdown:N,toggle:S,resetCountdown:B}=U(k,()=>{r()});async function r(){a.value=!0;try{const f={page:i.value,pageSize:v.value,filters:h()},y=await n.fetchData(f);l.value=y.list,u.value=y.total}catch(f){console.error("[VueExportTable] fetch error:",f)}finally{a.value=!1}}function c(){C(),r(),B()}function w(){o(),C(),r()}function b(f,y){_(f,y),r(),B()}return p.onMounted(()=>{n.immediate!==!1&&r()}),{loading:a,data:l,total:u,filters:m,pagination:g,currentPage:i,pageSize:v,handleSearch:c,handleReset:w,setFilter:s,handlePageChange:b,refresh:r,autoRefreshEnabled:V,countdown:N,toggleAutoRefresh:S}}const O={class:"vet-download-table-wrapper"},j={key:0,class:"vet-query-form-wrapper"},H={class:"vet-toolbar-wrapper"},Q={class:"vet-toolbar-left"},W={key:0,class:"vet-table-title"},G={class:"vet-toolbar-right"},J={key:1,class:"vet-countdown-text"},X=["onClick"],Y={key:1,class:"vet-pagination-wrapper"},F=e.defineComponent({__name:"DownloadTable",props:{columns:{},queryFields:{},fetchData:{},download:{default:void 0},autoRefresh:{},rowKey:{type:[String,Function],default:"id"},title:{},bordered:{type:Boolean,default:!0},pageSize:{default:10},showIndex:{type:Boolean,default:!1}},setup(n){const a=n,l=r=>a.download?a.download.canDownload?a.download.canDownload(r):r.status==="completed":!1,{loading:u,data:m,total:h,filters:o,currentPage:s,pageSize:i,handleSearch:v,handleReset:g,handlePageChange:_,refresh:C,autoRefreshEnabled:k,countdown:V,toggleAutoRefresh:N}=q({fetchData:a.fetchData,queryFields:a.queryFields,pageSize:a.pageSize,autoRefresh:a.autoRefresh,immediate:!0}),S=p.computed(()=>{const r=[];return a.showIndex&&r.push({title:"序号",dataIndex:"index",key:"index",width:80,align:"center",customRender:({index:c})=>(s.value-1)*i.value+c+1}),[...r,...a.columns]}),B=p.computed(()=>{const r=S.value.reduce((c,w)=>{const b=typeof w.width=="number"?w.width:0;return c+b},0);return r>0?{x:r}:void 0});return(r,c)=>{const w=e.resolveComponent("a-input"),b=e.resolveComponent("a-input-number"),f=e.resolveComponent("a-select"),y=e.resolveComponent("a-date-picker"),I=e.resolveComponent("a-range-picker"),R=e.resolveComponent("a-form-item"),x=e.resolveComponent("a-button"),E=e.resolveComponent("a-space"),A=e.resolveComponent("a-form"),M=e.resolveComponent("a-switch"),K=e.resolveComponent("a-table"),L=e.resolveComponent("a-pagination");return e.openBlock(),e.createElementBlock("div",O,[n.queryFields&&n.queryFields.length>0?(e.openBlock(),e.createElementBlock("div",j,[e.renderSlot(r.$slots,"query-form",{filters:e.unref(o),handleSearch:e.unref(v),handleReset:e.unref(g)},()=>[e.createVNode(A,{layout:"inline",model:e.unref(o)},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.queryFields,t=>(e.openBlock(),e.createBlock(R,{key:t.name,label:t.label},{default:e.withCtx(()=>[t.type==="input"?(e.openBlock(),e.createBlock(w,{key:0,value:e.unref(o)[t.name],"onUpdate:value":d=>e.unref(o)[t.name]=d,placeholder:t.placeholder||`请输入${t.label}`,"allow-clear":""},null,8,["value","onUpdate:value","placeholder"])):t.type==="number"?(e.openBlock(),e.createBlock(b,{key:1,value:e.unref(o)[t.name],"onUpdate:value":d=>e.unref(o)[t.name]=d,placeholder:t.placeholder||`请输入${t.label}`,style:{width:"180px"}},null,8,["value","onUpdate:value","placeholder"])):t.type==="select"?(e.openBlock(),e.createBlock(f,{key:2,value:e.unref(o)[t.name],"onUpdate:value":d=>e.unref(o)[t.name]=d,placeholder:t.placeholder||`请选择${t.label}`,options:t.options,"allow-clear":"",style:{"min-width":"150px"}},null,8,["value","onUpdate:value","placeholder","options"])):t.type==="datePicker"?(e.openBlock(),e.createBlock(y,{key:3,value:e.unref(o)[t.name],"onUpdate:value":d=>e.unref(o)[t.name]=d,placeholder:t.placeholder||`请选择${t.label}`,style:{width:"180px"}},null,8,["value","onUpdate:value","placeholder"])):t.type==="rangePicker"?(e.openBlock(),e.createBlock(I,{key:4,value:e.unref(o)[t.name],"onUpdate:value":d=>e.unref(o)[t.name]=d,placeholder:[t.placeholder||"开始日期",t.placeholder||"结束日期"],style:{width:"240px"}},null,8,["value","onUpdate:value","placeholder"])):e.createCommentVNode("",!0)]),_:2},1032,["label"]))),128)),e.createVNode(R,null,{default:e.withCtx(()=>[e.createVNode(E,null,{default:e.withCtx(()=>[e.createVNode(x,{type:"primary",onClick:e.unref(v)},{default:e.withCtx(()=>[...c[3]||(c[3]=[e.createTextVNode("查询",-1)])]),_:1},8,["onClick"]),e.createVNode(x,{onClick:e.unref(g)},{default:e.withCtx(()=>[...c[4]||(c[4]=[e.createTextVNode("重置",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1})]),_:1},8,["model"])])])):e.createCommentVNode("",!0),e.createElementVNode("div",H,[e.renderSlot(r.$slots,"toolbar",{loading:e.unref(u),refresh:e.unref(C)},()=>[e.createElementVNode("div",Q,[n.title?(e.openBlock(),e.createElementBlock("span",W,e.toDisplayString(n.title),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",G,[e.createVNode(E,null,{default:e.withCtx(()=>[e.createVNode(x,{loading:e.unref(u),onClick:e.unref(C)},{default:e.withCtx(()=>[...c[5]||(c[5]=[e.createElementVNode("svg",{class:"vet-icon-svg",viewBox:"64 64 896 896",width:"1em",height:"1em",fill:"currentColor"},[e.createElementVNode("path",{d:"M909.1 209.3l-56.4 44.1C775.8 155.1 653.5 96 512 96 282.7 96 96 282.7 96 512s186.7 416 416 416c165.3 0 309.1-96.4 376-236.1 8.3-17.2-4.3-37.1-23.1-37.1H745.6c-9.2 0-17.2 5.8-20.3 14.3C680.5 773.5 600.5 832 512 832c-176.7 0-320-143.3-320-320s143.3-320 320-320c88.5 0 168.5 36.1 226.4 94.3L704 356.3c-4.7-4.7-1.3-12.7 5.3-13.1l193.7-12.5c6.6-.4 12.3 4.9 12.3 11.5v193.7c0 6.6-8 10-12.7 5.3z"})],-1),e.createTextVNode(" 刷新 ",-1)])]),_:1},8,["loading","onClick"]),n.autoRefresh?(e.openBlock(),e.createBlock(M,{key:0,checked:e.unref(k),"onUpdate:checked":c[0]||(c[0]=t=>e.isRef(k)?k.value=t:null),"checked-children":"自动刷新","un-checked-children":"自动刷新",onChange:e.unref(N)},null,8,["checked","onChange"])):e.createCommentVNode("",!0),n.autoRefresh&&e.unref(k)?(e.openBlock(),e.createElementBlock("span",J,e.toDisplayString(e.unref(V))+"s ",1)):e.createCommentVNode("",!0)]),_:1})])])]),e.createVNode(K,e.mergeProps({dataSource:e.unref(m),columns:e.unref(S),loading:e.unref(u),pagination:!1,rowKey:n.rowKey,bordered:n.bordered,scroll:e.unref(B)},r.$attrs),{bodyCell:e.withCtx(({column:t,record:d,index:P,text:z})=>[t.dataIndex==="action"?e.renderSlot(r.$slots,"action",{key:0,record:d,index:P},()=>[n.download&&l(d)?(e.openBlock(),e.createElementBlock("a",{key:0,onClick:Z=>n.download.handleDownload(d)},"下载",8,X)):e.createCommentVNode("",!0)]):e.renderSlot(r.$slots,t.dataIndex,{key:1,record:d,index:P,text:z},()=>[e.createTextVNode(e.toDisplayString(z),1)])]),_:3},16,["dataSource","columns","loading","rowKey","bordered","scroll"]),e.unref(h)>0?(e.openBlock(),e.createElementBlock("div",Y,[e.createVNode(L,{current:e.unref(s),"onUpdate:current":c[1]||(c[1]=t=>e.isRef(s)?s.value=t:null),pageSize:e.unref(i),"onUpdate:pageSize":c[2]||(c[2]=t=>e.isRef(i)?i.value=t:null),total:e.unref(h),"show-size-changer":!0,"show-quick-jumper":!0,"show-total":t=>`共 ${t} 条`,onChange:e.unref(_),onShowSizeChange:e.unref(_)},null,8,["current","pageSize","total","show-total","onChange","onShowSizeChange"])])):e.createCommentVNode("",!0)])}}}),$={install(n){n.component("DownloadTable",F)}};exports.DownloadTable=F;exports.VueExportTable=$;exports.default=$;exports.useAutoRefresh=U;exports.usePagination=T;exports.useQuery=D;exports.useTable=q;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.download-table-wrapper
|
|
1
|
+
.vet-download-table-wrapper{padding:16px;background:#fff;border-radius:4px}.vet-query-form-wrapper{margin-bottom:16px;padding:16px;background:#fafafa;border-radius:4px}.vet-toolbar-wrapper{display:flex;justify-content:space-between;align-items:center;margin-bottom:16px}.vet-toolbar-left{display:flex;align-items:center}.vet-table-title{font-size:16px;font-weight:600;color:#333}.vet-toolbar-right{display:flex;align-items:center}.vet-countdown-text{color:#1890ff;font-size:14px;margin-left:8px}.vet-pagination-wrapper{margin-top:16px;text-align:right}.vet-icon-svg{display:inline-block;width:1em;height:1em;margin-right:4px;vertical-align:-.125em}
|
package/dist/vue-export-table.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { defineComponent as Y, resolveComponent as m, openBlock as h, createElementBlock as b, renderSlot as E, unref as a, createVNode as f, withCtx as g, Fragment as Z, renderList as ee, createBlock as k, createCommentVNode as _, createTextVNode as T, createElementVNode as D, toDisplayString as A, isRef as K, mergeProps as te } from "vue";
|
|
2
2
|
import { reactive as ae, ref as C, computed as L, onMounted as M, onUnmounted as ne } from "vue-demi";
|
|
3
|
-
function oe(
|
|
3
|
+
function oe(t) {
|
|
4
4
|
const o = ae({});
|
|
5
5
|
function l() {
|
|
6
|
-
|
|
6
|
+
t.forEach((n) => {
|
|
7
7
|
n.defaultValue !== void 0 ? o[n.name] = n.defaultValue : o[n.name] = n.type === "rangePicker" ? [] : void 0;
|
|
8
8
|
});
|
|
9
9
|
}
|
|
@@ -18,55 +18,55 @@ function oe(e) {
|
|
|
18
18
|
}
|
|
19
19
|
}), n;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function p() {
|
|
22
22
|
l();
|
|
23
23
|
}
|
|
24
24
|
function v(n, c) {
|
|
25
25
|
o[n] = c;
|
|
26
26
|
}
|
|
27
|
-
return { filters: o, onSearch: u, onReset:
|
|
27
|
+
return { filters: o, onSearch: u, onReset: p, setFilter: v };
|
|
28
28
|
}
|
|
29
|
-
function le(
|
|
30
|
-
const o = C(1), l = C(
|
|
29
|
+
function le(t = 10) {
|
|
30
|
+
const o = C(1), l = C(t), u = L(() => ({
|
|
31
31
|
current: o.value,
|
|
32
32
|
pageSize: l.value
|
|
33
33
|
}));
|
|
34
|
-
function
|
|
34
|
+
function p(n, c) {
|
|
35
35
|
o.value = n, c !== l.value && (l.value = c, o.value = 1);
|
|
36
36
|
}
|
|
37
37
|
function v() {
|
|
38
38
|
o.value = 1;
|
|
39
39
|
}
|
|
40
|
-
return { currentPage: o, pageSize: l, pagination: u, onPageChange:
|
|
40
|
+
return { currentPage: o, pageSize: l, pagination: u, onPageChange: p, resetPage: v };
|
|
41
41
|
}
|
|
42
|
-
function re(
|
|
43
|
-
const l = C(
|
|
44
|
-
let
|
|
42
|
+
function re(t, o) {
|
|
43
|
+
const l = C(t.enabled ?? t.interval > 0), u = C(t.interval);
|
|
44
|
+
let p = null;
|
|
45
45
|
function v() {
|
|
46
|
-
n(), !(!l.value ||
|
|
47
|
-
u.value -= 1, u.value <= 0 && (u.value =
|
|
46
|
+
n(), !(!l.value || t.interval <= 0) && (u.value = t.interval, p = setInterval(() => {
|
|
47
|
+
u.value -= 1, u.value <= 0 && (u.value = t.interval, o());
|
|
48
48
|
}, 1e3));
|
|
49
49
|
}
|
|
50
50
|
function n() {
|
|
51
|
-
|
|
51
|
+
p && (clearInterval(p), p = null);
|
|
52
52
|
}
|
|
53
53
|
function c(S) {
|
|
54
|
-
l.value = S ?? !l.value, l.value ? v() : (n(), u.value =
|
|
54
|
+
l.value = S ?? !l.value, l.value ? v() : (n(), u.value = t.interval);
|
|
55
55
|
}
|
|
56
56
|
function i() {
|
|
57
|
-
l.value && (u.value =
|
|
57
|
+
l.value && (u.value = t.interval);
|
|
58
58
|
}
|
|
59
59
|
function y() {
|
|
60
|
-
|
|
60
|
+
t.pauseOnHidden && (document.hidden ? n() : l.value && v());
|
|
61
61
|
}
|
|
62
62
|
return M(() => {
|
|
63
|
-
l.value &&
|
|
63
|
+
l.value && t.interval > 0 && (v(), t.pauseOnHidden && document.addEventListener("visibilitychange", y));
|
|
64
64
|
}), ne(() => {
|
|
65
65
|
n(), document.removeEventListener("visibilitychange", y);
|
|
66
66
|
}), { enabled: l, countdown: u, toggle: c, resetCountdown: i };
|
|
67
67
|
}
|
|
68
|
-
function ue(
|
|
69
|
-
const o = C(!1), l = C([]), u = C(0), { filters:
|
|
68
|
+
function ue(t) {
|
|
69
|
+
const o = C(!1), l = C([]), u = C(0), { filters: p, onSearch: v, onReset: n, setFilter: c } = oe(t.queryFields ?? []), { currentPage: i, pageSize: y, pagination: S, onPageChange: F, resetPage: U } = le(t.pageSize ?? 10), R = t.autoRefresh ?? {
|
|
70
70
|
interval: 0,
|
|
71
71
|
enabled: !1
|
|
72
72
|
}, { enabled: V, countdown: I, toggle: $, resetCountdown: q } = re(
|
|
@@ -82,7 +82,7 @@ function ue(e) {
|
|
|
82
82
|
page: i.value,
|
|
83
83
|
pageSize: y.value,
|
|
84
84
|
filters: v()
|
|
85
|
-
}, P = await
|
|
85
|
+
}, P = await t.fetchData(w);
|
|
86
86
|
l.value = P.list, u.value = P.total;
|
|
87
87
|
} catch (w) {
|
|
88
88
|
console.error("[VueExportTable] fetch error:", w);
|
|
@@ -91,22 +91,22 @@ function ue(e) {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
function s() {
|
|
94
|
-
|
|
94
|
+
U(), r(), q();
|
|
95
95
|
}
|
|
96
96
|
function z() {
|
|
97
|
-
n(),
|
|
97
|
+
n(), U(), r();
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function x(w, P) {
|
|
100
100
|
F(w, P), r(), q();
|
|
101
101
|
}
|
|
102
102
|
return M(() => {
|
|
103
|
-
|
|
103
|
+
t.immediate !== !1 && r();
|
|
104
104
|
}), {
|
|
105
105
|
// 状态
|
|
106
106
|
loading: o,
|
|
107
107
|
data: l,
|
|
108
108
|
total: u,
|
|
109
|
-
filters:
|
|
109
|
+
filters: p,
|
|
110
110
|
pagination: S,
|
|
111
111
|
currentPage: i,
|
|
112
112
|
pageSize: y,
|
|
@@ -115,7 +115,7 @@ function ue(e) {
|
|
|
115
115
|
handleReset: z,
|
|
116
116
|
setFilter: c,
|
|
117
117
|
// 分页
|
|
118
|
-
handlePageChange:
|
|
118
|
+
handlePageChange: x,
|
|
119
119
|
// 刷新
|
|
120
120
|
refresh: r,
|
|
121
121
|
// 自动刷新
|
|
@@ -124,18 +124,18 @@ function ue(e) {
|
|
|
124
124
|
toggleAutoRefresh: $
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
|
-
const se = { class: "download-table-wrapper" }, ce = {
|
|
127
|
+
const se = { class: "vet-download-table-wrapper" }, ce = {
|
|
128
128
|
key: 0,
|
|
129
|
-
class: "query-form-wrapper"
|
|
130
|
-
}, ie = { class: "toolbar-wrapper" }, de = { class: "toolbar-left" },
|
|
129
|
+
class: "vet-query-form-wrapper"
|
|
130
|
+
}, ie = { class: "vet-toolbar-wrapper" }, de = { class: "vet-toolbar-left" }, he = {
|
|
131
131
|
key: 0,
|
|
132
|
-
class: "table-title"
|
|
133
|
-
},
|
|
132
|
+
class: "vet-table-title"
|
|
133
|
+
}, pe = { class: "vet-toolbar-right" }, ve = {
|
|
134
134
|
key: 1,
|
|
135
|
-
class: "countdown-text"
|
|
135
|
+
class: "vet-countdown-text"
|
|
136
136
|
}, me = ["onClick"], fe = {
|
|
137
137
|
key: 1,
|
|
138
|
-
class: "pagination-wrapper"
|
|
138
|
+
class: "vet-pagination-wrapper"
|
|
139
139
|
}, ge = /* @__PURE__ */ Y({
|
|
140
140
|
__name: "DownloadTable",
|
|
141
141
|
props: {
|
|
@@ -150,10 +150,10 @@ const se = { class: "download-table-wrapper" }, ce = {
|
|
|
150
150
|
pageSize: { default: 10 },
|
|
151
151
|
showIndex: { type: Boolean, default: !1 }
|
|
152
152
|
},
|
|
153
|
-
setup(
|
|
154
|
-
const o =
|
|
153
|
+
setup(t) {
|
|
154
|
+
const o = t, l = (r) => o.download ? o.download.canDownload ? o.download.canDownload(r) : r.status === "completed" : !1, {
|
|
155
155
|
loading: u,
|
|
156
|
-
data:
|
|
156
|
+
data: p,
|
|
157
157
|
total: v,
|
|
158
158
|
filters: n,
|
|
159
159
|
currentPage: c,
|
|
@@ -161,7 +161,7 @@ const se = { class: "download-table-wrapper" }, ce = {
|
|
|
161
161
|
handleSearch: y,
|
|
162
162
|
handleReset: S,
|
|
163
163
|
handlePageChange: F,
|
|
164
|
-
refresh:
|
|
164
|
+
refresh: U,
|
|
165
165
|
autoRefreshEnabled: R,
|
|
166
166
|
countdown: V,
|
|
167
167
|
toggleAutoRefresh: I
|
|
@@ -183,15 +183,15 @@ const se = { class: "download-table-wrapper" }, ce = {
|
|
|
183
183
|
}), [...r, ...o.columns];
|
|
184
184
|
}), q = L(() => {
|
|
185
185
|
const r = $.value.reduce((s, z) => {
|
|
186
|
-
const
|
|
187
|
-
return s +
|
|
186
|
+
const x = typeof z.width == "number" ? z.width : 0;
|
|
187
|
+
return s + x;
|
|
188
188
|
}, 0);
|
|
189
189
|
return r > 0 ? { x: r } : void 0;
|
|
190
190
|
});
|
|
191
191
|
return (r, s) => {
|
|
192
|
-
const z = m("a-input"),
|
|
192
|
+
const z = m("a-input"), x = m("a-input-number"), w = m("a-select"), P = m("a-date-picker"), Q = m("a-range-picker"), N = m("a-form-item"), B = m("a-button"), H = m("a-space"), W = m("a-form"), G = m("a-switch"), J = m("a-table"), X = m("a-pagination");
|
|
193
193
|
return h(), b("div", se, [
|
|
194
|
-
|
|
194
|
+
t.queryFields && t.queryFields.length > 0 ? (h(), b("div", ce, [
|
|
195
195
|
E(r.$slots, "query-form", {
|
|
196
196
|
filters: a(n),
|
|
197
197
|
handleSearch: a(y),
|
|
@@ -202,42 +202,42 @@ const se = { class: "download-table-wrapper" }, ce = {
|
|
|
202
202
|
model: a(n)
|
|
203
203
|
}, {
|
|
204
204
|
default: g(() => [
|
|
205
|
-
(h(!0), b(Z, null, ee(
|
|
206
|
-
key:
|
|
207
|
-
label:
|
|
205
|
+
(h(!0), b(Z, null, ee(t.queryFields, (e) => (h(), k(N, {
|
|
206
|
+
key: e.name,
|
|
207
|
+
label: e.label
|
|
208
208
|
}, {
|
|
209
209
|
default: g(() => [
|
|
210
|
-
|
|
210
|
+
e.type === "input" ? (h(), k(z, {
|
|
211
211
|
key: 0,
|
|
212
|
-
value: a(n)[
|
|
213
|
-
"onUpdate:value": (
|
|
214
|
-
placeholder:
|
|
212
|
+
value: a(n)[e.name],
|
|
213
|
+
"onUpdate:value": (d) => a(n)[e.name] = d,
|
|
214
|
+
placeholder: e.placeholder || `请输入${e.label}`,
|
|
215
215
|
"allow-clear": ""
|
|
216
|
-
}, null, 8, ["value", "onUpdate:value", "placeholder"])) :
|
|
216
|
+
}, null, 8, ["value", "onUpdate:value", "placeholder"])) : e.type === "number" ? (h(), k(x, {
|
|
217
217
|
key: 1,
|
|
218
|
-
value: a(n)[
|
|
219
|
-
"onUpdate:value": (
|
|
220
|
-
placeholder:
|
|
218
|
+
value: a(n)[e.name],
|
|
219
|
+
"onUpdate:value": (d) => a(n)[e.name] = d,
|
|
220
|
+
placeholder: e.placeholder || `请输入${e.label}`,
|
|
221
221
|
style: { width: "180px" }
|
|
222
|
-
}, null, 8, ["value", "onUpdate:value", "placeholder"])) :
|
|
222
|
+
}, null, 8, ["value", "onUpdate:value", "placeholder"])) : e.type === "select" ? (h(), k(w, {
|
|
223
223
|
key: 2,
|
|
224
|
-
value: a(n)[
|
|
225
|
-
"onUpdate:value": (
|
|
226
|
-
placeholder:
|
|
227
|
-
options:
|
|
224
|
+
value: a(n)[e.name],
|
|
225
|
+
"onUpdate:value": (d) => a(n)[e.name] = d,
|
|
226
|
+
placeholder: e.placeholder || `请选择${e.label}`,
|
|
227
|
+
options: e.options,
|
|
228
228
|
"allow-clear": "",
|
|
229
229
|
style: { "min-width": "150px" }
|
|
230
|
-
}, null, 8, ["value", "onUpdate:value", "placeholder", "options"])) :
|
|
230
|
+
}, null, 8, ["value", "onUpdate:value", "placeholder", "options"])) : e.type === "datePicker" ? (h(), k(P, {
|
|
231
231
|
key: 3,
|
|
232
|
-
value: a(n)[
|
|
233
|
-
"onUpdate:value": (
|
|
234
|
-
placeholder:
|
|
232
|
+
value: a(n)[e.name],
|
|
233
|
+
"onUpdate:value": (d) => a(n)[e.name] = d,
|
|
234
|
+
placeholder: e.placeholder || `请选择${e.label}`,
|
|
235
235
|
style: { width: "180px" }
|
|
236
|
-
}, null, 8, ["value", "onUpdate:value", "placeholder"])) :
|
|
236
|
+
}, null, 8, ["value", "onUpdate:value", "placeholder"])) : e.type === "rangePicker" ? (h(), k(Q, {
|
|
237
237
|
key: 4,
|
|
238
|
-
value: a(n)[
|
|
239
|
-
"onUpdate:value": (
|
|
240
|
-
placeholder: [
|
|
238
|
+
value: a(n)[e.name],
|
|
239
|
+
"onUpdate:value": (d) => a(n)[e.name] = d,
|
|
240
|
+
placeholder: [e.placeholder || "开始日期", e.placeholder || "结束日期"],
|
|
241
241
|
style: { width: "240px" }
|
|
242
242
|
}, null, 8, ["value", "onUpdate:value", "placeholder"])) : _("", !0)
|
|
243
243
|
]),
|
|
@@ -245,7 +245,7 @@ const se = { class: "download-table-wrapper" }, ce = {
|
|
|
245
245
|
}, 1032, ["label"]))), 128)),
|
|
246
246
|
f(N, null, {
|
|
247
247
|
default: g(() => [
|
|
248
|
-
f(
|
|
248
|
+
f(H, null, {
|
|
249
249
|
default: g(() => [
|
|
250
250
|
f(B, {
|
|
251
251
|
type: "primary",
|
|
@@ -271,26 +271,26 @@ const se = { class: "download-table-wrapper" }, ce = {
|
|
|
271
271
|
]),
|
|
272
272
|
_: 1
|
|
273
273
|
}, 8, ["model"])
|
|
274
|
-
]
|
|
274
|
+
])
|
|
275
275
|
])) : _("", !0),
|
|
276
276
|
D("div", ie, [
|
|
277
277
|
E(r.$slots, "toolbar", {
|
|
278
278
|
loading: a(u),
|
|
279
|
-
refresh: a(
|
|
279
|
+
refresh: a(U)
|
|
280
280
|
}, () => [
|
|
281
281
|
D("div", de, [
|
|
282
|
-
|
|
282
|
+
t.title ? (h(), b("span", he, A(t.title), 1)) : _("", !0)
|
|
283
283
|
]),
|
|
284
|
-
D("div",
|
|
285
|
-
f(
|
|
284
|
+
D("div", pe, [
|
|
285
|
+
f(H, null, {
|
|
286
286
|
default: g(() => [
|
|
287
287
|
f(B, {
|
|
288
288
|
loading: a(u),
|
|
289
|
-
onClick: a(
|
|
289
|
+
onClick: a(U)
|
|
290
290
|
}, {
|
|
291
291
|
default: g(() => [...s[5] || (s[5] = [
|
|
292
292
|
D("svg", {
|
|
293
|
-
class: "icon-svg",
|
|
293
|
+
class: "vet-icon-svg",
|
|
294
294
|
viewBox: "64 64 896 896",
|
|
295
295
|
width: "1em",
|
|
296
296
|
height: "1em",
|
|
@@ -302,61 +302,61 @@ const se = { class: "download-table-wrapper" }, ce = {
|
|
|
302
302
|
])]),
|
|
303
303
|
_: 1
|
|
304
304
|
}, 8, ["loading", "onClick"]),
|
|
305
|
-
|
|
305
|
+
t.autoRefresh ? (h(), k(G, {
|
|
306
306
|
key: 0,
|
|
307
307
|
checked: a(R),
|
|
308
|
-
"onUpdate:checked": s[0] || (s[0] = (
|
|
308
|
+
"onUpdate:checked": s[0] || (s[0] = (e) => K(R) ? R.value = e : null),
|
|
309
309
|
"checked-children": "自动刷新",
|
|
310
310
|
"un-checked-children": "自动刷新",
|
|
311
311
|
onChange: a(I)
|
|
312
312
|
}, null, 8, ["checked", "onChange"])) : _("", !0),
|
|
313
|
-
|
|
313
|
+
t.autoRefresh && a(R) ? (h(), b("span", ve, A(a(V)) + "s ", 1)) : _("", !0)
|
|
314
314
|
]),
|
|
315
315
|
_: 1
|
|
316
316
|
})
|
|
317
317
|
])
|
|
318
|
-
]
|
|
318
|
+
])
|
|
319
319
|
]),
|
|
320
320
|
f(J, te({
|
|
321
|
-
dataSource: a(
|
|
321
|
+
dataSource: a(p),
|
|
322
322
|
columns: a($),
|
|
323
323
|
loading: a(u),
|
|
324
324
|
pagination: !1,
|
|
325
|
-
rowKey:
|
|
326
|
-
bordered:
|
|
325
|
+
rowKey: t.rowKey,
|
|
326
|
+
bordered: t.bordered,
|
|
327
327
|
scroll: a(q)
|
|
328
328
|
}, r.$attrs), {
|
|
329
|
-
bodyCell: g(({ column:
|
|
330
|
-
|
|
329
|
+
bodyCell: g(({ column: e, record: d, index: O, text: j }) => [
|
|
330
|
+
e.dataIndex === "action" ? E(r.$slots, "action", {
|
|
331
331
|
key: 0,
|
|
332
|
-
record:
|
|
333
|
-
index:
|
|
332
|
+
record: d,
|
|
333
|
+
index: O
|
|
334
334
|
}, () => [
|
|
335
|
-
|
|
335
|
+
t.download && l(d) ? (h(), b("a", {
|
|
336
336
|
key: 0,
|
|
337
|
-
onClick: (
|
|
337
|
+
onClick: (ye) => t.download.handleDownload(d)
|
|
338
338
|
}, "下载", 8, me)) : _("", !0)
|
|
339
|
-
]
|
|
339
|
+
]) : E(r.$slots, e.dataIndex, {
|
|
340
340
|
key: 1,
|
|
341
|
-
record:
|
|
342
|
-
index:
|
|
341
|
+
record: d,
|
|
342
|
+
index: O,
|
|
343
343
|
text: j
|
|
344
344
|
}, () => [
|
|
345
345
|
T(A(j), 1)
|
|
346
|
-
]
|
|
346
|
+
])
|
|
347
347
|
]),
|
|
348
348
|
_: 3
|
|
349
349
|
}, 16, ["dataSource", "columns", "loading", "rowKey", "bordered", "scroll"]),
|
|
350
350
|
a(v) > 0 ? (h(), b("div", fe, [
|
|
351
351
|
f(X, {
|
|
352
352
|
current: a(c),
|
|
353
|
-
"onUpdate:current": s[1] || (s[1] = (
|
|
353
|
+
"onUpdate:current": s[1] || (s[1] = (e) => K(c) ? c.value = e : null),
|
|
354
354
|
pageSize: a(i),
|
|
355
|
-
"onUpdate:pageSize": s[2] || (s[2] = (
|
|
355
|
+
"onUpdate:pageSize": s[2] || (s[2] = (e) => K(i) ? i.value = e : null),
|
|
356
356
|
total: a(v),
|
|
357
357
|
"show-size-changer": !0,
|
|
358
358
|
"show-quick-jumper": !0,
|
|
359
|
-
"show-total": (
|
|
359
|
+
"show-total": (e) => `共 ${e} 条`,
|
|
360
360
|
onChange: a(F),
|
|
361
361
|
onShowSizeChange: a(F)
|
|
362
362
|
}, null, 8, ["current", "pageSize", "total", "show-total", "onChange", "onShowSizeChange"])
|
|
@@ -364,20 +364,15 @@ const se = { class: "download-table-wrapper" }, ce = {
|
|
|
364
364
|
]);
|
|
365
365
|
};
|
|
366
366
|
}
|
|
367
|
-
}),
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
l[u] = d;
|
|
371
|
-
return l;
|
|
372
|
-
}, we = /* @__PURE__ */ ye(ge, [["__scopeId", "data-v-13092ac7"]]), Ce = {
|
|
373
|
-
install(e) {
|
|
374
|
-
e.component("DownloadTable", we);
|
|
367
|
+
}), ke = {
|
|
368
|
+
install(t) {
|
|
369
|
+
t.component("DownloadTable", ge);
|
|
375
370
|
}
|
|
376
371
|
};
|
|
377
372
|
export {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
373
|
+
ge as DownloadTable,
|
|
374
|
+
ke as VueExportTable,
|
|
375
|
+
ke as default,
|
|
381
376
|
re as useAutoRefresh,
|
|
382
377
|
le as usePagination,
|
|
383
378
|
oe as useQuery,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(u,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("vue-demi")):typeof define=="function"&&define.amd?define(["exports","vue","vue-demi"],e):(u=typeof globalThis<"u"?globalThis:u||self,e(u.VueExportTable={},u.Vue,u.VueDemi))})(this,(function(u,e,p){"use strict";function T(
|
|
1
|
+
(function(u,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("vue-demi")):typeof define=="function"&&define.amd?define(["exports","vue","vue-demi"],e):(u=typeof globalThis<"u"?globalThis:u||self,e(u.VueExportTable={},u.Vue,u.VueDemi))})(this,(function(u,e,p){"use strict";function T(n){const a=p.reactive({});function l(){n.forEach(o=>{o.defaultValue!==void 0?a[o.name]=o.defaultValue:a[o.name]=o.type==="rangePicker"?[]:void 0})}l();function c(){const o={};return Object.keys(a).forEach(d=>{const i=a[d];if(i!=null&&i!==""){if(Array.isArray(i)&&i.length===0)return;o[d]=i}}),o}function h(){l()}function m(o,d){a[o]=d}return{filters:a,onSearch:c,onReset:h,setFilter:m}}function P(n=10){const a=p.ref(1),l=p.ref(n),c=p.computed(()=>({current:a.value,pageSize:l.value}));function h(o,d){a.value=o,d!==l.value&&(l.value=d,a.value=1)}function m(){a.value=1}return{currentPage:a,pageSize:l,pagination:c,onPageChange:h,resetPage:m}}function z(n,a){const l=p.ref(n.enabled??n.interval>0),c=p.ref(n.interval);let h=null;function m(){o(),!(!l.value||n.interval<=0)&&(c.value=n.interval,h=setInterval(()=>{c.value-=1,c.value<=0&&(c.value=n.interval,a())},1e3))}function o(){h&&(clearInterval(h),h=null)}function d(y){l.value=y??!l.value,l.value?m():(o(),c.value=n.interval)}function i(){l.value&&(c.value=n.interval)}function g(){n.pauseOnHidden&&(document.hidden?o():l.value&&m())}return p.onMounted(()=>{l.value&&n.interval>0&&(m(),n.pauseOnHidden&&document.addEventListener("visibilitychange",g))}),p.onUnmounted(()=>{o(),document.removeEventListener("visibilitychange",g)}),{enabled:l,countdown:c,toggle:d,resetCountdown:i}}function U(n){const a=p.ref(!1),l=p.ref([]),c=p.ref(0),{filters:h,onSearch:m,onReset:o,setFilter:d}=T(n.queryFields??[]),{currentPage:i,pageSize:g,pagination:y,onPageChange:V,resetPage:_}=P(n.pageSize??10),w=n.autoRefresh??{interval:0,enabled:!1},{enabled:E,countdown:R,toggle:B,resetCountdown:N}=z(w,()=>{r()});async function r(){a.value=!0;try{const k={page:i.value,pageSize:g.value,filters:m()},b=await n.fetchData(k);l.value=b.list,c.value=b.total}catch(k){console.error("[VueExportTable] fetch error:",k)}finally{a.value=!1}}function s(){_(),r(),N()}function C(){o(),_(),r()}function S(k,b){V(k,b),r(),N()}return p.onMounted(()=>{n.immediate!==!1&&r()}),{loading:a,data:l,total:c,filters:h,pagination:y,currentPage:i,pageSize:g,handleSearch:s,handleReset:C,setFilter:d,handlePageChange:S,refresh:r,autoRefreshEnabled:E,countdown:R,toggleAutoRefresh:B}}const j={class:"vet-download-table-wrapper"},K={key:0,class:"vet-query-form-wrapper"},L={class:"vet-toolbar-wrapper"},O={class:"vet-toolbar-left"},D={key:0,class:"vet-table-title"},H={class:"vet-toolbar-right"},Q={key:1,class:"vet-countdown-text"},W=["onClick"],G={key:1,class:"vet-pagination-wrapper"},q=e.defineComponent({__name:"DownloadTable",props:{columns:{},queryFields:{},fetchData:{},download:{default:void 0},autoRefresh:{},rowKey:{type:[String,Function],default:"id"},title:{},bordered:{type:Boolean,default:!0},pageSize:{default:10},showIndex:{type:Boolean,default:!1}},setup(n){const a=n,l=r=>a.download?a.download.canDownload?a.download.canDownload(r):r.status==="completed":!1,{loading:c,data:h,total:m,filters:o,currentPage:d,pageSize:i,handleSearch:g,handleReset:y,handlePageChange:V,refresh:_,autoRefreshEnabled:w,countdown:E,toggleAutoRefresh:R}=U({fetchData:a.fetchData,queryFields:a.queryFields,pageSize:a.pageSize,autoRefresh:a.autoRefresh,immediate:!0}),B=p.computed(()=>{const r=[];return a.showIndex&&r.push({title:"序号",dataIndex:"index",key:"index",width:80,align:"center",customRender:({index:s})=>(d.value-1)*i.value+s+1}),[...r,...a.columns]}),N=p.computed(()=>{const r=B.value.reduce((s,C)=>{const S=typeof C.width=="number"?C.width:0;return s+S},0);return r>0?{x:r}:void 0});return(r,s)=>{const C=e.resolveComponent("a-input"),S=e.resolveComponent("a-input-number"),k=e.resolveComponent("a-select"),b=e.resolveComponent("a-date-picker"),J=e.resolveComponent("a-range-picker"),$=e.resolveComponent("a-form-item"),x=e.resolveComponent("a-button"),I=e.resolveComponent("a-space"),X=e.resolveComponent("a-form"),Y=e.resolveComponent("a-switch"),Z=e.resolveComponent("a-table"),v=e.resolveComponent("a-pagination");return e.openBlock(),e.createElementBlock("div",j,[n.queryFields&&n.queryFields.length>0?(e.openBlock(),e.createElementBlock("div",K,[e.renderSlot(r.$slots,"query-form",{filters:e.unref(o),handleSearch:e.unref(g),handleReset:e.unref(y)},()=>[e.createVNode(X,{layout:"inline",model:e.unref(o)},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.queryFields,t=>(e.openBlock(),e.createBlock($,{key:t.name,label:t.label},{default:e.withCtx(()=>[t.type==="input"?(e.openBlock(),e.createBlock(C,{key:0,value:e.unref(o)[t.name],"onUpdate:value":f=>e.unref(o)[t.name]=f,placeholder:t.placeholder||`请输入${t.label}`,"allow-clear":""},null,8,["value","onUpdate:value","placeholder"])):t.type==="number"?(e.openBlock(),e.createBlock(S,{key:1,value:e.unref(o)[t.name],"onUpdate:value":f=>e.unref(o)[t.name]=f,placeholder:t.placeholder||`请输入${t.label}`,style:{width:"180px"}},null,8,["value","onUpdate:value","placeholder"])):t.type==="select"?(e.openBlock(),e.createBlock(k,{key:2,value:e.unref(o)[t.name],"onUpdate:value":f=>e.unref(o)[t.name]=f,placeholder:t.placeholder||`请选择${t.label}`,options:t.options,"allow-clear":"",style:{"min-width":"150px"}},null,8,["value","onUpdate:value","placeholder","options"])):t.type==="datePicker"?(e.openBlock(),e.createBlock(b,{key:3,value:e.unref(o)[t.name],"onUpdate:value":f=>e.unref(o)[t.name]=f,placeholder:t.placeholder||`请选择${t.label}`,style:{width:"180px"}},null,8,["value","onUpdate:value","placeholder"])):t.type==="rangePicker"?(e.openBlock(),e.createBlock(J,{key:4,value:e.unref(o)[t.name],"onUpdate:value":f=>e.unref(o)[t.name]=f,placeholder:[t.placeholder||"开始日期",t.placeholder||"结束日期"],style:{width:"240px"}},null,8,["value","onUpdate:value","placeholder"])):e.createCommentVNode("",!0)]),_:2},1032,["label"]))),128)),e.createVNode($,null,{default:e.withCtx(()=>[e.createVNode(I,null,{default:e.withCtx(()=>[e.createVNode(x,{type:"primary",onClick:e.unref(g)},{default:e.withCtx(()=>[...s[3]||(s[3]=[e.createTextVNode("查询",-1)])]),_:1},8,["onClick"]),e.createVNode(x,{onClick:e.unref(y)},{default:e.withCtx(()=>[...s[4]||(s[4]=[e.createTextVNode("重置",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1})]),_:1},8,["model"])])])):e.createCommentVNode("",!0),e.createElementVNode("div",L,[e.renderSlot(r.$slots,"toolbar",{loading:e.unref(c),refresh:e.unref(_)},()=>[e.createElementVNode("div",O,[n.title?(e.openBlock(),e.createElementBlock("span",D,e.toDisplayString(n.title),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",H,[e.createVNode(I,null,{default:e.withCtx(()=>[e.createVNode(x,{loading:e.unref(c),onClick:e.unref(_)},{default:e.withCtx(()=>[...s[5]||(s[5]=[e.createElementVNode("svg",{class:"vet-icon-svg",viewBox:"64 64 896 896",width:"1em",height:"1em",fill:"currentColor"},[e.createElementVNode("path",{d:"M909.1 209.3l-56.4 44.1C775.8 155.1 653.5 96 512 96 282.7 96 96 282.7 96 512s186.7 416 416 416c165.3 0 309.1-96.4 376-236.1 8.3-17.2-4.3-37.1-23.1-37.1H745.6c-9.2 0-17.2 5.8-20.3 14.3C680.5 773.5 600.5 832 512 832c-176.7 0-320-143.3-320-320s143.3-320 320-320c88.5 0 168.5 36.1 226.4 94.3L704 356.3c-4.7-4.7-1.3-12.7 5.3-13.1l193.7-12.5c6.6-.4 12.3 4.9 12.3 11.5v193.7c0 6.6-8 10-12.7 5.3z"})],-1),e.createTextVNode(" 刷新 ",-1)])]),_:1},8,["loading","onClick"]),n.autoRefresh?(e.openBlock(),e.createBlock(Y,{key:0,checked:e.unref(w),"onUpdate:checked":s[0]||(s[0]=t=>e.isRef(w)?w.value=t:null),"checked-children":"自动刷新","un-checked-children":"自动刷新",onChange:e.unref(R)},null,8,["checked","onChange"])):e.createCommentVNode("",!0),n.autoRefresh&&e.unref(w)?(e.openBlock(),e.createElementBlock("span",Q,e.toDisplayString(e.unref(E))+"s ",1)):e.createCommentVNode("",!0)]),_:1})])])]),e.createVNode(Z,e.mergeProps({dataSource:e.unref(h),columns:e.unref(B),loading:e.unref(c),pagination:!1,rowKey:n.rowKey,bordered:n.bordered,scroll:e.unref(N)},r.$attrs),{bodyCell:e.withCtx(({column:t,record:f,index:A,text:M})=>[t.dataIndex==="action"?e.renderSlot(r.$slots,"action",{key:0,record:f,index:A},()=>[n.download&&l(f)?(e.openBlock(),e.createElementBlock("a",{key:0,onClick:ee=>n.download.handleDownload(f)},"下载",8,W)):e.createCommentVNode("",!0)]):e.renderSlot(r.$slots,t.dataIndex,{key:1,record:f,index:A,text:M},()=>[e.createTextVNode(e.toDisplayString(M),1)])]),_:3},16,["dataSource","columns","loading","rowKey","bordered","scroll"]),e.unref(m)>0?(e.openBlock(),e.createElementBlock("div",G,[e.createVNode(v,{current:e.unref(d),"onUpdate:current":s[1]||(s[1]=t=>e.isRef(d)?d.value=t:null),pageSize:e.unref(i),"onUpdate:pageSize":s[2]||(s[2]=t=>e.isRef(i)?i.value=t:null),total:e.unref(m),"show-size-changer":!0,"show-quick-jumper":!0,"show-total":t=>`共 ${t} 条`,onChange:e.unref(V),onShowSizeChange:e.unref(V)},null,8,["current","pageSize","total","show-total","onChange","onShowSizeChange"])])):e.createCommentVNode("",!0)])}}}),F={install(n){n.component("DownloadTable",q)}};u.DownloadTable=q,u.VueExportTable=F,u.default=F,u.useAutoRefresh=z,u.usePagination=P,u.useQuery=T,u.useTable=U,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("vue-demi"),t=require("vue");function D(e){const a=u.reactive({});function n(){e.forEach(l=>{l.defaultValue!==void 0?a[l.name]=l.defaultValue:a[l.name]=l.type==="rangePicker"?[]:void 0})}n();function s(){const l={};return Object.keys(a).forEach(d=>{const i=a[d];if(i!=null&&i!==""){if(Array.isArray(i)&&i.length===0)return;l[d]=i}}),l}function c(){n()}function m(l,d){a[l]=d}return{filters:a,onSearch:s,onReset:c,setFilter:m}}function E(e=10){const a=u.ref(1),n=u.ref(e),s=u.computed(()=>({current:a.value,pageSize:n.value}));function c(l,d){a.value=l,d!==n.value&&(n.value=d,a.value=1)}function m(){a.value=1}return{currentPage:a,pageSize:n,pagination:s,onPageChange:c,resetPage:m}}function N(e,a){const n=u.ref(e.enabled??e.interval>0),s=u.ref(e.interval);let c=null;function m(){l(),!(!n.value||e.interval<=0)&&(s.value=e.interval,c=setInterval(()=>{s.value-=1,s.value<=0&&(s.value=e.interval,a())},1e3))}function l(){c&&(clearInterval(c),c=null)}function d(g){n.value=g??!n.value,n.value?m():(l(),s.value=e.interval)}function i(){n.value&&(s.value=e.interval)}function p(){e.pauseOnHidden&&(document.hidden?l():n.value&&m())}return u.onMounted(()=>{n.value&&e.interval>0&&(m(),e.pauseOnHidden&&document.addEventListener("visibilitychange",p))}),u.onUnmounted(()=>{l(),document.removeEventListener("visibilitychange",p)}),{enabled:n,countdown:s,toggle:d,resetCountdown:i}}function R(e){const a=u.ref(!1),n=u.ref([]),s=u.ref(0),{filters:c,onSearch:m,onReset:l,setFilter:d}=D(e.queryFields??[]),{currentPage:i,pageSize:p,pagination:g,onPageChange:v,resetPage:h}=E(e.pageSize??10),y=e.autoRefresh??{interval:0,enabled:!1},{enabled:C,countdown:k,toggle:b,resetCountdown:w}=N(y,()=>{o()});async function o(){a.value=!0;try{const V={page:i.value,pageSize:p.value,filters:m()},B=await e.fetchData(V);n.value=B.list,s.value=B.total}catch(V){console.error("[VueExportTable] fetch error:",V)}finally{a.value=!1}}function r(){h(),o(),w()}function f(){l(),h(),o()}function S(V,B){v(V,B),o(),w()}return u.onMounted(()=>{e.immediate!==!1&&o()}),{loading:a,data:n,total:s,filters:c,pagination:g,currentPage:i,pageSize:p,handleSearch:r,handleReset:f,setFilter:d,handlePageChange:S,refresh:o,autoRefreshEnabled:C,countdown:k,toggleAutoRefresh:b}}const $=u.defineComponent({name:"DownloadTable",props:{columns:{type:Array,required:!0},queryFields:{type:Array,default:()=>[]},fetchData:{type:Function,required:!0},download:{type:Object,default:void 0},autoRefresh:{type:Object,default:void 0},rowKey:{type:[String,Function],default:"id"},title:{type:String,default:""},bordered:{type:Boolean,default:!0},pageSize:{type:Number,default:10},showIndex:{type:Boolean,default:!1},immediate:{type:Boolean,default:!0}},setup(e,{slots:a}){const{loading:n,data:s,total:c,filters:m,currentPage:l,pageSize:d,handleSearch:i,handleReset:p,handlePageChange:g,refresh:v,autoRefreshEnabled:h,countdown:y,toggleAutoRefresh:C}=R({fetchData:e.fetchData,queryFields:e.queryFields,pageSize:e.pageSize,autoRefresh:e.autoRefresh,immediate:e.immediate}),k=u.computed(()=>{const o=[];return e.showIndex&&o.push({title:"序号",dataIndex:"index",key:"index",width:80,align:"center",customRender:({index:r})=>(l.value-1)*d.value+r+1}),[...o,...e.columns]}),b=u.computed(()=>{const o=k.value.reduce((r,f)=>{const S=typeof f.width=="number"?f.width:0;return r+S},0);return o>0?{x:o}:void 0}),w=u.computed(()=>{const o=["query-form","toolbar"],r={};return Object.keys(a).forEach(f=>{o.includes(f)||(r[f]=!0)}),r});return{loading:n,data:s,total:c,filters:m,currentPage:l,pageSize:d,handleSearch:i,handleReset:p,handlePageChange:g,refresh:v,download:u.computed(()=>e.download),canDownload:o=>e.download?e.download.canDownload?e.download.canDownload(o):o&&o.status==="completed":!1,autoRefreshEnabled:h,countdown:y,toggleAutoRefresh:C,computedColumns:k,scroll:b,filteredSlots:w}}}),q=(e,a)=>{const n=e.__vccOpts||e;for(const[s,c]of a)n[s]=c;return n},z={class:"download-table-wrapper"},F={key:0,class:"query-form-wrapper"},U={class:"toolbar-wrapper"},_={class:"toolbar-left"},A={key:0,class:"table-title"},O={class:"toolbar-right"},j={key:1,class:"countdown-text"},I={key:1,class:"pagination-wrapper"};function L(e,a,n,s,c,m){const l=t.resolveComponent("a-input"),d=t.resolveComponent("a-input-number"),i=t.resolveComponent("a-select"),p=t.resolveComponent("a-date-picker"),g=t.resolveComponent("a-range-picker"),v=t.resolveComponent("a-form-item"),h=t.resolveComponent("a-button"),y=t.resolveComponent("a-space"),C=t.resolveComponent("a-form"),k=t.resolveComponent("a-switch"),b=t.resolveComponent("a-table"),w=t.resolveComponent("a-pagination");return t.openBlock(),t.createElementBlock("div",z,[e.queryFields&&e.queryFields.length>0?(t.openBlock(),t.createElementBlock("div",F,[t.renderSlot(e.$slots,"query-form",{filters:e.filters,handleSearch:e.handleSearch,handleReset:e.handleReset},()=>[t.createVNode(C,{layout:"inline",model:e.filters},{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.queryFields,o=>(t.openBlock(),t.createBlock(v,{key:o.name,label:o.label},{default:t.withCtx(()=>[o.type==="input"?(t.openBlock(),t.createBlock(l,{key:0,modelValue:e.filters[o.name],"onUpdate:modelValue":r=>e.filters[o.name]=r,placeholder:o.placeholder||`请输入${o.label}`,"allow-clear":""},null,8,["modelValue","onUpdate:modelValue","placeholder"])):o.type==="number"?(t.openBlock(),t.createBlock(d,{key:1,modelValue:e.filters[o.name],"onUpdate:modelValue":r=>e.filters[o.name]=r,placeholder:o.placeholder||`请输入${o.label}`,style:{width:"180px"}},null,8,["modelValue","onUpdate:modelValue","placeholder"])):o.type==="select"?(t.openBlock(),t.createBlock(i,{key:2,modelValue:e.filters[o.name],"onUpdate:modelValue":r=>e.filters[o.name]=r,placeholder:o.placeholder||`请选择${o.label}`,options:o.options,"allow-clear":"",style:{"min-width":"150px"}},null,8,["modelValue","onUpdate:modelValue","placeholder","options"])):o.type==="datePicker"?(t.openBlock(),t.createBlock(p,{key:3,modelValue:e.filters[o.name],"onUpdate:modelValue":r=>e.filters[o.name]=r,placeholder:o.placeholder||`请选择${o.label}`,style:{width:"180px"}},null,8,["modelValue","onUpdate:modelValue","placeholder"])):o.type==="rangePicker"?(t.openBlock(),t.createBlock(g,{key:4,modelValue:e.filters[o.name],"onUpdate:modelValue":r=>e.filters[o.name]=r,placeholder:[o.placeholder||"开始日期",o.placeholder||"结束日期"],style:{width:"240px"}},null,8,["modelValue","onUpdate:modelValue","placeholder"])):t.createCommentVNode("",!0)]),_:2},1032,["label"]))),128)),t.createVNode(v,null,{default:t.withCtx(()=>[t.createVNode(y,null,{default:t.withCtx(()=>[t.createVNode(h,{type:"primary",onClick:e.handleSearch},{default:t.withCtx(()=>[...a[1]||(a[1]=[t.createTextVNode("查询",-1)])]),_:1},8,["onClick"]),t.createVNode(h,{onClick:e.handleReset},{default:t.withCtx(()=>[...a[2]||(a[2]=[t.createTextVNode("重置",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1})]),_:1},8,["model"])],!0)])):t.createCommentVNode("",!0),t.createElementVNode("div",U,[t.renderSlot(e.$slots,"toolbar",{loading:e.loading,refresh:e.refresh},()=>[t.createElementVNode("div",_,[e.title?(t.openBlock(),t.createElementBlock("span",A,t.toDisplayString(e.title),1)):t.createCommentVNode("",!0)]),t.createElementVNode("div",O,[t.createVNode(y,null,{default:t.withCtx(()=>[t.createVNode(h,{loading:e.loading,onClick:e.refresh},{default:t.withCtx(()=>[...a[3]||(a[3]=[t.createElementVNode("svg",{class:"icon-refresh",viewBox:"64 64 896 896",width:"1em",height:"1em",fill:"currentColor"},[t.createElementVNode("path",{d:"M909.1 209.3l-56.4 44.1C775.8 155.1 653.5 96 512 96 282.7 96 96 282.7 96 512s186.7 416 416 416c165.3 0 309.1-96.4 376-236.1 8.3-17.2-4.3-37.1-23.1-37.1H745.6c-9.2 0-17.2 5.8-20.3 14.3C680.5 773.5 600.5 832 512 832c-176.7 0-320-143.3-320-320s143.3-320 320-320c88.5 0 168.5 36.1 226.4 94.3L704 356.3c-4.7-4.7-1.3-12.7 5.3-13.1l193.7-12.5c6.6-.4 12.3 4.9 12.3 11.5v193.7c0 6.6-8 10-12.7 5.3z"})],-1),t.createTextVNode(" 刷新 ",-1)])]),_:1},8,["loading","onClick"]),e.autoRefresh?(t.openBlock(),t.createBlock(k,{key:0,checked:e.autoRefreshEnabled,"checked-children":"自动刷新","un-checked-children":"自动刷新",onChange:e.toggleAutoRefresh},null,8,["checked","onChange"])):t.createCommentVNode("",!0),e.autoRefresh&&e.autoRefreshEnabled?(t.openBlock(),t.createElementBlock("span",j,t.toDisplayString(e.countdown)+"s ",1)):t.createCommentVNode("",!0)]),_:1})])],!0)]),t.createVNode(b,t.mergeProps({"data-source":e.data,columns:e.computedColumns,loading:e.loading,pagination:!1,"row-key":e.rowKey,bordered:e.bordered,scroll:e.scroll},e.$attrs,t.toHandlers(e.$listeners)),{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.filteredSlots,(o,r)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[r==="action"?t.renderSlot(e.$slots,"action",{key:0,record:e.slotData&&e.slotData.record,index:e.slotData&&e.slotData.index},()=>[e.download&&e.canDownload(e.slotData&&e.slotData.record)?(t.openBlock(),t.createElementBlock("a",{key:0,onClick:a[0]||(a[0]=f=>e.download.handleDownload(e.slotData.record))},"下载")):t.createCommentVNode("",!0)],!0):t.renderSlot(e.$slots,r,t.mergeProps({key:1,ref_for:!0},e.slotData||{}),()=>[t.createTextVNode(t.toDisplayString(e.slotData?e.slotData.text:""),1)],!0)],64))),256))]),_:3},16,["data-source","columns","loading","row-key","bordered","scroll"]),e.total>0?(t.openBlock(),t.createElementBlock("div",I,[t.createVNode(w,{current:e.currentPage,"page-size":e.pageSize,total:e.total,"show-size-changer":!0,"show-quick-jumper":!0,"show-total":o=>`共 ${o} 条`,onChange:e.handlePageChange,onShowSizeChange:e.handlePageChange},null,8,["current","page-size","total","show-total","onChange","onShowSizeChange"])])):t.createCommentVNode("",!0)])}const P=q($,[["render",L],["__scopeId","data-v-c29396f5"]]),T={install(e){e.component("DownloadTable",P)}};exports.DownloadTable=P;exports.VueExportTable=T;exports.default=T;exports.useAutoRefresh=N;exports.usePagination=E;exports.useQuery=D;exports.useTable=R;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("vue-demi"),t=require("vue");function D(e){const a=u.reactive({});function n(){e.forEach(l=>{l.defaultValue!==void 0?a[l.name]=l.defaultValue:a[l.name]=l.type==="rangePicker"?[]:void 0})}n();function s(){const l={};return Object.keys(a).forEach(d=>{const i=a[d];if(i!=null&&i!==""){if(Array.isArray(i)&&i.length===0)return;l[d]=i}}),l}function c(){n()}function m(l,d){a[l]=d}return{filters:a,onSearch:s,onReset:c,setFilter:m}}function E(e=10){const a=u.ref(1),n=u.ref(e),s=u.computed(()=>({current:a.value,pageSize:n.value}));function c(l,d){a.value=l,d!==n.value&&(n.value=d,a.value=1)}function m(){a.value=1}return{currentPage:a,pageSize:n,pagination:s,onPageChange:c,resetPage:m}}function N(e,a){const n=u.ref(e.enabled??e.interval>0),s=u.ref(e.interval);let c=null;function m(){l(),!(!n.value||e.interval<=0)&&(s.value=e.interval,c=setInterval(()=>{s.value-=1,s.value<=0&&(s.value=e.interval,a())},1e3))}function l(){c&&(clearInterval(c),c=null)}function d(v){n.value=v??!n.value,n.value?m():(l(),s.value=e.interval)}function i(){n.value&&(s.value=e.interval)}function p(){e.pauseOnHidden&&(document.hidden?l():n.value&&m())}return u.onMounted(()=>{n.value&&e.interval>0&&(m(),e.pauseOnHidden&&document.addEventListener("visibilitychange",p))}),u.onUnmounted(()=>{l(),document.removeEventListener("visibilitychange",p)}),{enabled:n,countdown:s,toggle:d,resetCountdown:i}}function R(e){const a=u.ref(!1),n=u.ref([]),s=u.ref(0),{filters:c,onSearch:m,onReset:l,setFilter:d}=D(e.queryFields??[]),{currentPage:i,pageSize:p,pagination:v,onPageChange:g,resetPage:h}=E(e.pageSize??10),y=e.autoRefresh??{interval:0,enabled:!1},{enabled:C,countdown:k,toggle:b,resetCountdown:w}=N(y,()=>{o()});async function o(){a.value=!0;try{const V={page:i.value,pageSize:p.value,filters:m()},B=await e.fetchData(V);n.value=B.list,s.value=B.total}catch(V){console.error("[VueExportTable] fetch error:",V)}finally{a.value=!1}}function r(){h(),o(),w()}function f(){l(),h(),o()}function S(V,B){g(V,B),o(),w()}return u.onMounted(()=>{e.immediate!==!1&&o()}),{loading:a,data:n,total:s,filters:c,pagination:v,currentPage:i,pageSize:p,handleSearch:r,handleReset:f,setFilter:d,handlePageChange:S,refresh:o,autoRefreshEnabled:C,countdown:k,toggleAutoRefresh:b}}const $=u.defineComponent({name:"DownloadTable",props:{columns:{type:Array,required:!0},queryFields:{type:Array,default:()=>[]},fetchData:{type:Function,required:!0},download:{type:Object,default:void 0},autoRefresh:{type:Object,default:void 0},rowKey:{type:[String,Function],default:"id"},title:{type:String,default:""},bordered:{type:Boolean,default:!0},pageSize:{type:Number,default:10},showIndex:{type:Boolean,default:!1},immediate:{type:Boolean,default:!0}},setup(e,{slots:a}){const{loading:n,data:s,total:c,filters:m,currentPage:l,pageSize:d,handleSearch:i,handleReset:p,handlePageChange:v,refresh:g,autoRefreshEnabled:h,countdown:y,toggleAutoRefresh:C}=R({fetchData:e.fetchData,queryFields:e.queryFields,pageSize:e.pageSize,autoRefresh:e.autoRefresh,immediate:e.immediate}),k=u.computed(()=>{const o=[];return e.showIndex&&o.push({title:"序号",dataIndex:"index",key:"index",width:80,align:"center",customRender:({index:r})=>(l.value-1)*d.value+r+1}),[...o,...e.columns]}),b=u.computed(()=>{const o=k.value.reduce((r,f)=>{const S=typeof f.width=="number"?f.width:0;return r+S},0);return o>0?{x:o}:void 0}),w=u.computed(()=>{const o=["query-form","toolbar"],r={};return Object.keys(a).forEach(f=>{o.includes(f)||(r[f]=!0)}),r});return{loading:n,data:s,total:c,filters:m,currentPage:l,pageSize:d,handleSearch:i,handleReset:p,handlePageChange:v,refresh:g,download:u.computed(()=>e.download),canDownload:o=>e.download?e.download.canDownload?e.download.canDownload(o):o&&o.status==="completed":!1,autoRefreshEnabled:h,countdown:y,toggleAutoRefresh:C,computedColumns:k,scroll:b,filteredSlots:w}}}),q=(e,a)=>{const n=e.__vccOpts||e;for(const[s,c]of a)n[s]=c;return n},z={class:"vet-download-table-wrapper"},F={key:0,class:"vet-query-form-wrapper"},U={class:"vet-toolbar-wrapper"},A={class:"vet-toolbar-left"},O={key:0,class:"vet-table-title"},_={class:"vet-toolbar-right"},j={key:1,class:"vet-countdown-text"},I={key:1,class:"vet-pagination-wrapper"};function L(e,a,n,s,c,m){const l=t.resolveComponent("a-input"),d=t.resolveComponent("a-input-number"),i=t.resolveComponent("a-select"),p=t.resolveComponent("a-date-picker"),v=t.resolveComponent("a-range-picker"),g=t.resolveComponent("a-form-item"),h=t.resolveComponent("a-button"),y=t.resolveComponent("a-space"),C=t.resolveComponent("a-form"),k=t.resolveComponent("a-switch"),b=t.resolveComponent("a-table"),w=t.resolveComponent("a-pagination");return t.openBlock(),t.createElementBlock("div",z,[e.queryFields&&e.queryFields.length>0?(t.openBlock(),t.createElementBlock("div",F,[t.renderSlot(e.$slots,"query-form",{filters:e.filters,handleSearch:e.handleSearch,handleReset:e.handleReset},()=>[t.createVNode(C,{layout:"inline",model:e.filters},{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.queryFields,o=>(t.openBlock(),t.createBlock(g,{key:o.name,label:o.label},{default:t.withCtx(()=>[o.type==="input"?(t.openBlock(),t.createBlock(l,{key:0,modelValue:e.filters[o.name],"onUpdate:modelValue":r=>e.filters[o.name]=r,placeholder:o.placeholder||`请输入${o.label}`,"allow-clear":""},null,8,["modelValue","onUpdate:modelValue","placeholder"])):o.type==="number"?(t.openBlock(),t.createBlock(d,{key:1,modelValue:e.filters[o.name],"onUpdate:modelValue":r=>e.filters[o.name]=r,placeholder:o.placeholder||`请输入${o.label}`,style:{width:"180px"}},null,8,["modelValue","onUpdate:modelValue","placeholder"])):o.type==="select"?(t.openBlock(),t.createBlock(i,{key:2,modelValue:e.filters[o.name],"onUpdate:modelValue":r=>e.filters[o.name]=r,placeholder:o.placeholder||`请选择${o.label}`,options:o.options,"allow-clear":"",style:{"min-width":"150px"}},null,8,["modelValue","onUpdate:modelValue","placeholder","options"])):o.type==="datePicker"?(t.openBlock(),t.createBlock(p,{key:3,modelValue:e.filters[o.name],"onUpdate:modelValue":r=>e.filters[o.name]=r,placeholder:o.placeholder||`请选择${o.label}`,style:{width:"180px"}},null,8,["modelValue","onUpdate:modelValue","placeholder"])):o.type==="rangePicker"?(t.openBlock(),t.createBlock(v,{key:4,modelValue:e.filters[o.name],"onUpdate:modelValue":r=>e.filters[o.name]=r,placeholder:[o.placeholder||"开始日期",o.placeholder||"结束日期"],style:{width:"240px"}},null,8,["modelValue","onUpdate:modelValue","placeholder"])):t.createCommentVNode("",!0)]),_:2},1032,["label"]))),128)),t.createVNode(g,null,{default:t.withCtx(()=>[t.createVNode(y,null,{default:t.withCtx(()=>[t.createVNode(h,{type:"primary",onClick:e.handleSearch},{default:t.withCtx(()=>[...a[1]||(a[1]=[t.createTextVNode("查询",-1)])]),_:1},8,["onClick"]),t.createVNode(h,{onClick:e.handleReset},{default:t.withCtx(()=>[...a[2]||(a[2]=[t.createTextVNode("重置",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1})]),_:1},8,["model"])])])):t.createCommentVNode("",!0),t.createElementVNode("div",U,[t.renderSlot(e.$slots,"toolbar",{loading:e.loading,refresh:e.refresh},()=>[t.createElementVNode("div",A,[e.title?(t.openBlock(),t.createElementBlock("span",O,t.toDisplayString(e.title),1)):t.createCommentVNode("",!0)]),t.createElementVNode("div",_,[t.createVNode(y,null,{default:t.withCtx(()=>[t.createVNode(h,{loading:e.loading,onClick:e.refresh},{default:t.withCtx(()=>[...a[3]||(a[3]=[t.createElementVNode("svg",{class:"vet-icon-svg",viewBox:"64 64 896 896",width:"1em",height:"1em",fill:"currentColor"},[t.createElementVNode("path",{d:"M909.1 209.3l-56.4 44.1C775.8 155.1 653.5 96 512 96 282.7 96 96 282.7 96 512s186.7 416 416 416c165.3 0 309.1-96.4 376-236.1 8.3-17.2-4.3-37.1-23.1-37.1H745.6c-9.2 0-17.2 5.8-20.3 14.3C680.5 773.5 600.5 832 512 832c-176.7 0-320-143.3-320-320s143.3-320 320-320c88.5 0 168.5 36.1 226.4 94.3L704 356.3c-4.7-4.7-1.3-12.7 5.3-13.1l193.7-12.5c6.6-.4 12.3 4.9 12.3 11.5v193.7c0 6.6-8 10-12.7 5.3z"})],-1),t.createTextVNode(" 刷新 ",-1)])]),_:1},8,["loading","onClick"]),e.autoRefresh?(t.openBlock(),t.createBlock(k,{key:0,checked:e.autoRefreshEnabled,"checked-children":"自动刷新","un-checked-children":"自动刷新",onChange:e.toggleAutoRefresh},null,8,["checked","onChange"])):t.createCommentVNode("",!0),e.autoRefresh&&e.autoRefreshEnabled?(t.openBlock(),t.createElementBlock("span",j,t.toDisplayString(e.countdown)+"s ",1)):t.createCommentVNode("",!0)]),_:1})])])]),t.createVNode(b,t.mergeProps({"data-source":e.data,columns:e.computedColumns,loading:e.loading,pagination:!1,"row-key":e.rowKey,bordered:e.bordered,scroll:e.scroll},e.$attrs,t.toHandlers(e.$listeners)),{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.filteredSlots,(o,r)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[r==="action"?t.renderSlot(e.$slots,"action",{key:0,record:e.slotData&&e.slotData.record,index:e.slotData&&e.slotData.index},()=>[e.download&&e.canDownload(e.slotData&&e.slotData.record)?(t.openBlock(),t.createElementBlock("a",{key:0,onClick:a[0]||(a[0]=f=>e.download.handleDownload(e.slotData.record))},"下载")):t.createCommentVNode("",!0)]):t.renderSlot(e.$slots,r,t.mergeProps({key:1,ref_for:!0},e.slotData||{}),()=>[t.createTextVNode(t.toDisplayString(e.slotData?e.slotData.text:""),1)])],64))),256))]),_:3},16,["data-source","columns","loading","row-key","bordered","scroll"]),e.total>0?(t.openBlock(),t.createElementBlock("div",I,[t.createVNode(w,{current:e.currentPage,"page-size":e.pageSize,total:e.total,"show-size-changer":!0,"show-quick-jumper":!0,"show-total":o=>`共 ${o} 条`,onChange:e.handlePageChange,onShowSizeChange:e.handlePageChange},null,8,["current","page-size","total","show-total","onChange","onShowSizeChange"])])):t.createCommentVNode("",!0)])}const P=q($,[["render",L]]),T={install(e){e.component("DownloadTable",P)}};exports.DownloadTable=P;exports.VueExportTable=T;exports.default=T;exports.useAutoRefresh=N;exports.usePagination=E;exports.useQuery=D;exports.useTable=R;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { reactive as N, ref as C, computed as E, onMounted as
|
|
2
|
-
import { resolveComponent as h, openBlock as
|
|
1
|
+
import { reactive as N, ref as C, computed as E, onMounted as I, onUnmounted as H, defineComponent as L } from "vue-demi";
|
|
2
|
+
import { resolveComponent as h, openBlock as u, createElementBlock as m, renderSlot as U, createVNode as f, withCtx as v, Fragment as B, renderList as _, createBlock as b, createCommentVNode as k, createTextVNode as T, createElementVNode as q, toDisplayString as O, mergeProps as j, toHandlers as K } from "vue";
|
|
3
3
|
function M(e) {
|
|
4
4
|
const t = N({});
|
|
5
5
|
function n() {
|
|
@@ -10,19 +10,19 @@ function M(e) {
|
|
|
10
10
|
n();
|
|
11
11
|
function r() {
|
|
12
12
|
const o = {};
|
|
13
|
-
return Object.keys(t).forEach((
|
|
14
|
-
const i = t[
|
|
13
|
+
return Object.keys(t).forEach((s) => {
|
|
14
|
+
const i = t[s];
|
|
15
15
|
if (i != null && i !== "") {
|
|
16
16
|
if (Array.isArray(i) && i.length === 0) return;
|
|
17
|
-
o[
|
|
17
|
+
o[s] = i;
|
|
18
18
|
}
|
|
19
19
|
}), o;
|
|
20
20
|
}
|
|
21
21
|
function d() {
|
|
22
22
|
n();
|
|
23
23
|
}
|
|
24
|
-
function c(o,
|
|
25
|
-
t[o] =
|
|
24
|
+
function c(o, s) {
|
|
25
|
+
t[o] = s;
|
|
26
26
|
}
|
|
27
27
|
return { filters: t, onSearch: r, onReset: d, setFilter: c };
|
|
28
28
|
}
|
|
@@ -31,8 +31,8 @@ function Q(e = 10) {
|
|
|
31
31
|
current: t.value,
|
|
32
32
|
pageSize: n.value
|
|
33
33
|
}));
|
|
34
|
-
function d(o,
|
|
35
|
-
t.value = o,
|
|
34
|
+
function d(o, s) {
|
|
35
|
+
t.value = o, s !== n.value && (n.value = s, t.value = 1);
|
|
36
36
|
}
|
|
37
37
|
function c() {
|
|
38
38
|
t.value = 1;
|
|
@@ -50,7 +50,7 @@ function W(e, t) {
|
|
|
50
50
|
function o() {
|
|
51
51
|
d && (clearInterval(d), d = null);
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function s(w) {
|
|
54
54
|
n.value = w ?? !n.value, n.value ? c() : (o(), r.value = e.interval);
|
|
55
55
|
}
|
|
56
56
|
function i() {
|
|
@@ -59,14 +59,14 @@ function W(e, t) {
|
|
|
59
59
|
function p() {
|
|
60
60
|
e.pauseOnHidden && (document.hidden ? o() : n.value && c());
|
|
61
61
|
}
|
|
62
|
-
return
|
|
62
|
+
return I(() => {
|
|
63
63
|
n.value && e.interval > 0 && (c(), e.pauseOnHidden && document.addEventListener("visibilitychange", p));
|
|
64
64
|
}), H(() => {
|
|
65
65
|
o(), document.removeEventListener("visibilitychange", p);
|
|
66
|
-
}), { enabled: n, countdown: r, toggle:
|
|
66
|
+
}), { enabled: n, countdown: r, toggle: s, resetCountdown: i };
|
|
67
67
|
}
|
|
68
68
|
function G(e) {
|
|
69
|
-
const t = C(!1), n = C([]), r = C(0), { filters: d, onSearch: c, onReset: o, setFilter:
|
|
69
|
+
const t = C(!1), n = C([]), r = C(0), { filters: d, onSearch: c, onReset: o, setFilter: s } = M(e.queryFields ?? []), { currentPage: i, pageSize: p, pagination: w, onPageChange: V, resetPage: g } = Q(e.pageSize ?? 10), S = e.autoRefresh ?? {
|
|
70
70
|
interval: 0,
|
|
71
71
|
enabled: !1
|
|
72
72
|
}, { enabled: P, countdown: D, toggle: $, resetCountdown: R } = W(
|
|
@@ -91,15 +91,15 @@ function G(e) {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
function l() {
|
|
94
|
-
|
|
94
|
+
g(), a(), R();
|
|
95
95
|
}
|
|
96
96
|
function y() {
|
|
97
|
-
o(),
|
|
97
|
+
o(), g(), a();
|
|
98
98
|
}
|
|
99
99
|
function A(z, F) {
|
|
100
100
|
V(z, F), a(), R();
|
|
101
101
|
}
|
|
102
|
-
return
|
|
102
|
+
return I(() => {
|
|
103
103
|
e.immediate !== !1 && a();
|
|
104
104
|
}), {
|
|
105
105
|
// 状态
|
|
@@ -113,7 +113,7 @@ function G(e) {
|
|
|
113
113
|
// 查询
|
|
114
114
|
handleSearch: l,
|
|
115
115
|
handleReset: y,
|
|
116
|
-
setFilter:
|
|
116
|
+
setFilter: s,
|
|
117
117
|
// 分页
|
|
118
118
|
handlePageChange: A,
|
|
119
119
|
// 刷新
|
|
@@ -179,12 +179,12 @@ const J = L({
|
|
|
179
179
|
total: d,
|
|
180
180
|
filters: c,
|
|
181
181
|
currentPage: o,
|
|
182
|
-
pageSize:
|
|
182
|
+
pageSize: s,
|
|
183
183
|
handleSearch: i,
|
|
184
184
|
handleReset: p,
|
|
185
185
|
handlePageChange: w,
|
|
186
186
|
refresh: V,
|
|
187
|
-
autoRefreshEnabled:
|
|
187
|
+
autoRefreshEnabled: g,
|
|
188
188
|
countdown: S,
|
|
189
189
|
toggleAutoRefresh: P
|
|
190
190
|
} = G({
|
|
@@ -201,7 +201,7 @@ const J = L({
|
|
|
201
201
|
key: "index",
|
|
202
202
|
width: 80,
|
|
203
203
|
align: "center",
|
|
204
|
-
customRender: ({ index: l }) => (o.value - 1) *
|
|
204
|
+
customRender: ({ index: l }) => (o.value - 1) * s.value + l + 1
|
|
205
205
|
}), [...a, ...e.columns];
|
|
206
206
|
}), $ = E(() => {
|
|
207
207
|
const a = D.value.reduce((l, y) => {
|
|
@@ -221,14 +221,14 @@ const J = L({
|
|
|
221
221
|
total: d,
|
|
222
222
|
filters: c,
|
|
223
223
|
currentPage: o,
|
|
224
|
-
pageSize:
|
|
224
|
+
pageSize: s,
|
|
225
225
|
handleSearch: i,
|
|
226
226
|
handleReset: p,
|
|
227
227
|
handlePageChange: w,
|
|
228
228
|
refresh: V,
|
|
229
229
|
download: E(() => e.download),
|
|
230
230
|
canDownload: (a) => e.download ? e.download.canDownload ? e.download.canDownload(a) : a && a.status === "completed" : !1,
|
|
231
|
-
autoRefreshEnabled:
|
|
231
|
+
autoRefreshEnabled: g,
|
|
232
232
|
countdown: S,
|
|
233
233
|
toggleAutoRefresh: P,
|
|
234
234
|
computedColumns: D,
|
|
@@ -241,23 +241,23 @@ const J = L({
|
|
|
241
241
|
for (const [r, d] of t)
|
|
242
242
|
n[r] = d;
|
|
243
243
|
return n;
|
|
244
|
-
}, Y = { class: "download-table-wrapper" }, Z = {
|
|
244
|
+
}, Y = { class: "vet-download-table-wrapper" }, Z = {
|
|
245
245
|
key: 0,
|
|
246
|
-
class: "query-form-wrapper"
|
|
247
|
-
}, x = { class: "toolbar-wrapper" }, ee = { class: "toolbar-left" }, ae = {
|
|
246
|
+
class: "vet-query-form-wrapper"
|
|
247
|
+
}, x = { class: "vet-toolbar-wrapper" }, ee = { class: "vet-toolbar-left" }, ae = {
|
|
248
248
|
key: 0,
|
|
249
|
-
class: "table-title"
|
|
250
|
-
}, te = { class: "toolbar-right" }, ne = {
|
|
249
|
+
class: "vet-table-title"
|
|
250
|
+
}, te = { class: "vet-toolbar-right" }, ne = {
|
|
251
251
|
key: 1,
|
|
252
|
-
class: "countdown-text"
|
|
252
|
+
class: "vet-countdown-text"
|
|
253
253
|
}, oe = {
|
|
254
254
|
key: 1,
|
|
255
|
-
class: "pagination-wrapper"
|
|
255
|
+
class: "vet-pagination-wrapper"
|
|
256
256
|
};
|
|
257
257
|
function le(e, t, n, r, d, c) {
|
|
258
|
-
const o = h("a-input"),
|
|
259
|
-
return
|
|
260
|
-
e.queryFields && e.queryFields.length > 0 ? (
|
|
258
|
+
const o = h("a-input"), s = h("a-input-number"), i = h("a-select"), p = h("a-date-picker"), w = h("a-range-picker"), V = h("a-form-item"), g = h("a-button"), S = h("a-space"), P = h("a-form"), D = h("a-switch"), $ = h("a-table"), R = h("a-pagination");
|
|
259
|
+
return u(), m("div", Y, [
|
|
260
|
+
e.queryFields && e.queryFields.length > 0 ? (u(), m("div", Z, [
|
|
261
261
|
U(e.$slots, "query-form", {
|
|
262
262
|
filters: e.filters,
|
|
263
263
|
handleSearch: e.handleSearch,
|
|
@@ -267,25 +267,25 @@ function le(e, t, n, r, d, c) {
|
|
|
267
267
|
layout: "inline",
|
|
268
268
|
model: e.filters
|
|
269
269
|
}, {
|
|
270
|
-
default:
|
|
271
|
-
(
|
|
270
|
+
default: v(() => [
|
|
271
|
+
(u(!0), m(B, null, _(e.queryFields, (a) => (u(), b(V, {
|
|
272
272
|
key: a.name,
|
|
273
273
|
label: a.label
|
|
274
274
|
}, {
|
|
275
|
-
default:
|
|
276
|
-
a.type === "input" ? (
|
|
275
|
+
default: v(() => [
|
|
276
|
+
a.type === "input" ? (u(), b(o, {
|
|
277
277
|
key: 0,
|
|
278
278
|
modelValue: e.filters[a.name],
|
|
279
279
|
"onUpdate:modelValue": (l) => e.filters[a.name] = l,
|
|
280
280
|
placeholder: a.placeholder || `请输入${a.label}`,
|
|
281
281
|
"allow-clear": ""
|
|
282
|
-
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"])) : a.type === "number" ? (
|
|
282
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"])) : a.type === "number" ? (u(), b(s, {
|
|
283
283
|
key: 1,
|
|
284
284
|
modelValue: e.filters[a.name],
|
|
285
285
|
"onUpdate:modelValue": (l) => e.filters[a.name] = l,
|
|
286
286
|
placeholder: a.placeholder || `请输入${a.label}`,
|
|
287
287
|
style: { width: "180px" }
|
|
288
|
-
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"])) : a.type === "select" ? (
|
|
288
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"])) : a.type === "select" ? (u(), b(i, {
|
|
289
289
|
key: 2,
|
|
290
290
|
modelValue: e.filters[a.name],
|
|
291
291
|
"onUpdate:modelValue": (l) => e.filters[a.name] = l,
|
|
@@ -293,13 +293,13 @@ function le(e, t, n, r, d, c) {
|
|
|
293
293
|
options: a.options,
|
|
294
294
|
"allow-clear": "",
|
|
295
295
|
style: { "min-width": "150px" }
|
|
296
|
-
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder", "options"])) : a.type === "datePicker" ? (
|
|
296
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder", "options"])) : a.type === "datePicker" ? (u(), b(p, {
|
|
297
297
|
key: 3,
|
|
298
298
|
modelValue: e.filters[a.name],
|
|
299
299
|
"onUpdate:modelValue": (l) => e.filters[a.name] = l,
|
|
300
300
|
placeholder: a.placeholder || `请选择${a.label}`,
|
|
301
301
|
style: { width: "180px" }
|
|
302
|
-
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"])) : a.type === "rangePicker" ? (
|
|
302
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"])) : a.type === "rangePicker" ? (u(), b(w, {
|
|
303
303
|
key: 4,
|
|
304
304
|
modelValue: e.filters[a.name],
|
|
305
305
|
"onUpdate:modelValue": (l) => e.filters[a.name] = l,
|
|
@@ -310,20 +310,20 @@ function le(e, t, n, r, d, c) {
|
|
|
310
310
|
_: 2
|
|
311
311
|
}, 1032, ["label"]))), 128)),
|
|
312
312
|
f(V, null, {
|
|
313
|
-
default:
|
|
313
|
+
default: v(() => [
|
|
314
314
|
f(S, null, {
|
|
315
|
-
default:
|
|
316
|
-
f(
|
|
315
|
+
default: v(() => [
|
|
316
|
+
f(g, {
|
|
317
317
|
type: "primary",
|
|
318
318
|
onClick: e.handleSearch
|
|
319
319
|
}, {
|
|
320
|
-
default:
|
|
320
|
+
default: v(() => [...t[1] || (t[1] = [
|
|
321
321
|
T("查询", -1)
|
|
322
322
|
])]),
|
|
323
323
|
_: 1
|
|
324
324
|
}, 8, ["onClick"]),
|
|
325
|
-
f(
|
|
326
|
-
default:
|
|
325
|
+
f(g, { onClick: e.handleReset }, {
|
|
326
|
+
default: v(() => [...t[2] || (t[2] = [
|
|
327
327
|
T("重置", -1)
|
|
328
328
|
])]),
|
|
329
329
|
_: 1
|
|
@@ -337,7 +337,7 @@ function le(e, t, n, r, d, c) {
|
|
|
337
337
|
]),
|
|
338
338
|
_: 1
|
|
339
339
|
}, 8, ["model"])
|
|
340
|
-
]
|
|
340
|
+
])
|
|
341
341
|
])) : k("", !0),
|
|
342
342
|
q("div", x, [
|
|
343
343
|
U(e.$slots, "toolbar", {
|
|
@@ -345,18 +345,18 @@ function le(e, t, n, r, d, c) {
|
|
|
345
345
|
refresh: e.refresh
|
|
346
346
|
}, () => [
|
|
347
347
|
q("div", ee, [
|
|
348
|
-
e.title ? (
|
|
348
|
+
e.title ? (u(), m("span", ae, O(e.title), 1)) : k("", !0)
|
|
349
349
|
]),
|
|
350
350
|
q("div", te, [
|
|
351
351
|
f(S, null, {
|
|
352
|
-
default:
|
|
353
|
-
f(
|
|
352
|
+
default: v(() => [
|
|
353
|
+
f(g, {
|
|
354
354
|
loading: e.loading,
|
|
355
355
|
onClick: e.refresh
|
|
356
356
|
}, {
|
|
357
|
-
default:
|
|
357
|
+
default: v(() => [...t[3] || (t[3] = [
|
|
358
358
|
q("svg", {
|
|
359
|
-
class: "icon-
|
|
359
|
+
class: "vet-icon-svg",
|
|
360
360
|
viewBox: "64 64 896 896",
|
|
361
361
|
width: "1em",
|
|
362
362
|
height: "1em",
|
|
@@ -368,21 +368,21 @@ function le(e, t, n, r, d, c) {
|
|
|
368
368
|
])]),
|
|
369
369
|
_: 1
|
|
370
370
|
}, 8, ["loading", "onClick"]),
|
|
371
|
-
e.autoRefresh ? (
|
|
371
|
+
e.autoRefresh ? (u(), b(D, {
|
|
372
372
|
key: 0,
|
|
373
373
|
checked: e.autoRefreshEnabled,
|
|
374
374
|
"checked-children": "自动刷新",
|
|
375
375
|
"un-checked-children": "自动刷新",
|
|
376
376
|
onChange: e.toggleAutoRefresh
|
|
377
377
|
}, null, 8, ["checked", "onChange"])) : k("", !0),
|
|
378
|
-
e.autoRefresh && e.autoRefreshEnabled ? (
|
|
378
|
+
e.autoRefresh && e.autoRefreshEnabled ? (u(), m("span", ne, O(e.countdown) + "s ", 1)) : k("", !0)
|
|
379
379
|
]),
|
|
380
380
|
_: 1
|
|
381
381
|
})
|
|
382
382
|
])
|
|
383
|
-
]
|
|
383
|
+
])
|
|
384
384
|
]),
|
|
385
|
-
f($,
|
|
385
|
+
f($, j({
|
|
386
386
|
"data-source": e.data,
|
|
387
387
|
columns: e.computedColumns,
|
|
388
388
|
loading: e.loading,
|
|
@@ -391,28 +391,28 @@ function le(e, t, n, r, d, c) {
|
|
|
391
391
|
bordered: e.bordered,
|
|
392
392
|
scroll: e.scroll
|
|
393
393
|
}, e.$attrs, K(e.$listeners)), {
|
|
394
|
-
default:
|
|
395
|
-
(
|
|
394
|
+
default: v(() => [
|
|
395
|
+
(u(!0), m(B, null, _(e.filteredSlots, (a, l) => (u(), m(B, null, [
|
|
396
396
|
l === "action" ? U(e.$slots, "action", {
|
|
397
397
|
key: 0,
|
|
398
398
|
record: e.slotData && e.slotData.record,
|
|
399
399
|
index: e.slotData && e.slotData.index
|
|
400
400
|
}, () => [
|
|
401
|
-
e.download && e.canDownload(e.slotData && e.slotData.record) ? (
|
|
401
|
+
e.download && e.canDownload(e.slotData && e.slotData.record) ? (u(), m("a", {
|
|
402
402
|
key: 0,
|
|
403
403
|
onClick: t[0] || (t[0] = (y) => e.download.handleDownload(e.slotData.record))
|
|
404
404
|
}, "下载")) : k("", !0)
|
|
405
|
-
]
|
|
405
|
+
]) : U(e.$slots, l, j({
|
|
406
406
|
key: 1,
|
|
407
407
|
ref_for: !0
|
|
408
408
|
}, e.slotData || {}), () => [
|
|
409
|
-
T(
|
|
410
|
-
]
|
|
409
|
+
T(O(e.slotData ? e.slotData.text : ""), 1)
|
|
410
|
+
])
|
|
411
411
|
], 64))), 256))
|
|
412
412
|
]),
|
|
413
413
|
_: 3
|
|
414
414
|
}, 16, ["data-source", "columns", "loading", "row-key", "bordered", "scroll"]),
|
|
415
|
-
e.total > 0 ? (
|
|
415
|
+
e.total > 0 ? (u(), m("div", oe, [
|
|
416
416
|
f(R, {
|
|
417
417
|
current: e.currentPage,
|
|
418
418
|
"page-size": e.pageSize,
|
|
@@ -426,7 +426,7 @@ function le(e, t, n, r, d, c) {
|
|
|
426
426
|
])) : k("", !0)
|
|
427
427
|
]);
|
|
428
428
|
}
|
|
429
|
-
const re = /* @__PURE__ */ X(J, [["render", le]
|
|
429
|
+
const re = /* @__PURE__ */ X(J, [["render", le]]), de = {
|
|
430
430
|
install(e) {
|
|
431
431
|
e.component("DownloadTable", re);
|
|
432
432
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(p,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("vue-demi"),require("vue")):typeof define=="function"&&define.amd?define(["exports","vue-demi","vue"],r):(p=typeof globalThis<"u"?globalThis:p||self,r(p.VueExportTable={},p.VueDemi,p.Vue))})(this,(function(p,r,t){"use strict";function R(e){const n=r.reactive({});function a(){e.forEach(l=>{l.defaultValue!==void 0?n[l.name]=l.defaultValue:n[l.name]=l.type==="rangePicker"?[]:void 0})}a();function d(){const l={};return Object.keys(n).forEach(c=>{const u=n[c];if(u!=null&&u!==""){if(Array.isArray(u)&&u.length===0)return;l[c]=u}}),l}function i(){a()}function m(l,c){n[l]=c}return{filters:n,onSearch:d,onReset:i,setFilter:m}}function P(e=10){const n=r.ref(1),a=r.ref(e),d=r.computed(()=>({current:n.value,pageSize:a.value}));function i(l,c){n.value=l,c!==a.value&&(a.value=c,n.value=1)}function m(){n.value=1}return{currentPage:n,pageSize:a,pagination:d,onPageChange:i,resetPage:m}}function T(e,n){const a=r.ref(e.enabled??e.interval>0),d=r.ref(e.interval);let i=null;function m(){l(),!(!a.value||e.interval<=0)&&(d.value=e.interval,i=setInterval(()=>{d.value-=1,d.value<=0&&(d.value=e.interval,n())},1e3))}function l(){i&&(clearInterval(i),i=null)}function c(y){a.value=y??!a.value,a.value?m():(l(),d.value=e.interval)}function u(){a.value&&(d.value=e.interval)}function h(){e.pauseOnHidden&&(document.hidden?l():a.value&&m())}return r.onMounted(()=>{a.value&&e.interval>0&&(m(),e.pauseOnHidden&&document.addEventListener("visibilitychange",h))}),r.onUnmounted(()=>{l(),document.removeEventListener("visibilitychange",h)}),{enabled:a,countdown:d,toggle:c,resetCountdown:u}}function $(e){const n=r.ref(!1),a=r.ref([]),d=r.ref(0),{filters:i,onSearch:m,onReset:l,setFilter:c}=R(e.queryFields??[]),{currentPage:u,pageSize:h,pagination:y,onPageChange:k,resetPage:f}=P(e.pageSize??10),w=e.autoRefresh??{interval:0,enabled:!1},{enabled:b,countdown:C,toggle:B,resetCountdown:V}=T(w,()=>{o()});async function o(){n.value=!0;try{const S={page:u.value,pageSize:h.value,filters:m()},E=await e.fetchData(S);a.value=E.list,d.value=E.total}catch(S){console.error("[VueExportTable] fetch error:",S)}finally{n.value=!1}}function s(){f(),o(),V()}function g(){l(),f(),o()}function N(S,E){k(S,E),o(),V()}return r.onMounted(()=>{e.immediate!==!1&&o()}),{loading:n,data:a,total:d,filters:i,pagination:y,currentPage:u,pageSize:h,handleSearch:s,handleReset:g,setFilter:c,handlePageChange:N,refresh:o,autoRefreshEnabled:b,countdown:C,toggleAutoRefresh:B}}const F=r.defineComponent({name:"DownloadTable",props:{columns:{type:Array,required:!0},queryFields:{type:Array,default:()=>[]},fetchData:{type:Function,required:!0},download:{type:Object,default:void 0},autoRefresh:{type:Object,default:void 0},rowKey:{type:[String,Function],default:"id"},title:{type:String,default:""},bordered:{type:Boolean,default:!0},pageSize:{type:Number,default:10},showIndex:{type:Boolean,default:!1},immediate:{type:Boolean,default:!0}},setup(e,{slots:n}){const{loading:a,data:d,total:i,filters:m,currentPage:l,pageSize:c,handleSearch:u,handleReset:h,handlePageChange:y,refresh:k,autoRefreshEnabled:f,countdown:w,toggleAutoRefresh:b}=$({fetchData:e.fetchData,queryFields:e.queryFields,pageSize:e.pageSize,autoRefresh:e.autoRefresh,immediate:e.immediate}),C=r.computed(()=>{const o=[];return e.showIndex&&o.push({title:"序号",dataIndex:"index",key:"index",width:80,align:"center",customRender:({index:s})=>(l.value-1)*c.value+s+1}),[...o,...e.columns]}),B=r.computed(()=>{const o=C.value.reduce((s,g)=>{const N=typeof g.width=="number"?g.width:0;return s+N},0);return o>0?{x:o}:void 0}),V=r.computed(()=>{const o=["query-form","toolbar"],s={};return Object.keys(n).forEach(g=>{o.includes(g)||(s[g]=!0)}),s});return{loading:a,data:d,total:i,filters:m,currentPage:l,pageSize:c,handleSearch:u,handleReset:h,handlePageChange:y,refresh:k,download:r.computed(()=>e.download),canDownload:o=>e.download?e.download.canDownload?e.download.canDownload(o):o&&o.status==="completed":!1,autoRefreshEnabled:f,countdown:w,toggleAutoRefresh:b,computedColumns:C,scroll:B,filteredSlots:V}}}),D=(e,n)=>{const a=e.__vccOpts||e;for(const[d,i]of n)a[d]=i;return a},U={class:"download-table-wrapper"},_={key:0,class:"query-form-wrapper"},A={class:"toolbar-wrapper"},O={class:"toolbar-left"},j={key:0,class:"table-title"},I={class:"toolbar-right"},L={key:1,class:"countdown-text"},M={key:1,class:"pagination-wrapper"};function H(e,n,a,d,i,m){const l=t.resolveComponent("a-input"),c=t.resolveComponent("a-input-number"),u=t.resolveComponent("a-select"),h=t.resolveComponent("a-date-picker"),y=t.resolveComponent("a-range-picker"),k=t.resolveComponent("a-form-item"),f=t.resolveComponent("a-button"),w=t.resolveComponent("a-space"),b=t.resolveComponent("a-form"),C=t.resolveComponent("a-switch"),B=t.resolveComponent("a-table"),V=t.resolveComponent("a-pagination");return t.openBlock(),t.createElementBlock("div",U,[e.queryFields&&e.queryFields.length>0?(t.openBlock(),t.createElementBlock("div",_,[t.renderSlot(e.$slots,"query-form",{filters:e.filters,handleSearch:e.handleSearch,handleReset:e.handleReset},()=>[t.createVNode(b,{layout:"inline",model:e.filters},{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.queryFields,o=>(t.openBlock(),t.createBlock(k,{key:o.name,label:o.label},{default:t.withCtx(()=>[o.type==="input"?(t.openBlock(),t.createBlock(l,{key:0,modelValue:e.filters[o.name],"onUpdate:modelValue":s=>e.filters[o.name]=s,placeholder:o.placeholder||`请输入${o.label}`,"allow-clear":""},null,8,["modelValue","onUpdate:modelValue","placeholder"])):o.type==="number"?(t.openBlock(),t.createBlock(c,{key:1,modelValue:e.filters[o.name],"onUpdate:modelValue":s=>e.filters[o.name]=s,placeholder:o.placeholder||`请输入${o.label}`,style:{width:"180px"}},null,8,["modelValue","onUpdate:modelValue","placeholder"])):o.type==="select"?(t.openBlock(),t.createBlock(u,{key:2,modelValue:e.filters[o.name],"onUpdate:modelValue":s=>e.filters[o.name]=s,placeholder:o.placeholder||`请选择${o.label}`,options:o.options,"allow-clear":"",style:{"min-width":"150px"}},null,8,["modelValue","onUpdate:modelValue","placeholder","options"])):o.type==="datePicker"?(t.openBlock(),t.createBlock(h,{key:3,modelValue:e.filters[o.name],"onUpdate:modelValue":s=>e.filters[o.name]=s,placeholder:o.placeholder||`请选择${o.label}`,style:{width:"180px"}},null,8,["modelValue","onUpdate:modelValue","placeholder"])):o.type==="rangePicker"?(t.openBlock(),t.createBlock(y,{key:4,modelValue:e.filters[o.name],"onUpdate:modelValue":s=>e.filters[o.name]=s,placeholder:[o.placeholder||"开始日期",o.placeholder||"结束日期"],style:{width:"240px"}},null,8,["modelValue","onUpdate:modelValue","placeholder"])):t.createCommentVNode("",!0)]),_:2},1032,["label"]))),128)),t.createVNode(k,null,{default:t.withCtx(()=>[t.createVNode(w,null,{default:t.withCtx(()=>[t.createVNode(f,{type:"primary",onClick:e.handleSearch},{default:t.withCtx(()=>[...n[1]||(n[1]=[t.createTextVNode("查询",-1)])]),_:1},8,["onClick"]),t.createVNode(f,{onClick:e.handleReset},{default:t.withCtx(()=>[...n[2]||(n[2]=[t.createTextVNode("重置",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1})]),_:1},8,["model"])],!0)])):t.createCommentVNode("",!0),t.createElementVNode("div",A,[t.renderSlot(e.$slots,"toolbar",{loading:e.loading,refresh:e.refresh},()=>[t.createElementVNode("div",O,[e.title?(t.openBlock(),t.createElementBlock("span",j,t.toDisplayString(e.title),1)):t.createCommentVNode("",!0)]),t.createElementVNode("div",I,[t.createVNode(w,null,{default:t.withCtx(()=>[t.createVNode(f,{loading:e.loading,onClick:e.refresh},{default:t.withCtx(()=>[...n[3]||(n[3]=[t.createElementVNode("svg",{class:"icon-refresh",viewBox:"64 64 896 896",width:"1em",height:"1em",fill:"currentColor"},[t.createElementVNode("path",{d:"M909.1 209.3l-56.4 44.1C775.8 155.1 653.5 96 512 96 282.7 96 96 282.7 96 512s186.7 416 416 416c165.3 0 309.1-96.4 376-236.1 8.3-17.2-4.3-37.1-23.1-37.1H745.6c-9.2 0-17.2 5.8-20.3 14.3C680.5 773.5 600.5 832 512 832c-176.7 0-320-143.3-320-320s143.3-320 320-320c88.5 0 168.5 36.1 226.4 94.3L704 356.3c-4.7-4.7-1.3-12.7 5.3-13.1l193.7-12.5c6.6-.4 12.3 4.9 12.3 11.5v193.7c0 6.6-8 10-12.7 5.3z"})],-1),t.createTextVNode(" 刷新 ",-1)])]),_:1},8,["loading","onClick"]),e.autoRefresh?(t.openBlock(),t.createBlock(C,{key:0,checked:e.autoRefreshEnabled,"checked-children":"自动刷新","un-checked-children":"自动刷新",onChange:e.toggleAutoRefresh},null,8,["checked","onChange"])):t.createCommentVNode("",!0),e.autoRefresh&&e.autoRefreshEnabled?(t.openBlock(),t.createElementBlock("span",L,t.toDisplayString(e.countdown)+"s ",1)):t.createCommentVNode("",!0)]),_:1})])],!0)]),t.createVNode(B,t.mergeProps({"data-source":e.data,columns:e.computedColumns,loading:e.loading,pagination:!1,"row-key":e.rowKey,bordered:e.bordered,scroll:e.scroll},e.$attrs,t.toHandlers(e.$listeners)),{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.filteredSlots,(o,s)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[s==="action"?t.renderSlot(e.$slots,"action",{key:0,record:e.slotData&&e.slotData.record,index:e.slotData&&e.slotData.index},()=>[e.download&&e.canDownload(e.slotData&&e.slotData.record)?(t.openBlock(),t.createElementBlock("a",{key:0,onClick:n[0]||(n[0]=g=>e.download.handleDownload(e.slotData.record))},"下载")):t.createCommentVNode("",!0)],!0):t.renderSlot(e.$slots,s,t.mergeProps({key:1,ref_for:!0},e.slotData||{}),()=>[t.createTextVNode(t.toDisplayString(e.slotData?e.slotData.text:""),1)],!0)],64))),256))]),_:3},16,["data-source","columns","loading","row-key","bordered","scroll"]),e.total>0?(t.openBlock(),t.createElementBlock("div",M,[t.createVNode(V,{current:e.currentPage,"page-size":e.pageSize,total:e.total,"show-size-changer":!0,"show-quick-jumper":!0,"show-total":o=>`共 ${o} 条`,onChange:e.handlePageChange,onShowSizeChange:e.handlePageChange},null,8,["current","page-size","total","show-total","onChange","onShowSizeChange"])])):t.createCommentVNode("",!0)])}const q=D(F,[["render",H],["__scopeId","data-v-c29396f5"]]),z={install(e){e.component("DownloadTable",q)}};p.DownloadTable=q,p.VueExportTable=z,p.default=z,p.useAutoRefresh=T,p.usePagination=P,p.useQuery=R,p.useTable=$,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
1
|
+
(function(p,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("vue-demi"),require("vue")):typeof define=="function"&&define.amd?define(["exports","vue-demi","vue"],r):(p=typeof globalThis<"u"?globalThis:p||self,r(p.VueExportTable={},p.VueDemi,p.Vue))})(this,(function(p,r,t){"use strict";function R(e){const n=r.reactive({});function a(){e.forEach(l=>{l.defaultValue!==void 0?n[l.name]=l.defaultValue:n[l.name]=l.type==="rangePicker"?[]:void 0})}a();function d(){const l={};return Object.keys(n).forEach(c=>{const u=n[c];if(u!=null&&u!==""){if(Array.isArray(u)&&u.length===0)return;l[c]=u}}),l}function i(){a()}function m(l,c){n[l]=c}return{filters:n,onSearch:d,onReset:i,setFilter:m}}function P(e=10){const n=r.ref(1),a=r.ref(e),d=r.computed(()=>({current:n.value,pageSize:a.value}));function i(l,c){n.value=l,c!==a.value&&(a.value=c,n.value=1)}function m(){n.value=1}return{currentPage:n,pageSize:a,pagination:d,onPageChange:i,resetPage:m}}function T(e,n){const a=r.ref(e.enabled??e.interval>0),d=r.ref(e.interval);let i=null;function m(){l(),!(!a.value||e.interval<=0)&&(d.value=e.interval,i=setInterval(()=>{d.value-=1,d.value<=0&&(d.value=e.interval,n())},1e3))}function l(){i&&(clearInterval(i),i=null)}function c(y){a.value=y??!a.value,a.value?m():(l(),d.value=e.interval)}function u(){a.value&&(d.value=e.interval)}function h(){e.pauseOnHidden&&(document.hidden?l():a.value&&m())}return r.onMounted(()=>{a.value&&e.interval>0&&(m(),e.pauseOnHidden&&document.addEventListener("visibilitychange",h))}),r.onUnmounted(()=>{l(),document.removeEventListener("visibilitychange",h)}),{enabled:a,countdown:d,toggle:c,resetCountdown:u}}function $(e){const n=r.ref(!1),a=r.ref([]),d=r.ref(0),{filters:i,onSearch:m,onReset:l,setFilter:c}=R(e.queryFields??[]),{currentPage:u,pageSize:h,pagination:y,onPageChange:k,resetPage:f}=P(e.pageSize??10),w=e.autoRefresh??{interval:0,enabled:!1},{enabled:b,countdown:C,toggle:B,resetCountdown:V}=T(w,()=>{o()});async function o(){n.value=!0;try{const S={page:u.value,pageSize:h.value,filters:m()},E=await e.fetchData(S);a.value=E.list,d.value=E.total}catch(S){console.error("[VueExportTable] fetch error:",S)}finally{n.value=!1}}function s(){f(),o(),V()}function g(){l(),f(),o()}function N(S,E){k(S,E),o(),V()}return r.onMounted(()=>{e.immediate!==!1&&o()}),{loading:n,data:a,total:d,filters:i,pagination:y,currentPage:u,pageSize:h,handleSearch:s,handleReset:g,setFilter:c,handlePageChange:N,refresh:o,autoRefreshEnabled:b,countdown:C,toggleAutoRefresh:B}}const F=r.defineComponent({name:"DownloadTable",props:{columns:{type:Array,required:!0},queryFields:{type:Array,default:()=>[]},fetchData:{type:Function,required:!0},download:{type:Object,default:void 0},autoRefresh:{type:Object,default:void 0},rowKey:{type:[String,Function],default:"id"},title:{type:String,default:""},bordered:{type:Boolean,default:!0},pageSize:{type:Number,default:10},showIndex:{type:Boolean,default:!1},immediate:{type:Boolean,default:!0}},setup(e,{slots:n}){const{loading:a,data:d,total:i,filters:m,currentPage:l,pageSize:c,handleSearch:u,handleReset:h,handlePageChange:y,refresh:k,autoRefreshEnabled:f,countdown:w,toggleAutoRefresh:b}=$({fetchData:e.fetchData,queryFields:e.queryFields,pageSize:e.pageSize,autoRefresh:e.autoRefresh,immediate:e.immediate}),C=r.computed(()=>{const o=[];return e.showIndex&&o.push({title:"序号",dataIndex:"index",key:"index",width:80,align:"center",customRender:({index:s})=>(l.value-1)*c.value+s+1}),[...o,...e.columns]}),B=r.computed(()=>{const o=C.value.reduce((s,g)=>{const N=typeof g.width=="number"?g.width:0;return s+N},0);return o>0?{x:o}:void 0}),V=r.computed(()=>{const o=["query-form","toolbar"],s={};return Object.keys(n).forEach(g=>{o.includes(g)||(s[g]=!0)}),s});return{loading:a,data:d,total:i,filters:m,currentPage:l,pageSize:c,handleSearch:u,handleReset:h,handlePageChange:y,refresh:k,download:r.computed(()=>e.download),canDownload:o=>e.download?e.download.canDownload?e.download.canDownload(o):o&&o.status==="completed":!1,autoRefreshEnabled:f,countdown:w,toggleAutoRefresh:b,computedColumns:C,scroll:B,filteredSlots:V}}}),D=(e,n)=>{const a=e.__vccOpts||e;for(const[d,i]of n)a[d]=i;return a},U={class:"vet-download-table-wrapper"},A={key:0,class:"vet-query-form-wrapper"},O={class:"vet-toolbar-wrapper"},_={class:"vet-toolbar-left"},j={key:0,class:"vet-table-title"},I={class:"vet-toolbar-right"},L={key:1,class:"vet-countdown-text"},M={key:1,class:"vet-pagination-wrapper"};function H(e,n,a,d,i,m){const l=t.resolveComponent("a-input"),c=t.resolveComponent("a-input-number"),u=t.resolveComponent("a-select"),h=t.resolveComponent("a-date-picker"),y=t.resolveComponent("a-range-picker"),k=t.resolveComponent("a-form-item"),f=t.resolveComponent("a-button"),w=t.resolveComponent("a-space"),b=t.resolveComponent("a-form"),C=t.resolveComponent("a-switch"),B=t.resolveComponent("a-table"),V=t.resolveComponent("a-pagination");return t.openBlock(),t.createElementBlock("div",U,[e.queryFields&&e.queryFields.length>0?(t.openBlock(),t.createElementBlock("div",A,[t.renderSlot(e.$slots,"query-form",{filters:e.filters,handleSearch:e.handleSearch,handleReset:e.handleReset},()=>[t.createVNode(b,{layout:"inline",model:e.filters},{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.queryFields,o=>(t.openBlock(),t.createBlock(k,{key:o.name,label:o.label},{default:t.withCtx(()=>[o.type==="input"?(t.openBlock(),t.createBlock(l,{key:0,modelValue:e.filters[o.name],"onUpdate:modelValue":s=>e.filters[o.name]=s,placeholder:o.placeholder||`请输入${o.label}`,"allow-clear":""},null,8,["modelValue","onUpdate:modelValue","placeholder"])):o.type==="number"?(t.openBlock(),t.createBlock(c,{key:1,modelValue:e.filters[o.name],"onUpdate:modelValue":s=>e.filters[o.name]=s,placeholder:o.placeholder||`请输入${o.label}`,style:{width:"180px"}},null,8,["modelValue","onUpdate:modelValue","placeholder"])):o.type==="select"?(t.openBlock(),t.createBlock(u,{key:2,modelValue:e.filters[o.name],"onUpdate:modelValue":s=>e.filters[o.name]=s,placeholder:o.placeholder||`请选择${o.label}`,options:o.options,"allow-clear":"",style:{"min-width":"150px"}},null,8,["modelValue","onUpdate:modelValue","placeholder","options"])):o.type==="datePicker"?(t.openBlock(),t.createBlock(h,{key:3,modelValue:e.filters[o.name],"onUpdate:modelValue":s=>e.filters[o.name]=s,placeholder:o.placeholder||`请选择${o.label}`,style:{width:"180px"}},null,8,["modelValue","onUpdate:modelValue","placeholder"])):o.type==="rangePicker"?(t.openBlock(),t.createBlock(y,{key:4,modelValue:e.filters[o.name],"onUpdate:modelValue":s=>e.filters[o.name]=s,placeholder:[o.placeholder||"开始日期",o.placeholder||"结束日期"],style:{width:"240px"}},null,8,["modelValue","onUpdate:modelValue","placeholder"])):t.createCommentVNode("",!0)]),_:2},1032,["label"]))),128)),t.createVNode(k,null,{default:t.withCtx(()=>[t.createVNode(w,null,{default:t.withCtx(()=>[t.createVNode(f,{type:"primary",onClick:e.handleSearch},{default:t.withCtx(()=>[...n[1]||(n[1]=[t.createTextVNode("查询",-1)])]),_:1},8,["onClick"]),t.createVNode(f,{onClick:e.handleReset},{default:t.withCtx(()=>[...n[2]||(n[2]=[t.createTextVNode("重置",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1})]),_:1},8,["model"])])])):t.createCommentVNode("",!0),t.createElementVNode("div",O,[t.renderSlot(e.$slots,"toolbar",{loading:e.loading,refresh:e.refresh},()=>[t.createElementVNode("div",_,[e.title?(t.openBlock(),t.createElementBlock("span",j,t.toDisplayString(e.title),1)):t.createCommentVNode("",!0)]),t.createElementVNode("div",I,[t.createVNode(w,null,{default:t.withCtx(()=>[t.createVNode(f,{loading:e.loading,onClick:e.refresh},{default:t.withCtx(()=>[...n[3]||(n[3]=[t.createElementVNode("svg",{class:"vet-icon-svg",viewBox:"64 64 896 896",width:"1em",height:"1em",fill:"currentColor"},[t.createElementVNode("path",{d:"M909.1 209.3l-56.4 44.1C775.8 155.1 653.5 96 512 96 282.7 96 96 282.7 96 512s186.7 416 416 416c165.3 0 309.1-96.4 376-236.1 8.3-17.2-4.3-37.1-23.1-37.1H745.6c-9.2 0-17.2 5.8-20.3 14.3C680.5 773.5 600.5 832 512 832c-176.7 0-320-143.3-320-320s143.3-320 320-320c88.5 0 168.5 36.1 226.4 94.3L704 356.3c-4.7-4.7-1.3-12.7 5.3-13.1l193.7-12.5c6.6-.4 12.3 4.9 12.3 11.5v193.7c0 6.6-8 10-12.7 5.3z"})],-1),t.createTextVNode(" 刷新 ",-1)])]),_:1},8,["loading","onClick"]),e.autoRefresh?(t.openBlock(),t.createBlock(C,{key:0,checked:e.autoRefreshEnabled,"checked-children":"自动刷新","un-checked-children":"自动刷新",onChange:e.toggleAutoRefresh},null,8,["checked","onChange"])):t.createCommentVNode("",!0),e.autoRefresh&&e.autoRefreshEnabled?(t.openBlock(),t.createElementBlock("span",L,t.toDisplayString(e.countdown)+"s ",1)):t.createCommentVNode("",!0)]),_:1})])])]),t.createVNode(B,t.mergeProps({"data-source":e.data,columns:e.computedColumns,loading:e.loading,pagination:!1,"row-key":e.rowKey,bordered:e.bordered,scroll:e.scroll},e.$attrs,t.toHandlers(e.$listeners)),{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.filteredSlots,(o,s)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[s==="action"?t.renderSlot(e.$slots,"action",{key:0,record:e.slotData&&e.slotData.record,index:e.slotData&&e.slotData.index},()=>[e.download&&e.canDownload(e.slotData&&e.slotData.record)?(t.openBlock(),t.createElementBlock("a",{key:0,onClick:n[0]||(n[0]=g=>e.download.handleDownload(e.slotData.record))},"下载")):t.createCommentVNode("",!0)]):t.renderSlot(e.$slots,s,t.mergeProps({key:1,ref_for:!0},e.slotData||{}),()=>[t.createTextVNode(t.toDisplayString(e.slotData?e.slotData.text:""),1)])],64))),256))]),_:3},16,["data-source","columns","loading","row-key","bordered","scroll"]),e.total>0?(t.openBlock(),t.createElementBlock("div",M,[t.createVNode(V,{current:e.currentPage,"page-size":e.pageSize,total:e.total,"show-size-changer":!0,"show-quick-jumper":!0,"show-total":o=>`共 ${o} 条`,onChange:e.handlePageChange,onShowSizeChange:e.handlePageChange},null,8,["current","page-size","total","show-total","onChange","onShowSizeChange"])])):t.createCommentVNode("",!0)])}const q=D(F,[["render",H]]),z={install(e){e.component("DownloadTable",q)}};p.DownloadTable=q,p.VueExportTable=z,p.default=z,p.useAutoRefresh=T,p.usePagination=P,p.useQuery=R,p.useTable=$,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
package/package.json
CHANGED