@ditari/bsui 1.0.25 → 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"),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"),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;
@@ -49,7 +49,7 @@ const Y = () => ({
49
49
  const t = v(a.keys || []), z = S(() => a.data), x = S(() => {
50
50
  var e;
51
51
  return ((e = a.config) == null ? void 0 : e.columns) ?? [];
52
- }), f = S(() => {
52
+ }), d = S(() => {
53
53
  var e;
54
54
  return ((e = a.config) == null ? void 0 : e.pagination) ?? {};
55
55
  }), {
@@ -63,15 +63,15 @@ const Y = () => ({
63
63
  const {
64
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, 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;
70
70
  try {
71
- const m = (r = o == null ? void 0 : o.value) == null ? void 0 : r.$el, J = R(m.getElementsByClassName("ant-table-header")[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
72
  let P = 0;
73
73
  if (a.config.pagination) {
74
- const Q = (N = c.value) == null ? void 0 : N.getElementsByClassName(T)[0];
74
+ const Q = (N = g.value) == null ? void 0 : N.getElementsByClassName(T)[0];
75
75
  P = R(Q) ?? 0;
76
76
  }
77
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];
@@ -81,19 +81,19 @@ const Y = () => ({
81
81
  };
82
82
  return F(() => {
83
83
  a.height !== 0 && I(() => {
84
- g(a.height);
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) && (t.value = [], w("update:keys", t.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) => e ? e(h, r) : void 0
96
+ onRowClassName: (h, f) => e ? e(h, f) : void 0
97
97
  };
98
98
  }
99
99
  const j = $();
@@ -102,27 +102,27 @@ const Y = () => ({
102
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) => {
110
+ const c = (o, i) => {
111
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);
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
116
  return L(() => a.keys, (o) => {
117
117
  t.value = o;
118
118
  }), {
119
119
  selectedRowKeys: t,
120
- onSelect: s,
121
- onSelectAll: c,
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
128
  const q = A();
@@ -130,14 +130,14 @@ const Y = () => ({
130
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 = e[d], g = () => {
140
+ } = a, l = e[s], r = () => {
141
141
  if (o === "N")
142
142
  return;
143
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);
@@ -146,12 +146,12 @@ const Y = () => ({
146
146
  onClick: () => {
147
147
  const u = i ? i(e) : null;
148
148
  u && u.value === l || (clearTimeout(n), n = setTimeout(() => {
149
- g(), s && s(e);
149
+ r(), c && c(e);
150
150
  }, 200));
151
151
  },
152
152
  // 点击行
153
153
  onDblclick: () => {
154
- clearTimeout(n), c && c(e);
154
+ clearTimeout(n), g && g(e);
155
155
  }
156
156
  // onContextmenu: (event) => {
157
157
  // //TODO
@@ -191,22 +191,23 @@ const Y = () => ({
191
191
  rowClassName: D
192
192
  }, {
193
193
  bodyCell: ({
194
- column: n
194
+ column: n,
195
+ record: s
195
196
  }) => {
196
197
  if (n.slot === "action")
197
198
  return p("div", {
198
199
  onClick: k,
199
200
  onDblclick: k
200
201
  }, [p(_, null, {
201
- default: () => [C.action && C.action()]
202
+ default: () => [C.action && C.action(s)]
202
203
  })]);
203
204
  }
204
205
  }), V(p(G, {
205
206
  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,
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,
210
211
  disabled: a.loading,
211
212
  "show-size-changer": !0,
212
213
  size: "default",
@@ -215,7 +216,7 @@ const Y = () => ({
215
216
  "default-page-size": y.defaultPageSize,
216
217
  "page-size-options": y.pageSizeOptions,
217
218
  "show-total": y.showTotal,
218
- total: f.value.total,
219
+ total: d.value.total,
219
220
  onChange: H
220
221
  }, null), [[W, a.config.pagination]])]);
221
222
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditari/bsui",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "files": [
5
5
  "dist/**",
6
6
  "src"
@@ -330,11 +330,11 @@ const DXTable = defineComponent({
330
330
  rowClassName={onRowClassName}
331
331
  >
332
332
  {{
333
- bodyCell: ({ column }: any) => {
333
+ bodyCell: ({ column, record }: any) => {
334
334
  if (column.slot === "action") {
335
335
  return (
336
336
  <div onClick={actionStop} onDblclick={actionStop}>
337
- <Space>{slots.action && slots.action()}</Space>
337
+ <Space>{slots.action && slots.action(record)}</Space>
338
338
  </div>
339
339
  );
340
340
  }