@ditari/bsui 1.0.24 → 1.0.26

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"),S=require("ant-design-vue"),N=require("../../utils/html.cjs.js"),$=require("../theme/index.cjs.js"),A=()=>({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=`${$.prefixName}-pagination`,J=n.defineComponent({name:"DTable",props:A(),emits:["update:keys"],setup:function(a,{emit:b,slots:p}){const e=n.ref(a.keys||[]),P=n.computed(()=>a.data),R=n.computed(()=>{var t;return((t=a.config)==null?void 0:t.columns)??[]}),f=n.computed(()=>{var t;return((t=a.config)==null?void 0:t.pagination)??{}}),{tableRef:z,tableRootRef:x,tableHeight:E,onPageChange:O,onRowClassName:H}=q();function q(){const{rowClassName:t,keepSelected:l,selection:h,onPageChange:c}=a.config,r=n.ref(),o=n.ref(null),u=n.ref(),i=n.ref(null),g=v=>{var d,C;try{const m=(d=o==null?void 0:o.value)==null?void 0:d.$el,V=N.useEleHeight(m.getElementsByClassName("ant-table-header")[0]);let k=0;if(a.config.pagination){const _=(C=r.value)==null?void 0:C.getElementsByClassName(T)[0];k=N.useEleHeight(_)??0}u.value=v-(V+k),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:o,tableRootRef:r,tableHeight:u,onPageChange:(v,d)=>{c&&c({page:v,size:d}),i.value.scrollTop=0,(h==="S"||!l)&&(e.value=[],b("update:keys",e.value))},onRowClassName:(v,d)=>t?t(v,d):void 0}}const B=j();function j(){const{rowKey:t,config:{selection:l,getCheckboxProps:h}}=a;if(l==="N")return;const c=(o,u)=>{l==="S"?(e.value=[],e.value=u?[o[t]]:[]):e.value=u?e.value.concat(o[t]):e.value.filter(i=>i!==o[t]),b("update:keys",e.value)},r=(o,u,i)=>{const g=i.map(s=>s[t]);e.value=o?e.value.concat(g):e.value.filter(s=>!g.includes(s)),b("update:keys",e.value)};return n.watch(()=>a.keys,o=>{e.value=o}),{selectedRowKeys:e,onSelect:c,onSelectAll:r,fixed:!0,columnTitle:l==="S"?"选择":null,columnWidth:l==="S"?60:40,getCheckboxProps:h}}const D=K();function K(){return t=>{let l;const{rowKey:h,config:{click:c,dbClick:r,selection:o,getCheckboxProps:u}}=a,i=t[h],g=()=>{if(o==="N")return;e.value.some(w=>w===i)?e.value=e.value.filter(w=>w!==i):(o==="S"&&(e.value=[]),e.value.push(i)),b("update:keys",e.value)};return{onClick:()=>{const s=u?u(t):null;s&&s.value===i||(clearTimeout(l),l=setTimeout(()=>{g(),c&&c(t)},200))},onDblclick:()=>{clearTimeout(l),r&&r(t)}}}}return()=>{var t;return n.createVNode("div",{ref:x},[n.createVNode(S.Table,{ref:z,"row-key":a.rowKey,bordered:a.config.bordered,columns:R.value,dataSource:P.value,loading:a.loading,size:((t=a.config)==null?void 0:t.size)??"small",scroll:{scrollToFirstRowOnChange:!0,x:"100%",y:E.value+"px"},pagination:!1,customRow:D,rowSelection:B,rowClassName:H},{bodyCell:({column:l})=>{if(l.slot==="action")return n.createVNode(S.Space,null,{default:()=>[p.action&&p.action()]})}}),n.withDirectives(n.createVNode(S.Pagination,{class:[T],current:f.value.current,"onUpdate:current":l=>f.value.current=l,pageSize:f.value.pageSize,"onUpdate:pageSize":l=>f.value.pageSize=l,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:O},null),[[n.vShow,a.config.pagination]])])}}});exports.default=J;
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,8 +1,8 @@
1
- import { defineComponent as Q, ref as v, computed as S, watchEffect as U, nextTick as F, watch as I, createVNode as b, withDirectives as L, vShow as V } from "vue";
2
- import { Table as W, Space as X, Pagination as _ } from "ant-design-vue";
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
3
  import { useEleHeight as R } from "../../utils/html.esm.js";
