@ditari/bsui 1.0.28 → 1.0.29
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),C=require("ant-design-vue"),x=require("../../utils/html.cjs.js"),J=require("../theme/index.cjs.js"),M=()=>({data:{type:Object,required:!0},height:{type:Number,default:300},keys:Array,rowKey:{type:String,default:"id"},loading:{type:Boolean,default:!1},pagination:{type:Object,default:()=>({})},config:{type:Object,default:()=>({})},expandedRowKeys:{type:Object,default:()=>[]}}),p={defaultPageSize:20,hideOnSinglePage:!1,pageSizeOptions:["10","20","30","40"],responsive:!0,showQuickJumper:!0,showLessItems:!0,showTotal:a=>`总共 ${a} 条`},P=`${J.prefixName}-pagination`,Q=t.defineComponent({name:"DTable",props:M(),emits:["update:keys"],setup:function(a,{emit:b,slots:h}){const n=t.ref(a.keys||[]),T=t.computed(()=>a.data),z=t.computed(()=>{var e;return((e=a.config)==null?void 0:e.columns)??[]}),m=t.computed(()=>{var e;return((e=a.config)==null?void 0:e.pagination)??{}}),S=t.ref(a.expandedRowKeys);t.watchEffect(()=>{const{expandedRowKeys:e}=a;S.value=e});const{tableRef:E,tableRootRef:K,tableHeight:O,onPageChange:V,onRowClassName:B}=H();function H(){const{rowClassName:e,keepSelected:o,onPageChange:i}=a.config,s=a.config.selection??"N",r=t.ref(),c=t.ref(null),l=t.ref(),u=t.ref(null),g=y=>{var v,k;try{const w=(v=c==null?void 0:c.value)==null?void 0:v.$el,$=x.useEleHeight(w.getElementsByClassName("ant-table-header")[0]);let N=0;if(a.config.pagination){const A=(k=r.value)==null?void 0:k.getElementsByClassName(P)[0];N=x.useEleHeight(A)??0}l.value=y-($+N),w.getElementsByClassName("ant-table-body")[0].style.height=l.value-10+"px",u.value=w.getElementsByClassName("ant-table-body")[0]}catch(w){console.warn(w)}};return t.watchEffect(()=>{a.height!==0&&t.nextTick(()=>{g(a.height)})}),{tableRef:c,tableRootRef:r,tableHeight:l,onPageChange:(y,v)=>{i&&i({page:y,size:v}),u.value.scrollTop=0,(s==="S"||!o)&&(n.value=[],b("update:keys",n.value))},onRowClassName:(y,v)=>e?e(y,v):void 0}}const j=q();function q(){const{rowKey:e,config:{getCheckboxProps:o}}=a;let i=a.config.selection??"N";const s=(l,u)=>{i==="S"?(n.value=[],n.value=u?[l[e]]:[]):n.value=u?n.value.concat(l[e]):n.value.filter(g=>g!==l[e]),b("update:keys",n.value)},r=(l,u,g)=>{const f=g.map(d=>d[e]);n.value=l?n.value.concat(f):n.value.filter(d=>!f.includes(d)),b("update:keys",n.value)};t.watch(()=>a.keys,l=>{n.value=l});const c=t.ref(void 0);return t.watchEffect(()=>{const{selection:l}=a.config;i=l,i!=="N"?c.value={selectedRowKeys:n,onSelect:s,onSelectAll:r,fixed:!0,columnTitle:i==="S"?"选择":null,columnWidth:i==="S"?60:40,getCheckboxProps:o}:c.value=void 0}),c}const D=F();function F(){return e=>{let o;const{rowKey:i,config:{click:s,dbClick:r,selection:c,getCheckboxProps:l}}=a,u=e[i],g=()=>{if(c==="N")return;n.value.some(d=>d===u)?n.value=n.value.filter(d=>d!==u):(c==="S"&&(n.value=[]),n.value.push(u)),b("update:keys",n.value)};return{onClick:()=>{const f=l?l(e):null;f&&f.value===u||(clearTimeout(o),o=setTimeout(()=>{g(),s&&s(e)},200))},onDblclick:()=>{clearTimeout(o),r&&r(e)}}}}const R=e=>{e.stopPropagation()},U=(e,o,i,s)=>t.createVNode(t.Fragment,null,[h.expandedRowRender&&h.expandedRowRender({record:e,index:o,indent:i,expanded:s})]),_=()=>t.createVNode(t.Fragment,null,[h.summary&&h.summary()]);return()=>{var e;return t.createVNode("div",{ref:K},[t.createVNode(C.Table,{ref:E,"row-key":a.rowKey,bordered:a.config.bordered,columns:z.value,dataSource:T.value,loading:a.loading,size:((e=a.config)==null?void 0:e.size)??"small",scroll:{scrollToFirstRowOnChange:!0,x:"100%",y:O.value+"px"},expandedRowKeys:S.value,"onUpdate:expandedRowKeys":o=>S.value=o,expandRowByClick:!0,pagination:!1,customRow:D,rowSelection:j.value,rowClassName:B},{bodyCell:({column:o,record:i})=>{if(o.slot==="action")return t.createVNode("div",{onClick:R,onDblclick:R},[t.createVNode(C.Space,null,{default:()=>[h.action&&h.action(i)]})])},expandedRowRender:U,summary:_}),t.withDirectives(t.createVNode(C.Pagination,{class:[P],current:m.value.current,"onUpdate:current":o=>m.value.current=o,pageSize:m.value.pageSize,"onUpdate:pageSize":o=>m.value.pageSize=o,disabled:a.loading,"show-size-changer":!0,size:"default","hide-on-single-page":p.hideOnSinglePage,"show-quick-jumper":p.showQuickJumper,"default-page-size":p.defaultPageSize,"page-size-options":p.pageSizeOptions,"show-total":p.showTotal,total:m.value.total,onChange:V},null),[[t.vShow,a.config.pagination]])])}}});exports.default=Q;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { defineComponent as W, ref as f, computed as R, watchEffect as k, nextTick as X, watch as _, createVNode as m, withDirectives as G, vShow as M, Fragment as T } from "vue";
|
|
2
2
|
import { Table as Y, Space as Z, Pagination as ee } from "ant-design-vue";
|
|
3
3
|
import { useEleHeight as z } from "../../utils/html.esm.js";
|
|
4
|
-
import { prefixName as
|
|
5
|
-
const
|
|
4
|
+
import { prefixName as te } from "../theme/index.esm.js";
|
|
5
|
+
const ne = () => ({
|
|
6
6
|
data: {
|
|
7
7
|
type: Object,
|
|
8
8
|
required: !0
|
|
@@ -39,28 +39,28 @@ const te = () => ({
|
|
|
39
39
|
responsive: !0,
|
|
40
40
|
showQuickJumper: !0,
|
|
41
41
|
showLessItems: !0,
|
|
42
|
-
showTotal: (
|
|
43
|
-
}, K = `${
|
|
42
|
+
showTotal: (t) => `总共 ${t} 条`
|
|
43
|
+
}, K = `${te}-pagination`, ue = /* @__PURE__ */ W({
|
|
44
44
|
name: "DTable",
|
|
45
|
-
props:
|
|
45
|
+
props: ne(),
|
|
46
46
|
// emits: { "update:keys": (keys: []) => void }
|
|
47
47
|
// TODO 需要做调整
|
|
48
48
|
emits: ["update:keys"],
|
|
49
|
-
setup: function(
|
|
49
|
+
setup: function(t, {
|
|
50
50
|
emit: S,
|
|
51
51
|
slots: h
|
|
52
52
|
}) {
|
|
53
|
-
const
|
|
53
|
+
const n = f(t.keys || []), O = R(() => t.data), E = R(() => {
|
|
54
54
|
var e;
|
|
55
|
-
return ((e =
|
|
55
|
+
return ((e = t.config) == null ? void 0 : e.columns) ?? [];
|
|
56
56
|
}), y = R(() => {
|
|
57
57
|
var e;
|
|
58
|
-
return ((e =
|
|
59
|
-
}), C = f(
|
|
58
|
+
return ((e = t.config) == null ? void 0 : e.pagination) ?? {};
|
|
59
|
+
}), C = f(t.expandedRowKeys);
|
|
60
60
|
k(() => {
|
|
61
61
|
const {
|
|
62
62
|
expandedRowKeys: e
|
|
63
|
-
} =
|
|
63
|
+
} = t;
|
|
64
64
|
C.value = e;
|
|
65
65
|
});
|
|
66
66
|
const {
|
|
@@ -75,12 +75,12 @@ const te = () => ({
|
|
|
75
75
|
rowClassName: e,
|
|
76
76
|
keepSelected: a,
|
|
77
77
|
onPageChange: l
|
|
78
|
-
} =
|
|
78
|
+
} = t.config, c = t.config.selection ?? "N", d = f(), u = f(null), o = f(), i = f(null), r = (w) => {
|
|
79
79
|
var v, N;
|
|
80
80
|
try {
|
|
81
81
|
const p = (v = u == null ? void 0 : u.value) == null ? void 0 : v.$el, L = z(p.getElementsByClassName("ant-table-header")[0]);
|
|
82
82
|
let P = 0;
|
|
83
|
-
if (
|
|
83
|
+
if (t.config.pagination) {
|
|
84
84
|
const V = (N = d.value) == null ? void 0 : N.getElementsByClassName(K)[0];
|
|
85
85
|
P = z(V) ?? 0;
|
|
86
86
|
}
|
|
@@ -90,8 +90,8 @@ const te = () => ({
|
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
92
|
return k(() => {
|
|
93
|
-
|
|
94
|
-
r(
|
|
93
|
+
t.height !== 0 && X(() => {
|
|
94
|
+
r(t.height);
|
|
95
95
|
});
|
|
96
96
|
}), {
|
|
97
97
|
tableRef: u,
|
|
@@ -101,7 +101,7 @@ const te = () => ({
|
|
|
101
101
|
l && l({
|
|
102
102
|
page: w,
|
|
103
103
|
size: v
|
|
104
|
-
}), i.value.scrollTop = 0, (
|
|
104
|
+
}), i.value.scrollTop = 0, (c === "S" || !a) && (n.value = [], S("update:keys", n.value));
|
|
105
105
|
},
|
|
106
106
|
onRowClassName: (w, v) => e ? e(w, v) : void 0
|
|
107
107
|
};
|
|
@@ -113,25 +113,25 @@ const te = () => ({
|
|
|
113
113
|
config: {
|
|
114
114
|
getCheckboxProps: a
|
|
115
115
|
}
|
|
116
|
-
} =
|
|
117
|
-
let l =
|
|
118
|
-
const
|
|
119
|
-
l === "S" ? (
|
|
116
|
+
} = t;
|
|
117
|
+
let l = t.config.selection ?? "N";
|
|
118
|
+
const c = (o, i) => {
|
|
119
|
+
l === "S" ? (n.value = [], n.value = i ? [o[e]] : []) : n.value = i ? n.value.concat(o[e]) : n.value.filter((r) => r !== o[e]), S("update:keys", n.value);
|
|
120
120
|
}, d = (o, i, r) => {
|
|
121
|
-
const g = r.map((
|
|
122
|
-
|
|
121
|
+
const g = r.map((s) => s[e]);
|
|
122
|
+
n.value = o ? n.value.concat(g) : n.value.filter((s) => !g.includes(s)), S("update:keys", n.value);
|
|
123
123
|
};
|
|
124
|
-
_(() =>
|
|
125
|
-
|
|
124
|
+
_(() => t.keys, (o) => {
|
|
125
|
+
n.value = o;
|
|
126
126
|
});
|
|
127
127
|
const u = f(void 0);
|
|
128
128
|
return k(() => {
|
|
129
129
|
const {
|
|
130
130
|
selection: o
|
|
131
|
-
} =
|
|
131
|
+
} = t.config;
|
|
132
132
|
l = o, l !== "N" ? u.value = {
|
|
133
|
-
selectedRowKeys:
|
|
134
|
-
onSelect:
|
|
133
|
+
selectedRowKeys: n,
|
|
134
|
+
onSelect: c,
|
|
135
135
|
onSelectAll: d,
|
|
136
136
|
fixed: !0,
|
|
137
137
|
columnTitle: l === "S" ? "选择" : null,
|
|
@@ -147,21 +147,21 @@ const te = () => ({
|
|
|
147
147
|
const {
|
|
148
148
|
rowKey: l,
|
|
149
149
|
config: {
|
|
150
|
-
click:
|
|
150
|
+
click: c,
|
|
151
151
|
dbClick: d,
|
|
152
152
|
selection: u,
|
|
153
153
|
getCheckboxProps: o
|
|
154
154
|
}
|
|
155
|
-
} =
|
|
155
|
+
} = t, i = e[l], r = () => {
|
|
156
156
|
if (u === "N")
|
|
157
157
|
return;
|
|
158
|
-
|
|
158
|
+
n.value.some((s) => s === i) ? n.value = n.value.filter((s) => s !== i) : (u === "S" && (n.value = []), n.value.push(i)), S("update:keys", n.value);
|
|
159
159
|
};
|
|
160
160
|
return {
|
|
161
161
|
onClick: () => {
|
|
162
162
|
const g = o ? o(e) : null;
|
|
163
163
|
g && g.value === i || (clearTimeout(a), a = setTimeout(() => {
|
|
164
|
-
r(),
|
|
164
|
+
r(), c && c(e);
|
|
165
165
|
}, 200));
|
|
166
166
|
},
|
|
167
167
|
// 点击行
|
|
@@ -182,19 +182,24 @@ const te = () => ({
|
|
|
182
182
|
}
|
|
183
183
|
const x = (e) => {
|
|
184
184
|
e.stopPropagation();
|
|
185
|
-
}, Q = (e, a, l,
|
|
185
|
+
}, Q = (e, a, l, c) => m(T, null, [h.expandedRowRender && h.expandedRowRender({
|
|
186
|
+
record: e,
|
|
187
|
+
index: a,
|
|
188
|
+
indent: l,
|
|
189
|
+
expanded: c
|
|
190
|
+
})]), I = () => m(T, null, [h.summary && h.summary()]);
|
|
186
191
|
return () => {
|
|
187
192
|
var e;
|
|
188
193
|
return m("div", {
|
|
189
194
|
ref: H
|
|
190
195
|
}, [m(Y, {
|
|
191
196
|
ref: B,
|
|
192
|
-
"row-key":
|
|
193
|
-
bordered:
|
|
197
|
+
"row-key": t.rowKey,
|
|
198
|
+
bordered: t.config.bordered,
|
|
194
199
|
columns: E.value,
|
|
195
200
|
dataSource: O.value,
|
|
196
|
-
loading:
|
|
197
|
-
size: ((e =
|
|
201
|
+
loading: t.loading,
|
|
202
|
+
size: ((e = t.config) == null ? void 0 : e.size) ?? "small",
|
|
198
203
|
scroll: {
|
|
199
204
|
scrollToFirstRowOnChange: !0,
|
|
200
205
|
x: "100%",
|
|
@@ -230,7 +235,7 @@ const te = () => ({
|
|
|
230
235
|
"onUpdate:current": (a) => y.value.current = a,
|
|
231
236
|
pageSize: y.value.pageSize,
|
|
232
237
|
"onUpdate:pageSize": (a) => y.value.pageSize = a,
|
|
233
|
-
disabled:
|
|
238
|
+
disabled: t.loading,
|
|
234
239
|
"show-size-changer": !0,
|
|
235
240
|
size: "default",
|
|
236
241
|
"hide-on-single-page": b.hideOnSinglePage,
|
|
@@ -240,7 +245,7 @@ const te = () => ({
|
|
|
240
245
|
"show-total": b.showTotal,
|
|
241
246
|
total: y.value.total,
|
|
242
247
|
onChange: D
|
|
243
|
-
}, null), [[M,
|
|
248
|
+
}, null), [[M, t.config.pagination]])]);
|
|
244
249
|
};
|
|
245
250
|
}
|
|
246
251
|
});
|
package/package.json
CHANGED
|
@@ -358,7 +358,12 @@ const DXTable = defineComponent({
|
|
|
358
358
|
indent: number,
|
|
359
359
|
expanded: any
|
|
360
360
|
) => {
|
|
361
|
-
return
|
|
361
|
+
return (
|
|
362
|
+
<>
|
|
363
|
+
{slots.expandedRowRender &&
|
|
364
|
+
slots.expandedRowRender({ record, index, indent, expanded })}
|
|
365
|
+
</>
|
|
366
|
+
);
|
|
362
367
|
};
|
|
363
368
|
|
|
364
369
|
const summary = () => {
|