vxe-table 3.15.34 → 3.15.36

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.
Files changed (62) hide show
  1. package/es/grid/src/grid.js +50 -17
  2. package/es/style.css +1 -1
  3. package/es/table/module/edit/mixin.js +2 -2
  4. package/es/table/module/validator/mixin.js +11 -2
  5. package/es/table/src/body.js +20 -3
  6. package/es/table/src/cell.js +52 -36
  7. package/es/table/src/column.js +2 -0
  8. package/es/table/src/columnInfo.js +2 -0
  9. package/es/table/src/methods.js +135 -76
  10. package/es/table/src/props.js +3 -1
  11. package/es/table/src/table.js +19 -6
  12. package/es/table/src/util.js +5 -2
  13. package/es/ui/index.js +4 -4
  14. package/es/ui/src/log.js +1 -1
  15. package/lib/grid/src/grid.js +57 -24
  16. package/lib/grid/src/grid.min.js +1 -1
  17. package/lib/index.umd.js +323 -149
  18. package/lib/index.umd.min.js +1 -1
  19. package/lib/style.css +1 -1
  20. package/lib/table/module/edit/mixin.js +2 -2
  21. package/lib/table/module/edit/mixin.min.js +1 -1
  22. package/lib/table/module/validator/mixin.js +14 -2
  23. package/lib/table/module/validator/mixin.min.js +1 -1
  24. package/lib/table/src/body.js +19 -2
  25. package/lib/table/src/body.min.js +1 -1
  26. package/lib/table/src/cell.js +43 -28
  27. package/lib/table/src/cell.min.js +1 -1
  28. package/lib/table/src/column.js +2 -0
  29. package/lib/table/src/column.min.js +1 -1
  30. package/lib/table/src/columnInfo.js +2 -0
  31. package/lib/table/src/columnInfo.min.js +1 -1
  32. package/lib/table/src/methods.js +151 -74
  33. package/lib/table/src/methods.min.js +1 -1
  34. package/lib/table/src/props.js +3 -1
  35. package/lib/table/src/props.min.js +1 -1
  36. package/lib/table/src/table.js +19 -6
  37. package/lib/table/src/table.min.js +1 -1
  38. package/lib/table/src/util.js +7 -4
  39. package/lib/table/src/util.min.js +1 -1
  40. package/lib/ui/index.js +4 -4
  41. package/lib/ui/index.min.js +1 -1
  42. package/lib/ui/src/log.js +1 -1
  43. package/lib/ui/src/log.min.js +1 -1
  44. package/package.json +1 -1
  45. package/packages/grid/src/grid.ts +56 -17
  46. package/packages/table/module/edit/mixin.ts +2 -2
  47. package/packages/table/module/validator/mixin.ts +11 -3
  48. package/packages/table/src/body.ts +20 -3
  49. package/packages/table/src/cell.ts +52 -36
  50. package/packages/table/src/column.ts +2 -0
  51. package/packages/table/src/columnInfo.ts +3 -0
  52. package/packages/table/src/methods.ts +143 -77
  53. package/packages/table/src/props.ts +3 -1
  54. package/packages/table/src/table.ts +20 -6
  55. package/packages/table/src/util.ts +6 -2
  56. package/packages/ui/index.ts +3 -3
  57. /package/es/{iconfont.1749092456241.ttf → iconfont.1749440099787.ttf} +0 -0
  58. /package/es/{iconfont.1749092456241.woff → iconfont.1749440099787.woff} +0 -0
  59. /package/es/{iconfont.1749092456241.woff2 → iconfont.1749440099787.woff2} +0 -0
  60. /package/lib/{iconfont.1749092456241.ttf → iconfont.1749440099787.ttf} +0 -0
  61. /package/lib/{iconfont.1749092456241.woff → iconfont.1749440099787.woff} +0 -0
  62. /package/lib/{iconfont.1749092456241.woff2 → iconfont.1749440099787.woff2} +0 -0
