@ditari/bsui 1.0.48 → 1.0.49
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 t=require("vue"),C=require("ant-design-vue"),P=require("../../utils/html.cjs.js"),M=require("../theme/index.cjs.js"),Q=()=>({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:()=>[]}}),b={defaultPageSize:20,hideOnSinglePage:!1,pageSizeOptions:["10","20","30","40"],responsive:!0,showQuickJumper:!0,showLessItems:!0,showTotal:
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),C=require("ant-design-vue"),P=require("../../utils/html.cjs.js"),M=require("../theme/index.cjs.js"),Q=()=>({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:()=>[]}}),b={defaultPageSize:20,hideOnSinglePage:!1,pageSizeOptions:["10","20","30","40"],responsive:!0,showQuickJumper:!0,showLessItems:!0,showTotal:a=>`总共 ${a} 条`},z=`${M.prefixName}-pagination`,I=t.defineComponent({name:"DTable",props:Q(),emits:["update:keys"],setup:function(a,{emit:p,slots:d}){const n=t.ref(a.keys||[]),E=t.computed(()=>a.data),K=t.computed(()=>{var e;return((e=a.config)==null?void 0:e.columns)??[]}),v=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:O,tableRootRef:B,tableHeight:V,onPageChange:H,onRowClassName:j}=q();function q(){const{rowClassName:e,keepSelected:l,onPageChange:i}=a.config,f=a.config.selection??"N",r=t.ref(),c=t.ref(null),o=t.ref(),u=t.ref(null),g=s=>{var h,N;try{const m=(h=c==null?void 0:c.value)==null?void 0:h.$el,x=P.useEleHeight(m.getElementsByClassName("ant-table-header")[0]);console.log(m.getElementsByClassName("ant-table-header")[0]),console.log(x);let T=0;if(a.config.pagination){const J=(N=r.value)==null?void 0:N.getElementsByClassName(z)[0];T=P.useEleHeight(J)??0}o.value=s-(x+T),m.getElementsByClassName("ant-table-body")[0].style.height=o.value+"px",u.value=m.getElementsByClassName("ant-table-body")[0]}catch(m){console.warn(m)}};return t.watchEffect(()=>{a.height!==0&&t.nextTick(()=>{setTimeout(()=>{g(a.height)},10)})}),{tableRef:c,tableRootRef:r,tableHeight:o,onPageChange:(s,h)=>{i&&i({page:s,size:h}),u.value.scrollTop=0,(f==="S"||!l)&&(n.value=[],p("update:keys",n.value))},onRowClassName:(s,h)=>e?e(s,h):void 0}}const D=F();function F(){const{rowKey:e,config:{getCheckboxProps:l}}=a;let i=a.config.selection??"N";const f=(o,u)=>{i==="S"?(n.value=[],n.value=u?[o[e]]:[]):n.value=u?n.value.concat(o[e]):n.value.filter(g=>g!==o[e]),p("update:keys",n.value)},r=(o,u,g)=>{const y=g.map(w=>w[e]);n.value=o?n.value.concat(y):n.value.filter(w=>!y.includes(w)),p("update:keys",n.value)};t.watch(()=>a.keys,o=>{n.value=o});const c=t.ref(void 0);return t.watchEffect(()=>{const{selection:o}=a.config;i=o,i!=="N"?c.value={selectedRowKeys:n,onSelect:f,onSelectAll:r,fixed:!0,columnTitle:i==="S"?"选择":null,columnWidth:i==="S"?60:40,getCheckboxProps:l}:c.value=void 0}),c}const U=_();function _(){return e=>{let l;const{rowKey:i,config:{click:f,dbClick:r,selection:c,getCheckboxProps:o}}=a,u=e[i],g=()=>{const y=o===void 0?!1:o(e).disabled;if(c==="N"||y)return;n.value.some(s=>s===u)?n.value=n.value.filter(s=>s!==u):(c==="S"&&(n.value=[]),n.value.push(u)),p("update:keys",n.value)};return{onClick:()=>{clearTimeout(l),l=setTimeout(()=>{g(),f&&f(e)},200)},onDblclick:()=>{clearTimeout(l),r&&r(e)}}}}const R=e=>{e.stopPropagation()},$=t.computed(()=>{const{selection:e}=a.config;return e==="N"}),k={};d.expandedRowRender&&(k.expandedRowRender=e=>t.createVNode(t.Fragment,null,[d.expandedRowRender&&d.expandedRowRender(e)]));const A=()=>t.createVNode(t.Fragment,null,[d.summary&&d.summary()]);return()=>{var e;return t.createVNode("div",{ref:B,style:{height:"100%"}},[t.createVNode(C.Table,{ref:O,"row-key":a.rowKey,bordered:a.config.bordered,columns:K.value,dataSource:E.value,loading:a.loading,size:((e=a.config)==null?void 0:e.size)??"small",scroll:{scrollToFirstRowOnChange:!0,x:"100%",y:V.value+"px"},expandedRowKeys:S.value,"onUpdate:expandedRowKeys":l=>S.value=l,expandRowByClick:$.value,pagination:!1,customRow:U,rowSelection:D.value,rowClassName:j},{bodyCell:({column:l,record:i})=>{if(l.slot==="action")return t.createVNode("div",{onClick:R,onDblclick:R},[t.createVNode(C.Space,null,{default:()=>[d.action&&d.action(i)]})])},...k,summary:A}),t.withDirectives(t.createVNode(C.Pagination,{class:[z],current:v.value.current,"onUpdate:current":l=>v.value.current=l,pageSize:v.value.pageSize,"onUpdate:pageSize":l=>v.value.pageSize=l,disabled:a.loading,"show-size-changer":!0,size:"default","hide-on-single-page":b.hideOnSinglePage,"show-quick-jumper":b.showQuickJumper,"default-page-size":b.defaultPageSize,"page-size-options":b.pageSizeOptions,"show-total":b.showTotal,total:v.value.total,onChange:H},null),[[t.vShow,a.config.pagination]])])}}});exports.default=I;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent as X, ref as r, computed as C, watchEffect as k, nextTick as _, watch as G, createVNode as f, withDirectives as M, vShow as Y, Fragment as
|
|
1
|
+
import { defineComponent as X, ref as r, computed as C, watchEffect as k, nextTick as _, watch as G, createVNode as f, withDirectives as M, vShow as Y, Fragment as K } from "vue";
|
|
2
2
|
import { Table as Z, Space as ee, Pagination as te } from "ant-design-vue";
|
|
3
|
-
import { useEleHeight as
|
|
3
|
+
import { useEleHeight as E } from "../../utils/html.esm.js";
|
|
4
4
|
import { prefixName as ne } from "../theme/index.esm.js";
|
|
5
5
|
const ae = () => ({
|
|
6
6
|
data: {
|
|
@@ -32,7 +32,7 @@ const ae = () => ({
|
|
|
32
32
|
type: Object,
|
|
33
33
|
default: () => []
|
|
34
34
|
}
|
|
35
|
-
}),
|
|
35
|
+
}), p = {
|
|
36
36
|
defaultPageSize: 20,
|
|
37
37
|
hideOnSinglePage: !1,
|
|
38
38
|
pageSizeOptions: ["10", "20", "30", "40"],
|
|
@@ -40,7 +40,7 @@ const ae = () => ({
|
|
|
40
40
|
showQuickJumper: !0,
|
|
41
41
|
showLessItems: !0,
|
|
42
42
|
showTotal: (t) => `总共 ${t} 条`
|
|
43
|
-
},
|
|
43
|
+
}, B = `${ne}-pagination`, ue = /* @__PURE__ */ X({
|
|
44
44
|
name: "DTable",
|
|
45
45
|
props: ae(),
|
|
46
46
|
// emits: { "update:keys": (keys: []) => void }
|
|
@@ -50,10 +50,10 @@ const ae = () => ({
|
|
|
50
50
|
emit: S,
|
|
51
51
|
slots: s
|
|
52
52
|
}) {
|
|
53
|
-
const n = r(t.keys || []), O = C(() => t.data),
|
|
53
|
+
const n = r(t.keys || []), O = C(() => t.data), H = C(() => {
|
|
54
54
|
var e;
|
|
55
55
|
return ((e = t.config) == null ? void 0 : e.columns) ?? [];
|
|
56
|
-
}),
|
|
56
|
+
}), y = C(() => {
|
|
57
57
|
var e;
|
|
58
58
|
return ((e = t.config) == null ? void 0 : e.pagination) ?? {};
|
|
59
59
|
}), R = r(t.expandedRowKeys);
|
|
@@ -64,34 +64,37 @@ const ae = () => ({
|
|
|
64
64
|
R.value = e;
|
|
65
65
|
});
|
|
66
66
|
const {
|
|
67
|
-
tableRef:
|
|
68
|
-
tableRootRef:
|
|
69
|
-
tableHeight:
|
|
70
|
-
onPageChange:
|
|
71
|
-
onRowClassName:
|
|
72
|
-
} =
|
|
73
|
-
function
|
|
67
|
+
tableRef: j,
|
|
68
|
+
tableRootRef: D,
|
|
69
|
+
tableHeight: U,
|
|
70
|
+
onPageChange: $,
|
|
71
|
+
onRowClassName: q
|
|
72
|
+
} = A();
|
|
73
|
+
function A() {
|
|
74
74
|
const {
|
|
75
75
|
rowClassName: e,
|
|
76
76
|
keepSelected: o,
|
|
77
77
|
onPageChange: l
|
|
78
78
|
} = t.config, m = t.config.selection ?? "N", d = r(), i = r(null), a = r(), c = r(null), g = (u) => {
|
|
79
|
-
var h,
|
|
79
|
+
var h, T;
|
|
80
80
|
try {
|
|
81
|
-
const
|
|
82
|
-
|
|
81
|
+
const v = (h = i == null ? void 0 : i.value) == null ? void 0 : h.$el, P = E(v.getElementsByClassName("ant-table-header")[0]);
|
|
82
|
+
console.log(v.getElementsByClassName("ant-table-header")[0]), console.log(P);
|
|
83
|
+
let z = 0;
|
|
83
84
|
if (t.config.pagination) {
|
|
84
|
-
const W = (
|
|
85
|
-
|
|
85
|
+
const W = (T = d.value) == null ? void 0 : T.getElementsByClassName(B)[0];
|
|
86
|
+
z = E(W) ?? 0;
|
|
86
87
|
}
|
|
87
|
-
a.value = u - (
|
|
88
|
-
} catch (
|
|
89
|
-
console.warn(
|
|
88
|
+
a.value = u - (P + z), v.getElementsByClassName("ant-table-body")[0].style.height = a.value + "px", c.value = v.getElementsByClassName("ant-table-body")[0];
|
|
89
|
+
} catch (v) {
|
|
90
|
+
console.warn(v);
|
|
90
91
|
}
|
|
91
92
|
};
|
|
92
93
|
return k(() => {
|
|
93
94
|
t.height !== 0 && _(() => {
|
|
94
|
-
|
|
95
|
+
setTimeout(() => {
|
|
96
|
+
g(t.height);
|
|
97
|
+
}, 10);
|
|
95
98
|
});
|
|
96
99
|
}), {
|
|
97
100
|
tableRef: i,
|
|
@@ -106,8 +109,8 @@ const ae = () => ({
|
|
|
106
109
|
onRowClassName: (u, h) => e ? e(u, h) : void 0
|
|
107
110
|
};
|
|
108
111
|
}
|
|
109
|
-
const
|
|
110
|
-
function
|
|
112
|
+
const F = J();
|
|
113
|
+
function J() {
|
|
111
114
|
const {
|
|
112
115
|
rowKey: e,
|
|
113
116
|
config: {
|
|
@@ -118,8 +121,8 @@ const ae = () => ({
|
|
|
118
121
|
const m = (a, c) => {
|
|
119
122
|
l === "S" ? (n.value = [], n.value = c ? [a[e]] : []) : n.value = c ? n.value.concat(a[e]) : n.value.filter((g) => g !== a[e]), S("update:keys", n.value);
|
|
120
123
|
}, d = (a, c, g) => {
|
|
121
|
-
const
|
|
122
|
-
n.value = a ? n.value.concat(
|
|
124
|
+
const w = g.map((b) => b[e]);
|
|
125
|
+
n.value = a ? n.value.concat(w) : n.value.filter((b) => !w.includes(b)), S("update:keys", n.value);
|
|
123
126
|
};
|
|
124
127
|
G(() => t.keys, (a) => {
|
|
125
128
|
n.value = a;
|
|
@@ -140,8 +143,8 @@ const ae = () => ({
|
|
|
140
143
|
} : i.value = void 0;
|
|
141
144
|
}), i;
|
|
142
145
|
}
|
|
143
|
-
const
|
|
144
|
-
function
|
|
146
|
+
const Q = I();
|
|
147
|
+
function I() {
|
|
145
148
|
return (e) => {
|
|
146
149
|
let o;
|
|
147
150
|
const {
|
|
@@ -153,8 +156,8 @@ const ae = () => ({
|
|
|
153
156
|
getCheckboxProps: a
|
|
154
157
|
}
|
|
155
158
|
} = t, c = e[l], g = () => {
|
|
156
|
-
const
|
|
157
|
-
if (i === "N" ||
|
|
159
|
+
const w = a === void 0 ? !1 : a(e).disabled;
|
|
160
|
+
if (i === "N" || w)
|
|
158
161
|
return;
|
|
159
162
|
n.value.some((u) => u === c) ? n.value = n.value.filter((u) => u !== c) : (i === "S" && (n.value = []), n.value.push(c)), S("update:keys", n.value);
|
|
160
163
|
};
|
|
@@ -182,41 +185,41 @@ const ae = () => ({
|
|
|
182
185
|
}
|
|
183
186
|
const x = (e) => {
|
|
184
187
|
e.stopPropagation();
|
|
185
|
-
},
|
|
188
|
+
}, L = C(() => {
|
|
186
189
|
const {
|
|
187
190
|
selection: e
|
|
188
191
|
} = t.config;
|
|
189
192
|
return e === "N";
|
|
190
193
|
}), N = {};
|
|
191
|
-
s.expandedRowRender && (N.expandedRowRender = (e) => f(
|
|
192
|
-
const
|
|
194
|
+
s.expandedRowRender && (N.expandedRowRender = (e) => f(K, null, [s.expandedRowRender && s.expandedRowRender(e)]));
|
|
195
|
+
const V = () => f(K, null, [s.summary && s.summary()]);
|
|
193
196
|
return () => {
|
|
194
197
|
var e;
|
|
195
198
|
return f("div", {
|
|
196
|
-
ref:
|
|
199
|
+
ref: D,
|
|
197
200
|
style: {
|
|
198
201
|
height: "100%"
|
|
199
202
|
}
|
|
200
203
|
}, [f(Z, {
|
|
201
|
-
ref:
|
|
204
|
+
ref: j,
|
|
202
205
|
"row-key": t.rowKey,
|
|
203
206
|
bordered: t.config.bordered,
|
|
204
|
-
columns:
|
|
207
|
+
columns: H.value,
|
|
205
208
|
dataSource: O.value,
|
|
206
209
|
loading: t.loading,
|
|
207
210
|
size: ((e = t.config) == null ? void 0 : e.size) ?? "small",
|
|
208
211
|
scroll: {
|
|
209
212
|
scrollToFirstRowOnChange: !0,
|
|
210
213
|
x: "100%",
|
|
211
|
-
y:
|
|
214
|
+
y: U.value + "px"
|
|
212
215
|
},
|
|
213
216
|
expandedRowKeys: R.value,
|
|
214
217
|
"onUpdate:expandedRowKeys": (o) => R.value = o,
|
|
215
|
-
expandRowByClick:
|
|
218
|
+
expandRowByClick: L.value,
|
|
216
219
|
pagination: !1,
|
|
217
|
-
customRow:
|
|
218
|
-
rowSelection:
|
|
219
|
-
rowClassName:
|
|
220
|
+
customRow: Q,
|
|
221
|
+
rowSelection: F.value,
|
|
222
|
+
rowClassName: q
|
|
220
223
|
}, {
|
|
221
224
|
bodyCell: ({
|
|
222
225
|
column: o,
|
|
@@ -232,23 +235,23 @@ const ae = () => ({
|
|
|
232
235
|
},
|
|
233
236
|
...N,
|
|
234
237
|
// 总结栏插槽
|
|
235
|
-
summary:
|
|
238
|
+
summary: V
|
|
236
239
|
}), M(f(te, {
|
|
237
|
-
class: [
|
|
238
|
-
current:
|
|
239
|
-
"onUpdate:current": (o) =>
|
|
240
|
-
pageSize:
|
|
241
|
-
"onUpdate:pageSize": (o) =>
|
|
240
|
+
class: [B],
|
|
241
|
+
current: y.value.current,
|
|
242
|
+
"onUpdate:current": (o) => y.value.current = o,
|
|
243
|
+
pageSize: y.value.pageSize,
|
|
244
|
+
"onUpdate:pageSize": (o) => y.value.pageSize = o,
|
|
242
245
|
disabled: t.loading,
|
|
243
246
|
"show-size-changer": !0,
|
|
244
247
|
size: "default",
|
|
245
|
-
"hide-on-single-page":
|
|
246
|
-
"show-quick-jumper":
|
|
247
|
-
"default-page-size":
|
|
248
|
-
"page-size-options":
|
|
249
|
-
"show-total":
|
|
250
|
-
total:
|
|
251
|
-
onChange:
|
|
248
|
+
"hide-on-single-page": p.hideOnSinglePage,
|
|
249
|
+
"show-quick-jumper": p.showQuickJumper,
|
|
250
|
+
"default-page-size": p.defaultPageSize,
|
|
251
|
+
"page-size-options": p.pageSizeOptions,
|
|
252
|
+
"show-total": p.showTotal,
|
|
253
|
+
total: y.value.total,
|
|
254
|
+
onChange: $
|
|
252
255
|
}, null), [[Y, t.config.pagination]])]);
|
|
253
256
|
};
|
|
254
257
|
}
|
package/package.json
CHANGED
|
@@ -141,6 +141,8 @@ const DXTable = defineComponent({
|
|
|
141
141
|
const headerHeight = useEleHeight(
|
|
142
142
|
tableEl.getElementsByClassName("ant-table-header")[0]
|
|
143
143
|
);
|
|
144
|
+
console.log(tableEl.getElementsByClassName("ant-table-header")[0]);
|
|
145
|
+
console.log(headerHeight);
|
|
144
146
|
// 获取分页组件高度
|
|
145
147
|
let paginationHeight = 0;
|
|
146
148
|
if (props.config.pagination) {
|
|
@@ -164,7 +166,10 @@ const DXTable = defineComponent({
|
|
|
164
166
|
if (props.height !== 0) {
|
|
165
167
|
nextTick(() => {
|
|
166
168
|
// 必须在组件挂载成功后 执行计算高度 否则无法正确获取元素的高度
|
|
167
|
-
|
|
169
|
+
setTimeout(() => {
|
|
170
|
+
// 如果表格头 有多行的清空下,获取到的头部高度不对,需要延迟执行获取高度方法
|
|
171
|
+
playHeight(props.height);
|
|
172
|
+
}, 10);
|
|
168
173
|
});
|
|
169
174
|
}
|
|
170
175
|
});
|