@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.
@@ -1 +1 @@
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
+ "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<import("./interface/table").Config>;
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<import("./interface/table").Config>;
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: import("./interface/table").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: any;
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: (record: any) => any;
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<import("./interface/table").Config>;
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<import("./interface/table").Config>;
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: import("./interface/table").Config;
73
+ config: Config;
74
+ expandedRowKeys: string[] | undefined;
66
75
  }>;
67
76
  export default DXTable;
@@ -1,8 +1,8 @@
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
- import { useEleHeight as R } from "../../utils/html.esm.js";
4
- import { prefixName as M } from "../theme/index.esm.js";
5
- const Y = () => ({
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
- }), y = {
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: (a) => `总共 ${a} 条`
39
- }, T = `${M}-pagination`, ne = /* @__PURE__ */ U({
42
+ showTotal: (n) => `总共 ${n} 条`
43
+ }, K = `${ne}-pagination`, ue = /* @__PURE__ */ W({
40
44
  name: "DTable",
41
- props: Y(),
45
+ props: te(),
42
46
  // emits: { "update:keys": (keys: []) => void }
43
47
  // TODO 需要做调整
44
48
  emits: ["update:keys"],
45
- setup: function(a, {
46
- emit: w,
47
- slots: C
49
+ setup: function(n, {
50
+ emit: S,
51
+ slots: h
48
52
  }) {
49
- const t = v(a.keys || []), z = S(() => a.data), x = S(() => {
53
+ const t = f(n.keys || []), O = R(() => n.data), E = R(() => {
50
54
  var e;
51
- return ((e = a.config) == null ? void 0 : e.columns) ?? [];
52
- }), d = S(() => {
55
+ return ((e = n.config) == null ? void 0 : e.columns) ?? [];
56
+ }), y = R(() => {
53
57
  var e;
54
- return ((e = a.config) == null ? void 0 : e.pagination) ?? {};
55
- }), {
56
- tableRef: E,
57
- tableRootRef: O,
58
- tableHeight: B,
59
- onPageChange: H,
60
- onRowClassName: D
61
- } = K();
62
- function K() {
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: n,
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;
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 m = (f = o == null ? void 0 : o.value) == null ? void 0 : f.$el, J = R(m.getElementsByClassName("ant-table-header")[0]);
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 (a.config.pagination) {
74
- const Q = (N = g.value) == null ? void 0 : N.getElementsByClassName(T)[0];
75
- P = R(Q) ?? 0;
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
- 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
- } catch (m) {
79
- console.warn(m);
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 F(() => {
83
- a.height !== 0 && I(() => {
84
- r(a.height);
92
+ return k(() => {
93
+ n.height !== 0 && X(() => {
94
+ r(n.height);
85
95
  });
86
96
  }), {
87
- tableRef: o,
88
- tableRootRef: g,
89
- tableHeight: i,
90
- onPageChange: (h, f) => {
91
- c && c({
92
- page: h,
93
- size: f
94
- }), l.value.scrollTop = 0, (s === "S" || !n) && (t.value = [], w("update:keys", t.value));
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: (h, f) => e ? e(h, f) : void 0
106
+ onRowClassName: (w, v) => e ? e(w, v) : void 0
97
107
  };
98
108
  }
99
- const j = $();
100
- function $() {
109
+ const q = A();
110
+ function A() {
101
111
  const {
102
112
  rowKey: e,
103
113
  config: {
104
- selection: n,
105
- getCheckboxProps: s
114
+ getCheckboxProps: a
106
115
  }
107
- } = a;
108
- if (n === "N")
109
- return;
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);
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
- return L(() => a.keys, (o) => {
124
+ _(() => n.keys, (o) => {
117
125
  t.value = o;
118
- }), {
119
- selectedRowKeys: t,
120
- onSelect: c,
121
- onSelectAll: g,
122
- fixed: !0,
123
- columnTitle: n === "S" ? "选择" : null,
124
- columnWidth: n === "S" ? 60 : 40,
125
- getCheckboxProps: s
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 q = A();
129
- function A() {
143
+ const F = J();
144
+ function J() {
130
145
  return (e) => {
131
- let n;
146
+ let a;
132
147
  const {
133
- rowKey: s,
148
+ rowKey: l,
134
149
  config: {
135
- click: c,
136
- dbClick: g,
137
- selection: o,
138
- getCheckboxProps: i
150
+ click: s,
151
+ dbClick: d,
152
+ selection: u,
153
+ getCheckboxProps: o
139
154
  }
140
- } = a, l = e[s], r = () => {
141
- if (o === "N")
155
+ } = n, i = e[l], r = () => {
156
+ if (u === "N")
142
157
  return;
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);
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 u = i ? i(e) : null;
148
- u && u.value === l || (clearTimeout(n), n = setTimeout(() => {
149
- r(), c && c(e);
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(n), g && g(e);
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 k = (e) => {
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 p("div", {
174
- ref: O
175
- }, [p(X, {
176
- ref: E,
177
- "row-key": a.rowKey,
178
- bordered: a.config.bordered,
179
- columns: x.value,
180
- dataSource: z.value,
181
- loading: a.loading,
182
- size: ((e = a.config) == null ? void 0 : e.size) ?? "small",
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: B.value + "px"
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: q,
190
- rowSelection: j,
191
- rowClassName: D
207
+ customRow: F,
208
+ rowSelection: q.value,
209
+ rowClassName: U
192
210
  }, {
193
211
  bodyCell: ({
194
- column: n,
195
- record: s
212
+ column: a,
213
+ record: l
196
214
  }) => {
197
- if (n.slot === "action")
198
- return p("div", {
199
- onClick: k,
200
- onDblclick: k
201
- }, [p(_, null, {
202
- default: () => [C.action && C.action(s)]
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
- }), V(p(G, {
206
- class: [T],
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,
211
- disabled: a.loading,
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": y.hideOnSinglePage,
215
- "show-quick-jumper": y.showQuickJumper,
216
- "default-page-size": y.defaultPageSize,
217
- "page-size-options": y.pageSizeOptions,
218
- "show-total": y.showTotal,
219
- total: d.value.total,
220
- onChange: H
221
- }, null), [[W, a.config.pagination]])]);
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
- ne as default
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: any;
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: (record: any) => any;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditari/bsui",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "files": [
5
5
  "dist/**",
6
6
  "src"
@@ -108,6 +108,7 @@ function useSelect() {
108
108
 
109
109
  // 监听数据改变
110
110
  const onChange = () => {
111
+ //TODO 变化的时候 需要发送字典的所有数据
111
112
  emits("update:value", modelValue.value);
112
113
  emits("change", modelValue.value);
113
114
  };
@@ -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: { selection, getCheckboxProps }
201
+ config: { getCheckboxProps }
184
202
  } = props;
185
- if (selection === "N") return undefined;
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 (selection === "S") {
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
- return {
223
- selectedRowKeys,
224
- onSelect,
225
- onSelectAll,
226
- fixed: true,
227
- columnTitle: selection === "S" ? "选择" : null,
228
- columnWidth: selection === "S" ? 60 : 40,
229
- getCheckboxProps: getCheckboxProps
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: any;
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: (record: any) => any;
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
  //表格高度