@ditari/bsui 1.0.11 → 1.0.13

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"),C=require("../../utils/html.cjs.js"),D=require("../theme/index.cjs.js"),K=()=>({data:{type:Object,required:!0},height:{type:Number,default:300},keys:Array,rowKey:{type:String,required:!0,default:"id"},loading:{type:Boolean,default:!1},pagination:{type:Object,default:()=>({})},config:{type:Object,default:()=>({})}}),v={defaultPageSize:20,hideOnSinglePage:!1,pageSizeOptions:["10","20","30","40"],responsive:!0,showQuickJumper:!0,showLessItems:!0,showTotal:a=>`总共 ${a} 条`},k=`${D.prefixName}-pagination`,V=n.defineComponent({name:"DTable",props:K(),emits:["update:keys"],setup(a,{emit:y,slots:S}){const e=n.ref(a.keys),N=n.computed(()=>a.data),T=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:P,tableHeight:z,onPageChange:R,onRowClassName:x}=O();function O(){const{rowClassName:t,keepSelected:l,selection:h,onPageChange:g}=a.config,u=n.ref(null),o=n.ref(),s=n.ref(null),i=c=>{var p;const d=(p=u==null?void 0:u.value)==null?void 0:p.$el,j=C.useEleHeight(d.getElementsByClassName("ant-table-header")[0]);let b=0;a.config.pagination&&(b=C.useEleHeight(document.getElementsByClassName(k)[0])),o.value=c-(j+b),d.getElementsByClassName("ant-table-body")[0].style.height=o.value-10+"px",s.value=d.getElementsByClassName("ant-table-body")[0]};return n.watchEffect(()=>{a.height!==0&&n.nextTick(()=>{i(a.height)})}),{tableRef:u,tableHeight:o,onPageChange:(c,d)=>{g&&g({page:c,size:d}),s.value.scrollTop=0,(h==="S"||!l)&&(e.value=[],y("update:keys",e.value))},onRowClassName:(c,d)=>t?t(c,d):void 0}}const E=q();function q(){const{rowKey:t,config:{selection:l,getCheckboxProps:h}}=a;if(l==="N")return;const g=(o,s)=>{l==="S"?(e.value=[],e.value=s?[o[t]]:[]):e.value=s?e.value.concat(o[t]):e.value.filter(i=>i!==o[t]),y("update:keys",e.value)},u=(o,s,i)=>{const m=i.map(r=>r[t]);e.value=o?e.value.concat(m):e.value.filter(r=>!m.includes(r)),y("update:keys",e.value)};return n.watch(()=>a.keys,o=>{e.value=o}),{selectedRowKeys:e,onSelect:g,onSelectAll:u,fixed:!0,columnTitle:l==="S"?"选择":null,columnWidth:l==="S"?60:40,getCheckboxProps:h}}const H=B();function B(){return t=>{let l;const{rowKey:h,config:{click:g,dbClick:u,selection:o,getCheckboxProps:s}}=a,i=t[h],m=()=>{if(o==="N")return;e.value.some(c=>c===i)?e.value=e.value.filter(c=>c!==i):(o==="S"&&(e.value=[]),e.value.push(i)),y("update:keys",e.value)};return{onClick:()=>{if(!g)return;const r=s?s(t):null;r&&r.value===i||(clearTimeout(l),l=setTimeout(()=>{m(),g(t)},200))},onDblclick:()=>{u&&(clearTimeout(l),u(t))}}}}return()=>{var t;return n.createVNode(n.Fragment,null,[n.createVNode(w.Table,{ref:P,"row-key":a.rowKey,bordered:a.config.bordered,columns:T.value,dataSource:N.value,loading:a.loading,size:((t=a.config)==null?void 0:t.size)??"small",scroll:{scrollToFirstRowOnChange:!0,x:"100%",y:z.value+"px"},pagination:!1,customRow:H,rowSelection:E,rowClassName:x},{bodyCell:({column:l})=>{if(l.slot==="action")return n.createVNode(w.Space,null,{default:()=>[S.action&&S.action()]})}}),n.withDirectives(n.createVNode(w.Pagination,{class:[k],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":v.hideOnSinglePage,"show-quick-jumper":v.showQuickJumper,"default-page-size":v.defaultPageSize,"page-size-options":v.pageSizeOptions,"show-total":v.showTotal,total:f.value.total,onChange:R},null),[[n.vShow,a.config.pagination]])])}}});exports.default=V;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),S=require("ant-design-vue"),k=require("../../utils/html.cjs.js"),D=require("../theme/index.cjs.js"),K=()=>({data:{type:Object,required:!0},height:{type:Number,default:300},keys:Array,rowKey:{type:String,required:!0,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} 条`},N=`${D.prefixName}-pagination`,V=n.defineComponent({name:"DTable",props:K(),emits:["update:keys"],setup(a,{emit:b,slots:p}){const e=n.ref(a.keys),T=n.computed(()=>a.data),P=n.computed(()=>{var t;return((t=a.config)==null?void 0:t.columns)??[]}),h=n.computed(()=>{var t;return((t=a.config)==null?void 0:t.pagination)??{}}),{tableRef:z,tableHeight:R,onPageChange:x,onRowClassName:H}=E();function E(){const{rowClassName:t,keepSelected:l,selection:m,onPageChange:g}=a.config,s=n.ref(null),o=n.ref(),u=n.ref(null),i=c=>{var d;try{const f=(d=s==null?void 0:s.value)==null?void 0:d.$el;console.log("tableEl",f);const C=k.useEleHeight(f.getElementsByClassName("ant-table-header")[0]);console.log("headerHeight",C);let w=0;a.config.pagination&&(w=k.useEleHeight(document.getElementsByClassName(N)[0])),console.log("paginationHeight",w),o.value=c-(C+w),console.log("tableHeight",o),f.getElementsByClassName("ant-table-body")[0].style.height=o.value-10+"px",u.value=f.getElementsByClassName("ant-table-body")[0],console.log("antTableBodyRef",u)}catch(f){console.warn(f)}};return n.watchEffect(()=>{a.height!==0&&n.nextTick(()=>{i(a.height)})}),{tableRef:s,tableHeight:o,onPageChange:(c,d)=>{g&&g({page:c,size:d}),u.value.scrollTop=0,(m==="S"||!l)&&(e.value=[],b("update:keys",e.value))},onRowClassName:(c,d)=>t?t(c,d):void 0}}const O=q();function q(){const{rowKey:t,config:{selection:l,getCheckboxProps:m}}=a;if(l==="N")return;const g=(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)},s=(o,u,i)=>{const v=i.map(r=>r[t]);e.value=o?e.value.concat(v):e.value.filter(r=>!v.includes(r)),b("update:keys",e.value)};return n.watch(()=>a.keys,o=>{e.value=o}),{selectedRowKeys:e,onSelect:g,onSelectAll:s,fixed:!0,columnTitle:l==="S"?"选择":null,columnWidth:l==="S"?60:40,getCheckboxProps:m}}const B=j();function j(){return t=>{let l;const{rowKey:m,config:{click:g,dbClick:s,selection:o,getCheckboxProps:u}}=a,i=t[m],v=()=>{if(o==="N")return;e.value.some(c=>c===i)?e.value=e.value.filter(c=>c!==i):(o==="S"&&(e.value=[]),e.value.push(i)),b("update:keys",e.value)};return{onClick:()=>{if(!g)return;const r=u?u(t):null;r&&r.value===i||(clearTimeout(l),l=setTimeout(()=>{v(),g(t)},200))},onDblclick:()=>{s&&(clearTimeout(l),s(t))}}}}return()=>{var t;return n.createVNode(n.Fragment,null,[n.createVNode(S.Table,{ref:z,"row-key":a.rowKey,bordered:a.config.bordered,columns:P.value,dataSource:T.value,loading:a.loading,size:((t=a.config)==null?void 0:t.size)??"small",scroll:{scrollToFirstRowOnChange:!0,x:"100%",y:R.value+"px"},pagination:!1,customRow:B,rowSelection:O,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:[N],current:h.value.current,"onUpdate:current":l=>h.value.current=l,pageSize:h.value.pageSize,"onUpdate:pageSize":l=>h.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:h.value.total,onChange:x},null),[[n.vShow,a.config.pagination]])])}}});exports.default=V;
@@ -1,6 +1,6 @@
1
- import { defineComponent as q, ref as y, computed as p, watchEffect as $, nextTick as A, watch as F, createVNode as w, Fragment as J, withDirectives as Q, vShow as U } from "vue";
1
+ import { defineComponent as q, ref as w, computed as S, watchEffect as $, nextTick as A, watch as F, createVNode as b, Fragment as J, withDirectives as Q, vShow as U } from "vue";
2
2
  import { Table as I, Space as L, Pagination as V } from "ant-design-vue";
3
- import { useEleHeight as k } from "../../utils/html.esm.js";
3
+ import { useEleHeight as T } from "../../utils/html.esm.js";
4
4
  import { prefixName as W } from "../theme/index.esm.js";
5
5
  const X = () => ({
6
6
  data: {
@@ -29,7 +29,7 @@ const X = () => ({
29
29
  type: Object,
30
30
  default: () => ({})
31
31
  }
32
- }), m = {
32
+ }), v = {
33
33
  defaultPageSize: 20,
34
34
  hideOnSinglePage: !1,
35
35
  pageSizeOptions: ["10", "20", "30", "40"],
@@ -44,107 +44,114 @@ const X = () => ({
44
44
  // TODO 需要做调整
45
45
  emits: ["update:keys"],
46
46
  setup(a, {
47
- emit: v,
48
- slots: S
47
+ emit: y,
48
+ slots: C
49
49
  }) {
50
- const e = y(a.keys), T = p(() => a.data), z = p(() => {
50
+ const e = w(a.keys), z = S(() => a.data), P = S(() => {
51
51
  var t;
52
52
  return ((t = a.config) == null ? void 0 : t.columns) ?? [];
53
- }), f = p(() => {
53
+ }), f = S(() => {
54
54
  var t;
55
55
  return ((t = a.config) == null ? void 0 : t.pagination) ?? {};
56
56
  }), {
57
- tableRef: P,
58
- tableHeight: R,
59
- onPageChange: x,
60
- onRowClassName: O
61
- } = E();
62
- function E() {
57
+ tableRef: R,
58
+ tableHeight: x,
59
+ onPageChange: H,
60
+ onRowClassName: E
61
+ } = O();
62
+ function O() {
63
63
  const {
64
64
  rowClassName: t,
65
65
  keepSelected: n,
66
- selection: d,
67
- onPageChange: r
68
- } = a.config, i = y(null), l = y(), u = y(null), o = (s) => {
69
- var C;
70
- const g = (C = i == null ? void 0 : i.value) == null ? void 0 : C.$el, D = k(g.getElementsByClassName("ant-table-header")[0]);
71
- let b = 0;
72
- a.config.pagination && (b = k(document.getElementsByClassName(N)[0])), l.value = s - (D + b), g.getElementsByClassName("ant-table-body")[0].style.height = l.value - 10 + "px", u.value = g.getElementsByClassName("ant-table-body")[0];
66
+ selection: h,
67
+ onPageChange: g
68
+ } = a.config, u = w(null), l = w(), i = w(null), o = (s) => {
69
+ var r;
70
+ try {
71
+ const d = (r = u == null ? void 0 : u.value) == null ? void 0 : r.$el;
72
+ console.log("tableEl", d);
73
+ const k = T(d.getElementsByClassName("ant-table-header")[0]);
74
+ console.log("headerHeight", k);
75
+ let p = 0;
76
+ a.config.pagination && (p = T(document.getElementsByClassName(N)[0])), console.log("paginationHeight", p), l.value = s - (k + p), console.log("tableHeight", l), d.getElementsByClassName("ant-table-body")[0].style.height = l.value - 10 + "px", i.value = d.getElementsByClassName("ant-table-body")[0], console.log("antTableBodyRef", i);
77
+ } catch (d) {
78
+ console.warn(d);
79
+ }
73
80
  };
74
81
  return $(() => {
75
82
  a.height !== 0 && A(() => {
76
83
  o(a.height);
77
84
  });
78
85
  }), {
79
- tableRef: i,
86
+ tableRef: u,
80
87
  tableHeight: l,
81
- onPageChange: (s, g) => {
82
- r && r({
88
+ onPageChange: (s, r) => {
89
+ g && g({
83
90
  page: s,
84
- size: g
85
- }), u.value.scrollTop = 0, (d === "S" || !n) && (e.value = [], v("update:keys", e.value));
91
+ size: r
92
+ }), i.value.scrollTop = 0, (h === "S" || !n) && (e.value = [], y("update:keys", e.value));
86
93
  },
87
- onRowClassName: (s, g) => t ? t(s, g) : void 0
94
+ onRowClassName: (s, r) => t ? t(s, r) : void 0
88
95
  };
89
96
  }
90
- const B = H();
91
- function H() {
97
+ const B = K();
98
+ function K() {
92
99
  const {
93
100
  rowKey: t,
94
101
  config: {
95
102
  selection: n,
96
- getCheckboxProps: d
103
+ getCheckboxProps: h
97
104
  }
98
105
  } = a;
99
106
  if (n === "N")
100
107
  return;
101
- const r = (l, u) => {
102
- n === "S" ? (e.value = [], e.value = u ? [l[t]] : []) : e.value = u ? e.value.concat(l[t]) : e.value.filter((o) => o !== l[t]), v("update:keys", e.value);
103
- }, i = (l, u, o) => {
104
- const h = o.map((c) => c[t]);
105
- e.value = l ? e.value.concat(h) : e.value.filter((c) => !h.includes(c)), v("update:keys", e.value);
108
+ const g = (l, i) => {
109
+ n === "S" ? (e.value = [], e.value = i ? [l[t]] : []) : e.value = i ? e.value.concat(l[t]) : e.value.filter((o) => o !== l[t]), y("update:keys", e.value);
110
+ }, u = (l, i, o) => {
111
+ const m = o.map((c) => c[t]);
112
+ e.value = l ? e.value.concat(m) : e.value.filter((c) => !m.includes(c)), y("update:keys", e.value);
106
113
  };
107
114
  return F(() => a.keys, (l) => {
108
115
  e.value = l;
109
116
  }), {
110
117
  selectedRowKeys: e,
111
- onSelect: r,
112
- onSelectAll: i,
118
+ onSelect: g,
119
+ onSelectAll: u,
113
120
  fixed: !0,
114
121
  columnTitle: n === "S" ? "选择" : null,
115
122
  columnWidth: n === "S" ? 60 : 40,
116
- getCheckboxProps: d
123
+ getCheckboxProps: h
117
124
  };
118
125
  }
119
- const K = j();
120
- function j() {
126
+ const j = D();
127
+ function D() {
121
128
  return (t) => {
122
129
  let n;
123
130
  const {
124
- rowKey: d,
131
+ rowKey: h,
125
132
  config: {
126
- click: r,
127
- dbClick: i,
133
+ click: g,
134
+ dbClick: u,
128
135
  selection: l,
129
- getCheckboxProps: u
136
+ getCheckboxProps: i
130
137
  }
131
- } = a, o = t[d], h = () => {
138
+ } = a, o = t[h], m = () => {
132
139
  if (l === "N")
133
140
  return;
134
- e.value.some((s) => s === o) ? e.value = e.value.filter((s) => s !== o) : (l === "S" && (e.value = []), e.value.push(o)), v("update:keys", e.value);
141
+ e.value.some((s) => s === o) ? e.value = e.value.filter((s) => s !== o) : (l === "S" && (e.value = []), e.value.push(o)), y("update:keys", e.value);
135
142
  };
136
143
  return {
137
144
  onClick: () => {
138
- if (!r)
145
+ if (!g)
139
146
  return;
140
- const c = u ? u(t) : null;
147
+ const c = i ? i(t) : null;
141
148
  c && c.value === o || (clearTimeout(n), n = setTimeout(() => {
142
- h(), r(t);
149
+ m(), g(t);
143
150
  }, 200));
144
151
  },
145
152
  // 点击行
146
153
  onDblclick: () => {
147
- i && (clearTimeout(n), i(t));
154
+ u && (clearTimeout(n), u(t));
148
155
  }
149
156
  // onContextmenu: (event) => {
150
157
  // //TODO
@@ -160,33 +167,33 @@ const X = () => ({
160
167
  }
161
168
  return () => {
162
169
  var t;
163
- return w(J, null, [w(I, {
164
- ref: P,
170
+ return b(J, null, [b(I, {
171
+ ref: R,
165
172
  "row-key": a.rowKey,
166
173
  bordered: a.config.bordered,
167
- columns: z.value,
168
- dataSource: T.value,
174
+ columns: P.value,
175
+ dataSource: z.value,
169
176
  loading: a.loading,
170
177
  size: ((t = a.config) == null ? void 0 : t.size) ?? "small",
171
178
  scroll: {
172
179
  scrollToFirstRowOnChange: !0,
173
180
  x: "100%",
174
- y: R.value + "px"
181
+ y: x.value + "px"
175
182
  },
176
183
  pagination: !1,
177
- customRow: K,
184
+ customRow: j,
178
185
  rowSelection: B,
179
- rowClassName: O
186
+ rowClassName: E
180
187
  }, {
181
188
  bodyCell: ({
182
189
  column: n
183
190
  }) => {
184
191
  if (n.slot === "action")
185
- return w(L, null, {
186
- default: () => [S.action && S.action()]
192
+ return b(L, null, {
193
+ default: () => [C.action && C.action()]
187
194
  });
188
195
  }
189
- }), Q(w(V, {
196
+ }), Q(b(V, {
190
197
  class: [N],
191
198
  current: f.value.current,
192
199
  "onUpdate:current": (n) => f.value.current = n,
@@ -195,13 +202,13 @@ const X = () => ({
195
202
  disabled: a.loading,
196
203
  "show-size-changer": !0,
197
204
  size: "default",
198
- "hide-on-single-page": m.hideOnSinglePage,
199
- "show-quick-jumper": m.showQuickJumper,
200
- "default-page-size": m.defaultPageSize,
201
- "page-size-options": m.pageSizeOptions,
202
- "show-total": m.showTotal,
205
+ "hide-on-single-page": v.hideOnSinglePage,
206
+ "show-quick-jumper": v.showQuickJumper,
207
+ "default-page-size": v.defaultPageSize,
208
+ "page-size-options": v.pageSizeOptions,
209
+ "show-total": v.showTotal,
203
210
  total: f.value.total,
204
- onChange: x
211
+ onChange: H
205
212
  }, null), [[U, a.config.pagination]])]);
206
213
  };
207
214
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditari/bsui",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "files": [
5
5
  "dist/**",
6
6
  "src"
@@ -1,16 +1,14 @@
1
1
  import {
2
2
  computed,
3
3
  defineComponent,
4
- defineEmits,
5
4
  nextTick,
6
5
  PropType,
7
6
  ref,
8
7
  watch,
9
- watchEffect,
10
- createSlots
8
+ watchEffect
11
9
  } from "vue";
12
10
  import { Pagination, Space, Table } from "ant-design-vue";
13
- import { useEleHeight } from "../../utils";
11
+ import { useEleHeight } from "../../utils/html";
14
12
  import { prefixName } from "../theme";
15
13
 
16
14
  import type { TableProps, Key } from "./interface/table";
@@ -110,24 +108,33 @@ const DXTable = defineComponent({
110
108
  const antTableBodyRef = ref<any>(null);
111
109
  // 计算高度
112
110
  const playHeight = (height: number) => {
113
- const tableEl = tableRef?.value?.$el;
114
- const headerHeight = useEleHeight(
115
- tableEl.getElementsByClassName("ant-table-header")[0]
116
- );
117
- // 获取分页组件高度
118
- let paginationHeight = 0;
119
- if (props.config.pagination) {
120
- paginationHeight = useEleHeight(
121
- document.getElementsByClassName(basePageClassName)[0]
111
+ try {
112
+ const tableEl = tableRef?.value?.$el;
113
+ console.log("tableEl", tableEl);
114
+ const headerHeight = useEleHeight(
115
+ tableEl.getElementsByClassName("ant-table-header")[0]
122
116
  );
117
+ console.log("headerHeight", headerHeight);
118
+ // 获取分页组件高度
119
+ let paginationHeight = 0;
120
+ if (props.config.pagination) {
121
+ paginationHeight = useEleHeight(
122
+ document.getElementsByClassName(basePageClassName)[0]
123
+ );
124
+ }
125
+ console.log("paginationHeight", paginationHeight);
126
+ tableHeight.value = height - (headerHeight + paginationHeight);
127
+ console.log("tableHeight", tableHeight);
128
+ // 设置body高度
129
+ tableEl.getElementsByClassName("ant-table-body")[0].style.height =
130
+ tableHeight.value - 10 + "px";
131
+ // 表格body对象 用于切换页码后滚动条置顶
132
+ antTableBodyRef.value =
133
+ tableEl.getElementsByClassName("ant-table-body")[0];
134
+ console.log("antTableBodyRef", antTableBodyRef);
135
+ } catch (e) {
136
+ console.warn(e);
123
137
  }
124
- tableHeight.value = height - (headerHeight + paginationHeight);
125
- // 设置body高度
126
- tableEl.getElementsByClassName("ant-table-body")[0].style.height =
127
- tableHeight.value - 10 + "px";
128
- // 表格body对象 用于切换页码后滚动条置顶
129
- antTableBodyRef.value =
130
- tableEl.getElementsByClassName("ant-table-body")[0];
131
138
  };
132
139
  //监听传入的height的变化 默认组件创建的时候会执行一次
133
140
  watchEffect(() => {