@@ -221,12 +221,14 @@ export default {
221
221
  beginValidate(rows, cols, cb, isFull) {
222
222
  const $xeTable = this;
223
223
  const props = $xeTable;
224
+ const reactData = $xeTable;
224
225
  const internalData = $xeTable;
225
226
  const validRest = {};
226
227
  const { editRules, treeConfig } = props;
228
+ const { isRowGroupStatus } = reactData;
227
229
  const { afterFullData, pendingRowMaps, removeRowMaps } = internalData;
228
230
  const treeOpts = $xeTable.computeTreeOpts;
229
- const childrenField = treeOpts.children || treeOpts.childrenField;
231
+ const aggregateOpts = $xeTable.computeAggregateOpts;
230
232
  let validList;
231
233
  if (rows === true) {
232
234
  validList = afterFullData;
@@ -259,6 +261,9 @@ export default {
259
261
  if (pendingRowMaps[rowid]) {
260
262
  return;
261
263
  }
264
+ if ($xeTable.isAggregateRecord(row)) {
265
+ return;
266
+ }
262
267
  if (isFull || !this.validRuleErr) {
263
268
  const colVailds = [];
264
269
  columns.forEach((column) => {
@@ -296,7 +301,11 @@ export default {
296
301
  rowValidErrs.push(Promise.all(colVailds));
297
302
  }
298
303
  };
299
- if (treeConfig) {
304
+ if (isRowGroupStatus) {
305
+ XEUtils.eachTree(validList, handleVaild, { children: aggregateOpts.mapChildrenField });
306
+ }
307
+ else if (treeConfig) {
308
+ const childrenField = treeOpts.children || treeOpts.childrenField;
300
309
  XEUtils.eachTree(validList, handleVaild, { children: childrenField });
301
310
  }
302
311
  else {
@@ -1,7 +1,7 @@
1
1
  import XEUtils from 'xe-utils';
2
2
  import { VxeUI } from '../../ui';
3
3
  import { isEnableConf, getClass } from '../../ui/src/utils';
4
- import { getOffsetSize, calcTreeLine, getRowid, createHandleGetRowId } from './util';
4
+ import { getOffsetSize, calcTreeLine, getRowid, createHandleGetRowId, getCellRestHeight } from './util';
5
5
  import { updateCellTitle } from '../../ui/src/dom';
6
6
  import { getSlotVNs } from '../../ui/src/vn';
7
7
  const { getI18n, renderer, renderEmptyElement } = VxeUI;
@@ -190,6 +190,7 @@ function renderTdColumn(h, $xeTable, seq, rowid, fixedType, isOptimizeMode, rowL
190
190
  $xeTable.triggerCellDblclickEvent(evnt, cellParams);
191
191
  };
192
192
  let isMergeCell = false;
193
+ let mergeRowspan = 1;
193
194
  // 合并行或列
194
195
  if (mergeBodyFlag && mergeBodyList.length) {
195
196
  const spanRest = mergeBodyCellMaps[`${_rowIndex}:${_columnIndex}`];
@@ -200,6 +201,7 @@ function renderTdColumn(h, $xeTable, seq, rowid, fixedType, isOptimizeMode, rowL
200
201
  }
201
202
  if (rowspan > 1) {
202
203
  isMergeCell = true;
204
+ mergeRowspan = rowspan;
203
205
  tdAttrs.rowspan = rowspan;
204
206
  }
205
207
  if (colspan > 1) {
@@ -215,9 +217,12 @@ function renderTdColumn(h, $xeTable, seq, rowid, fixedType, isOptimizeMode, rowL
215
217
  return null;
216
218
  }
217
219
  if (rowspan > 1) {
220
+ isMergeCell = true;
221
+ mergeRowspan = rowspan;
218
222
  tdAttrs.rowspan = rowspan;
219
223
  }
220
224
  if (colspan > 1) {
225
+ isMergeCell = true;
221
226
  tdAttrs.colspan = colspan;
222
227
  }
223
228
  }
@@ -232,7 +237,7 @@ function renderTdColumn(h, $xeTable, seq, rowid, fixedType, isOptimizeMode, rowL
232
237
  isDirty = $xeTable.isUpdateByRow(row, column.field);
233
238
  }
234
239
  const isVNAutoHeight = scrollYLoad && !hasEllipsis;
235
- const cellHeight = rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight;
240
+ let cellHeight = getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight);
236
241
  const isLastColumn = $columnIndex === columns.length - 1;
237
242
  const isAutoCellWidth = !column.resizeWidth && (column.minWidth === 'auto' || column.width === 'auto');
238
243
  let isVNPreEmptyStatus = false;
@@ -246,6 +251,15 @@ function renderTdColumn(h, $xeTable, seq, rowid, fixedType, isOptimizeMode, rowL
246
251
  }
247
252
  }
248
253
  }
254
+ if (mergeRowspan > 1) {
255
+ const mEndRow = afterFullData[_rowIndex + mergeRowspan - 1];
256
+ if (mEndRow) {
257
+ const meRowRest = fullAllDataRowIdData[getRowid($xeTable, mEndRow)];
258
+ if (meRowRest) {
259
+ cellHeight += meRowRest.oTop - rowRest.oTop + getCellRestHeight(meRowRest, cellOpts, rowOpts, defaultRowHeight);
260
+ }
261
+ }
262
+ }
249
263
  const tcStyle = {};
250
264
  if (hasEllipsis && resizeWidthFlag) {
251
265
  let tsColspan = tdAttrs.colspan || 0;
@@ -279,7 +293,10 @@ function renderTdColumn(h, $xeTable, seq, rowid, fixedType, isOptimizeMode, rowL
279
293
  }
280
294
  else {
281
295
  // 渲染单元格
282
- tdVNs.push(...renderLine(h, $xeTable, rowid, cellParams, cellHeight), h('div', {
296
+ if (treeConfig) {
297
+ tdVNs.push(...renderLine(h, $xeTable, rowid, cellParams, cellHeight));
298
+ }
299
+ tdVNs.push(h('div', {
283
300
  key: 'tc',
284
301
  class: ['vxe-cell', {
285
302
  'c--title': showTitle,
@@ -253,11 +253,11 @@ function renderCellHandle(h, params) {
253
253
  const { editConfig } = tableProps;
254
254
  const { isRowGroupStatus } = tableReactData;
255
255
  const { type, treeNode, rowGroupNode, editRender } = column;
256
- const rowGroupOpts = $table.computeRowGroupOpts;
257
- const { mode } = rowGroupOpts;
256
+ const aggregateOpts = $table.computeAggregateOpts;
257
+ const { mode } = aggregateOpts;
258
258
  const checkboxOpts = $table.computeCheckboxOpts;
259
259
  const editOpts = $table.computeEditOpts;
260
- const isDeepCell = treeNode || (isRowGroupStatus && row.isAggregate && (mode === 'column' ? column.field === row.groupField : rowGroupNode));
260
+ const isDeepCell = treeNode || (isRowGroupStatus && (mode === 'column' ? column.field === row.groupField : rowGroupNode));
261
261
  switch (type) {
262
262
  case 'seq':
263
263
  return isDeepCell ? Cell.renderDeepIndexCell(h, params) : Cell.renderSeqCell(h, params);
@@ -356,7 +356,7 @@ export const Cell = {
356
356
  const tableReactData = $table;
357
357
  const tableInternalData = $table;
358
358
  const { isRowGroupStatus } = tableReactData;
359
- const { field, slots, editRender, cellRender, rowGroupNode } = column;
359
+ const { field, slots, editRender, cellRender, rowGroupNode, aggFunc } = column;
360
360
  const renderOpts = editRender || cellRender;
361
361
  if (slots && slots.default) {
362
362
  return renderCellBaseVNs(h, params, $table.callSlot(slots.default, params, h));
@@ -371,40 +371,52 @@ export const Cell = {
371
371
  }
372
372
  }
373
373
  let cellValue = '';
374
- if (isRowGroupStatus && row.isAggregate) {
374
+ if (isRowGroupStatus && field && row.isAggregate) {
375
+ const aggRow = row;
375
376
  const { fullColumnFieldData } = tableInternalData;
376
- const rowGroupOpts = $table.computeRowGroupOpts;
377
- const { mode, showTotal, totalMethod, countFields, countMethod, contentMethod, mapChildrenField } = rowGroupOpts;
378
- const groupField = row.groupField;
379
- const groupContent = row.groupContent;
380
- const childList = mapChildrenField ? (row[mapChildrenField] || []) : [];
381
- const totalValue = row.childCount;
377
+ const aggregateOpts = $table.computeAggregateOpts;
378
+ const { mode, showTotal, totalMethod, countFields, contentMethod, mapChildrenField } = aggregateOpts;
379
+ const aggMethod = aggregateOpts.aggregateMethod || aggregateOpts.countMethod;
380
+ const groupField = aggRow.groupField;
381
+ const groupContent = aggRow.groupContent;
382
+ const childList = mapChildrenField ? (aggRow[mapChildrenField] || []) : [];
383
+ const childCount = aggRow.childCount;
382
384
  const colRest = fullColumnFieldData[groupField] || {};
383
- const params = {
385
+ const ctParams = {
384
386
  $table,
385
387
  groupField,
386
388
  groupColumn: (colRest ? colRest.column : null),
387
389
  column,
388
390
  groupValue: groupContent,
389
391
  children: childList,
390
- totalValue: totalValue
392
+ childCount,
393
+ aggValue: null,
394
+ /**
395
+ * 已废弃
396
+ * @deprecated
397
+ */
398
+ totalValue: childCount
391
399
  };
392
- if (mode === 'column' ? column.field === row.groupField : rowGroupNode) {
400
+ if (mode === 'column' ? field === aggRow.groupField : rowGroupNode) {
393
401
  cellValue = groupContent;
394
402
  if (contentMethod) {
395
- cellValue = `${contentMethod(params)}`;
403
+ cellValue = `${contentMethod(ctParams)}`;
396
404
  }
397
405
  if (showTotal) {
398
- cellValue = getI18n('vxe.table.rowGroupContentTotal', [cellValue, totalMethod ? totalMethod(params) : totalValue, totalValue]);
406
+ cellValue = getI18n('vxe.table.rowGroupContentTotal', [cellValue, totalMethod ? totalMethod(ctParams) : childCount, childCount]);
399
407
  }
400
408
  }
401
- else if (countFields && countFields.includes(field)) {
402
- if (countMethod) {
403
- cellValue = `${countMethod(params)}`;
409
+ else if ($table.getPivotTableAggregateCellAggValue) {
410
+ cellValue = $table.getPivotTableAggregateCellAggValue(params);
411
+ }
412
+ else if (aggFunc === true || (countFields && countFields.includes(field))) {
413
+ if (aggMethod) {
414
+ ctParams.aggValue = childCount;
415
+ cellValue = `${aggMethod(ctParams)}`;
404
416
  }
405
417
  }
406
418
  }
407
- else if (!(isRowGroupStatus && row.isAggregate)) {
419
+ else {
408
420
  cellValue = $table.getCellLabel(row, column);
409
421
  }
410
422
  const cellPlaceholder = editRender ? editRender.placeholder : '';
@@ -437,8 +449,8 @@ export const Cell = {
437
449
  const { row, level } = params;
438
450
  const { rowGroupExpandedFlag } = tableReactData;
439
451
  const { rowGroupExpandedMaps } = tableInternalData;
440
- const rowGroupOpts = $table.computeRowGroupOpts;
441
- const { padding, indent } = rowGroupOpts;
452
+ const aggregateOpts = $table.computeAggregateOpts;
453
+ const { padding, indent } = aggregateOpts;
442
454
  const rowid = getRowid($table, row);
443
455
  const isExpand = !!rowGroupExpandedFlag && !!rowGroupExpandedMaps[rowid];
444
456
  return h('div', {
@@ -451,18 +463,20 @@ export const Cell = {
451
463
  }
452
464
  : undefined
453
465
  }, [
454
- h('span', {
455
- class: 'vxe-row-group--node-btn',
456
- on: {
457
- click(evnt) {
458
- $table.triggerRowGroupExpandEvent(evnt, params);
466
+ row.isAggregate
467
+ ? h('span', {
468
+ class: 'vxe-row-group--node-btn',
469
+ on: {
470
+ click(evnt) {
471
+ $table.triggerRowGroupExpandEvent(evnt, params);
472
+ }
459
473
  }
460
- }
461
- }, [
462
- h('i', {
463
- class: isExpand ? getIcon().TABLE_ROW_GROUP_OPEN : getIcon().TABLE_ROW_GROUP_CLOSE
464
- })
465
- ]),
474
+ }, [
475
+ h('i', {
476
+ class: isExpand ? getIcon().TABLE_ROW_GROUP_OPEN : getIcon().TABLE_ROW_GROUP_CLOSE
477
+ })
478
+ ])
479
+ : renderEmptyElement($table),
466
480
  h('div', {
467
481
  class: 'vxe-row-group-cell'
468
482
  }, cellVNodes)
@@ -545,9 +559,11 @@ export const Cell = {
545
559
  renderDeepNodeBtn(h, params, cellVNodes) {
546
560
  const { $table, row, column } = params;
547
561
  const { rowGroupNode } = column;
548
- if (row.isAggregate) {
549
- const rowGroupOpts = $table.computeRowGroupOpts;
550
- const { mode } = rowGroupOpts;
562
+ const tableReactData = $table;
563
+ const { rowGroupList } = tableReactData;
564
+ if (rowGroupList.length) {
565
+ const aggregateOpts = $table.computeAggregateOpts;
566
+ const { mode } = aggregateOpts;
551
567
  if (mode === 'column' ? column.field === row.groupField : rowGroupNode) {
552
568
  return [Cell.renderRowGroupBtn(h, params, cellVNodes)];
553
569
  }
@@ -127,6 +127,8 @@ export const columnProps = {
127
127
  editRender: Object,
128
128
  // 内容渲染配置项
129
129
  contentRender: Object,
130
+ // 聚合函数
131
+ aggFunc: [String, Boolean],
130
132
  // 额外的参数
131
133
  params: Object
132
134
  };
@@ -97,6 +97,7 @@ export class ColumnInfo {
97
97
  titleHelp: _vm.titleHelp,
98
98
  titlePrefix: _vm.titlePrefix,
99
99
  titleSuffix: _vm.titleSuffix,
100
+ aggFunc: _vm.aggFunc,
100
101
  // 自定义参数
101
102
  params: _vm.params,
102
103
  // 渲染属性
@@ -119,6 +120,7 @@ export class ColumnInfo {
119
120
  // 列排序
120
121
  sortNumber: 0,
121
122
  renderSortNumber: 0,
123
+ renderAggFn: '',
122
124
  renderFixed: '',
123
125
  renderVisible: false,
124
126
  renderWidth: 0,