@ditari/bsui 1.0.11 → 1.0.13
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 n=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),S=require("ant-design-vue"),k=require("../../utils/html.cjs.js"),D=require("../theme/index.cjs.js"),K=()=>({data:{type:Object,required:!0},height:{type:Number,default:300},keys:Array,rowKey:{type:String,required:!0,default:"id"},loading:{type:Boolean,default:!1},pagination:{type:Object,default:()=>({})},config:{type:Object,default:()=>({})}}),y={defaultPageSize:20,hideOnSinglePage:!1,pageSizeOptions:["10","20","30","40"],responsive:!0,showQuickJumper:!0,showLessItems:!0,showTotal:a=>`总共 ${a} 条`},N=`${D.prefixName}-pagination`,V=n.defineComponent({name:"DTable",props:K(),emits:["update:keys"],setup(a,{emit:b,slots:p}){const e=n.ref(a.keys),T=n.computed(()=>a.data),P=n.computed(()=>{var t;return((t=a.config)==null?void 0:t.columns)??[]}),h=n.computed(()=>{var t;return((t=a.config)==null?void 0:t.pagination)??{}}),{tableRef:z,tableHeight:R,onPageChange:x,onRowClassName:H}=E();function E(){const{rowClassName:t,keepSelected:l,selection:m,onPageChange:g}=a.config,s=n.ref(null),o=n.ref(),u=n.ref(null),i=c=>{var d;try{const f=(d=s==null?void 0:s.value)==null?void 0:d.$el;console.log("tableEl",f);const C=k.useEleHeight(f.getElementsByClassName("ant-table-header")[0]);console.log("headerHeight",C);let w=0;a.config.pagination&&(w=k.useEleHeight(document.getElementsByClassName(N)[0])),console.log("paginationHeight",w),o.value=c-(C+w),console.log("tableHeight",o),f.getElementsByClassName("ant-table-body")[0].style.height=o.value-10+"px",u.value=f.getElementsByClassName("ant-table-body")[0],console.log("antTableBodyRef",u)}catch(f){console.warn(f)}};return n.watchEffect(()=>{a.height!==0&&n.nextTick(()=>{i(a.height)})}),{tableRef:s,tableHeight:o,onPageChange:(c,d)=>{g&&g({page:c,size:d}),u.value.scrollTop=0,(m==="S"||!l)&&(e.value=[],b("update:keys",e.value))},onRowClassName:(c,d)=>t?t(c,d):void 0}}const O=q();function q(){const{rowKey:t,config:{selection:l,getCheckboxProps:m}}=a;if(l==="N")return;const g=(o,u)=>{l==="S"?(e.value=[],e.value=u?[o[t]]:[]):e.value=u?e.value.concat(o[t]):e.value.filter(i=>i!==o[t]),b("update:keys",e.value)},s=(o,u,i)=>{const v=i.map(r=>r[t]);e.value=o?e.value.concat(v):e.value.filter(r=>!v.includes(r)),b("update:keys",e.value)};return n.watch(()=>a.keys,o=>{e.value=o}),{selectedRowKeys:e,onSelect:g,onSelectAll:s,fixed:!0,columnTitle:l==="S"?"选择":null,columnWidth:l==="S"?60:40,getCheckboxProps:m}}const B=j();function j(){return t=>{let l;const{rowKey:m,config:{click:g,dbClick:s,selection:o,getCheckboxProps:u}}=a,i=t[m],v=()=>{if(o==="N")return;e.value.some(c=>c===i)?e.value=e.value.filter(c=>c!==i):(o==="S"&&(e.value=[]),e.value.push(i)),b("update:keys",e.value)};return{onClick:()=>{if(!g)return;const r=u?u(t):null;r&&r.value===i||(clearTimeout(l),l=setTimeout(()=>{v(),g(t)},200))},onDblclick:()=>{s&&(clearTimeout(l),s(t))}}}}return()=>{var t;return n.createVNode(n.Fragment,null,[n.createVNode(S.Table,{ref:z,"row-key":a.rowKey,bordered:a.config.bordered,columns:P.value,dataSource:T.value,loading:a.loading,size:((t=a.config)==null?void 0:t.size)??"small",scroll:{scrollToFirstRowOnChange:!0,x:"100%",y:R.value+"px"},pagination:!1,customRow:B,rowSelection:O,rowClassName:H},{bodyCell:({column:l})=>{if(l.slot==="action")return n.createVNode(S.Space,null,{default:()=>[p.action&&p.action()]})}}),n.withDirectives(n.createVNode(S.Pagination,{class:[N],current:h.value.current,"onUpdate:current":l=>h.value.current=l,pageSize:h.value.pageSize,"onUpdate:pageSize":l=>h.value.pageSize=l,disabled:a.loading,"show-size-changer":!0,size:"default","hide-on-single-page":y.hideOnSinglePage,"show-quick-jumper":y.showQuickJumper,"default-page-size":y.defaultPageSize,"page-size-options":y.pageSizeOptions,"show-total":y.showTotal,total:h.value.total,onChange:x},null),[[n.vShow,a.config.pagination]])])}}});exports.default=V;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent as q, ref as
|
|
1
|
+
import { defineComponent as q, ref as w, computed as S, watchEffect as $, nextTick as A, watch as F, createVNode as b, Fragment as J, withDirectives as Q, vShow as U } from "vue";
|
|
2
2
|
import { Table as I, Space as L, Pagination as V } from "ant-design-vue";
|
|
3
|
-
import { useEleHeight as
|
|
3
|
+
import { useEleHeight as T } from "../../utils/html.esm.js";
|
|
4
4
|
import { prefixName as W } from "../theme/index.esm.js";
|
|
5
5
|
const X = () => ({
|
|
6
6
|
data: {
|
|
@@ -29,7 +29,7 @@ const X = () => ({
|
|
|
29
29
|
type: Object,
|
|
30
30
|
default: () => ({})
|
|
31
31
|
}
|
|
32
|
-
}),
|
|
32
|
+
}), v = {
|
|
33
33
|
defaultPageSize: 20,
|
|
34
34
|
hideOnSinglePage: !1,
|
|
35
35
|
pageSizeOptions: ["10", "20", "30", "40"],
|
|
@@ -44,107 +44,114 @@ const X = () => ({
|
|
|
44
44
|
// TODO 需要做调整
|
|
45
45
|
emits: ["update:keys"],
|
|
46
46
|
setup(a, {
|
|
47
|
-
emit:
|
|
48
|
-
slots:
|
|
47
|
+
emit: y,
|
|
48
|
+
slots: C
|
|
49
49
|
}) {
|
|
50
|
-
const e =
|
|
50
|
+
const e = w(a.keys), z = S(() => a.data), P = S(() => {
|
|
51
51
|
var t;
|
|
52
52
|
return ((t = a.config) == null ? void 0 : t.columns) ?? [];
|
|
53
|
-
}), f =
|
|
53
|
+
}), f = S(() => {
|
|
54
54
|
var t;
|
|
55
55
|
return ((t = a.config) == null ? void 0 : t.pagination) ?? {};
|
|
56
56
|
}), {
|
|
57
|
-
tableRef:
|
|
58
|
-
tableHeight:
|
|
59
|
-
onPageChange:
|
|
60
|
-
onRowClassName:
|
|
61
|
-
} =
|
|
62
|
-
function
|
|
57
|
+
tableRef: R,
|
|
58
|
+
tableHeight: x,
|
|
59
|
+
onPageChange: H,
|
|
60
|
+
onRowClassName: E
|
|
61
|
+
} = O();
|
|
62
|
+
function O() {
|
|
63
63
|
const {
|
|
64
64
|
rowClassName: t,
|
|
65
65
|
keepSelected: n,
|
|
66
|
-
selection:
|
|
67
|
-
onPageChange:
|
|
68
|
-
} = a.config,
|
|
69
|
-
var
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
66
|
+
selection: h,
|
|
67
|
+
onPageChange: g
|
|
68
|
+
} = a.config, u = w(null), l = w(), i = w(null), o = (s) => {
|
|
69
|
+
var r;
|
|
70
|
+
try {
|
|
71
|
+
const d = (r = u == null ? void 0 : u.value) == null ? void 0 : r.$el;
|
|
72
|
+
console.log("tableEl", d);
|
|
73
|
+
const k = T(d.getElementsByClassName("ant-table-header")[0]);
|
|
74
|
+
console.log("headerHeight", k);
|
|
75
|
+
let p = 0;
|
|
76
|
+
a.config.pagination && (p = T(document.getElementsByClassName(N)[0])), console.log("paginationHeight", p), l.value = s - (k + p), console.log("tableHeight", l), d.getElementsByClassName("ant-table-body")[0].style.height = l.value - 10 + "px", i.value = d.getElementsByClassName("ant-table-body")[0], console.log("antTableBodyRef", i);
|
|
77
|
+
} catch (d) {
|
|
78
|
+
console.warn(d);
|
|
79
|
+
}
|
|
73
80
|
};
|
|
74
81
|
return $(() => {
|
|
75
82
|
a.height !== 0 && A(() => {
|
|
76
83
|
o(a.height);
|
|
77
84
|
});
|
|
78
85
|
}), {
|
|
79
|
-
tableRef:
|
|
86
|
+
tableRef: u,
|
|
80
87
|
tableHeight: l,
|
|
81
|
-
onPageChange: (s,
|
|
82
|
-
|
|
88
|
+
onPageChange: (s, r) => {
|
|
89
|
+
g && g({
|
|
83
90
|
page: s,
|
|
84
|
-
size:
|
|
85
|
-
}),
|
|
91
|
+
size: r
|
|
92
|
+
}), i.value.scrollTop = 0, (h === "S" || !n) && (e.value = [], y("update:keys", e.value));
|
|
86
93
|
},
|
|
87
|
-
onRowClassName: (s,
|
|
94
|
+
onRowClassName: (s, r) => t ? t(s, r) : void 0
|
|
88
95
|
};
|
|
89
96
|
}
|
|
90
|
-
const B =
|
|
91
|
-
function
|
|
97
|
+
const B = K();
|
|
98
|
+
function K() {
|
|
92
99
|
const {
|
|
93
100
|
rowKey: t,
|
|
94
101
|
config: {
|
|
95
102
|
selection: n,
|
|
96
|
-
getCheckboxProps:
|
|
103
|
+
getCheckboxProps: h
|
|
97
104
|
}
|
|
98
105
|
} = a;
|
|
99
106
|
if (n === "N")
|
|
100
107
|
return;
|
|
101
|
-
const
|
|
102
|
-
n === "S" ? (e.value = [], e.value =
|
|
103
|
-
},
|
|
104
|
-
const
|
|
105
|
-
e.value = l ? e.value.concat(
|
|
108
|
+
const g = (l, i) => {
|
|
109
|
+
n === "S" ? (e.value = [], e.value = i ? [l[t]] : []) : e.value = i ? e.value.concat(l[t]) : e.value.filter((o) => o !== l[t]), y("update:keys", e.value);
|
|
110
|
+
}, u = (l, i, o) => {
|
|
111
|
+
const m = o.map((c) => c[t]);
|
|
112
|
+
e.value = l ? e.value.concat(m) : e.value.filter((c) => !m.includes(c)), y("update:keys", e.value);
|
|
106
113
|
};
|
|
107
114
|
return F(() => a.keys, (l) => {
|
|
108
115
|
e.value = l;
|
|
109
116
|
}), {
|
|
110
117
|
selectedRowKeys: e,
|
|
111
|
-
onSelect:
|
|
112
|
-
onSelectAll:
|
|
118
|
+
onSelect: g,
|
|
119
|
+
onSelectAll: u,
|
|
113
120
|
fixed: !0,
|
|
114
121
|
columnTitle: n === "S" ? "选择" : null,
|
|
115
122
|
columnWidth: n === "S" ? 60 : 40,
|
|
116
|
-
getCheckboxProps:
|
|
123
|
+
getCheckboxProps: h
|
|
117
124
|
};
|
|
118
125
|
}
|
|
119
|
-
const
|
|
120
|
-
function
|
|
126
|
+
const j = D();
|
|
127
|
+
function D() {
|
|
121
128
|
return (t) => {
|
|
122
129
|
let n;
|
|
123
130
|
const {
|
|
124
|
-
rowKey:
|
|
131
|
+
rowKey: h,
|
|
125
132
|
config: {
|
|
126
|
-
click:
|
|
127
|
-
dbClick:
|
|
133
|
+
click: g,
|
|
134
|
+
dbClick: u,
|
|
128
135
|
selection: l,
|
|
129
|
-
getCheckboxProps:
|
|
136
|
+
getCheckboxProps: i
|
|
130
137
|
}
|
|
131
|
-
} = a, o = t[
|
|
138
|
+
} = a, o = t[h], m = () => {
|
|
132
139
|
if (l === "N")
|
|
133
140
|
return;
|
|
134
|
-
e.value.some((s) => s === o) ? e.value = e.value.filter((s) => s !== o) : (l === "S" && (e.value = []), e.value.push(o)),
|
|
141
|
+
e.value.some((s) => s === o) ? e.value = e.value.filter((s) => s !== o) : (l === "S" && (e.value = []), e.value.push(o)), y("update:keys", e.value);
|
|
135
142
|
};
|
|
136
143
|
return {
|
|
137
144
|
onClick: () => {
|
|
138
|
-
if (!
|
|
145
|
+
if (!g)
|
|
139
146
|
return;
|
|
140
|
-
const c =
|
|
147
|
+
const c = i ? i(t) : null;
|
|
141
148
|
c && c.value === o || (clearTimeout(n), n = setTimeout(() => {
|
|
142
|
-
|
|
149
|
+
m(), g(t);
|
|
143
150
|
}, 200));
|
|
144
151
|
},
|
|
145
152
|
// 点击行
|
|
146
153
|
onDblclick: () => {
|
|
147
|
-
|
|
154
|
+
u && (clearTimeout(n), u(t));
|
|
148
155
|
}
|
|
149
156
|
// onContextmenu: (event) => {
|
|
150
157
|
// //TODO
|
|
@@ -160,33 +167,33 @@ const X = () => ({
|
|
|
160
167
|
}
|
|
161
168
|
return () => {
|
|
162
169
|
var t;
|
|
163
|
-
return
|
|
164
|
-
ref:
|
|
170
|
+
return b(J, null, [b(I, {
|
|
171
|
+
ref: R,
|
|
165
172
|
"row-key": a.rowKey,
|
|
166
173
|
bordered: a.config.bordered,
|
|
167
|
-
columns:
|
|
168
|
-
dataSource:
|
|
174
|
+
columns: P.value,
|
|
175
|
+
dataSource: z.value,
|
|
169
176
|
loading: a.loading,
|
|
170
177
|
size: ((t = a.config) == null ? void 0 : t.size) ?? "small",
|
|
171
178
|
scroll: {
|
|
172
179
|
scrollToFirstRowOnChange: !0,
|
|
173
180
|
x: "100%",
|
|
174
|
-
y:
|
|
181
|
+
y: x.value + "px"
|
|
175
182
|
},
|
|
176
183
|
pagination: !1,
|
|
177
|
-
customRow:
|
|
184
|
+
customRow: j,
|
|
178
185
|
rowSelection: B,
|
|
179
|
-
rowClassName:
|
|
186
|
+
rowClassName: E
|
|
180
187
|
}, {
|
|
181
188
|
bodyCell: ({
|
|
182
189
|
column: n
|
|
183
190
|
}) => {
|
|
184
191
|
if (n.slot === "action")
|
|
185
|
-
return
|
|
186
|
-
default: () => [
|
|
192
|
+
return b(L, null, {
|
|
193
|
+
default: () => [C.action && C.action()]
|
|
187
194
|
});
|
|
188
195
|
}
|
|
189
|
-
}), Q(
|
|
196
|
+
}), Q(b(V, {
|
|
190
197
|
class: [N],
|
|
191
198
|
current: f.value.current,
|
|
192
199
|
"onUpdate:current": (n) => f.value.current = n,
|
|
@@ -195,13 +202,13 @@ const X = () => ({
|
|
|
195
202
|
disabled: a.loading,
|
|
196
203
|
"show-size-changer": !0,
|
|
197
204
|
size: "default",
|
|
198
|
-
"hide-on-single-page":
|
|
199
|
-
"show-quick-jumper":
|
|
200
|
-
"default-page-size":
|
|
201
|
-
"page-size-options":
|
|
202
|
-
"show-total":
|
|
205
|
+
"hide-on-single-page": v.hideOnSinglePage,
|
|
206
|
+
"show-quick-jumper": v.showQuickJumper,
|
|
207
|
+
"default-page-size": v.defaultPageSize,
|
|
208
|
+
"page-size-options": v.pageSizeOptions,
|
|
209
|
+
"show-total": v.showTotal,
|
|
203
210
|
total: f.value.total,
|
|
204
|
-
onChange:
|
|
211
|
+
onChange: H
|
|
205
212
|
}, null), [[U, a.config.pagination]])]);
|
|
206
213
|
};
|
|
207
214
|
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
computed,
|
|
3
3
|
defineComponent,
|
|
4
|
-
defineEmits,
|
|
5
4
|
nextTick,
|
|
6
5
|
PropType,
|
|
7
6
|
ref,
|
|
8
7
|
watch,
|
|
9
|
-
watchEffect
|
|
10
|
-
createSlots
|
|
8
|
+
watchEffect
|
|
11
9
|
} from "vue";
|
|
12
10
|
import { Pagination, Space, Table } from "ant-design-vue";
|
|
13
|
-
import { useEleHeight } from "../../utils";
|
|
11
|
+
import { useEleHeight } from "../../utils/html";
|
|
14
12
|
import { prefixName } from "../theme";
|
|
15
13
|
|
|
16
14
|
import type { TableProps, Key } from "./interface/table";
|
|
@@ -110,24 +108,33 @@ const DXTable = defineComponent({
|
|
|
110
108
|
const antTableBodyRef = ref<any>(null);
|
|
111
109
|
// 计算高度
|
|
112
110
|
const playHeight = (height: number) => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
let paginationHeight = 0;
|
|
119
|
-
if (props.config.pagination) {
|
|
120
|
-
paginationHeight = useEleHeight(
|
|
121
|
-
document.getElementsByClassName(basePageClassName)[0]
|
|
111
|
+
try {
|
|
112
|
+
const tableEl = tableRef?.value?.$el;
|
|
113
|
+
console.log("tableEl", tableEl);
|
|
114
|
+
const headerHeight = useEleHeight(
|
|
115
|
+
tableEl.getElementsByClassName("ant-table-header")[0]
|
|
122
116
|
);
|
|
117
|
+
console.log("headerHeight", headerHeight);
|
|
118
|
+
// 获取分页组件高度
|
|
119
|
+
let paginationHeight = 0;
|
|
120
|
+
if (props.config.pagination) {
|
|
121
|
+
paginationHeight = useEleHeight(
|
|
122
|
+
document.getElementsByClassName(basePageClassName)[0]
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
console.log("paginationHeight", paginationHeight);
|
|
126
|
+
tableHeight.value = height - (headerHeight + paginationHeight);
|
|
127
|
+
console.log("tableHeight", tableHeight);
|
|
128
|
+
// 设置body高度
|
|
129
|
+
tableEl.getElementsByClassName("ant-table-body")[0].style.height =
|
|
130
|
+
tableHeight.value - 10 + "px";
|
|
131
|
+
// 表格body对象 用于切换页码后滚动条置顶
|
|
132
|
+
antTableBodyRef.value =
|
|
133
|
+
tableEl.getElementsByClassName("ant-table-body")[0];
|
|
134
|
+
console.log("antTableBodyRef", antTableBodyRef);
|
|
135
|
+
} catch (e) {
|
|
136
|
+
console.warn(e);
|
|
123
137
|
}
|
|
124
|
-
tableHeight.value = height - (headerHeight + paginationHeight);
|
|
125
|
-
// 设置body高度
|
|
126
|
-
tableEl.getElementsByClassName("ant-table-body")[0].style.height =
|
|
127
|
-
tableHeight.value - 10 + "px";
|
|
128
|
-
// 表格body对象 用于切换页码后滚动条置顶
|
|
129
|
-
antTableBodyRef.value =
|
|
130
|
-
tableEl.getElementsByClassName("ant-table-body")[0];
|
|
131
138
|
};
|
|
132
139
|
//监听传入的height的变化 默认组件创建的时候会执行一次
|
|
133
140
|
watchEffect(() => {
|