@ditari/bsui 1.0.68 → 1.0.69

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,11 +1,8 @@
1
- import { defineComponent as G, ref as m, computed as C, watchEffect as T, nextTick as M, watch as Y, createVNode as h, withDirectives as Z, vShow as ee, isVNode as te, Fragment as O } from "vue";
2
- import { Table as ne, Space as ae, Pagination as le } from "ant-design-vue";
1
+ import { defineComponent as X, ref as r, computed as S, watchEffect as k, nextTick as _, watch as G, createVNode as f, withDirectives as M, vShow as Y, Fragment as z } from "vue";
2
+ import { Table as Z, Space as ee, Pagination as te } from "ant-design-vue";
3
3
  import { useEleHeight as E } from "../../utils/html.esm.js";
4
- import { prefixName as oe } from "../theme/index.esm.js";
5
- function ie(t) {
6
- return typeof t == "function" || Object.prototype.toString.call(t) === "[object Object]" && !te(t);
7
- }
8
- const ue = () => ({
4
+ import { prefixName as ae } from "../theme/index.esm.js";
5
+ const ne = () => ({
9
6
  data: {
10
7
  type: Object,
11
8
  required: !0
@@ -37,7 +34,7 @@ const ue = () => ({
37
34
  },
38
35
  defaultExpandAllRows: Boolean,
39
36
  default: () => !0
40
- }), p = {
37
+ }), b = {
41
38
  defaultPageSize: 20,
42
39
  hideOnSinglePage: !1,
43
40
  pageSizeOptions: ["10", "20", "30", "40"],
@@ -45,136 +42,135 @@ const ue = () => ({
45
42
  showQuickJumper: !0,
46
43
  showLessItems: !0,
47
44
  showTotal: (t) => `总共 ${t} 条`
48
- }, K = `${oe}-pagination`, ge = /* @__PURE__ */ G({
45
+ }, K = `${ae}-pagination`, ce = /* @__PURE__ */ X({
49
46
  name: "DTable",
50
- props: ue(),
47
+ props: ne(),
51
48
  // emits: { "update:keys": (keys: []) => void }
52
49
  // TODO 需要做调整
53
50
  emits: ["update:keys"],
54
51
  setup: function(t, {
55
52
  emit: R,
56
- slots: r
53
+ slots: s
57
54
  }) {
58
- const a = m(t.keys || []), j = C(() => t.data), B = C(() => {
59
- var e, n;
60
- return (n = (e = t.config) === null || e === void 0 ? void 0 : e.columns) !== null && n !== void 0 ? n : [];
61
- }), y = C(() => {
62
- var e, n;
63
- return (n = (e = t.config) === null || e === void 0 ? void 0 : e.pagination) !== null && n !== void 0 ? n : {};
64
- }), k = m(t.expandedRowKeys);
65
- T(() => {
55
+ const a = r(t.keys || []), B = S(() => t.data), O = S(() => {
56
+ var e;
57
+ return ((e = t.config) == null ? void 0 : e.columns) ?? [];
58
+ }), v = S(() => {
59
+ var e;
60
+ return ((e = t.config) == null ? void 0 : e.pagination) ?? {};
61
+ }), C = r(t.expandedRowKeys);
62
+ k(() => {
66
63
  const {
67
64
  expandedRowKeys: e
68
65
  } = t;
69
- k.value = e;
66
+ C.value = e;
70
67
  });
71
68
  const {
72
69
  tableRef: H,
73
- tableRootRef: A,
74
- tableHeight: D,
75
- onPageChange: U,
76
- onRowClassName: $
77
- } = q();
78
- function q() {
79
- var e;
70
+ tableRootRef: j,
71
+ tableHeight: A,
72
+ onPageChange: D,
73
+ onRowClassName: U
74
+ } = $();
75
+ function $() {
80
76
  const {
81
- rowClassName: n,
82
- keepSelected: u,
77
+ rowClassName: e,
78
+ keepSelected: o,
83
79
  onPageChange: l
84
- } = t.config, c = (e = t.config.selection) !== null && e !== void 0 ? e : "N", g = m(), i = m(null), o = m(), s = m(null), f = (w) => {
85
- var v, x, N;
80
+ } = t.config, m = t.config.selection ?? "N", d = r(), i = r(null), n = r(), u = r(null), g = (c) => {
81
+ var h, T;
86
82
  try {
87
- const b = (v = i == null ? void 0 : i.value) === null || v === void 0 ? void 0 : v.$el, W = E(b.getElementsByClassName("ant-table-header")[0]);
88
- let _ = 0;
83
+ const p = (h = i == null ? void 0 : i.value) == null ? void 0 : h.$el, V = E(p.getElementsByClassName("ant-table-header")[0]);
84
+ let P = 0;
89
85
  if (t.config.pagination) {
90
- const X = (x = g.value) === null || x === void 0 ? void 0 : x.getElementsByClassName(K)[0];
91
- _ = (N = E(X)) !== null && N !== void 0 ? N : 0;
86
+ const W = (T = d.value) == null ? void 0 : T.getElementsByClassName(K)[0];
87
+ P = E(W) ?? 0;
92
88
  }
93
- o.value = w - (W + _), b.getElementsByClassName("ant-table-body")[0].style.height = o.value + "px", s.value = b.getElementsByClassName("ant-table-body")[0];
94
- } catch (b) {
95
- console.warn(b);
89
+ n.value = c - (V + P), p.getElementsByClassName("ant-table-body")[0].style.height = n.value + "px", u.value = p.getElementsByClassName("ant-table-body")[0];
90
+ } catch (p) {
91
+ console.warn(p);
96
92
  }
97
93
  };
98
- return T(() => {
99
- t.height !== 0 && M(() => {
94
+ return k(() => {
95
+ t.height !== 0 && _(() => {
100
96
  setTimeout(() => {
101
- f(t.height);
97
+ g(t.height);
102
98
  }, 10);
103
99
  });
104
100
  }), {
105
101
  tableRef: i,
106
- tableRootRef: g,
107
- tableHeight: o,
108
- onPageChange: (w, v) => {
102
+ tableRootRef: d,
103
+ tableHeight: n,
104
+ onPageChange: (c, h) => {
109
105
  l && l({
110
- page: w,
111
- size: v
112
- }), s.value.scrollTop = 0, (c === "S" || !u) && (a.value = [], R("update:keys", a.value));
106
+ page: c,
107
+ size: h
108
+ }), u.value.scrollTop = 0, (m === "S" || !o) && (a.value = [], R("update:keys", a.value));
113
109
  },
114
- onRowClassName: (w, v) => n ? n(w, v) : void 0
110
+ onRowClassName: (c, h) => e ? e(c, h) : void 0
115
111
  };
116
112
  }
117
- const F = J();
118
- function J() {
119
- var e;
113
+ const q = F();
114
+ function F() {
120
115
  const {
121
- rowKey: n,
116
+ rowKey: e,
122
117
  config: {
123
- getCheckboxProps: u
118
+ getCheckboxProps: o
124
119
  }
125
120
  } = t;
126
- let l = (e = t.config.selection) !== null && e !== void 0 ? e : "N";
127
- const c = (o, s) => {
128
- l === "S" ? (a.value = [], a.value = s ? [o[n]] : []) : a.value = s ? a.value.concat(o[n]) : a.value.filter((f) => f !== o[n]), R("update:keys", a.value);
129
- }, g = (o, s, f) => {
130
- const S = f.map((d) => d[n]);
131
- a.value = o ? a.value.concat(S) : a.value.filter((d) => !S.includes(d)), R("update:keys", a.value);
121
+ let l = t.config.selection ?? "N";
122
+ const m = (n, u) => {
123
+ l === "S" ? (a.value = [], a.value = u ? [n[e]] : []) : a.value = u ? a.value.concat(n[e]) : a.value.filter((g) => g !== n[e]), R("update:keys", a.value);
124
+ }, d = (n, u, g) => {
125
+ const w = g.map((y) => y[e]);
126
+ a.value = n ? a.value.concat(w) : a.value.filter((y) => !w.includes(y)), R("update:keys", a.value);
132
127
  };
133
- Y(() => t.keys, (o) => {
134
- a.value = o;
128
+ G(() => t.keys, (n) => {
129
+ a.value = n;
135
130
  });
136
- const i = m(void 0);
137
- return T(() => {
131
+ const i = r(void 0);
132
+ return k(() => {
138
133
  const {
139
- selection: o
134
+ selection: n
140
135
  } = t.config;
141
- l = o, l !== "N" ? i.value = {
136
+ l = n, l !== "N" ? i.value = {
142
137
  selectedRowKeys: a,
143
- onSelect: c,
144
- onSelectAll: g,
138
+ onSelect: m,
139
+ onSelectAll: d,
145
140
  fixed: !0,
146
141
  columnTitle: l === "S" ? "选择" : null,
147
142
  columnWidth: l === "S" ? 60 : 40,
148
- getCheckboxProps: u
143
+ getCheckboxProps: o
149
144
  } : i.value = void 0;
150
145
  }), i;
151
146
  }
152
- const Q = V();
153
- function V() {
147
+ const J = Q();
148
+ function Q() {
154
149
  return (e) => {
155
- let n;
150
+ let o;
156
151
  const {
157
- rowKey: u,
152
+ rowKey: l,
158
153
  config: {
159
- click: l,
160
- dbClick: c,
161
- selection: g,
162
- getCheckboxProps: i
154
+ click: m,
155
+ dbClick: d,
156
+ selection: i,
157
+ getCheckboxProps: n
163
158
  }
164
- } = t, o = e[u], s = () => {
165
- const f = i === void 0 ? !1 : i(e).disabled;
166
- if (g === "N" || f)
159
+ } = t, u = e[l], g = () => {
160
+ const w = n === void 0 ? !1 : n(e).disabled;
161
+ if (i === "N" || w)
167
162
  return;
168
- a.value.some((d) => d === o) ? a.value = a.value.filter((d) => d !== o) : (g === "S" && (a.value = []), a.value.push(o)), R("update:keys", a.value);
163
+ a.value.some((c) => c === u) ? a.value = a.value.filter((c) => c !== u) : (i === "S" && (a.value = []), a.value.push(u)), R("update:keys", a.value);
169
164
  };
170
165
  return {
171
166
  onClick: () => {
172
- clearTimeout(n), n = setTimeout(() => {
173
- s(), l && l(e);
167
+ clearTimeout(o), o = setTimeout(() => {
168
+ g(), m && m(e);
174
169
  }, 200);
175
170
  },
171
+ // 点击行
176
172
  onDblclick: () => {
177
- clearTimeout(n), c && c(e);
173
+ clearTimeout(o), d && d(e);
178
174
  }
179
175
  // onContextmenu: (event) => {
180
176
  // //TODO
@@ -188,83 +184,80 @@ const ue = () => ({
188
184
  };
189
185
  };
190
186
  }
191
- const P = (e) => {
187
+ const x = (e) => {
192
188
  e.stopPropagation();
193
- }, I = C(() => {
189
+ }, I = S(() => {
194
190
  const {
195
191
  selection: e
196
192
  } = t.config;
197
193
  return e === "N";
198
- }), z = {};
199
- r.expandedRowRender && (z.expandedRowRender = (e) => h(O, null, [r.expandedRowRender && r.expandedRowRender(e)]));
200
- const L = () => h(O, null, [r.summary && r.summary()]);
194
+ }), N = {};
195
+ s.expandedRowRender && (N.expandedRowRender = (e) => f(z, null, [s.expandedRowRender && s.expandedRowRender(e)]));
196
+ const L = () => f(z, null, [s.summary && s.summary()]);
201
197
  return () => {
202
- let e;
203
- var n, u;
204
- return h("div", {
205
- ref: A,
198
+ var e;
199
+ return f("div", {
200
+ ref: j,
206
201
  style: {
207
202
  height: "100%"
208
203
  }
209
- }, [h(ne, {
204
+ }, [f(Z, {
210
205
  ref: H,
211
206
  "row-key": t.rowKey,
212
207
  bordered: t.config.bordered,
213
- columns: B.value,
214
- dataSource: j.value,
208
+ columns: O.value,
209
+ dataSource: B.value,
215
210
  loading: t.loading,
216
- size: (u = (n = t.config) === null || n === void 0 ? void 0 : n.size) !== null && u !== void 0 ? u : "small",
211
+ size: ((e = t.config) == null ? void 0 : e.size) ?? "small",
217
212
  scroll: {
218
213
  scrollToFirstRowOnChange: !0,
219
214
  x: "100%",
220
- y: D.value + "px"
215
+ y: A.value + "px"
221
216
  },
222
- expandedRowKeys: k.value,
223
- "onUpdate:expandedRowKeys": (l) => k.value = l,
217
+ expandedRowKeys: C.value,
218
+ "onUpdate:expandedRowKeys": (o) => C.value = o,
224
219
  expandRowByClick: I.value,
225
220
  defaultExpandAllRows: t.defaultExpandAllRows,
226
221
  pagination: !1,
227
- customRow: Q,
228
- rowSelection: F.value,
229
- rowClassName: $
230
- }, ie(e = Object.assign(Object.assign({
222
+ customRow: J,
223
+ rowSelection: q.value,
224
+ rowClassName: U
225
+ }, {
231
226
  bodyCell: ({
232
- column: l,
233
- record: c
227
+ column: o,
228
+ record: l
234
229
  }) => {
235
- if (l.slot === "action")
236
- return h("div", {
237
- onClick: P,
238
- onDblclick: P
239
- }, [h(ae, null, {
240
- default: () => [r.action && r.action(c)]
230
+ if (o.slot === "action")
231
+ return f("div", {
232
+ onClick: x,
233
+ onDblclick: x
234
+ }, [f(ee, null, {
235
+ default: () => [s.action && s.action(l)]
241
236
  })]);
242
- }
243
- }, z), {
237
+ },
238
+ ...N,
244
239
  // 总结栏插槽
245
240
  summary: L
246
- })) ? e : {
247
- default: () => [e]
248
- }), Z(h(le, {
241
+ }), M(f(te, {
249
242
  class: [K],
250
- current: y.value.current,
251
- "onUpdate:current": (l) => y.value.current = l,
252
- pageSize: y.value.pageSize,
253
- "onUpdate:pageSize": (l) => y.value.pageSize = l,
243
+ current: v.value.current,
244
+ "onUpdate:current": (o) => v.value.current = o,
245
+ pageSize: v.value.pageSize,
246
+ "onUpdate:pageSize": (o) => v.value.pageSize = o,
254
247
  disabled: t.loading,
255
248
  "show-size-changer": !0,
256
249
  size: "default",
257
- "hide-on-single-page": p.hideOnSinglePage,
258
- "show-quick-jumper": p.showQuickJumper,
259
- "default-page-size": p.defaultPageSize,
260
- "page-size-options": p.pageSizeOptions,
261
- "show-total": p.showTotal,
262
- total: y.value.total,
263
- onChange: U
264
- }, null), [[ee, t.config.pagination]])]);
250
+ "hide-on-single-page": b.hideOnSinglePage,
251
+ "show-quick-jumper": b.showQuickJumper,
252
+ "default-page-size": b.defaultPageSize,
253
+ "page-size-options": b.pageSizeOptions,
254
+ "show-total": b.showTotal,
255
+ total: v.value.total,
256
+ onChange: D
257
+ }, null), [[Y, t.config.pagination]])]);
265
258
  };
266
259
  }
267
260
  });
268
261
  export {
269
- ge as default
262
+ ce as default
270
263
  };
@@ -0,0 +1,75 @@
1
+ export declare const DTable: import("../../utils/install").SFCWithInstall<import("vue").DefineComponent<{
2
+ data: {
3
+ type: import("vue").PropType<any>;
4
+ required: boolean;
5
+ };
6
+ height: {
7
+ type: import("vue").PropType<number>;
8
+ default: number;
9
+ };
10
+ keys: import("vue").PropType<import("./interface/table").Key[] | undefined>;
11
+ rowKey: {
12
+ type: import("vue").PropType<string>;
13
+ default: string;
14
+ };
15
+ loading: {
16
+ type: import("vue").PropType<false | undefined>;
17
+ default: boolean;
18
+ };
19
+ pagination: {
20
+ type: import("vue").PropType<any>;
21
+ default: () => {};
22
+ };
23
+ config: {
24
+ type: import("vue").PropType<import("./interface/table").Config>;
25
+ default: () => {};
26
+ };
27
+ expandedRowKeys: {
28
+ type: import("vue").PropType<string[] | undefined>;
29
+ default: () => never[];
30
+ };
31
+ defaultExpandAllRows: import("vue").PropType<boolean | undefined>;
32
+ default: () => boolean;
33
+ }, () => 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<{
34
+ data: {
35
+ type: import("vue").PropType<any>;
36
+ required: boolean;
37
+ };
38
+ height: {
39
+ type: import("vue").PropType<number>;
40
+ default: number;
41
+ };
42
+ keys: import("vue").PropType<import("./interface/table").Key[] | undefined>;
43
+ rowKey: {
44
+ type: import("vue").PropType<string>;
45
+ default: string;
46
+ };
47
+ loading: {
48
+ type: import("vue").PropType<false | undefined>;
49
+ default: boolean;
50
+ };
51
+ pagination: {
52
+ type: import("vue").PropType<any>;
53
+ default: () => {};
54
+ };
55
+ config: {
56
+ type: import("vue").PropType<import("./interface/table").Config>;
57
+ default: () => {};
58
+ };
59
+ expandedRowKeys: {
60
+ type: import("vue").PropType<string[] | undefined>;
61
+ default: () => never[];
62
+ };
63
+ defaultExpandAllRows: import("vue").PropType<boolean | undefined>;
64
+ default: () => boolean;
65
+ }>> & {
66
+ "onUpdate:keys"?: ((...args: any[]) => any) | undefined;
67
+ }, {
68
+ height: number;
69
+ loading: false | undefined;
70
+ rowKey: string;
71
+ pagination: any;
72
+ config: import("./interface/table").Config;
73
+ expandedRowKeys: string[] | undefined;
74
+ }>>;
75
+ export default DTable;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditari/bsui",
3
- "version": "1.0.68",
3
+ "version": "1.0.69",
4
4
  "files": [
5
5
  "dist/**",
6
6
  "src"
@@ -1,4 +1,6 @@
1
1
  <script setup lang="ts">
2
+ import { useElementSize } from "@vueuse/core";
3
+
2
4
  import {
3
5
  useSlots,
4
6
  ref,
@@ -35,12 +37,12 @@ const height = ref(0);
35
37
 
36
38
  let stopHandleWatch: WatchStopHandle;
37
39
 
38
- nextTick(() => {
39
- setTimeout(() => {
40
- height.value = tableRef?.value?.offsetHeight;
41
- show.value = true;
42
- }, 1);
43
- });
40
+ // nextTick(() => {
41
+ // setTimeout(() => {
42
+ // height.value = tableRef?.value?.offsetHeight;
43
+ // show.value = true;
44
+ // }, 1);
45
+ // });
44
46
 
45
47
  watch(
46
48
  () => configProvider?.componentSize,
@@ -91,6 +93,21 @@ function useWatch() {
91
93
  }
92
94
  );
93
95
  }
96
+
97
+ // 监听表单高度变化
98
+ // 然后再获取表格高度
99
+ const formRef = ref(null);
100
+ const { height: formHeight } = useElementSize(formRef);
101
+ watch(
102
+ () => formHeight.value,
103
+ (val) => {
104
+ show.value = false;
105
+ setTimeout(() => {
106
+ height.value = tableRef?.value?.offsetHeight;
107
+ show.value = true;
108
+ }, 10);
109
+ }
110
+ );
94
111
  </script>
95
112
  <script lang="ts">
96
113
  export default {
@@ -119,7 +136,7 @@ export default {
119
136
  </a-space>
120
137
  </div>
121
138
  <div ref="tableRef" style="flex: 1">
122
- <div style="height: 100%" v-show="show">
139
+ <div v-show="show" style="height: 100%">
123
140
  <slot name="table" :height="height" />
124
141
  </div>
125
142
  </div>
@@ -1,19 +1,17 @@
1
1
  import {
2
2
  computed,
3
- createVNode,
4
3
  defineComponent,
5
4
  nextTick,
6
5
  PropType,
7
- reactive,
8
6
  ref,
9
7
  watch,
10
8
  watchEffect
11
9
  } from "vue";
12
- import { Pagination, Space, Table, Card } from "ant-design-vue";
10
+ import { Pagination, Space, Table } from "ant-design-vue";
13
11
  import { useEleHeight } from "../../utils/html";
14
12
  import { prefixName } from "../theme";
15
13
 
16
- import type { TableProps, Key, Config } from "./interface/table";
14
+ import type { TableProps, Key } from "./interface/table";
17
15
  /**
18
16
  * 表格组件 基于TSX封装ATable
19
17
  */
@@ -80,11 +78,6 @@ const paginationConfig = {
80
78
  //分页class名称
81
79
  const basePageClassName = `${prefixName}-pagination`;
82
80
 
83
- const configDefault: Config = {
84
- selection: "N",
85
- bordered: true
86
- };
87
-
88
81
  /**
89
82
  * 表格组件定义
90
83
  */
@@ -383,6 +376,7 @@ const DXTable = defineComponent({
383
376
  const summary = () => {
384
377
  return <>{slots.summary && slots.summary()}</>;
385
378
  };
379
+
386
380
  return () => (
387
381
  <div ref={tableRootRef} style={{ height: "100%" }}>
388
382
  <Table