@ditari/bsui 1.0.11 → 1.0.12
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"),C=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} 条`},k=`${D.prefixName}-pagination`,V=n.defineComponent({name:"DTable",props:K(),emits:["update:keys"],setup(a,{emit:w,slots:b}){const e=n.ref(a.keys),N=n.computed(()=>a.data),T=n.computed(()=>{var t;return((t=a.config)==null?void 0:t.columns)??[]}),f=n.computed(()=>{var t;return((t=a.config)==null?void 0:t.pagination)??{}}),{tableRef:P,tableHeight:z,onPageChange:R,onRowClassName:x}=O();function O(){const{rowClassName:t,keepSelected:l,selection:h,onPageChange:g}=a.config,u=n.ref(null),o=n.ref(),s=n.ref(null),i=c=>{var d;try{const v=(d=u==null?void 0:u.value)==null?void 0:d.$el,j=C.useEleHeight(v.getElementsByClassName("ant-table-header")[0]);let p=0;a.config.pagination&&(p=C.useEleHeight(document.getElementsByClassName(k)[0])),o.value=c-(j+p),v.getElementsByClassName("ant-table-body")[0].style.height=o.value-10+"px",s.value=v.getElementsByClassName("ant-table-body")[0]}catch(v){console.warn(v)}};return n.watchEffect(()=>{a.height!==0&&n.nextTick(()=>{i(a.height)})}),{tableRef:u,tableHeight:o,onPageChange:(c,d)=>{g&&g({page:c,size:d}),s.value.scrollTop=0,(h==="S"||!l)&&(e.value=[],w("update:keys",e.value))},onRowClassName:(c,d)=>t?t(c,d):void 0}}const E=q();function q(){const{rowKey:t,config:{selection:l,getCheckboxProps:h}}=a;if(l==="N")return;const g=(o,s)=>{l==="S"?(e.value=[],e.value=s?[o[t]]:[]):e.value=s?e.value.concat(o[t]):e.value.filter(i=>i!==o[t]),w("update:keys",e.value)},u=(o,s,i)=>{const m=i.map(r=>r[t]);e.value=o?e.value.concat(m):e.value.filter(r=>!m.includes(r)),w("update:keys",e.value)};return n.watch(()=>a.keys,o=>{e.value=o}),{selectedRowKeys:e,onSelect:g,onSelectAll:u,fixed:!0,columnTitle:l==="S"?"选择":null,columnWidth:l==="S"?60:40,getCheckboxProps:h}}const H=B();function B(){return t=>{let l;const{rowKey:h,config:{click:g,dbClick:u,selection:o,getCheckboxProps:s}}=a,i=t[h],m=()=>{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)),w("update:keys",e.value)};return{onClick:()=>{if(!g)return;const r=s?s(t):null;r&&r.value===i||(clearTimeout(l),l=setTimeout(()=>{m(),g(t)},200))},onDblclick:()=>{u&&(clearTimeout(l),u(t))}}}}return()=>{var t;return n.createVNode(n.Fragment,null,[n.createVNode(S.Table,{ref:P,"row-key":a.rowKey,bordered:a.config.bordered,columns:T.value,dataSource:N.value,loading:a.loading,size:((t=a.config)==null?void 0:t.size)??"small",scroll:{scrollToFirstRowOnChange:!0,x:"100%",y:z.value+"px"},pagination:!1,customRow:H,rowSelection:E,rowClassName:x},{bodyCell:({column:l})=>{if(l.slot==="action")return n.createVNode(S.Space,null,{default:()=>[b.action&&b.action()]})}}),n.withDirectives(n.createVNode(S.Pagination,{class:[k],current:f.value.current,"onUpdate:current":l=>f.value.current=l,pageSize:f.value.pageSize,"onUpdate:pageSize":l=>f.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:f.value.total,onChange:R},null),[[n.vShow,a.config.pagination]])])}}});exports.default=V;
|
|
@@ -1,4 +1,4 @@
|
|
|
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 p, 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
3
|
import { useEleHeight as k } from "../../utils/html.esm.js";
|
|
4
4
|
import { prefixName as W } from "../theme/index.esm.js";
|
|
@@ -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,13 +44,13 @@ const X = () => ({
|
|
|
44
44
|
// TODO 需要做调整
|
|
45
45
|
emits: ["update:keys"],
|
|
46
46
|
setup(a, {
|
|
47
|
-
emit:
|
|
48
|
-
slots:
|
|
47
|
+
emit: y,
|
|
48
|
+
slots: b
|
|
49
49
|
}) {
|
|
50
|
-
const e =
|
|
50
|
+
const e = w(a.keys), T = S(() => a.data), z = 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
|
}), {
|
|
@@ -65,11 +65,15 @@ const X = () => ({
|
|
|
65
65
|
keepSelected: n,
|
|
66
66
|
selection: d,
|
|
67
67
|
onPageChange: r
|
|
68
|
-
} = a.config, i =
|
|
69
|
-
var
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
} = a.config, i = w(null), l = w(), u = w(null), o = (s) => {
|
|
69
|
+
var g;
|
|
70
|
+
try {
|
|
71
|
+
const m = (g = i == null ? void 0 : i.value) == null ? void 0 : g.$el, D = k(m.getElementsByClassName("ant-table-header")[0]);
|
|
72
|
+
let C = 0;
|
|
73
|
+
a.config.pagination && (C = k(document.getElementsByClassName(N)[0])), l.value = s - (D + C), m.getElementsByClassName("ant-table-body")[0].style.height = l.value - 10 + "px", u.value = m.getElementsByClassName("ant-table-body")[0];
|
|
74
|
+
} catch (m) {
|
|
75
|
+
console.warn(m);
|
|
76
|
+
}
|
|
73
77
|
};
|
|
74
78
|
return $(() => {
|
|
75
79
|
a.height !== 0 && A(() => {
|
|
@@ -82,7 +86,7 @@ const X = () => ({
|
|
|
82
86
|
r && r({
|
|
83
87
|
page: s,
|
|
84
88
|
size: g
|
|
85
|
-
}), u.value.scrollTop = 0, (d === "S" || !n) && (e.value = [],
|
|
89
|
+
}), u.value.scrollTop = 0, (d === "S" || !n) && (e.value = [], y("update:keys", e.value));
|
|
86
90
|
},
|
|
87
91
|
onRowClassName: (s, g) => t ? t(s, g) : void 0
|
|
88
92
|
};
|
|
@@ -99,10 +103,10 @@ const X = () => ({
|
|
|
99
103
|
if (n === "N")
|
|
100
104
|
return;
|
|
101
105
|
const r = (l, u) => {
|
|
102
|
-
n === "S" ? (e.value = [], e.value = u ? [l[t]] : []) : e.value = u ? e.value.concat(l[t]) : e.value.filter((o) => o !== l[t]),
|
|
106
|
+
n === "S" ? (e.value = [], e.value = u ? [l[t]] : []) : e.value = u ? e.value.concat(l[t]) : e.value.filter((o) => o !== l[t]), y("update:keys", e.value);
|
|
103
107
|
}, i = (l, u, o) => {
|
|
104
108
|
const h = o.map((c) => c[t]);
|
|
105
|
-
e.value = l ? e.value.concat(h) : e.value.filter((c) => !h.includes(c)),
|
|
109
|
+
e.value = l ? e.value.concat(h) : e.value.filter((c) => !h.includes(c)), y("update:keys", e.value);
|
|
106
110
|
};
|
|
107
111
|
return F(() => a.keys, (l) => {
|
|
108
112
|
e.value = l;
|
|
@@ -131,7 +135,7 @@ const X = () => ({
|
|
|
131
135
|
} = a, o = t[d], h = () => {
|
|
132
136
|
if (l === "N")
|
|
133
137
|
return;
|
|
134
|
-
e.value.some((s) => s === o) ? e.value = e.value.filter((s) => s !== o) : (l === "S" && (e.value = []), e.value.push(o)),
|
|
138
|
+
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
139
|
};
|
|
136
140
|
return {
|
|
137
141
|
onClick: () => {
|
|
@@ -160,7 +164,7 @@ const X = () => ({
|
|
|
160
164
|
}
|
|
161
165
|
return () => {
|
|
162
166
|
var t;
|
|
163
|
-
return
|
|
167
|
+
return p(J, null, [p(I, {
|
|
164
168
|
ref: P,
|
|
165
169
|
"row-key": a.rowKey,
|
|
166
170
|
bordered: a.config.bordered,
|
|
@@ -182,11 +186,11 @@ const X = () => ({
|
|
|
182
186
|
column: n
|
|
183
187
|
}) => {
|
|
184
188
|
if (n.slot === "action")
|
|
185
|
-
return
|
|
186
|
-
default: () => [
|
|
189
|
+
return p(L, null, {
|
|
190
|
+
default: () => [b.action && b.action()]
|
|
187
191
|
});
|
|
188
192
|
}
|
|
189
|
-
}), Q(
|
|
193
|
+
}), Q(p(V, {
|
|
190
194
|
class: [N],
|
|
191
195
|
current: f.value.current,
|
|
192
196
|
"onUpdate:current": (n) => f.value.current = n,
|
|
@@ -195,11 +199,11 @@ const X = () => ({
|
|
|
195
199
|
disabled: a.loading,
|
|
196
200
|
"show-size-changer": !0,
|
|
197
201
|
size: "default",
|
|
198
|
-
"hide-on-single-page":
|
|
199
|
-
"show-quick-jumper":
|
|
200
|
-
"default-page-size":
|
|
201
|
-
"page-size-options":
|
|
202
|
-
"show-total":
|
|
202
|
+
"hide-on-single-page": v.hideOnSinglePage,
|
|
203
|
+
"show-quick-jumper": v.showQuickJumper,
|
|
204
|
+
"default-page-size": v.defaultPageSize,
|
|
205
|
+
"page-size-options": v.pageSizeOptions,
|
|
206
|
+
"show-total": v.showTotal,
|
|
203
207
|
total: f.value.total,
|
|
204
208
|
onChange: x
|
|
205
209
|
}, null), [[U, a.config.pagination]])]);
|
package/package.json
CHANGED
|
@@ -110,24 +110,28 @@ const DXTable = defineComponent({
|
|
|
110
110
|
const antTableBodyRef = ref<any>(null);
|
|
111
111
|
// 计算高度
|
|
112
112
|
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]
|
|
113
|
+
try {
|
|
114
|
+
const tableEl = tableRef?.value?.$el;
|
|
115
|
+
const headerHeight = useEleHeight(
|
|
116
|
+
tableEl.getElementsByClassName("ant-table-header")[0]
|
|
122
117
|
);
|
|
118
|
+
// 获取分页组件高度
|
|
119
|
+
let paginationHeight = 0;
|
|
120
|
+
if (props.config.pagination) {
|
|
121
|
+
paginationHeight = useEleHeight(
|
|
122
|
+
document.getElementsByClassName(basePageClassName)[0]
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
tableHeight.value = height - (headerHeight + paginationHeight);
|
|
126
|
+
// 设置body高度
|
|
127
|
+
tableEl.getElementsByClassName("ant-table-body")[0].style.height =
|
|
128
|
+
tableHeight.value - 10 + "px";
|
|
129
|
+
// 表格body对象 用于切换页码后滚动条置顶
|
|
130
|
+
antTableBodyRef.value =
|
|
131
|
+
tableEl.getElementsByClassName("ant-table-body")[0];
|
|
132
|
+
} catch (e) {
|
|
133
|
+
console.warn(e);
|
|
123
134
|
}
|
|
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
135
|
};
|
|
132
136
|
//监听传入的height的变化 默认组件创建的时候会执行一次
|
|
133
137
|
watchEffect(() => {
|