@ditari/bsui 1.0.24 → 1.0.26
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"),w=require("ant-design-vue"),P=require("../../utils/html.cjs.js"),A=require("../theme/index.cjs.js"),J=()=>({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:()=>({})}}),y={defaultPageSize:20,hideOnSinglePage:!1,pageSizeOptions:["10","20","30","40"],responsive:!0,showQuickJumper:!0,showLessItems:!0,showTotal:a=>`总共 ${a} 条`},T=`${A.prefixName}-pagination`,M=n.defineComponent({name:"DTable",props:J(),emits:["update:keys"],setup:function(a,{emit:b,slots:S}){const t=n.ref(a.keys||[]),R=n.computed(()=>a.data),z=n.computed(()=>{var e;return((e=a.config)==null?void 0:e.columns)??[]}),h=n.computed(()=>{var e;return((e=a.config)==null?void 0:e.pagination)??{}}),{tableRef:x,tableRootRef:E,tableHeight:O,onPageChange:H,onRowClassName:q}=B();function B(){const{rowClassName:e,keepSelected:o,selection:c,onPageChange:r}=a.config,g=n.ref(),l=n.ref(null),u=n.ref(),i=n.ref(null),d=v=>{var f,k;try{const m=(f=l==null?void 0:l.value)==null?void 0:f.$el,_=P.useEleHeight(m.getElementsByClassName("ant-table-header")[0]);let N=0;if(a.config.pagination){const $=(k=g.value)==null?void 0:k.getElementsByClassName(T)[0];N=P.useEleHeight($)??0}u.value=v-(_+N),m.getElementsByClassName("ant-table-body")[0].style.height=u.value-10+"px",i.value=m.getElementsByClassName("ant-table-body")[0]}catch(m){console.warn(m)}};return n.watchEffect(()=>{a.height!==0&&n.nextTick(()=>{d(a.height)})}),{tableRef:l,tableRootRef:g,tableHeight:u,onPageChange:(v,f)=>{r&&r({page:v,size:f}),i.value.scrollTop=0,(c==="S"||!o)&&(t.value=[],b("update:keys",t.value))},onRowClassName:(v,f)=>e?e(v,f):void 0}}const D=V();function V(){const{rowKey:e,config:{selection:o,getCheckboxProps:c}}=a;if(o==="N")return;const r=(l,u)=>{o==="S"?(t.value=[],t.value=u?[l[e]]:[]):t.value=u?t.value.concat(l[e]):t.value.filter(i=>i!==l[e]),b("update:keys",t.value)},g=(l,u,i)=>{const d=i.map(s=>s[e]);t.value=l?t.value.concat(d):t.value.filter(s=>!d.includes(s)),b("update:keys",t.value)};return n.watch(()=>a.keys,l=>{t.value=l}),{selectedRowKeys:t,onSelect:r,onSelectAll:g,fixed:!0,columnTitle:o==="S"?"选择":null,columnWidth:o==="S"?60:40,getCheckboxProps:c}}const j=K();function K(){return e=>{let o;const{rowKey:c,config:{click:r,dbClick:g,selection:l,getCheckboxProps:u}}=a,i=e[c],d=()=>{if(l==="N")return;t.value.some(p=>p===i)?t.value=t.value.filter(p=>p!==i):(l==="S"&&(t.value=[]),t.value.push(i)),b("update:keys",t.value)};return{onClick:()=>{const s=u?u(e):null;s&&s.value===i||(clearTimeout(o),o=setTimeout(()=>{d(),r&&r(e)},200))},onDblclick:()=>{clearTimeout(o),g&&g(e)}}}}const C=e=>{e.stopPropagation()};return()=>{var e;return n.createVNode("div",{ref:E},[n.createVNode(w.Table,{ref:x,"row-key":a.rowKey,bordered:a.config.bordered,columns:z.value,dataSource:R.value,loading:a.loading,size:((e=a.config)==null?void 0:e.size)??"small",scroll:{scrollToFirstRowOnChange:!0,x:"100%",y:O.value+"px"},pagination:!1,customRow:j,rowSelection:D,rowClassName:q},{bodyCell:({column:o,record:c})=>{if(o.slot==="action")return n.createVNode("div",{onClick:C,onDblclick:C},[n.createVNode(w.Space,null,{default:()=>[S.action&&S.action(c)]})])}}),n.withDirectives(n.createVNode(w.Pagination,{class:[T],current:h.value.current,"onUpdate:current":o=>h.value.current=o,pageSize:h.value.pageSize,"onUpdate:pageSize":o=>h.value.pageSize=o,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:H},null),[[n.vShow,a.config.pagination]])])}}});exports.default=M;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Table as
|
|
1
|
+
import { defineComponent as U, ref as v, computed as S, watchEffect as F, nextTick as I, watch as L, createVNode as p, withDirectives as V, vShow as W } from "vue";
|
|
2
|
+
import { Table as X, Space as _, Pagination as G } from "ant-design-vue";
|
|
3
3
|
import { useEleHeight as R } from "../../utils/html.esm.js";
|
|
4
|
-
import { prefixName as
|
|
5
|
-
const
|
|
4
|
+
import { prefixName as M } from "../theme/index.esm.js";
|
|
5
|
+
const Y = () => ({
|
|
6
6
|
data: {
|
|
7
7
|
type: Object,
|
|
8
8
|
required: !0
|
|
@@ -36,9 +36,9 @@ const M = () => ({
|
|
|
36
36
|
showQuickJumper: !0,
|
|
37
37
|
showLessItems: !0,
|
|
38
38
|
showTotal: (a) => `总共 ${a} 条`
|
|
39
|
-
}, T = `${
|
|
39
|
+
}, T = `${M}-pagination`, ne = /* @__PURE__ */ U({
|
|
40
40
|
name: "DTable",
|
|
41
|
-
props:
|
|
41
|
+
props: Y(),
|
|
42
42
|
// emits: { "update:keys": (keys: []) => void }
|
|
43
43
|
// TODO 需要做调整
|
|
44
44
|
emits: ["update:keys"],
|
|
@@ -46,112 +46,112 @@ const M = () => ({
|
|
|
46
46
|
emit: w,
|
|
47
47
|
slots: C
|
|
48
48
|
}) {
|
|
49
|
-
const
|
|
50
|
-
var
|
|
51
|
-
return ((
|
|
52
|
-
}),
|
|
53
|
-
var
|
|
54
|
-
return ((
|
|
49
|
+
const t = v(a.keys || []), z = S(() => a.data), x = S(() => {
|
|
50
|
+
var e;
|
|
51
|
+
return ((e = a.config) == null ? void 0 : e.columns) ?? [];
|
|
52
|
+
}), d = S(() => {
|
|
53
|
+
var e;
|
|
54
|
+
return ((e = a.config) == null ? void 0 : e.pagination) ?? {};
|
|
55
55
|
}), {
|
|
56
|
-
tableRef:
|
|
57
|
-
tableRootRef:
|
|
58
|
-
tableHeight:
|
|
59
|
-
onPageChange:
|
|
60
|
-
onRowClassName:
|
|
56
|
+
tableRef: E,
|
|
57
|
+
tableRootRef: O,
|
|
58
|
+
tableHeight: B,
|
|
59
|
+
onPageChange: H,
|
|
60
|
+
onRowClassName: D
|
|
61
61
|
} = K();
|
|
62
62
|
function K() {
|
|
63
63
|
const {
|
|
64
|
-
rowClassName:
|
|
64
|
+
rowClassName: e,
|
|
65
65
|
keepSelected: n,
|
|
66
|
-
selection:
|
|
67
|
-
onPageChange:
|
|
68
|
-
} = a.config,
|
|
69
|
-
var
|
|
66
|
+
selection: s,
|
|
67
|
+
onPageChange: c
|
|
68
|
+
} = a.config, g = v(), o = v(null), i = v(), l = v(null), r = (h) => {
|
|
69
|
+
var f, N;
|
|
70
70
|
try {
|
|
71
|
-
const m = (
|
|
72
|
-
let
|
|
71
|
+
const m = (f = o == null ? void 0 : o.value) == null ? void 0 : f.$el, J = R(m.getElementsByClassName("ant-table-header")[0]);
|
|
72
|
+
let P = 0;
|
|
73
73
|
if (a.config.pagination) {
|
|
74
|
-
const
|
|
75
|
-
|
|
74
|
+
const Q = (N = g.value) == null ? void 0 : N.getElementsByClassName(T)[0];
|
|
75
|
+
P = R(Q) ?? 0;
|
|
76
76
|
}
|
|
77
|
-
i.value = h - (
|
|
77
|
+
i.value = h - (J + P), m.getElementsByClassName("ant-table-body")[0].style.height = i.value - 10 + "px", l.value = m.getElementsByClassName("ant-table-body")[0];
|
|
78
78
|
} catch (m) {
|
|
79
79
|
console.warn(m);
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
|
-
return
|
|
83
|
-
a.height !== 0 &&
|
|
84
|
-
|
|
82
|
+
return F(() => {
|
|
83
|
+
a.height !== 0 && I(() => {
|
|
84
|
+
r(a.height);
|
|
85
85
|
});
|
|
86
86
|
}), {
|
|
87
87
|
tableRef: o,
|
|
88
|
-
tableRootRef:
|
|
88
|
+
tableRootRef: g,
|
|
89
89
|
tableHeight: i,
|
|
90
|
-
onPageChange: (h,
|
|
91
|
-
|
|
90
|
+
onPageChange: (h, f) => {
|
|
91
|
+
c && c({
|
|
92
92
|
page: h,
|
|
93
|
-
size:
|
|
94
|
-
}), l.value.scrollTop = 0, (
|
|
93
|
+
size: f
|
|
94
|
+
}), l.value.scrollTop = 0, (s === "S" || !n) && (t.value = [], w("update:keys", t.value));
|
|
95
95
|
},
|
|
96
|
-
onRowClassName: (h,
|
|
96
|
+
onRowClassName: (h, f) => e ? e(h, f) : void 0
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
|
-
const j =
|
|
100
|
-
function
|
|
99
|
+
const j = $();
|
|
100
|
+
function $() {
|
|
101
101
|
const {
|
|
102
|
-
rowKey:
|
|
102
|
+
rowKey: e,
|
|
103
103
|
config: {
|
|
104
104
|
selection: n,
|
|
105
|
-
getCheckboxProps:
|
|
105
|
+
getCheckboxProps: s
|
|
106
106
|
}
|
|
107
107
|
} = a;
|
|
108
108
|
if (n === "N")
|
|
109
109
|
return;
|
|
110
|
-
const
|
|
111
|
-
n === "S" ? (
|
|
112
|
-
},
|
|
113
|
-
const
|
|
114
|
-
|
|
110
|
+
const c = (o, i) => {
|
|
111
|
+
n === "S" ? (t.value = [], t.value = i ? [o[e]] : []) : t.value = i ? t.value.concat(o[e]) : t.value.filter((l) => l !== o[e]), w("update:keys", t.value);
|
|
112
|
+
}, g = (o, i, l) => {
|
|
113
|
+
const r = l.map((u) => u[e]);
|
|
114
|
+
t.value = o ? t.value.concat(r) : t.value.filter((u) => !r.includes(u)), w("update:keys", t.value);
|
|
115
115
|
};
|
|
116
|
-
return
|
|
117
|
-
|
|
116
|
+
return L(() => a.keys, (o) => {
|
|
117
|
+
t.value = o;
|
|
118
118
|
}), {
|
|
119
|
-
selectedRowKeys:
|
|
120
|
-
onSelect:
|
|
121
|
-
onSelectAll:
|
|
119
|
+
selectedRowKeys: t,
|
|
120
|
+
onSelect: c,
|
|
121
|
+
onSelectAll: g,
|
|
122
122
|
fixed: !0,
|
|
123
123
|
columnTitle: n === "S" ? "选择" : null,
|
|
124
124
|
columnWidth: n === "S" ? 60 : 40,
|
|
125
|
-
getCheckboxProps:
|
|
125
|
+
getCheckboxProps: s
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
|
-
const
|
|
129
|
-
function
|
|
130
|
-
return (
|
|
128
|
+
const q = A();
|
|
129
|
+
function A() {
|
|
130
|
+
return (e) => {
|
|
131
131
|
let n;
|
|
132
132
|
const {
|
|
133
|
-
rowKey:
|
|
133
|
+
rowKey: s,
|
|
134
134
|
config: {
|
|
135
|
-
click:
|
|
136
|
-
dbClick:
|
|
135
|
+
click: c,
|
|
136
|
+
dbClick: g,
|
|
137
137
|
selection: o,
|
|
138
138
|
getCheckboxProps: i
|
|
139
139
|
}
|
|
140
|
-
} = a, l =
|
|
140
|
+
} = a, l = e[s], r = () => {
|
|
141
141
|
if (o === "N")
|
|
142
142
|
return;
|
|
143
|
-
|
|
143
|
+
t.value.some((b) => b === l) ? t.value = t.value.filter((b) => b !== l) : (o === "S" && (t.value = []), t.value.push(l)), w("update:keys", t.value);
|
|
144
144
|
};
|
|
145
145
|
return {
|
|
146
146
|
onClick: () => {
|
|
147
|
-
const u = i ? i(
|
|
147
|
+
const u = i ? i(e) : null;
|
|
148
148
|
u && u.value === l || (clearTimeout(n), n = setTimeout(() => {
|
|
149
|
-
|
|
149
|
+
r(), c && c(e);
|
|
150
150
|
}, 200));
|
|
151
151
|
},
|
|
152
152
|
// 点击行
|
|
153
153
|
onDblclick: () => {
|
|
154
|
-
clearTimeout(n),
|
|
154
|
+
clearTimeout(n), g && g(e);
|
|
155
155
|
}
|
|
156
156
|
// onContextmenu: (event) => {
|
|
157
157
|
// //TODO
|
|
@@ -165,42 +165,49 @@ const M = () => ({
|
|
|
165
165
|
};
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
|
+
const k = (e) => {
|
|
169
|
+
e.stopPropagation();
|
|
170
|
+
};
|
|
168
171
|
return () => {
|
|
169
|
-
var
|
|
170
|
-
return
|
|
171
|
-
ref:
|
|
172
|
-
}, [
|
|
173
|
-
ref:
|
|
172
|
+
var e;
|
|
173
|
+
return p("div", {
|
|
174
|
+
ref: O
|
|
175
|
+
}, [p(X, {
|
|
176
|
+
ref: E,
|
|
174
177
|
"row-key": a.rowKey,
|
|
175
178
|
bordered: a.config.bordered,
|
|
176
|
-
columns:
|
|
179
|
+
columns: x.value,
|
|
177
180
|
dataSource: z.value,
|
|
178
181
|
loading: a.loading,
|
|
179
|
-
size: ((
|
|
182
|
+
size: ((e = a.config) == null ? void 0 : e.size) ?? "small",
|
|
180
183
|
scroll: {
|
|
181
184
|
scrollToFirstRowOnChange: !0,
|
|
182
185
|
x: "100%",
|
|
183
|
-
y:
|
|
186
|
+
y: B.value + "px"
|
|
184
187
|
},
|
|
185
188
|
pagination: !1,
|
|
186
|
-
customRow:
|
|
189
|
+
customRow: q,
|
|
187
190
|
rowSelection: j,
|
|
188
|
-
rowClassName:
|
|
191
|
+
rowClassName: D
|
|
189
192
|
}, {
|
|
190
193
|
bodyCell: ({
|
|
191
|
-
column: n
|
|
194
|
+
column: n,
|
|
195
|
+
record: s
|
|
192
196
|
}) => {
|
|
193
197
|
if (n.slot === "action")
|
|
194
|
-
return
|
|
195
|
-
|
|
196
|
-
|
|
198
|
+
return p("div", {
|
|
199
|
+
onClick: k,
|
|
200
|
+
onDblclick: k
|
|
201
|
+
}, [p(_, null, {
|
|
202
|
+
default: () => [C.action && C.action(s)]
|
|
203
|
+
})]);
|
|
197
204
|
}
|
|
198
|
-
}),
|
|
205
|
+
}), V(p(G, {
|
|
199
206
|
class: [T],
|
|
200
|
-
current:
|
|
201
|
-
"onUpdate:current": (n) =>
|
|
202
|
-
pageSize:
|
|
203
|
-
"onUpdate:pageSize": (n) =>
|
|
207
|
+
current: d.value.current,
|
|
208
|
+
"onUpdate:current": (n) => d.value.current = n,
|
|
209
|
+
pageSize: d.value.pageSize,
|
|
210
|
+
"onUpdate:pageSize": (n) => d.value.pageSize = n,
|
|
204
211
|
disabled: a.loading,
|
|
205
212
|
"show-size-changer": !0,
|
|
206
213
|
size: "default",
|
|
@@ -209,12 +216,12 @@ const M = () => ({
|
|
|
209
216
|
"default-page-size": y.defaultPageSize,
|
|
210
217
|
"page-size-options": y.pageSizeOptions,
|
|
211
218
|
"show-total": y.showTotal,
|
|
212
|
-
total:
|
|
213
|
-
onChange:
|
|
214
|
-
}, null), [[
|
|
219
|
+
total: d.value.total,
|
|
220
|
+
onChange: H
|
|
221
|
+
}, null), [[W, a.config.pagination]])]);
|
|
215
222
|
};
|
|
216
223
|
}
|
|
217
224
|
});
|
|
218
225
|
export {
|
|
219
|
-
|
|
226
|
+
ne as default
|
|
220
227
|
};
|
package/package.json
CHANGED
|
@@ -306,6 +306,9 @@ const DXTable = defineComponent({
|
|
|
306
306
|
};
|
|
307
307
|
}
|
|
308
308
|
|
|
309
|
+
const actionStop = (event: MouseEvent) => {
|
|
310
|
+
event.stopPropagation();
|
|
311
|
+
};
|
|
309
312
|
return () => (
|
|
310
313
|
<div ref={tableRootRef}>
|
|
311
314
|
<Table
|
|
@@ -327,9 +330,13 @@ const DXTable = defineComponent({
|
|
|
327
330
|
rowClassName={onRowClassName}
|
|
328
331
|
>
|
|
329
332
|
{{
|
|
330
|
-
bodyCell: ({ column }: any) => {
|
|
333
|
+
bodyCell: ({ column, record }: any) => {
|
|
331
334
|
if (column.slot === "action") {
|
|
332
|
-
return
|
|
335
|
+
return (
|
|
336
|
+
<div onClick={actionStop} onDblclick={actionStop}>
|
|
337
|
+
<Space>{slots.action && slots.action(record)}</Space>
|
|
338
|
+
</div>
|
|
339
|
+
);
|
|
333
340
|
}
|
|
334
341
|
}
|
|
335
342
|
}}
|