@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.
@@ -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)??[]}),f=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:h,onPageChange:c}=a.config,r=n.ref(),l=n.ref(null),u=n.ref(),i=n.ref(null),g=v=>{var d,k;try{const m=(d=l==null?void 0:l.value)==null?void 0:d.$el,_=P.useEleHeight(m.getElementsByClassName("ant-table-header")[0]);let N=0;if(a.config.pagination){const $=(k=r.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(()=>{g(a.height)})}),{tableRef:l,tableRootRef:r,tableHeight:u,onPageChange:(v,d)=>{c&&c({page:v,size:d}),i.value.scrollTop=0,(h==="S"||!o)&&(t.value=[],b("update:keys",t.value))},onRowClassName:(v,d)=>e?e(v,d):void 0}}const D=V();function V(){const{rowKey:e,config:{selection:o,getCheckboxProps:h}}=a;if(o==="N")return;const c=(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)},r=(l,u,i)=>{const g=i.map(s=>s[e]);t.value=l?t.value.concat(g):t.value.filter(s=>!g.includes(s)),b("update:keys",t.value)};return n.watch(()=>a.keys,l=>{t.value=l}),{selectedRowKeys:t,onSelect:c,onSelectAll:r,fixed:!0,columnTitle:o==="S"?"选择":null,columnWidth:o==="S"?60:40,getCheckboxProps:h}}const j=K();function K(){return e=>{let o;const{rowKey:h,config:{click:c,dbClick:r,selection:l,getCheckboxProps:u}}=a,i=e[h],g=()=>{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(()=>{g(),c&&c(e)},200))},onDblclick:()=>{clearTimeout(o),r&&r(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})=>{if(o.slot==="action")return n.createVNode("div",{onClick:C,onDblclick:C},[n.createVNode(w.Space,null,{default:()=>[S.action&&S.action()]})])}}),n.withDirectives(n.createVNode(w.Pagination,{class:[T],current:f.value.current,"onUpdate:current":o=>f.value.current=o,pageSize:f.value.pageSize,"onUpdate:pageSize":o=>f.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:f.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 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<import("./interface/table").Config>;
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<import("./interface/table").Config>;
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: import("./interface/table").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: 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;
@@ -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<import("./interface/table").Config>;
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<import("./interface/table").Config>;
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: import("./interface/table").Config;
65
+ config: Config;
66
66
  }>;
67
67
  export default DXTable;
@@ -1,6 +1,6 @@
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";
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 R } from "../../utils/html.esm.js";
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
- }), y = {
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: (a) => `总共 ${a} 条`
39
- }, T = `${M}-pagination`, ne = /* @__PURE__ */ U({
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(a, {
46
- emit: w,
45
+ setup: function(t, {
46
+ emit: b,
47
47
  slots: C
48
48
  }) {
49
- const t = v(a.keys || []), z = S(() => a.data), x = S(() => {
49
+ const a = h(t.keys || []), x = p(() => t.data), E = p(() => {
50
50
  var e;
51
- return ((e = a.config) == null ? void 0 : e.columns) ?? [];
52
- }), f = S(() => {
51
+ return ((e = t.config) == null ? void 0 : e.columns) ?? [];
52
+ }), v = p(() => {
53
53
  var e;
54
- return ((e = a.config) == null ? void 0 : e.pagination) ?? {};
54
+ return ((e = t.config) == null ? void 0 : e.pagination) ?? {};
55
55
  }), {
56
- tableRef: E,
57
- tableRootRef: O,
58
- tableHeight: B,
59
- onPageChange: H,
60
- onRowClassName: D
61
- } = K();
62
- function K() {
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: n,
66
- selection: d,
67
- onPageChange: s
68
- } = a.config, c = v(), o = v(null), i = v(), l = v(null), g = (h) => {
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 m = (r = o == null ? void 0 : o.value) == null ? void 0 : r.$el, J = R(m.getElementsByClassName("ant-table-header")[0]);
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 (a.config.pagination) {
74
- const Q = (N = c.value) == null ? void 0 : N.getElementsByClassName(T)[0];
75
- P = R(Q) ?? 0;
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
- 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);
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 F(() => {
83
- a.height !== 0 && I(() => {
84
- g(a.height);
81
+ return R(() => {
82
+ t.height !== 0 && I(() => {
83
+ g(t.height);
85
84
  });
86
85
  }), {
87
- tableRef: o,
88
- tableRootRef: c,
89
- tableHeight: i,
90
- onPageChange: (h, r) => {
91
- s && s({
92
- page: h,
93
- size: r
94
- }), l.value.scrollTop = 0, (d === "S" || !n) && (t.value = [], w("update:keys", t.value));
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: (h, r) => e ? e(h, r) : void 0
95
+ onRowClassName: (m, d) => e ? e(m, d) : void 0
97
96
  };
98
97
  }
99
- const j = $();
100
- function $() {
98
+ const $ = q();
99
+ function q() {
101
100
  const {
102
101
  rowKey: e,
103
102
  config: {
104
- selection: n,
105
- getCheckboxProps: d
103
+ getCheckboxProps: o
106
104
  }
107
- } = a;
108
- if (n === "N")
109
- return;
110
- const s = (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
- }, c = (o, i, l) => {
113
- const g = l.map((u) => u[e]);
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 q = A();
129
- function A() {
132
+ const A = J();
133
+ function J() {
130
134
  return (e) => {
131
- let n;
135
+ let o;
132
136
  const {
133
- rowKey: d,
137
+ rowKey: l,
134
138
  config: {
135
- click: s,
136
- dbClick: c,
137
- selection: o,
138
- getCheckboxProps: i
139
+ click: f,
140
+ dbClick: s,
141
+ selection: u,
142
+ getCheckboxProps: n
139
143
  }
140
- } = a, l = e[d], g = () => {
141
- if (o === "N")
144
+ } = t, i = e[l], g = () => {
145
+ if (u === "N")
142
146
  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);
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 u = i ? i(e) : null;
148
- u && u.value === l || (clearTimeout(n), n = setTimeout(() => {
149
- g(), s && s(e);
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(n), c && c(e);
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 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",
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: B.value + "px"
190
+ y: H.value + "px"
187
191
  },
188
192
  pagination: !1,
189
- customRow: q,
190
- rowSelection: j,
191
- rowClassName: D
193
+ customRow: A,
194
+ rowSelection: $.value,
195
+ rowClassName: K
192
196
  }, {
193
197
  bodyCell: ({
194
- column: n
198
+ column: o,
199
+ record: l
195
200
  }) => {
196
- if (n.slot === "action")
197
- return p("div", {
201
+ if (o.slot === "action")
202
+ return y("div", {
198
203
  onClick: k,
199
204
  onDblclick: k
200
- }, [p(_, null, {
201
- default: () => [C.action && C.action()]
205
+ }, [y(_, null, {
206
+ default: () => [C.action && C.action(l)]
202
207
  })]);
203
208
  }
204
- }), V(p(G, {
205
- class: [T],
206
- current: f.value.current,
207
- "onUpdate:current": (n) => f.value.current = n,
208
- pageSize: f.value.pageSize,
209
- "onUpdate:pageSize": (n) => f.value.pageSize = n,
210
- disabled: a.loading,
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": y.hideOnSinglePage,
214
- "show-quick-jumper": y.showQuickJumper,
215
- "default-page-size": y.defaultPageSize,
216
- "page-size-options": y.pageSizeOptions,
217
- "show-total": y.showTotal,
218
- total: f.value.total,
219
- onChange: H
220
- }, null), [[W, a.config.pagination]])]);
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: 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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditari/bsui",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "files": [
5
5
  "dist/**",
6
6
  "src"
@@ -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: { selection, getCheckboxProps }
191
+ config: { getCheckboxProps }
184
192
  } = props;
185
- if (selection === "N") return undefined;
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 (selection === "S") {
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
- 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
- };
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: 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 {