vxe-table 3.13.21 → 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
  ]);
@@ -1095,18 +1118,6 @@ export default {
1095
1118
  }
1096
1119
  }
1097
1120
  },
1098
- pageChangeEvent(params) {
1099
- const { proxyConfig, tablePage } = this;
1100
- const { currentPage, pageSize } = params;
1101
- tablePage.currentPage = currentPage;
1102
- tablePage.pageSize = pageSize;
1103
- this.$emit('page-change', Object.assign({ $grid: this }, params));
1104
- if (proxyConfig) {
1105
- this.commitProxy('query').then((rest) => {
1106
- this.$emit('proxy-query', Object.assign(Object.assign({}, rest), { $grid: this, $event: params.$event }));
1107
- });
1108
- }
1109
- },
1110
1121
  sortChangeEvent(params) {
1111
1122
  const { $table, column, sortList } = params;
1112
1123
  const isRemote = XEUtils.isBoolean(column.remoteSort) ? column.remoteSort : $table.sortOpts.remote;