vxe-table 3.13.20 → 3.13.22

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.
@@ -75,6 +75,26 @@ function getFuncSlot($xeGrid, optSlots, slotKey) {
75
75
  }
76
76
  return null;
77
77
  }
78
+ const getConfigSlot = ($xeGrid, slotConfigs) => {
79
+ const slots = $xeGrid.$scopedSlots;
80
+ const slotConf = {};
81
+ XEUtils.objectMap(slotConfigs, (slotFunc, slotKey) => {
82
+ if (slotFunc) {
83
+ if (XEUtils.isString(slotFunc)) {
84
+ if (slots[slotFunc]) {
85
+ slotConf[slotKey] = slots[slotFunc];
86
+ }
87
+ else {
88
+ errLog('vxe.error.notSlot', [slotFunc]);
89
+ }
90
+ }
91
+ else {
92
+ slotConf[slotKey] = slotFunc;
93
+ }
94
+ }
95
+ });
96
+ return slotConf;
97
+ };
78
98
  function getToolbarSlots(_vm) {
79
99
  const { $scopedSlots, toolbarOpts } = _vm;
80
100
  const toolbarOptSlots = toolbarOpts.slots;
@@ -101,24 +121,6 @@ function getToolbarSlots(_vm) {
101
121
  }
102
122
  return slots;
103
123
  }
104
- function getPagerSlots(_vm) {
105
- const { pagerOpts } = _vm;
106
- const pagerOptSlots = pagerOpts.slots;
107
- const slots = {};
108
- let leftSlot;
109
- let rightSlot;
110
- if (pagerOptSlots) {
111
- leftSlot = getFuncSlot(_vm, pagerOptSlots, 'left');
112
- rightSlot = getFuncSlot(_vm, pagerOptSlots, 'right');
113
- if (leftSlot) {
114
- slots.left = leftSlot;
115
- }
116
- if (rightSlot) {
117
- slots.right = rightSlot;
118
- }
119
- }
120
- return slots;
121
- }
122
124
  function getTableOns(_vm) {
123
125
  const { $listeners, proxyConfig, proxyOpts } = _vm;
124
126
  const ons = {};
@@ -137,6 +139,22 @@ function getTableOns(_vm) {
137
139
  }
138
140
  return ons;
139
141
  }
142
+ function pageChangeEvent($xeGrid, params) {
143
+ const props = $xeGrid;
144
+ const reactData = $xeGrid;
145
+ const { proxyConfig } = props;
146
+ const { tablePage } = reactData;
147
+ const { $event, currentPage, pageSize } = params;
148
+ const proxyOpts = $xeGrid.computeProxyOpts;
149
+ tablePage.currentPage = currentPage;
150
+ tablePage.pageSize = pageSize;
151
+ $xeGrid.dispatchEvent('page-change', params, $event);
152
+ if (proxyConfig && isEnableConf(proxyOpts)) {
153
+ $xeGrid.commitProxy('query').then((rest) => {
154
+ $xeGrid.dispatchEvent('proxy-query', rest, $event);
155
+ });
156
+ }
157
+ }
140
158
  /**
141
159
  * 渲染表单
142
160
  */
