@ditari/bsui 1.0.25 → 1.0.27
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.
- package/dist/cjs/components/table/Table.cjs.js +1 -1
- package/dist/cjs/components/table/Table.d.ts +4 -4
- package/dist/cjs/components/table/interface/table.d.ts +3 -2
- package/dist/esm/components/table/Table.d.ts +4 -4
- package/dist/esm/components/table/Table.esm.js +119 -114
- package/dist/esm/components/table/interface/table.d.ts +3 -2
- package/package.json +1 -1
- package/src/components/table/Table.tsx +49 -17
- package/src/components/table/interface/table.ts +3 -2
|
@@ -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"),b=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:t=>`总共 ${t} 条`},T=`${A.prefixName}-pagination`,M=n.defineComponent({name:"DTable",props:J(),emits:["update:keys"],setup:function(t,{emit:S,slots:C}){const a=n.ref(t.keys||[]),R=n.computed(()=>t.data),z=n.computed(()=>{var e;return((e=t.config)==null?void 0:e.columns)??[]}),v=n.computed(()=>{var e;return((e=t.config)==null?void 0:e.pagination)??{}}),{tableRef:x,tableRootRef:E,tableHeight:O,onPageChange:H,onRowClassName:q}=B();function B(){const{rowClassName:e,keepSelected:l,onPageChange:i}=t.config,f=t.config.selection??"N",r=n.ref(),c=n.ref(null),o=n.ref(),u=n.ref(null),g=m=>{var h,k;try{const w=(h=c==null?void 0:c.value)==null?void 0:h.$el,_=P.useEleHeight(w.getElementsByClassName("ant-table-header")[0]);let N=0;if(t.config.pagination){const $=(k=r.value)==null?void 0:k.getElementsByClassName(T)[0];N=P.useEleHeight($)??0}o.value=m-(_+N),w.getElementsByClassName("ant-table-body")[0].style.height=o.value-10+"px",u.value=w.getElementsByClassName("ant-table-body")[0]}catch(w){console.warn(w)}};return n.watchEffect(()=>{t.height!==0&&n.nextTick(()=>{g(t.height)})}),{tableRef:c,tableRootRef:r,tableHeight:o,onPageChange:(m,h)=>{i&&i({page:m,size:h}),u.value.scrollTop=0,(f==="S"||!l)&&(a.value=[],S("update:keys",a.value))},onRowClassName:(m,h)=>e?e(m,h):void 0}}const D=V();function V(){const{rowKey:e,config:{getCheckboxProps:l}}=t;let i=t.config.selection??"N";const f=(o,u)=>{i==="S"?(a.value=[],a.value=u?[o[e]]:[]):a.value=u?a.value.concat(o[e]):a.value.filter(g=>g!==o[e]),S("update:keys",a.value)},r=(o,u,g)=>{const d=g.map(s=>s[e]);a.value=o?a.value.concat(d):a.value.filter(s=>!d.includes(s)),S("update:keys",a.value)};n.watch(()=>t.keys,o=>{a.value=o});const c=n.ref(void 0);return n.watchEffect(()=>{const{selection:o}=t.config;i=o,i!=="N"?c.value={selectedRowKeys:a,onSelect:f,onSelectAll:r,fixed:!0,columnTitle:i==="S"?"选择":null,columnWidth:i==="S"?60:40,getCheckboxProps:l}:c.value=void 0}),c}const j=K();function K(){return e=>{let l;const{rowKey:i,config:{click:f,dbClick:r,selection:c,getCheckboxProps:o}}=t,u=e[i],g=()=>{if(c==="N")return;a.value.some(s=>s===u)?a.value=a.value.filter(s=>s!==u):(c==="S"&&(a.value=[]),a.value.push(u)),S("update:keys",a.value)};return{onClick:()=>{const d=o?o(e):null;d&&d.value===u||(clearTimeout(l),l=setTimeout(()=>{g(),f&&f(e)},200))},onDblclick:()=>{clearTimeout(l),r&&r(e)}}}}const p=e=>{e.stopPropagation()};return()=>{var e;return n.createVNode("div",{ref:E},[n.createVNode(b.Table,{ref:x,"row-key":t.rowKey,bordered:t.config.bordered,columns:z.value,dataSource:R.value,loading:t.loading,size:((e=t.config)==null?void 0:e.size)??"small",scroll:{scrollToFirstRowOnChange:!0,x:"100%",y:O.value+"px"},pagination:!1,customRow:j,rowSelection:D.value,rowClassName:q},{bodyCell:({column:l,record:i})=>{if(l.slot==="action")return n.createVNode("div",{onClick:p,onDblclick:p},[n.createVNode(b.Space,null,{default:()=>[C.action&&C.action(i)]})])}}),n.withDirectives(n.createVNode(b.Pagination,{class:[T],current:v.value.current,"onUpdate:current":l=>v.value.current=l,pageSize:v.value.pageSize,"onUpdate:pageSize":l=>v.value.pageSize=l,disabled:t.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:v.value.total,onChange:H},null),[[n.vShow,t.config.pagination]])])}}});exports.default=M;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PropType } from "vue";
|
|
2
|
-
import type { Key } from "./interface/table";
|
|
2
|
+
import type { Key, Config } from "./interface/table";
|
|
3
3
|
/**
|
|
4
4
|
* 表格组件定义
|
|
5
5
|
*/
|
|
@@ -26,7 +26,7 @@ declare const DXTable: import("vue").DefineComponent<{
|
|
|
26
26
|
default: () => {};
|
|
27
27
|
};
|
|
28
28
|
config: {
|
|
29
|
-
type: PropType<
|
|
29
|
+
type: PropType<Config>;
|
|
30
30
|
default: () => {};
|
|
31
31
|
};
|
|
32
32
|
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:keys"[], "update:keys", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
@@ -52,7 +52,7 @@ declare const DXTable: import("vue").DefineComponent<{
|
|
|
52
52
|
default: () => {};
|
|
53
53
|
};
|
|
54
54
|
config: {
|
|
55
|
-
type: PropType<
|
|
55
|
+
type: PropType<Config>;
|
|
56
56
|
default: () => {};
|
|
57
57
|
};
|
|
58
58
|
}>> & {
|
|
@@ -62,6 +62,6 @@ declare const DXTable: import("vue").DefineComponent<{
|
|
|
62
62
|
loading: false | undefined;
|
|
63
63
|
rowKey: string;
|
|
64
64
|
pagination: any;
|
|
65
|
-
config:
|
|
65
|
+
config: Config;
|
|
66
66
|
}>;
|
|
67
67
|
export default DXTable;
|
|
@@ -2,8 +2,9 @@ export type Key = string | number;
|
|
|
2
2
|
export type SelectionType = "N" | "S" | "M";
|
|
3
3
|
export type SizeType = "small" | "middle" | "middle";
|
|
4
4
|
export interface Config {
|
|
5
|
+
[key: string]: any;
|
|
5
6
|
bordered?: boolean;
|
|
6
|
-
columns
|
|
7
|
+
columns?: any;
|
|
7
8
|
size?: SizeType;
|
|
8
9
|
selection?: SelectionType;
|
|
9
10
|
keepSelected?: boolean;
|
|
@@ -15,7 +16,7 @@ export interface Config {
|
|
|
15
16
|
rowClassName?: (record: any, index: number) => any;
|
|
16
17
|
click?: (record: unknown) => void;
|
|
17
18
|
dbClick?: (record: any) => void;
|
|
18
|
-
getCheckboxProps
|
|
19
|
+
getCheckboxProps?: (record: any) => any;
|
|
19
20
|
}
|
|
20
21
|
export interface Pagination {
|
|
21
22
|
total: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PropType } from "vue";
|
|
2
|
-
import type { Key } from "./interface/table";
|
|
2
|
+
import type { Key, Config } from "./interface/table";
|
|
3
3
|
/**
|
|
4
4
|
* 表格组件定义
|
|
5
5
|
*/
|
|
@@ -26,7 +26,7 @@ declare const DXTable: import("vue").DefineComponent<{
|
|
|
26
26
|
default: () => {};
|
|
27
27
|
};
|
|
28
28
|
config: {
|
|
29
|
-
type: PropType<
|
|
29
|
+
type: PropType<Config>;
|
|
30
30
|
default: () => {};
|
|
31
31
|
};
|
|
32
32
|
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:keys"[], "update:keys", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
@@ -52,7 +52,7 @@ declare const DXTable: import("vue").DefineComponent<{
|
|
|
52
52
|
default: () => {};
|
|
53
53
|
};
|
|
54
54
|
config: {
|
|
55
|
-
type: PropType<
|
|
55
|
+
type: PropType<Config>;
|
|
56
56
|
default: () => {};
|
|
57
57
|
};
|
|
58
58
|
}>> & {
|
|
@@ -62,6 +62,6 @@ declare const DXTable: import("vue").DefineComponent<{
|
|
|
62
62
|
loading: false | undefined;
|
|
63
63
|
rowKey: string;
|
|
64
64
|
pagination: any;
|
|
65
|
-
config:
|
|
65
|
+
config: Config;
|
|
66
66
|
}>;
|
|
67
67
|
export default DXTable;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as F, ref as h, computed as p, watchEffect as R, nextTick as I, watch as L, createVNode as y, withDirectives as V, vShow as W } from "vue";
|
|
2
2
|
import { Table as X, Space as _, Pagination as G } from "ant-design-vue";
|
|
3
|
-
import { useEleHeight as
|
|
3
|
+
import { useEleHeight as T } from "../../utils/html.esm.js";
|
|
4
4
|
import { prefixName as M } from "../theme/index.esm.js";
|
|
5
5
|
const Y = () => ({
|
|
6
6
|
data: {
|
|
@@ -28,130 +28,134 @@ const Y = () => ({
|
|
|
28
28
|
type: Object,
|
|
29
29
|
default: () => ({})
|
|
30
30
|
}
|
|
31
|
-
}),
|
|
31
|
+
}), S = {
|
|
32
32
|
defaultPageSize: 20,
|
|
33
33
|
hideOnSinglePage: !1,
|
|
34
34
|
pageSizeOptions: ["10", "20", "30", "40"],
|
|
35
35
|
responsive: !0,
|
|
36
36
|
showQuickJumper: !0,
|
|
37
37
|
showLessItems: !0,
|
|
38
|
-
showTotal: (
|
|
39
|
-
},
|
|
38
|
+
showTotal: (t) => `总共 ${t} 条`
|
|
39
|
+
}, z = `${M}-pagination`, ne = /* @__PURE__ */ F({
|
|
40
40
|
name: "DTable",
|
|
41
41
|
props: Y(),
|
|
42
42
|
// emits: { "update:keys": (keys: []) => void }
|
|
43
43
|
// TODO 需要做调整
|
|
44
44
|
emits: ["update:keys"],
|
|
45
|
-
setup: function(
|
|
46
|
-
emit:
|
|
45
|
+
setup: function(t, {
|
|
46
|
+
emit: b,
|
|
47
47
|
slots: C
|
|
48
48
|
}) {
|
|
49
|
-
const
|
|
49
|
+
const a = h(t.keys || []), x = p(() => t.data), E = p(() => {
|
|
50
50
|
var e;
|
|
51
|
-
return ((e =
|
|
52
|
-
}),
|
|
51
|
+
return ((e = t.config) == null ? void 0 : e.columns) ?? [];
|
|
52
|
+
}), v = p(() => {
|
|
53
53
|
var e;
|
|
54
|
-
return ((e =
|
|
54
|
+
return ((e = t.config) == null ? void 0 : e.pagination) ?? {};
|
|
55
55
|
}), {
|
|
56
|
-
tableRef:
|
|
57
|
-
tableRootRef:
|
|
58
|
-
tableHeight:
|
|
59
|
-
onPageChange:
|
|
60
|
-
onRowClassName:
|
|
61
|
-
} =
|
|
62
|
-
function
|
|
56
|
+
tableRef: O,
|
|
57
|
+
tableRootRef: B,
|
|
58
|
+
tableHeight: H,
|
|
59
|
+
onPageChange: D,
|
|
60
|
+
onRowClassName: K
|
|
61
|
+
} = j();
|
|
62
|
+
function j() {
|
|
63
63
|
const {
|
|
64
64
|
rowClassName: e,
|
|
65
|
-
keepSelected:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
var r, N;
|
|
65
|
+
keepSelected: o,
|
|
66
|
+
onPageChange: l
|
|
67
|
+
} = t.config, f = t.config.selection ?? "N", s = h(), u = h(null), n = h(), i = h(null), g = (m) => {
|
|
68
|
+
var d, N;
|
|
70
69
|
try {
|
|
71
|
-
const
|
|
70
|
+
const w = (d = u == null ? void 0 : u.value) == null ? void 0 : d.$el, Q = T(w.getElementsByClassName("ant-table-header")[0]);
|
|
72
71
|
let P = 0;
|
|
73
|
-
if (
|
|
74
|
-
const
|
|
75
|
-
P =
|
|
72
|
+
if (t.config.pagination) {
|
|
73
|
+
const U = (N = s.value) == null ? void 0 : N.getElementsByClassName(z)[0];
|
|
74
|
+
P = T(U) ?? 0;
|
|
76
75
|
}
|
|
77
|
-
|
|
78
|
-
} catch (
|
|
79
|
-
console.warn(
|
|
76
|
+
n.value = m - (Q + P), w.getElementsByClassName("ant-table-body")[0].style.height = n.value - 10 + "px", i.value = w.getElementsByClassName("ant-table-body")[0];
|
|
77
|
+
} catch (w) {
|
|
78
|
+
console.warn(w);
|
|
80
79
|
}
|
|
81
80
|
};
|
|
82
|
-
return
|
|
83
|
-
|
|
84
|
-
g(
|
|
81
|
+
return R(() => {
|
|
82
|
+
t.height !== 0 && I(() => {
|
|
83
|
+
g(t.height);
|
|
85
84
|
});
|
|
86
85
|
}), {
|
|
87
|
-
tableRef:
|
|
88
|
-
tableRootRef:
|
|
89
|
-
tableHeight:
|
|
90
|
-
onPageChange: (
|
|
91
|
-
|
|
92
|
-
page:
|
|
93
|
-
size:
|
|
94
|
-
}),
|
|
86
|
+
tableRef: u,
|
|
87
|
+
tableRootRef: s,
|
|
88
|
+
tableHeight: n,
|
|
89
|
+
onPageChange: (m, d) => {
|
|
90
|
+
l && l({
|
|
91
|
+
page: m,
|
|
92
|
+
size: d
|
|
93
|
+
}), i.value.scrollTop = 0, (f === "S" || !o) && (a.value = [], b("update:keys", a.value));
|
|
95
94
|
},
|
|
96
|
-
onRowClassName: (
|
|
95
|
+
onRowClassName: (m, d) => e ? e(m, d) : void 0
|
|
97
96
|
};
|
|
98
97
|
}
|
|
99
|
-
const
|
|
100
|
-
function
|
|
98
|
+
const $ = q();
|
|
99
|
+
function q() {
|
|
101
100
|
const {
|
|
102
101
|
rowKey: e,
|
|
103
102
|
config: {
|
|
104
|
-
|
|
105
|
-
getCheckboxProps: d
|
|
103
|
+
getCheckboxProps: o
|
|
106
104
|
}
|
|
107
|
-
} =
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
t.value = o ? t.value.concat(g) : t.value.filter((u) => !g.includes(u)), w("update:keys", t.value);
|
|
115
|
-
};
|
|
116
|
-
return L(() => a.keys, (o) => {
|
|
117
|
-
t.value = o;
|
|
118
|
-
}), {
|
|
119
|
-
selectedRowKeys: t,
|
|
120
|
-
onSelect: s,
|
|
121
|
-
onSelectAll: c,
|
|
122
|
-
fixed: !0,
|
|
123
|
-
columnTitle: n === "S" ? "选择" : null,
|
|
124
|
-
columnWidth: n === "S" ? 60 : 40,
|
|
125
|
-
getCheckboxProps: d
|
|
105
|
+
} = t;
|
|
106
|
+
let l = t.config.selection ?? "N";
|
|
107
|
+
const f = (n, i) => {
|
|
108
|
+
l === "S" ? (a.value = [], a.value = i ? [n[e]] : []) : a.value = i ? a.value.concat(n[e]) : a.value.filter((g) => g !== n[e]), b("update:keys", a.value);
|
|
109
|
+
}, s = (n, i, g) => {
|
|
110
|
+
const r = g.map((c) => c[e]);
|
|
111
|
+
a.value = n ? a.value.concat(r) : a.value.filter((c) => !r.includes(c)), b("update:keys", a.value);
|
|
126
112
|
};
|
|
113
|
+
L(() => t.keys, (n) => {
|
|
114
|
+
a.value = n;
|
|
115
|
+
});
|
|
116
|
+
const u = h(void 0);
|
|
117
|
+
return R(() => {
|
|
118
|
+
const {
|
|
119
|
+
selection: n
|
|
120
|
+
} = t.config;
|
|
121
|
+
l = n, l !== "N" ? u.value = {
|
|
122
|
+
selectedRowKeys: a,
|
|
123
|
+
onSelect: f,
|
|
124
|
+
onSelectAll: s,
|
|
125
|
+
fixed: !0,
|
|
126
|
+
columnTitle: l === "S" ? "选择" : null,
|
|
127
|
+
columnWidth: l === "S" ? 60 : 40,
|
|
128
|
+
getCheckboxProps: o
|
|
129
|
+
} : u.value = void 0;
|
|
130
|
+
}), u;
|
|
127
131
|
}
|
|
128
|
-
const
|
|
129
|
-
function
|
|
132
|
+
const A = J();
|
|
133
|
+
function J() {
|
|
130
134
|
return (e) => {
|
|
131
|
-
let
|
|
135
|
+
let o;
|
|
132
136
|
const {
|
|
133
|
-
rowKey:
|
|
137
|
+
rowKey: l,
|
|
134
138
|
config: {
|
|
135
|
-
click:
|
|
136
|
-
dbClick:
|
|
137
|
-
selection:
|
|
138
|
-
getCheckboxProps:
|
|
139
|
+
click: f,
|
|
140
|
+
dbClick: s,
|
|
141
|
+
selection: u,
|
|
142
|
+
getCheckboxProps: n
|
|
139
143
|
}
|
|
140
|
-
} =
|
|
141
|
-
if (
|
|
144
|
+
} = t, i = e[l], g = () => {
|
|
145
|
+
if (u === "N")
|
|
142
146
|
return;
|
|
143
|
-
|
|
147
|
+
a.value.some((c) => c === i) ? a.value = a.value.filter((c) => c !== i) : (u === "S" && (a.value = []), a.value.push(i)), b("update:keys", a.value);
|
|
144
148
|
};
|
|
145
149
|
return {
|
|
146
150
|
onClick: () => {
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
g(),
|
|
151
|
+
const r = n ? n(e) : null;
|
|
152
|
+
r && r.value === i || (clearTimeout(o), o = setTimeout(() => {
|
|
153
|
+
g(), f && f(e);
|
|
150
154
|
}, 200));
|
|
151
155
|
},
|
|
152
156
|
// 点击行
|
|
153
157
|
onDblclick: () => {
|
|
154
|
-
clearTimeout(
|
|
158
|
+
clearTimeout(o), s && s(e);
|
|
155
159
|
}
|
|
156
160
|
// onContextmenu: (event) => {
|
|
157
161
|
// //TODO
|
|
@@ -170,54 +174,55 @@ const Y = () => ({
|
|
|
170
174
|
};
|
|
171
175
|
return () => {
|
|
172
176
|
var e;
|
|
173
|
-
return
|
|
174
|
-
ref:
|
|
175
|
-
}, [
|
|
176
|
-
ref:
|
|
177
|
-
"row-key":
|
|
178
|
-
bordered:
|
|
179
|
-
columns:
|
|
180
|
-
dataSource:
|
|
181
|
-
loading:
|
|
182
|
-
size: ((e =
|
|
177
|
+
return y("div", {
|
|
178
|
+
ref: B
|
|
179
|
+
}, [y(X, {
|
|
180
|
+
ref: O,
|
|
181
|
+
"row-key": t.rowKey,
|
|
182
|
+
bordered: t.config.bordered,
|
|
183
|
+
columns: E.value,
|
|
184
|
+
dataSource: x.value,
|
|
185
|
+
loading: t.loading,
|
|
186
|
+
size: ((e = t.config) == null ? void 0 : e.size) ?? "small",
|
|
183
187
|
scroll: {
|
|
184
188
|
scrollToFirstRowOnChange: !0,
|
|
185
189
|
x: "100%",
|
|
186
|
-
y:
|
|
190
|
+
y: H.value + "px"
|
|
187
191
|
},
|
|
188
192
|
pagination: !1,
|
|
189
|
-
customRow:
|
|
190
|
-
rowSelection:
|
|
191
|
-
rowClassName:
|
|
193
|
+
customRow: A,
|
|
194
|
+
rowSelection: $.value,
|
|
195
|
+
rowClassName: K
|
|
192
196
|
}, {
|
|
193
197
|
bodyCell: ({
|
|
194
|
-
column:
|
|
198
|
+
column: o,
|
|
199
|
+
record: l
|
|
195
200
|
}) => {
|
|
196
|
-
if (
|
|
197
|
-
return
|
|
201
|
+
if (o.slot === "action")
|
|
202
|
+
return y("div", {
|
|
198
203
|
onClick: k,
|
|
199
204
|
onDblclick: k
|
|
200
|
-
}, [
|
|
201
|
-
default: () => [C.action && C.action()]
|
|
205
|
+
}, [y(_, null, {
|
|
206
|
+
default: () => [C.action && C.action(l)]
|
|
202
207
|
})]);
|
|
203
208
|
}
|
|
204
|
-
}), V(
|
|
205
|
-
class: [
|
|
206
|
-
current:
|
|
207
|
-
"onUpdate:current": (
|
|
208
|
-
pageSize:
|
|
209
|
-
"onUpdate:pageSize": (
|
|
210
|
-
disabled:
|
|
209
|
+
}), V(y(G, {
|
|
210
|
+
class: [z],
|
|
211
|
+
current: v.value.current,
|
|
212
|
+
"onUpdate:current": (o) => v.value.current = o,
|
|
213
|
+
pageSize: v.value.pageSize,
|
|
214
|
+
"onUpdate:pageSize": (o) => v.value.pageSize = o,
|
|
215
|
+
disabled: t.loading,
|
|
211
216
|
"show-size-changer": !0,
|
|
212
217
|
size: "default",
|
|
213
|
-
"hide-on-single-page":
|
|
214
|
-
"show-quick-jumper":
|
|
215
|
-
"default-page-size":
|
|
216
|
-
"page-size-options":
|
|
217
|
-
"show-total":
|
|
218
|
-
total:
|
|
219
|
-
onChange:
|
|
220
|
-
}, null), [[W,
|
|
218
|
+
"hide-on-single-page": S.hideOnSinglePage,
|
|
219
|
+
"show-quick-jumper": S.showQuickJumper,
|
|
220
|
+
"default-page-size": S.defaultPageSize,
|
|
221
|
+
"page-size-options": S.pageSizeOptions,
|
|
222
|
+
"show-total": S.showTotal,
|
|
223
|
+
total: v.value.total,
|
|
224
|
+
onChange: D
|
|
225
|
+
}, null), [[W, t.config.pagination]])]);
|
|
221
226
|
};
|
|
222
227
|
}
|
|
223
228
|
});
|
|
@@ -2,8 +2,9 @@ export type Key = string | number;
|
|
|
2
2
|
export type SelectionType = "N" | "S" | "M";
|
|
3
3
|
export type SizeType = "small" | "middle" | "middle";
|
|
4
4
|
export interface Config {
|
|
5
|
+
[key: string]: any;
|
|
5
6
|
bordered?: boolean;
|
|
6
|
-
columns
|
|
7
|
+
columns?: any;
|
|
7
8
|
size?: SizeType;
|
|
8
9
|
selection?: SelectionType;
|
|
9
10
|
keepSelected?: boolean;
|
|
@@ -15,7 +16,7 @@ export interface Config {
|
|
|
15
16
|
rowClassName?: (record: any, index: number) => any;
|
|
16
17
|
click?: (record: unknown) => void;
|
|
17
18
|
dbClick?: (record: any) => void;
|
|
18
|
-
getCheckboxProps
|
|
19
|
+
getCheckboxProps?: (record: any) => any;
|
|
19
20
|
}
|
|
20
21
|
export interface Pagination {
|
|
21
22
|
total: number;
|
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
defineComponent,
|
|
4
4
|
nextTick,
|
|
5
5
|
PropType,
|
|
6
|
+
reactive,
|
|
6
7
|
ref,
|
|
7
8
|
watch,
|
|
8
9
|
watchEffect
|
|
@@ -11,7 +12,7 @@ import { Pagination, Space, Table } from "ant-design-vue";
|
|
|
11
12
|
import { useEleHeight } from "../../utils/html";
|
|
12
13
|
import { prefixName } from "../theme";
|
|
13
14
|
|
|
14
|
-
import type { TableProps, Key } from "./interface/table";
|
|
15
|
+
import type { TableProps, Key, Config } from "./interface/table";
|
|
15
16
|
/**
|
|
16
17
|
* 表格组件 基于TSX封装ATable
|
|
17
18
|
*/
|
|
@@ -70,6 +71,11 @@ const paginationConfig = {
|
|
|
70
71
|
//分页class名称
|
|
71
72
|
const basePageClassName = `${prefixName}-pagination`;
|
|
72
73
|
|
|
74
|
+
const configDefault: Config = {
|
|
75
|
+
selection: "N",
|
|
76
|
+
bordered: true
|
|
77
|
+
};
|
|
78
|
+
|
|
73
79
|
/**
|
|
74
80
|
* 表格组件定义
|
|
75
81
|
*/
|
|
@@ -103,9 +109,11 @@ const DXTable = defineComponent({
|
|
|
103
109
|
const {
|
|
104
110
|
rowClassName,
|
|
105
111
|
keepSelected,
|
|
106
|
-
selection,
|
|
107
112
|
onPageChange: onChange
|
|
108
113
|
} = props.config;
|
|
114
|
+
|
|
115
|
+
const selection = props.config.selection ?? "N";
|
|
116
|
+
|
|
109
117
|
// 表格根div
|
|
110
118
|
const tableRootRef = ref<HTMLElement>();
|
|
111
119
|
// 表格组件对象
|
|
@@ -180,11 +188,14 @@ const DXTable = defineComponent({
|
|
|
180
188
|
function useRowSelection() {
|
|
181
189
|
const {
|
|
182
190
|
rowKey,
|
|
183
|
-
config: {
|
|
191
|
+
config: { getCheckboxProps }
|
|
184
192
|
} = props;
|
|
185
|
-
|
|
193
|
+
|
|
194
|
+
let localSelection = props.config.selection ?? "N";
|
|
195
|
+
//if (selection === "N") return undefined;
|
|
196
|
+
|
|
186
197
|
const onSelect = (record: any, selected: any) => {
|
|
187
|
-
if (
|
|
198
|
+
if (localSelection === "S") {
|
|
188
199
|
selectedRowKeys.value = [];
|
|
189
200
|
selectedRowKeys.value = selected ? [record[rowKey]] : [];
|
|
190
201
|
} else {
|
|
@@ -219,15 +230,36 @@ const DXTable = defineComponent({
|
|
|
219
230
|
}
|
|
220
231
|
);
|
|
221
232
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
233
|
+
const rowSelection = ref<any>(undefined);
|
|
234
|
+
|
|
235
|
+
watchEffect(() => {
|
|
236
|
+
const { selection } = props.config;
|
|
237
|
+
localSelection = selection as any;
|
|
238
|
+
if (localSelection !== "N") {
|
|
239
|
+
rowSelection.value = {
|
|
240
|
+
selectedRowKeys,
|
|
241
|
+
onSelect,
|
|
242
|
+
onSelectAll,
|
|
243
|
+
fixed: true,
|
|
244
|
+
columnTitle: localSelection === "S" ? "选择" : null,
|
|
245
|
+
columnWidth: localSelection === "S" ? 60 : 40,
|
|
246
|
+
getCheckboxProps: getCheckboxProps
|
|
247
|
+
};
|
|
248
|
+
} else {
|
|
249
|
+
rowSelection.value = undefined;
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
// return {
|
|
254
|
+
// selectedRowKeys,
|
|
255
|
+
// onSelect,
|
|
256
|
+
// onSelectAll,
|
|
257
|
+
// fixed: true,
|
|
258
|
+
// columnTitle: localSelection === "S" ? "选择" : null,
|
|
259
|
+
// columnWidth: localSelection === "S" ? 60 : 40,
|
|
260
|
+
// getCheckboxProps: getCheckboxProps
|
|
261
|
+
// };
|
|
262
|
+
return rowSelection;
|
|
231
263
|
}
|
|
232
264
|
|
|
233
265
|
const customRow = useCustomRow();
|
|
@@ -326,15 +358,15 @@ const DXTable = defineComponent({
|
|
|
326
358
|
}}
|
|
327
359
|
pagination={false}
|
|
328
360
|
customRow={customRow}
|
|
329
|
-
rowSelection={rowSelection}
|
|
361
|
+
rowSelection={rowSelection.value}
|
|
330
362
|
rowClassName={onRowClassName}
|
|
331
363
|
>
|
|
332
364
|
{{
|
|
333
|
-
bodyCell: ({ column }: any) => {
|
|
365
|
+
bodyCell: ({ column, record }: any) => {
|
|
334
366
|
if (column.slot === "action") {
|
|
335
367
|
return (
|
|
336
368
|
<div onClick={actionStop} onDblclick={actionStop}>
|
|
337
|
-
<Space>{slots.action && slots.action()}</Space>
|
|
369
|
+
<Space>{slots.action && slots.action(record)}</Space>
|
|
338
370
|
</div>
|
|
339
371
|
);
|
|
340
372
|
}
|
|
@@ -4,10 +4,11 @@ export type SizeType = "small" | "middle" | "middle";
|
|
|
4
4
|
|
|
5
5
|
//表格配置
|
|
6
6
|
export interface Config {
|
|
7
|
+
[key: string]: any;
|
|
7
8
|
// 是否开启边框
|
|
8
9
|
bordered?: boolean;
|
|
9
10
|
//表格列配置
|
|
10
|
-
columns
|
|
11
|
+
columns?: any;
|
|
11
12
|
// 表格大小
|
|
12
13
|
size?: SizeType;
|
|
13
14
|
// 复选框
|
|
@@ -25,7 +26,7 @@ export interface Config {
|
|
|
25
26
|
// 双击
|
|
26
27
|
dbClick?: (record: any) => void;
|
|
27
28
|
// 选择框的默认属性配置
|
|
28
|
-
getCheckboxProps
|
|
29
|
+
getCheckboxProps?: (record: any) => any;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
export interface Pagination {
|