4
- import { prefixName as G } from "../theme/index.esm.js";
5
- const M = () => ({
4
+ import { prefixName as M } from "../theme/index.esm.js";
5
+ const Y = () => ({
6
6
  data: {
7
7
  type: Object,
8
8
  required: !0
@@ -36,9 +36,9 @@ const M = () => ({
36
36
  showQuickJumper: !0,
37
37
  showLessItems: !0,
38
38
  showTotal: (a) => `总共 ${a} 条`
39
- }, T = `${G}-pagination`, ae = /* @__PURE__ */ Q({
39
+ }, T = `${M}-pagination`, ne = /* @__PURE__ */ U({
40
40
  name: "DTable",
41
- props: M(),
41
+ props: Y(),
42
42
  // emits: { "update:keys": (keys: []) => void }
43
43
  // TODO 需要做调整
44
44
  emits: ["update:keys"],
@@ -46,112 +46,112 @@ const M = () => ({
46
46
  emit: w,
47
47
  slots: C
48
48
  }) {
49
- const e = v(a.keys || []), z = S(() => a.data), P = S(() => {
50
- var t;
51
- return ((t = a.config) == null ? void 0 : t.columns) ?? [];
52
- }), f = S(() => {
53
- var t;
54
- return ((t = a.config) == null ? void 0 : t.pagination) ?? {};
49
+ const t = v(a.keys || []), z = S(() => a.data), x = S(() => {
50
+ var e;
51
+ return ((e = a.config) == null ? void 0 : e.columns) ?? [];
52
+ }), d = S(() => {
53
+ var e;
54
+ return ((e = a.config) == null ? void 0 : e.pagination) ?? {};
55
55
  }), {
56
- tableRef: x,
57
- tableRootRef: E,
58
- tableHeight: O,
59
- onPageChange: B,
60
- onRowClassName: H
56
+ tableRef: E,
57
+ tableRootRef: O,
58
+ tableHeight: B,
59
+ onPageChange: H,
60
+ onRowClassName: D
61
61
  } = K();
62
62
  function K() {
63
63
  const {
64
- rowClassName: t,
64
+ rowClassName: e,
65
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, k;
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;
70
70
  try {
71
- const m = (r = o == null ? void 0 : o.value) == null ? void 0 : r.$el, A = R(m.getElementsByClassName("ant-table-header")[0]);
72
- let N = 0;
71
+ const m = (f = o == null ? void 0 : o.value) == null ? void 0 : f.$el, J = R(m.getElementsByClassName("ant-table-header")[0]);
72
+ let P = 0;
73
73
  if (a.config.pagination) {
74
- const J = (k = c.value) == null ? void 0 : k.getElementsByClassName(T)[0];
75
- N = R(J) ?? 0;
74
+ const Q = (N = g.value) == null ? void 0 : N.getElementsByClassName(T)[0];
75
+ P = R(Q) ?? 0;
76
76
  }
77
- i.value = h - (A + N), m.getElementsByClassName("ant-table-body")[0].style.height = i.value - 10 + "px", l.value = m.getElementsByClassName("ant-table-body")[0];
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
78
  } catch (m) {
79
79
  console.warn(m);
80
80
  }
81
81
  };
82
- return U(() => {
83
- a.height !== 0 && F(() => {
84
- g(a.height);
82
+ return F(() => {
83
+ a.height !== 0 && I(() => {
84
+ r(a.height);
85
85
  });
86
86
  }), {
87
87
  tableRef: o,
88
- tableRootRef: c,
88
+ tableRootRef: g,
89
89
  tableHeight: i,
90
- onPageChange: (h, r) => {
91
- s && s({
90
+ onPageChange: (h, f) => {
91
+ c && c({
92
92
  page: h,
93
- size: r
94
- }), l.value.scrollTop = 0, (d === "S" || !n) && (e.value = [], w("update:keys", e.value));
93
+ size: f
94
+ }), l.value.scrollTop = 0, (s === "S" || !n) && (t.value = [], w("update:keys", t.value));
95
95
  },
96
- onRowClassName: (h, r) => t ? t(h, r) : void 0
96
+ onRowClassName: (h, f) => e ? e(h, f) : void 0
97
97
  };
98
98
  }
99
- const j = D();
100
- function D() {
99
+ const j = $();
100
+ function $() {
101
101
  const {
102
- rowKey: t,
102
+ rowKey: e,
103
103
  config: {
104
104
  selection: n,
105
- getCheckboxProps: d
105
+ getCheckboxProps: s
106
106
  }
107
107
  } = a;
108
108
  if (n === "N")
109
109
  return;
110
- const s = (o, i) => {
111
- n === "S" ? (e.value = [], e.value = i ? [o[t]] : []) : e.value = i ? e.value.concat(o[t]) : e.value.filter((l) => l !== o[t]), w("update:keys", e.value);
112
- }, c = (o, i, l) => {
113
- const g = l.map((u) => u[t]);
114
- e.value = o ? e.value.concat(g) : e.value.filter((u) => !g.includes(u)), w("update:keys", e.value);
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);
115
115
  };
116
- return I(() => a.keys, (o) => {
117
- e.value = o;
116
+ return L(() => a.keys, (o) => {
117
+ t.value = o;
118
118
  }), {
119
- selectedRowKeys: e,
120
- onSelect: s,
121
- onSelectAll: c,
119
+ selectedRowKeys: t,
120
+ onSelect: c,
121
+ onSelectAll: g,
122
122
  fixed: !0,
123
123
  columnTitle: n === "S" ? "选择" : null,
124
124
  columnWidth: n === "S" ? 60 : 40,
125
- getCheckboxProps: d
125
+ getCheckboxProps: s
126
126
  };
127
127
  }
128
- const $ = q();
129
- function q() {
130
- return (t) => {
128
+ const q = A();
129
+ function A() {
130
+ return (e) => {
131
131
  let n;
132
132
  const {
133
- rowKey: d,
133
+ rowKey: s,
134
134
  config: {
135
- click: s,
136
- dbClick: c,
135
+ click: c,
136
+ dbClick: g,
137
137
  selection: o,
138
138
  getCheckboxProps: i
139
139
  }
140
- } = a, l = t[d], g = () => {
140
+ } = a, l = e[s], r = () => {
141
141
  if (o === "N")
142
142
  return;
143
- e.value.some((p) => p === l) ? e.value = e.value.filter((p) => p !== l) : (o === "S" && (e.value = []), e.value.push(l)), w("update:keys", e.value);
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);
144
144
  };
145
145
  return {
146
146
  onClick: () => {
147
- const u = i ? i(t) : null;
147
+ const u = i ? i(e) : null;
148
148
  u && u.value === l || (clearTimeout(n), n = setTimeout(() => {
149
- g(), s && s(t);
149
+ r(), c && c(e);
150
150
  }, 200));
151
151
  },
152
152
  // 点击行
153
153
  onDblclick: () => {
154
- clearTimeout(n), c && c(t);
154
+ clearTimeout(n), g && g(e);
155
155
  }
156
156
  // onContextmenu: (event) => {
157
157
  // //TODO
@@ -165,42 +165,49 @@ const M = () => ({
165
165
  };
166
166
  };
167
167
  }
168
+ const k = (e) => {
169
+ e.stopPropagation();
170
+ };
168
171
  return () => {
169
- var t;
170
- return b("div", {
171
- ref: E
172
- }, [b(W, {
173
- ref: x,
172
+ var e;
173
+ return p("div", {
174
+ ref: O
175
+ }, [p(X, {
176
+ ref: E,
174
177
  "row-key": a.rowKey,
175
178
  bordered: a.config.bordered,
176
- columns: P.value,
179
+ columns: x.value,
177
180
  dataSource: z.value,
178
181
  loading: a.loading,
179
- size: ((t = a.config) == null ? void 0 : t.size) ?? "small",
182
+ size: ((e = a.config) == null ? void 0 : e.size) ?? "small",
180
183
  scroll: {
181
184
  scrollToFirstRowOnChange: !0,
182
185
  x: "100%",
183
- y: O.value + "px"
186
+ y: B.value + "px"
184
187
  },
185
188
  pagination: !1,
186
- customRow: $,
189
+ customRow: q,
187
190
  rowSelection: j,
188
- rowClassName: H
191
+ rowClassName: D
189
192
  }, {
190
193
  bodyCell: ({
191
- column: n
194
+ column: n,
195
+ record: s
192
196
  }) => {
193
197
  if (n.slot === "action")
194
- return b(X, null, {
195
- default: () => [C.action && C.action()]
196
- });
198
+ return p("div", {
199
+ onClick: k,
200
+ onDblclick: k
201
+ }, [p(_, null, {
202
+ default: () => [C.action && C.action(s)]
203
+ })]);
197
204
  }
198
- }), L(b(_, {
205
+ }), V(p(G, {
199
206
  class: [T],
200
- current: f.value.current,
201
- "onUpdate:current": (n) => f.value.current = n,
202
- pageSize: f.value.pageSize,
203
- "onUpdate:pageSize": (n) => f.value.pageSize = n,
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,
204
211
  disabled: a.loading,
205
212
  "show-size-changer": !0,
206
213
  size: "default",
@@ -209,12 +216,12 @@ const M = () => ({
209
216
  "default-page-size": y.defaultPageSize,
210
217
  "page-size-options": y.pageSizeOptions,
211
218
  "show-total": y.showTotal,
212
- total: f.value.total,
213
- onChange: B
214
- }, null), [[V, a.config.pagination]])]);
219
+ total: d.value.total,
220
+ onChange: H
221
+ }, null), [[W, a.config.pagination]])]);
215
222
  };
216
223
  }
217
224
  });
218
225
  export {
219
- ae as default
226
+ ne as default
220
227
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditari/bsui",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "files": [
5
5
  "dist/**",
6
6
  "src"
@@ -306,6 +306,9 @@ const DXTable = defineComponent({
306
306
  };
307
307
  }
308
308
 
309
+ const actionStop = (event: MouseEvent) => {
310
+ event.stopPropagation();
311
+ };
309
312
  return () => (
310
313
  <div ref={tableRootRef}>
311
314
  <Table
@@ -327,9 +330,13 @@ const DXTable = defineComponent({
327
330
  rowClassName={onRowClassName}
328
331
  >
329
332
  {{
330
- bodyCell: ({ column }: any) => {
333
+ bodyCell: ({ column, record }: any) => {
331
334
  if (column.slot === "action") {
332
- return <Space>{slots.action && slots.action()}</Space>;
335
+ return (
336
+ <div onClick={actionStop} onDblclick={actionStop}>
337
+ <Space>{slots.action && slots.action(record)}</Space>
338
+ </div>
339
+ );
333
340
  }
334
341
  }
335
342
  }}