@@ -248,25 +266,30 @@ function renderBottom(h, _vm) {
248
266
  function renderPager(h, $xeGrid) {
249
267
  const VxeUIPagerComponent = VxeUI.getComponent('VxePager');
250
268
  const props = $xeGrid;
251
- const { pagerConfig, proxyConfig } = props;
252
- const { $scopedSlots, tablePage } = $xeGrid;
253
- const pagerSlot = $scopedSlots.pager;
254
- const hasPager = !!(pagerSlot || isEnableConf(pagerConfig));
255
- if (hasPager) {
269
+ const slots = $xeGrid.$scopedSlots;
270
+ const reactData = $xeGrid;
271
+ const { proxyConfig, pagerConfig } = props;
272
+ const proxyOpts = $xeGrid.computeProxyOpts;
273
+ const pagerOpts = $xeGrid.computePagerOpts;
274
+ const pagerSlot = slots.pager;
275
+ if ((pagerConfig && isEnableConf(pagerOpts)) || slots.pager) {
256
276
  return h('div', {
257
- key: 'pager',
258
277
  ref: 'refPagerWrapper',
278
+ key: 'pager',
259
279
  class: 'vxe-grid--pager-wrapper'
260
280
  }, pagerSlot
261
- ? pagerSlot.call($xeGrid, { $grid: $xeGrid }, h)
281
+ ? pagerSlot.call($xeGrid, { $grid: $xeGrid })
262
282
  : [
263
283
  VxeUIPagerComponent
264
284
  ? h(VxeUIPagerComponent, {
265
- props: Object.assign(Object.assign({}, $xeGrid.pagerOpts), (proxyConfig ? tablePage : {})),
285
+ ref: 'refPager',
286
+ props: Object.assign(Object.assign({}, pagerOpts), (proxyConfig && isEnableConf(proxyOpts) ? reactData.tablePage : {})),
266
287
  on: {
267
- 'page-change': $xeGrid.pageChangeEvent
288
+ 'page-change'(params) {
289
+ pageChangeEvent($xeGrid, params);
290
+ }
268
291
  },
269
- scopedSlots: getPagerSlots($xeGrid)
292
+ scopedSlots: getConfigSlot($xeGrid, pagerOpts.slots)
270
293
  })
271
294
  : renderEmptyElement($xeGrid)
272
295
  ]);
@@ -606,20 +629,25 @@ export default {
606
629
  const reactData = $xeGrid;
607
630
  const { isZMax } = reactData;
608
631
  const el = $xeGrid.$refs.refElem;
609
- const formWrapper = $xeGrid.$refs.refFormWrapper;
610
- const toolbarWrapper = $xeGrid.$refs.refToolbarWrapper;
611
- const topWrapper = $xeGrid.$refs.refTopWrapper;
612
- const bottomWrapper = $xeGrid.$refs.refBottomWrapper;
613
- const pagerWrapper = $xeGrid.$refs.refPagerWrapper;
614
- const parentPaddingSize = isZMax ? 0 : getPaddingTopBottomSize(el.parentNode);
615
- return parentPaddingSize + getPaddingTopBottomSize(el) + getOffsetHeight(formWrapper) + getOffsetHeight(toolbarWrapper) + getOffsetHeight(topWrapper) + getOffsetHeight(bottomWrapper) + getOffsetHeight(pagerWrapper);
632
+ if (el) {
633
+ const formWrapper = $xeGrid.$refs.refFormWrapper;
634
+ const toolbarWrapper = $xeGrid.$refs.refToolbarWrapper;
635
+ const topWrapper = $xeGrid.$refs.refTopWrapper;
636
+ const bottomWrapper = $xeGrid.$refs.refBottomWrapper;
637
+ const pagerWrapper = $xeGrid.$refs.refPagerWrapper;
638
+ const parentEl = el.parentElement;
639
+ const parentPaddingSize = isZMax ? 0 : (parentEl ? getPaddingTopBottomSize(parentEl) : 0);
640
+ return parentPaddingSize + getPaddingTopBottomSize(el) + getOffsetHeight(formWrapper) + getOffsetHeight(toolbarWrapper) + getOffsetHeight(topWrapper) + getOffsetHeight(bottomWrapper) + getOffsetHeight(pagerWrapper);
641
+ }
642
+ return 0;
616
643
  },
617
644
  getParentHeight() {
618
645
  const $xeGrid = this;
619
646
  const reactData = $xeGrid;
620
647
  const el = $xeGrid.$refs.refElem;
621
648
  if (el) {
622
- return (reactData.isZMax ? getDomNode().visibleHeight : XEUtils.toNumber(getComputedStyle(el.parentNode).height)) - $xeGrid.getExcludeHeight();
649
+ const parentEl = el.parentElement;
650
+ return (reactData.isZMax ? getDomNode().visibleHeight : (parentEl ? XEUtils.toNumber(getComputedStyle(parentEl).height) : 0)) - $xeGrid.getExcludeHeight();
623
651
  }
624
652
  return 0;
625
653
  },
@@ -1090,18 +1118,6 @@ export default {
1090
1118
  }
1091
1119
  }
1092
1120
  },
1093
- pageChangeEvent(params) {
1094
- const { proxyConfig, tablePage } = this;
1095
- const { currentPage, pageSize } = params;
1096
- tablePage.currentPage = currentPage;
1097
- tablePage.pageSize = pageSize;
1098
- this.$emit('page-change', Object.assign({ $grid: this }, params));
1099
- if (proxyConfig) {
1100
- this.commitProxy('query').then((rest) => {
1101
- this.$emit('proxy-query', Object.assign(Object.assign({}, rest), { $grid: this, $event: params.$event }));
1102
- });
1103
- }
1104
- },
1105
1121
  sortChangeEvent(params) {
1106
1122
  const { $table, column, sortList } = params;
1107
1123
  const isRemote = XEUtils.isBoolean(column.remoteSort) ? column.remoteSort : $table.sortOpts.remote;