@ditari/bsui 1.0.26 → 1.0.28
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 +13 -4
- package/dist/cjs/components/table/index.d.ts +9 -0
- package/dist/cjs/components/table/interface/table.d.ts +4 -2
- package/dist/esm/components/table/Table.d.ts +13 -4
- package/dist/esm/components/table/Table.esm.js +148 -126
- package/dist/esm/components/table/index.d.ts +9 -0
- package/dist/esm/components/table/interface/table.d.ts +4 -2
- package/package.json +1 -1
- package/src/components/select/Select.vue +1 -0
- package/src/components/table/Table.tsx +77 -16
- package/src/components/table/interface/table.ts +5 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),C=require("ant-design-vue"),N=require("../../utils/html.cjs.js"),J=require("../theme/index.cjs.js"),M=()=>({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:()=>[]}}),p={defaultPageSize:20,hideOnSinglePage:!1,pageSizeOptions:["10","20","30","40"],responsive:!0,showQuickJumper:!0,showLessItems:!0,showTotal:n=>`总共 ${n} 条`},P=`${J.prefixName}-pagination`,Q=e.defineComponent({name:"DTable",props:M(),emits:["update:keys"],setup:function(n,{emit:b,slots:h}){const a=e.ref(n.keys||[]),T=e.computed(()=>n.data),z=e.computed(()=>{var t;return((t=n.config)==null?void 0:t.columns)??[]}),m=e.computed(()=>{var t;return((t=n.config)==null?void 0:t.pagination)??{}}),S=e.ref(n.expandedRowKeys);e.watchEffect(()=>{const{expandedRowKeys:t}=n;S.value=t});const{tableRef:E,tableRootRef:K,tableHeight:O,onPageChange:V,onRowClassName:B}=H();function H(){const{rowClassName:t,keepSelected:o,onPageChange:i}=n.config,d=n.config.selection??"N",r=e.ref(),c=e.ref(null),l=e.ref(),u=e.ref(null),g=y=>{var v,k;try{const w=(v=c==null?void 0:c.value)==null?void 0:v.$el,$=N.useEleHeight(w.getElementsByClassName("ant-table-header")[0]);let x=0;if(n.config.pagination){const A=(k=r.value)==null?void 0:k.getElementsByClassName(P)[0];x=N.useEleHeight(A)??0}l.value=y-($+x),w.getElementsByClassName("ant-table-body")[0].style.height=l.value-10+"px",u.value=w.getElementsByClassName("ant-table-body")[0]}catch(w){console.warn(w)}};return e.watchEffect(()=>{n.height!==0&&e.nextTick(()=>{g(n.height)})}),{tableRef:c,tableRootRef:r,tableHeight:l,onPageChange:(y,v)=>{i&&i({page:y,size:v}),u.value.scrollTop=0,(d==="S"||!o)&&(a.value=[],b("update:keys",a.value))},onRowClassName:(y,v)=>t?t(y,v):void 0}}const j=q();function q(){const{rowKey:t,config:{getCheckboxProps:o}}=n;let i=n.config.selection??"N";const d=(l,u)=>{i==="S"?(a.value=[],a.value=u?[l[t]]:[]):a.value=u?a.value.concat(l[t]):a.value.filter(g=>g!==l[t]),b("update:keys",a.value)},r=(l,u,g)=>{const f=g.map(s=>s[t]);a.value=l?a.value.concat(f):a.value.filter(s=>!f.includes(s)),b("update:keys",a.value)};e.watch(()=>n.keys,l=>{a.value=l});const c=e.ref(void 0);return e.watchEffect(()=>{const{selection:l}=n.config;i=l,i!=="N"?c.value={selectedRowKeys:a,onSelect:d,onSelectAll:r,fixed:!0,columnTitle:i==="S"?"选择":null,columnWidth:i==="S"?60:40,getCheckboxProps:o}:c.value=void 0}),c}const D=F();function F(){return t=>{let o;const{rowKey:i,config:{click:d,dbClick:r,selection:c,getCheckboxProps:l}}=n,u=t[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)),b("update:keys",a.value)};return{onClick:()=>{const f=l?l(t):null;f&&f.value===u||(clearTimeout(o),o=setTimeout(()=>{g(),d&&d(t)},200))},onDblclick:()=>{clearTimeout(o),r&&r(t)}}}}const R=t=>{t.stopPropagation()},U=(t,o,i,d)=>e.createVNode(e.Fragment,null,[h.expandedRowRender&&h.expandedRowRender()]),_=()=>e.createVNode(e.Fragment,null,[h.summary&&h.summary()]);return()=>{var t;return e.createVNode("div",{ref:K},[e.createVNode(C.Table,{ref:E,"row-key":n.rowKey,bordered:n.config.bordered,columns:z.value,dataSource:T.value,loading:n.loading,size:((t=n.config)==null?void 0:t.size)??"small",scroll:{scrollToFirstRowOnChange:!0,x:"100%",y:O.value+"px"},expandedRowKeys:S.value,"onUpdate:expandedRowKeys":o=>S.value=o,expandRowByClick:!0,pagination:!1,customRow:D,rowSelection:j.value,rowClassName:B},{bodyCell:({column:o,record:i})=>{if(o.slot==="action")return e.createVNode("div",{onClick:R,onDblclick:R},[e.createVNode(C.Space,null,{default:()=>[h.action&&h.action(i)]})])},expandedRowRender:U,summary:_}),e.withDirectives(e.createVNode(C.Pagination,{class:[P],current:m.value.current,"onUpdate:current":o=>m.value.current=o,pageSize:m.value.pageSize,"onUpdate:pageSize":o=>m.value.pageSize=o,disabled:n.loading,"show-size-changer":!0,size:"default","hide-on-single-page":p.hideOnSinglePage,"show-quick-jumper":p.showQuickJumper,"default-page-size":p.defaultPageSize,"page-size-options":p.pageSizeOptions,"show-total":p.showTotal,total:m.value.total,onChange:V},null),[[e.vShow,n.config.pagination]])])}}});exports.default=Q;
|
|
@@ -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,9 +26,13 @@ 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
|
+
expandedRowKeys: {
|
|
33
|
+
type: PropType<string[] | undefined>;
|
|
34
|
+
default: () => never[];
|
|
35
|
+
};
|
|
32
36
|
}, () => 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<{
|
|
33
37
|
data: {
|
|
34
38
|
type: PropType<any>;
|
|
@@ -52,9 +56,13 @@ declare const DXTable: import("vue").DefineComponent<{
|
|
|
52
56
|
default: () => {};
|
|
53
57
|
};
|
|
54
58
|
config: {
|
|
55
|
-
type: PropType<
|
|
59
|
+
type: PropType<Config>;
|
|
56
60
|
default: () => {};
|
|
57
61
|
};
|
|
62
|
+
expandedRowKeys: {
|
|
63
|
+
type: PropType<string[] | undefined>;
|
|
64
|
+
default: () => never[];
|
|
65
|
+
};
|
|
58
66
|
}>> & {
|
|
59
67
|
"onUpdate:keys"?: ((...args: any[]) => any) | undefined;
|
|
60
68
|
}, {
|
|
@@ -62,6 +70,7 @@ declare const DXTable: import("vue").DefineComponent<{
|
|
|
62
70
|
loading: false | undefined;
|
|
63
71
|
rowKey: string;
|
|
64
72
|
pagination: any;
|
|
65
|
-
config:
|
|
73
|
+
config: Config;
|
|
74
|
+
expandedRowKeys: string[] | undefined;
|
|
66
75
|
}>;
|
|
67
76
|
export default DXTable;
|
|
@@ -24,6 +24,10 @@ export declare const DTable: import("../../utils/install").SFCWithInstall<import
|
|
|
24
24
|
type: import("vue").PropType<import("./interface/table").Config>;
|
|
25
25
|
default: () => {};
|
|
26
26
|
};
|
|
27
|
+
expandedRowKeys: {
|
|
28
|
+
type: import("vue").PropType<string[] | undefined>;
|
|
29
|
+
default: () => never[];
|
|
30
|
+
};
|
|
27
31
|
}, () => 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<{
|
|
28
32
|
data: {
|
|
29
33
|
type: import("vue").PropType<any>;
|
|
@@ -50,6 +54,10 @@ export declare const DTable: import("../../utils/install").SFCWithInstall<import
|
|
|
50
54
|
type: import("vue").PropType<import("./interface/table").Config>;
|
|
51
55
|
default: () => {};
|
|
52
56
|
};
|
|
57
|
+
expandedRowKeys: {
|
|
58
|
+
type: import("vue").PropType<string[] | undefined>;
|
|
59
|
+
default: () => never[];
|
|
60
|
+
};
|
|
53
61
|
}>> & {
|
|
54
62
|
"onUpdate:keys"?: ((...args: any[]) => any) | undefined;
|
|
55
63
|
}, {
|
|
@@ -58,5 +66,6 @@ export declare const DTable: import("../../utils/install").SFCWithInstall<import
|
|
|
58
66
|
rowKey: string;
|
|
59
67
|
pagination: any;
|
|
60
68
|
config: import("./interface/table").Config;
|
|
69
|
+
expandedRowKeys: string[] | undefined;
|
|
61
70
|
}>>;
|
|
62
71
|
export default DTable;
|
|
@@ -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;
|
|
@@ -26,6 +27,7 @@ export interface TableProps {
|
|
|
26
27
|
keys?: Key[];
|
|
27
28
|
data: any;
|
|
28
29
|
rowKey: string;
|
|
30
|
+
expandedRowKeys?: string[];
|
|
29
31
|
loading?: false;
|
|
30
32
|
height: number;
|
|
31
33
|
pagination?: any;
|
|
@@ -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,9 +26,13 @@ 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
|
+
expandedRowKeys: {
|
|
33
|
+
type: PropType<string[] | undefined>;
|
|
34
|
+
default: () => never[];
|
|
35
|
+
};
|
|
32
36
|
}, () => 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<{
|
|
33
37
|
data: {
|
|
34
38
|
type: PropType<any>;
|
|
@@ -52,9 +56,13 @@ declare const DXTable: import("vue").DefineComponent<{
|
|
|
52
56
|
default: () => {};
|
|
53
57
|
};
|
|
54
58
|
config: {
|
|
55
|
-
type: PropType<
|
|
59
|
+
type: PropType<Config>;
|
|
56
60
|
default: () => {};
|
|
57
61
|
};
|
|
62
|
+
expandedRowKeys: {
|
|
63
|
+
type: PropType<string[] | undefined>;
|
|
64
|
+
default: () => never[];
|
|
65
|
+
};
|
|
58
66
|
}>> & {
|
|
59
67
|
"onUpdate:keys"?: ((...args: any[]) => any) | undefined;
|
|
60
68
|
}, {
|
|
@@ -62,6 +70,7 @@ declare const DXTable: import("vue").DefineComponent<{
|
|
|
62
70
|
loading: false | undefined;
|
|
63
71
|
rowKey: string;
|
|
64
72
|
pagination: any;
|
|
65
|
-
config:
|
|
73
|
+
config: Config;
|
|
74
|
+
expandedRowKeys: string[] | undefined;
|
|
66
75
|
}>;
|
|
67
76
|
export default DXTable;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Table as
|
|
3
|
-
import { useEleHeight as
|
|
4
|
-
import { prefixName as
|
|
5
|
-
const
|
|
1
|
+
import { defineComponent as W, ref as f, computed as R, watchEffect as k, nextTick as X, watch as _, createVNode as m, withDirectives as G, vShow as M, Fragment as T } from "vue";
|
|
2
|
+
import { Table as Y, Space as Z, Pagination as ee } from "ant-design-vue";
|
|
3
|
+
import { useEleHeight as z } from "../../utils/html.esm.js";
|
|
4
|
+
import { prefixName as ne } from "../theme/index.esm.js";
|
|
5
|
+
const te = () => ({
|
|
6
6
|
data: {
|
|
7
7
|
type: Object,
|
|
8
8
|
required: !0
|
|
@@ -27,131 +27,146 @@ const Y = () => ({
|
|
|
27
27
|
config: {
|
|
28
28
|
type: Object,
|
|
29
29
|
default: () => ({})
|
|
30
|
+
},
|
|
31
|
+
expandedRowKeys: {
|
|
32
|
+
type: Object,
|
|
33
|
+
default: () => []
|
|
30
34
|
}
|
|
31
|
-
}),
|
|
35
|
+
}), b = {
|
|
32
36
|
defaultPageSize: 20,
|
|
33
37
|
hideOnSinglePage: !1,
|
|
34
38
|
pageSizeOptions: ["10", "20", "30", "40"],
|
|
35
39
|
responsive: !0,
|
|
36
40
|
showQuickJumper: !0,
|
|
37
41
|
showLessItems: !0,
|
|
38
|
-
showTotal: (
|
|
39
|
-
},
|
|
42
|
+
showTotal: (n) => `总共 ${n} 条`
|
|
43
|
+
}, K = `${ne}-pagination`, ue = /* @__PURE__ */ W({
|
|
40
44
|
name: "DTable",
|
|
41
|
-
props:
|
|
45
|
+
props: te(),
|
|
42
46
|
// emits: { "update:keys": (keys: []) => void }
|
|
43
47
|
// TODO 需要做调整
|
|
44
48
|
emits: ["update:keys"],
|
|
45
|
-
setup: function(
|
|
46
|
-
emit:
|
|
47
|
-
slots:
|
|
49
|
+
setup: function(n, {
|
|
50
|
+
emit: S,
|
|
51
|
+
slots: h
|
|
48
52
|
}) {
|
|
49
|
-
const t =
|
|
53
|
+
const t = f(n.keys || []), O = R(() => n.data), E = R(() => {
|
|
50
54
|
var e;
|
|
51
|
-
return ((e =
|
|
52
|
-
}),
|
|
55
|
+
return ((e = n.config) == null ? void 0 : e.columns) ?? [];
|
|
56
|
+
}), y = R(() => {
|
|
53
57
|
var e;
|
|
54
|
-
return ((e =
|
|
55
|
-
}),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
58
|
+
return ((e = n.config) == null ? void 0 : e.pagination) ?? {};
|
|
59
|
+
}), C = f(n.expandedRowKeys);
|
|
60
|
+
k(() => {
|
|
61
|
+
const {
|
|
62
|
+
expandedRowKeys: e
|
|
63
|
+
} = n;
|
|
64
|
+
C.value = e;
|
|
65
|
+
});
|
|
66
|
+
const {
|
|
67
|
+
tableRef: B,
|
|
68
|
+
tableRootRef: H,
|
|
69
|
+
tableHeight: j,
|
|
70
|
+
onPageChange: D,
|
|
71
|
+
onRowClassName: U
|
|
72
|
+
} = $();
|
|
73
|
+
function $() {
|
|
63
74
|
const {
|
|
64
75
|
rowClassName: e,
|
|
65
|
-
keepSelected:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
var f, N;
|
|
76
|
+
keepSelected: a,
|
|
77
|
+
onPageChange: l
|
|
78
|
+
} = n.config, s = n.config.selection ?? "N", d = f(), u = f(null), o = f(), i = f(null), r = (w) => {
|
|
79
|
+
var v, N;
|
|
70
80
|
try {
|
|
71
|
-
const
|
|
81
|
+
const p = (v = u == null ? void 0 : u.value) == null ? void 0 : v.$el, L = z(p.getElementsByClassName("ant-table-header")[0]);
|
|
72
82
|
let P = 0;
|
|
73
|
-
if (
|
|
74
|
-
const
|
|
75
|
-
P =
|
|
83
|
+
if (n.config.pagination) {
|
|
84
|
+
const V = (N = d.value) == null ? void 0 : N.getElementsByClassName(K)[0];
|
|
85
|
+
P = z(V) ?? 0;
|
|
76
86
|
}
|
|
77
|
-
|
|
78
|
-
} catch (
|
|
79
|
-
console.warn(
|
|
87
|
+
o.value = w - (L + P), p.getElementsByClassName("ant-table-body")[0].style.height = o.value - 10 + "px", i.value = p.getElementsByClassName("ant-table-body")[0];
|
|
88
|
+
} catch (p) {
|
|
89
|
+
console.warn(p);
|
|
80
90
|
}
|
|
81
91
|
};
|
|
82
|
-
return
|
|
83
|
-
|
|
84
|
-
r(
|
|
92
|
+
return k(() => {
|
|
93
|
+
n.height !== 0 && X(() => {
|
|
94
|
+
r(n.height);
|
|
85
95
|
});
|
|
86
96
|
}), {
|
|
87
|
-
tableRef:
|
|
88
|
-
tableRootRef:
|
|
89
|
-
tableHeight:
|
|
90
|
-
onPageChange: (
|
|
91
|
-
|
|
92
|
-
page:
|
|
93
|
-
size:
|
|
94
|
-
}),
|
|
97
|
+
tableRef: u,
|
|
98
|
+
tableRootRef: d,
|
|
99
|
+
tableHeight: o,
|
|
100
|
+
onPageChange: (w, v) => {
|
|
101
|
+
l && l({
|
|
102
|
+
page: w,
|
|
103
|
+
size: v
|
|
104
|
+
}), i.value.scrollTop = 0, (s === "S" || !a) && (t.value = [], S("update:keys", t.value));
|
|
95
105
|
},
|
|
96
|
-
onRowClassName: (
|
|
106
|
+
onRowClassName: (w, v) => e ? e(w, v) : void 0
|
|
97
107
|
};
|
|
98
108
|
}
|
|
99
|
-
const
|
|
100
|
-
function
|
|
109
|
+
const q = A();
|
|
110
|
+
function A() {
|
|
101
111
|
const {
|
|
102
112
|
rowKey: e,
|
|
103
113
|
config: {
|
|
104
|
-
|
|
105
|
-
getCheckboxProps: s
|
|
114
|
+
getCheckboxProps: a
|
|
106
115
|
}
|
|
107
|
-
} =
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
t.value = o ? t.value.concat(r) : t.value.filter((u) => !r.includes(u)), w("update:keys", t.value);
|
|
116
|
+
} = n;
|
|
117
|
+
let l = n.config.selection ?? "N";
|
|
118
|
+
const s = (o, i) => {
|
|
119
|
+
l === "S" ? (t.value = [], t.value = i ? [o[e]] : []) : t.value = i ? t.value.concat(o[e]) : t.value.filter((r) => r !== o[e]), S("update:keys", t.value);
|
|
120
|
+
}, d = (o, i, r) => {
|
|
121
|
+
const g = r.map((c) => c[e]);
|
|
122
|
+
t.value = o ? t.value.concat(g) : t.value.filter((c) => !g.includes(c)), S("update:keys", t.value);
|
|
115
123
|
};
|
|
116
|
-
|
|
124
|
+
_(() => n.keys, (o) => {
|
|
117
125
|
t.value = o;
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
126
|
+
});
|
|
127
|
+
const u = f(void 0);
|
|
128
|
+
return k(() => {
|
|
129
|
+
const {
|
|
130
|
+
selection: o
|
|
131
|
+
} = n.config;
|
|
132
|
+
l = o, l !== "N" ? u.value = {
|
|
133
|
+
selectedRowKeys: t,
|
|
134
|
+
onSelect: s,
|
|
135
|
+
onSelectAll: d,
|
|
136
|
+
fixed: !0,
|
|
137
|
+
columnTitle: l === "S" ? "选择" : null,
|
|
138
|
+
columnWidth: l === "S" ? 60 : 40,
|
|
139
|
+
getCheckboxProps: a
|
|
140
|
+
} : u.value = void 0;
|
|
141
|
+
}), u;
|
|
127
142
|
}
|
|
128
|
-
const
|
|
129
|
-
function
|
|
143
|
+
const F = J();
|
|
144
|
+
function J() {
|
|
130
145
|
return (e) => {
|
|
131
|
-
let
|
|
146
|
+
let a;
|
|
132
147
|
const {
|
|
133
|
-
rowKey:
|
|
148
|
+
rowKey: l,
|
|
134
149
|
config: {
|
|
135
|
-
click:
|
|
136
|
-
dbClick:
|
|
137
|
-
selection:
|
|
138
|
-
getCheckboxProps:
|
|
150
|
+
click: s,
|
|
151
|
+
dbClick: d,
|
|
152
|
+
selection: u,
|
|
153
|
+
getCheckboxProps: o
|
|
139
154
|
}
|
|
140
|
-
} =
|
|
141
|
-
if (
|
|
155
|
+
} = n, i = e[l], r = () => {
|
|
156
|
+
if (u === "N")
|
|
142
157
|
return;
|
|
143
|
-
t.value.some((
|
|
158
|
+
t.value.some((c) => c === i) ? t.value = t.value.filter((c) => c !== i) : (u === "S" && (t.value = []), t.value.push(i)), S("update:keys", t.value);
|
|
144
159
|
};
|
|
145
160
|
return {
|
|
146
161
|
onClick: () => {
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
r(),
|
|
162
|
+
const g = o ? o(e) : null;
|
|
163
|
+
g && g.value === i || (clearTimeout(a), a = setTimeout(() => {
|
|
164
|
+
r(), s && s(e);
|
|
150
165
|
}, 200));
|
|
151
166
|
},
|
|
152
167
|
// 点击行
|
|
153
168
|
onDblclick: () => {
|
|
154
|
-
clearTimeout(
|
|
169
|
+
clearTimeout(a), d && d(e);
|
|
155
170
|
}
|
|
156
171
|
// onContextmenu: (event) => {
|
|
157
172
|
// //TODO
|
|
@@ -165,63 +180,70 @@ const Y = () => ({
|
|
|
165
180
|
};
|
|
166
181
|
};
|
|
167
182
|
}
|
|
168
|
-
const
|
|
183
|
+
const x = (e) => {
|
|
169
184
|
e.stopPropagation();
|
|
170
|
-
};
|
|
185
|
+
}, Q = (e, a, l, s) => m(T, null, [h.expandedRowRender && h.expandedRowRender()]), I = () => m(T, null, [h.summary && h.summary()]);
|
|
171
186
|
return () => {
|
|
172
187
|
var e;
|
|
173
|
-
return
|
|
174
|
-
ref:
|
|
175
|
-
}, [
|
|
176
|
-
ref:
|
|
177
|
-
"row-key":
|
|
178
|
-
bordered:
|
|
179
|
-
columns:
|
|
180
|
-
dataSource:
|
|
181
|
-
loading:
|
|
182
|
-
size: ((e =
|
|
188
|
+
return m("div", {
|
|
189
|
+
ref: H
|
|
190
|
+
}, [m(Y, {
|
|
191
|
+
ref: B,
|
|
192
|
+
"row-key": n.rowKey,
|
|
193
|
+
bordered: n.config.bordered,
|
|
194
|
+
columns: E.value,
|
|
195
|
+
dataSource: O.value,
|
|
196
|
+
loading: n.loading,
|
|
197
|
+
size: ((e = n.config) == null ? void 0 : e.size) ?? "small",
|
|
183
198
|
scroll: {
|
|
184
199
|
scrollToFirstRowOnChange: !0,
|
|
185
200
|
x: "100%",
|
|
186
|
-
y:
|
|
201
|
+
y: j.value + "px"
|
|
187
202
|
},
|
|
203
|
+
expandedRowKeys: C.value,
|
|
204
|
+
"onUpdate:expandedRowKeys": (a) => C.value = a,
|
|
205
|
+
expandRowByClick: !0,
|
|
188
206
|
pagination: !1,
|
|
189
|
-
customRow:
|
|
190
|
-
rowSelection:
|
|
191
|
-
rowClassName:
|
|
207
|
+
customRow: F,
|
|
208
|
+
rowSelection: q.value,
|
|
209
|
+
rowClassName: U
|
|
192
210
|
}, {
|
|
193
211
|
bodyCell: ({
|
|
194
|
-
column:
|
|
195
|
-
record:
|
|
212
|
+
column: a,
|
|
213
|
+
record: l
|
|
196
214
|
}) => {
|
|
197
|
-
if (
|
|
198
|
-
return
|
|
199
|
-
onClick:
|
|
200
|
-
onDblclick:
|
|
201
|
-
}, [
|
|
202
|
-
default: () => [
|
|
215
|
+
if (a.slot === "action")
|
|
216
|
+
return m("div", {
|
|
217
|
+
onClick: x,
|
|
218
|
+
onDblclick: x
|
|
219
|
+
}, [m(Z, null, {
|
|
220
|
+
default: () => [h.action && h.action(l)]
|
|
203
221
|
})]);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
222
|
+
},
|
|
223
|
+
// 展开插槽
|
|
224
|
+
expandedRowRender: Q,
|
|
225
|
+
// 总结栏插槽
|
|
226
|
+
summary: I
|
|
227
|
+
}), G(m(ee, {
|
|
228
|
+
class: [K],
|
|
229
|
+
current: y.value.current,
|
|
230
|
+
"onUpdate:current": (a) => y.value.current = a,
|
|
231
|
+
pageSize: y.value.pageSize,
|
|
232
|
+
"onUpdate:pageSize": (a) => y.value.pageSize = a,
|
|
233
|
+
disabled: n.loading,
|
|
212
234
|
"show-size-changer": !0,
|
|
213
235
|
size: "default",
|
|
214
|
-
"hide-on-single-page":
|
|
215
|
-
"show-quick-jumper":
|
|
216
|
-
"default-page-size":
|
|
217
|
-
"page-size-options":
|
|
218
|
-
"show-total":
|
|
219
|
-
total:
|
|
220
|
-
onChange:
|
|
221
|
-
}, null), [[
|
|
236
|
+
"hide-on-single-page": b.hideOnSinglePage,
|
|
237
|
+
"show-quick-jumper": b.showQuickJumper,
|
|
238
|
+
"default-page-size": b.defaultPageSize,
|
|
239
|
+
"page-size-options": b.pageSizeOptions,
|
|
240
|
+
"show-total": b.showTotal,
|
|
241
|
+
total: y.value.total,
|
|
242
|
+
onChange: D
|
|
243
|
+
}, null), [[M, n.config.pagination]])]);
|
|
222
244
|
};
|
|
223
245
|
}
|
|
224
246
|
});
|
|
225
247
|
export {
|
|
226
|
-
|
|
248
|
+
ue as default
|
|
227
249
|
};
|
|
@@ -24,6 +24,10 @@ export declare const DTable: import("../../utils/install").SFCWithInstall<import
|
|
|
24
24
|
type: import("vue").PropType<import("./interface/table").Config>;
|
|
25
25
|
default: () => {};
|
|
26
26
|
};
|
|
27
|
+
expandedRowKeys: {
|
|
28
|
+
type: import("vue").PropType<string[] | undefined>;
|
|
29
|
+
default: () => never[];
|
|
30
|
+
};
|
|
27
31
|
}, () => 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<{
|
|
28
32
|
data: {
|
|
29
33
|
type: import("vue").PropType<any>;
|
|
@@ -50,6 +54,10 @@ export declare const DTable: import("../../utils/install").SFCWithInstall<import
|
|
|
50
54
|
type: import("vue").PropType<import("./interface/table").Config>;
|
|
51
55
|
default: () => {};
|
|
52
56
|
};
|
|
57
|
+
expandedRowKeys: {
|
|
58
|
+
type: import("vue").PropType<string[] | undefined>;
|
|
59
|
+
default: () => never[];
|
|
60
|
+
};
|
|
53
61
|
}>> & {
|
|
54
62
|
"onUpdate:keys"?: ((...args: any[]) => any) | undefined;
|
|
55
63
|
}, {
|
|
@@ -58,5 +66,6 @@ export declare const DTable: import("../../utils/install").SFCWithInstall<import
|
|
|
58
66
|
rowKey: string;
|
|
59
67
|
pagination: any;
|
|
60
68
|
config: import("./interface/table").Config;
|
|
69
|
+
expandedRowKeys: string[] | undefined;
|
|
61
70
|
}>>;
|
|
62
71
|
export default DTable;
|
|
@@ -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;
|
|
@@ -26,6 +27,7 @@ export interface TableProps {
|
|
|
26
27
|
keys?: Key[];
|
|
27
28
|
data: any;
|
|
28
29
|
rowKey: string;
|
|
30
|
+
expandedRowKeys?: string[];
|
|
29
31
|
loading?: false;
|
|
30
32
|
height: number;
|
|
31
33
|
pagination?: any;
|
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
|
*/
|
|
@@ -41,6 +42,10 @@ const tableProps = () => {
|
|
|
41
42
|
config: {
|
|
42
43
|
type: Object as PropType<TableProps["config"]>,
|
|
43
44
|
default: () => ({})
|
|
45
|
+
},
|
|
46
|
+
expandedRowKeys: {
|
|
47
|
+
type: Object as PropType<TableProps["expandedRowKeys"]>,
|
|
48
|
+
default: () => []
|
|
44
49
|
}
|
|
45
50
|
};
|
|
46
51
|
};
|
|
@@ -70,6 +75,11 @@ const paginationConfig = {
|
|
|
70
75
|
//分页class名称
|
|
71
76
|
const basePageClassName = `${prefixName}-pagination`;
|
|
72
77
|
|
|
78
|
+
const configDefault: Config = {
|
|
79
|
+
selection: "N",
|
|
80
|
+
bordered: true
|
|
81
|
+
};
|
|
82
|
+
|
|
73
83
|
/**
|
|
74
84
|
* 表格组件定义
|
|
75
85
|
*/
|
|
@@ -89,6 +99,12 @@ const DXTable = defineComponent({
|
|
|
89
99
|
const paginationState = computed(
|
|
90
100
|
() => props.config?.pagination ?? ({} as any)
|
|
91
101
|
);
|
|
102
|
+
// 展开行
|
|
103
|
+
const expandedKeys = ref<any>(props.expandedRowKeys);
|
|
104
|
+
watchEffect(() => {
|
|
105
|
+
const { expandedRowKeys } = props;
|
|
106
|
+
expandedKeys.value = expandedRowKeys;
|
|
107
|
+
});
|
|
92
108
|
|
|
93
109
|
// 初始化表格
|
|
94
110
|
const {
|
|
@@ -103,9 +119,11 @@ const DXTable = defineComponent({
|
|
|
103
119
|
const {
|
|
104
120
|
rowClassName,
|
|
105
121
|
keepSelected,
|
|
106
|
-
selection,
|
|
107
122
|
onPageChange: onChange
|
|
108
123
|
} = props.config;
|
|
124
|
+
|
|
125
|
+
const selection = props.config.selection ?? "N";
|
|
126
|
+
|
|
109
127
|
// 表格根div
|
|
110
128
|
const tableRootRef = ref<HTMLElement>();
|
|
111
129
|
// 表格组件对象
|
|
@@ -180,11 +198,14 @@ const DXTable = defineComponent({
|
|
|
180
198
|
function useRowSelection() {
|
|
181
199
|
const {
|
|
182
200
|
rowKey,
|
|
183
|
-
config: {
|
|
201
|
+
config: { getCheckboxProps }
|
|
184
202
|
} = props;
|
|
185
|
-
|
|
203
|
+
|
|
204
|
+
let localSelection = props.config.selection ?? "N";
|
|
205
|
+
//if (selection === "N") return undefined;
|
|
206
|
+
|
|
186
207
|
const onSelect = (record: any, selected: any) => {
|
|
187
|
-
if (
|
|
208
|
+
if (localSelection === "S") {
|
|
188
209
|
selectedRowKeys.value = [];
|
|
189
210
|
selectedRowKeys.value = selected ? [record[rowKey]] : [];
|
|
190
211
|
} else {
|
|
@@ -219,15 +240,36 @@ const DXTable = defineComponent({
|
|
|
219
240
|
}
|
|
220
241
|
);
|
|
221
242
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
243
|
+
const rowSelection = ref<any>(undefined);
|
|
244
|
+
|
|
245
|
+
watchEffect(() => {
|
|
246
|
+
const { selection } = props.config;
|
|
247
|
+
localSelection = selection as any;
|
|
248
|
+
if (localSelection !== "N") {
|
|
249
|
+
rowSelection.value = {
|
|
250
|
+
selectedRowKeys,
|
|
251
|
+
onSelect,
|
|
252
|
+
onSelectAll,
|
|
253
|
+
fixed: true,
|
|
254
|
+
columnTitle: localSelection === "S" ? "选择" : null,
|
|
255
|
+
columnWidth: localSelection === "S" ? 60 : 40,
|
|
256
|
+
getCheckboxProps: getCheckboxProps
|
|
257
|
+
};
|
|
258
|
+
} else {
|
|
259
|
+
rowSelection.value = undefined;
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
// return {
|
|
264
|
+
// selectedRowKeys,
|
|
265
|
+
// onSelect,
|
|
266
|
+
// onSelectAll,
|
|
267
|
+
// fixed: true,
|
|
268
|
+
// columnTitle: localSelection === "S" ? "选择" : null,
|
|
269
|
+
// columnWidth: localSelection === "S" ? 60 : 40,
|
|
270
|
+
// getCheckboxProps: getCheckboxProps
|
|
271
|
+
// };
|
|
272
|
+
return rowSelection;
|
|
231
273
|
}
|
|
232
274
|
|
|
233
275
|
const customRow = useCustomRow();
|
|
@@ -309,6 +351,19 @@ const DXTable = defineComponent({
|
|
|
309
351
|
const actionStop = (event: MouseEvent) => {
|
|
310
352
|
event.stopPropagation();
|
|
311
353
|
};
|
|
354
|
+
|
|
355
|
+
const expandedRowRender = (
|
|
356
|
+
record: any,
|
|
357
|
+
index: number,
|
|
358
|
+
indent: number,
|
|
359
|
+
expanded: any
|
|
360
|
+
) => {
|
|
361
|
+
return <>{slots.expandedRowRender && slots.expandedRowRender()}</>;
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
const summary = () => {
|
|
365
|
+
return <>{slots.summary && slots.summary()}</>;
|
|
366
|
+
};
|
|
312
367
|
return () => (
|
|
313
368
|
<div ref={tableRootRef}>
|
|
314
369
|
<Table
|
|
@@ -324,9 +379,11 @@ const DXTable = defineComponent({
|
|
|
324
379
|
x: "100%",
|
|
325
380
|
y: tableHeight.value + "px"
|
|
326
381
|
}}
|
|
382
|
+
v-model:expandedRowKeys={expandedKeys.value}
|
|
383
|
+
expandRowByClick={true}
|
|
327
384
|
pagination={false}
|
|
328
385
|
customRow={customRow}
|
|
329
|
-
rowSelection={rowSelection}
|
|
386
|
+
rowSelection={rowSelection.value}
|
|
330
387
|
rowClassName={onRowClassName}
|
|
331
388
|
>
|
|
332
389
|
{{
|
|
@@ -338,7 +395,11 @@ const DXTable = defineComponent({
|
|
|
338
395
|
</div>
|
|
339
396
|
);
|
|
340
397
|
}
|
|
341
|
-
}
|
|
398
|
+
},
|
|
399
|
+
// 展开插槽
|
|
400
|
+
expandedRowRender: expandedRowRender,
|
|
401
|
+
// 总结栏插槽
|
|
402
|
+
summary: summary
|
|
342
403
|
}}
|
|
343
404
|
</Table>
|
|
344
405
|
<Pagination
|
|
@@ -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 {
|
|
@@ -41,6 +42,8 @@ export interface TableProps {
|
|
|
41
42
|
data: any;
|
|
42
43
|
//主键id
|
|
43
44
|
rowKey: string;
|
|
45
|
+
// 展开行的ID
|
|
46
|
+
expandedRowKeys?: string[];
|
|
44
47
|
//加载状态
|
|
45
48
|
loading?: false;
|
|
46
49
|
//表格高度
|