@ditari/bsui 1.0.9 → 1.0.10
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"),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:()=>({})}}),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),S=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:w}){console.log(w);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(S.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(S.Space,null,{default:()=>[w.action&&w.action()]})}}),n.withDirectives(n.createVNode(S.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,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as q, ref as y, computed as S, watchEffect as $, nextTick as A, watch as F, createVNode as
|
|
1
|
+
import { defineComponent as q, ref as y, computed as S, watchEffect as $, nextTick as A, watch as F, createVNode as w, 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
3
|
import { useEleHeight as k } from "../../utils/html.esm.js";
|
|
4
4
|
import { prefixName as W } from "../theme/index.esm.js";
|
|
@@ -45,13 +45,13 @@ const X = () => ({
|
|
|
45
45
|
emits: ["update:keys"],
|
|
46
46
|
setup(a, {
|
|
47
47
|
emit: v,
|
|
48
|
-
slots:
|
|
48
|
+
slots: p
|
|
49
49
|
}) {
|
|
50
|
-
console.log(
|
|
50
|
+
console.log(p);
|
|
51
51
|
const e = y(a.keys), T = S(() => a.data), z = S(() => {
|
|
52
52
|
var t;
|
|
53
53
|
return ((t = a.config) == null ? void 0 : t.columns) ?? [];
|
|
54
|
-
}),
|
|
54
|
+
}), f = S(() => {
|
|
55
55
|
var t;
|
|
56
56
|
return ((t = a.config) == null ? void 0 : t.pagination) ?? {};
|
|
57
57
|
}), {
|
|
@@ -64,7 +64,7 @@ const X = () => ({
|
|
|
64
64
|
const {
|
|
65
65
|
rowClassName: t,
|
|
66
66
|
keepSelected: n,
|
|
67
|
-
selection:
|
|
67
|
+
selection: d,
|
|
68
68
|
onPageChange: r
|
|
69
69
|
} = a.config, i = y(null), l = y(), u = y(null), o = (s) => {
|
|
70
70
|
var C;
|
|
@@ -83,7 +83,7 @@ const X = () => ({
|
|
|
83
83
|
r && r({
|
|
84
84
|
page: s,
|
|
85
85
|
size: g
|
|
86
|
-
}), u.value.scrollTop = 0, (
|
|
86
|
+
}), u.value.scrollTop = 0, (d === "S" || !n) && (e.value = [], v("update:keys", e.value));
|
|
87
87
|
},
|
|
88
88
|
onRowClassName: (s, g) => t ? t(s, g) : void 0
|
|
89
89
|
};
|
|
@@ -94,7 +94,7 @@ const X = () => ({
|
|
|
94
94
|
rowKey: t,
|
|
95
95
|
config: {
|
|
96
96
|
selection: n,
|
|
97
|
-
getCheckboxProps:
|
|
97
|
+
getCheckboxProps: d
|
|
98
98
|
}
|
|
99
99
|
} = a;
|
|
100
100
|
if (n === "N")
|
|
@@ -114,7 +114,7 @@ const X = () => ({
|
|
|
114
114
|
fixed: !0,
|
|
115
115
|
columnTitle: n === "S" ? "选择" : null,
|
|
116
116
|
columnWidth: n === "S" ? 60 : 40,
|
|
117
|
-
getCheckboxProps:
|
|
117
|
+
getCheckboxProps: d
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
120
|
const K = j();
|
|
@@ -122,14 +122,14 @@ const X = () => ({
|
|
|
122
122
|
return (t) => {
|
|
123
123
|
let n;
|
|
124
124
|
const {
|
|
125
|
-
rowKey:
|
|
125
|
+
rowKey: d,
|
|
126
126
|
config: {
|
|
127
127
|
click: r,
|
|
128
128
|
dbClick: i,
|
|
129
129
|
selection: l,
|
|
130
130
|
getCheckboxProps: u
|
|
131
131
|
}
|
|
132
|
-
} = a, o = t[
|
|
132
|
+
} = a, o = t[d], h = () => {
|
|
133
133
|
if (l === "N")
|
|
134
134
|
return;
|
|
135
135
|
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);
|
|
@@ -161,7 +161,7 @@ const X = () => ({
|
|
|
161
161
|
}
|
|
162
162
|
return () => {
|
|
163
163
|
var t;
|
|
164
|
-
return
|
|
164
|
+
return w(J, null, [w(I, {
|
|
165
165
|
ref: P,
|
|
166
166
|
"row-key": a.rowKey,
|
|
167
167
|
bordered: a.config.bordered,
|
|
@@ -183,16 +183,16 @@ const X = () => ({
|
|
|
183
183
|
column: n
|
|
184
184
|
}) => {
|
|
185
185
|
if (n.slot === "action")
|
|
186
|
-
return
|
|
187
|
-
default: () => [
|
|
186
|
+
return w(L, null, {
|
|
187
|
+
default: () => [p.action && p.action()]
|
|
188
188
|
});
|
|
189
189
|
}
|
|
190
|
-
}), Q(
|
|
190
|
+
}), Q(w(V, {
|
|
191
191
|
class: [N],
|
|
192
|
-
current:
|
|
193
|
-
"onUpdate:current": (n) =>
|
|
194
|
-
pageSize:
|
|
195
|
-
"onUpdate:pageSize": (n) =>
|
|
192
|
+
current: f.value.current,
|
|
193
|
+
"onUpdate:current": (n) => f.value.current = n,
|
|
194
|
+
pageSize: f.value.pageSize,
|
|
195
|
+
"onUpdate:pageSize": (n) => f.value.pageSize = n,
|
|
196
196
|
disabled: a.loading,
|
|
197
197
|
"show-size-changer": !0,
|
|
198
198
|
size: "default",
|
|
@@ -201,9 +201,9 @@ const X = () => ({
|
|
|
201
201
|
"default-page-size": m.defaultPageSize,
|
|
202
202
|
"page-size-options": m.pageSizeOptions,
|
|
203
203
|
"show-total": m.showTotal,
|
|
204
|
-
total:
|
|
204
|
+
total: f.value.total,
|
|
205
205
|
onChange: x
|
|
206
|
-
}, null), [[U,
|
|
206
|
+
}, null), [[U, a.config.pagination]])]);
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
209
|
});
|
package/package.json
CHANGED
|
@@ -318,7 +318,7 @@ const DXTable = defineComponent({
|
|
|
318
318
|
}}
|
|
319
319
|
</Table>
|
|
320
320
|
<Pagination
|
|
321
|
-
v-show={
|
|
321
|
+
v-show={props.config.pagination}
|
|
322
322
|
class={[basePageClassName]}
|
|
323
323
|
v-model:current={paginationState.value.current}
|
|
324
324
|
v-model:pageSize={paginationState.value.pageSize}
|