vxe-table 4.17.20 → 4.17.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.
Files changed (34) hide show
  1. package/es/grid/src/grid.js +136 -30
  2. package/es/style.css +1 -1
  3. package/es/table/render/index.js +113 -4
  4. package/es/table/src/cell.js +10 -8
  5. package/es/table/src/table.js +172 -67
  6. package/es/ui/index.js +3 -2
  7. package/es/ui/src/log.js +1 -1
  8. package/lib/grid/src/grid.js +152 -43
  9. package/lib/grid/src/grid.min.js +1 -1
  10. package/lib/index.umd.js +331 -75
  11. package/lib/index.umd.min.js +1 -1
  12. package/lib/style.css +1 -1
  13. package/lib/table/render/index.js +140 -10
  14. package/lib/table/render/index.min.js +1 -1
  15. package/lib/table/src/cell.js +13 -7
  16. package/lib/table/src/cell.min.js +1 -1
  17. package/lib/table/src/table.js +19 -11
  18. package/lib/table/src/table.min.js +1 -1
  19. package/lib/ui/index.js +3 -2
  20. package/lib/ui/index.min.js +1 -1
  21. package/lib/ui/src/log.js +1 -1
  22. package/lib/ui/src/log.min.js +1 -1
  23. package/package.json +2 -2
  24. package/packages/grid/src/grid.ts +132 -29
  25. package/packages/table/render/index.ts +115 -4
  26. package/packages/table/src/cell.ts +10 -8
  27. package/packages/table/src/table.ts +170 -63
  28. package/packages/ui/index.ts +2 -1
  29. /package/es/{iconfont.1764045862093.ttf → iconfont.1764380640866.ttf} +0 -0
  30. /package/es/{iconfont.1764045862093.woff → iconfont.1764380640866.woff} +0 -0
  31. /package/es/{iconfont.1764045862093.woff2 → iconfont.1764380640866.woff2} +0 -0
  32. /package/lib/{iconfont.1764045862093.ttf → iconfont.1764380640866.ttf} +0 -0
  33. /package/lib/{iconfont.1764045862093.woff → iconfont.1764380640866.woff} +0 -0
  34. /package/lib/{iconfont.1764045862093.woff2 → iconfont.1764380640866.woff2} +0 -0
@@ -397,8 +397,9 @@ export const Cell = {
397
397
  const { fullColumnFieldData } = tableInternalData
398
398
  const { computeAggregateOpts } = $table.getComputeMaps()
399
399
  const aggregateOpts = computeAggregateOpts.value
400
- const { mode, showTotal, totalMethod, countFields, contentMethod, mapChildrenField } = aggregateOpts
401
- const aggCalcMethod = aggregateOpts.calcValuesMethod || aggregateOpts.countMethod || aggregateOpts.aggregateMethod
400
+ const { mode, showTotal, totalMethod, countFields, contentMethod, formatValuesMethod, mapChildrenField } = aggregateOpts
401
+ const aggData = aggRow.aggData
402
+ const currAggData = aggData ? aggData[field] : null
402
403
  const groupField = aggRow.groupField
403
404
  const groupContent = aggRow.groupContent
404
405
  const childList = mapChildrenField ? (aggRow[mapChildrenField] || []) : []
@@ -439,9 +440,10 @@ export const Cell = {
439
440
  } else if ($table.getPivotTableAggregateCellAggValue) {
440
441
  cellValue = $table.getPivotTableAggregateCellAggValue(params)
441
442
  } else if (aggFunc === true || (countFields && countFields.includes(field))) {
442
- if (aggCalcMethod) {
443
- ctParams.aggValue = childCount
444
- cellValue = `${aggCalcMethod(ctParams)}`
443
+ cellValue = currAggData ? currAggData.value : childCount
444
+ ctParams.aggValue = cellValue
445
+ if (formatValuesMethod) {
446
+ cellValue = formatValuesMethod(ctParams)
445
447
  }
446
448
  }
447
449
  } else {
@@ -496,7 +498,7 @@ export const Cell = {
496
498
  const { rowGroupExpandedFlag } = tableReactData
497
499
  const { rowGroupExpandedMaps } = tableInternalData
498
500
  const aggregateOpts = computeAggregateOpts.value
499
- const { mode, padding, indent } = aggregateOpts
501
+ const { mode, padding, indent, showIcon, iconOpen, iconClose } = aggregateOpts
500
502
  const rowid = getRowid($table, row)
501
503
  const isExpand = !!rowGroupExpandedFlag && !!rowGroupExpandedMaps[rowid]
502
504
  return h('div', {
@@ -509,7 +511,7 @@ export const Cell = {
509
511
  }
510
512
  : undefined
511
513
  }, [
512
- row.isAggregate
514
+ showIcon && row.isAggregate
513
515
  ? h('span', {
514
516
  class: 'vxe-row-group--node-btn',
515
517
  onClick (evnt: MouseEvent) {
@@ -517,7 +519,7 @@ export const Cell = {
517
519
  }
518
520
  }, [
519
521
  h('i', {
520
- class: isExpand ? getIcon().TABLE_ROW_GROUP_OPEN : getIcon().TABLE_ROW_GROUP_CLOSE
522
+ class: isExpand ? (iconOpen || getIcon().TABLE_ROW_GROUP_OPEN) : (iconClose || getIcon().TABLE_ROW_GROUP_CLOSE)
521
523
  })
522
524
  ])
523
525
  : renderEmptyElement($table),
@@ -41,6 +41,8 @@ const customStorageKey = 'VXE_CUSTOM_STORE'
41
41
  const maxYHeight = 5e6
42
42
  const maxXWidth = 5e6
43
43
 
44
+ const sourceType = 'table'
45
+
44
46
  let crossTableDragRowObj: {
45
47
  $oldTable: VxeTableConstructor & VxeTablePrivateMethods
46
48
  $newTable: (VxeTableConstructor & VxeTablePrivateMethods) | null
@@ -930,6 +932,14 @@ export default defineVxeComponent({
930
932
  return rgColumns
931
933
  })
932
934
 
935
+ const computeAggFuncColumns = computed(() => {
936
+ const { rowGroupList, tableColumn } = reactData
937
+ if (rowGroupList.length) {
938
+ return tableColumn.filter(column => column.aggFunc)
939
+ }
940
+ return []
941
+ })
942
+
933
943
  const refMaps: VxeTablePrivateRef = {
934
944
  refElem,
935
945
  refTooltip,
@@ -1030,6 +1040,7 @@ export default defineVxeComponent({
1030
1040
  computeVirtualScrollBars,
1031
1041
  computeRowGroupFields,
1032
1042
  computeRowGroupColumns,
1043
+ computeAggFuncColumns,
1033
1044
 
1034
1045
  computeFNROpts,
1035
1046
  computeSXOpts,
@@ -2211,23 +2222,46 @@ export default defineVxeComponent({
2211
2222
  }
2212
2223
 
2213
2224
  const getOrderField = (column: VxeTableDefines.ColumnInfo) => {
2214
- const { sortBy, sortType } = column
2215
- return (row: any) => {
2216
- let cellValue
2217
- if (sortBy) {
2218
- cellValue = XEUtils.isFunction(sortBy) ? sortBy({ row, column }) : XEUtils.get(row, sortBy)
2219
- } else {
2220
- cellValue = tableMethods.getCellLabel(row, column)
2221
- }
2222
- if (!sortType || sortType === 'auto') {
2223
- return isNaN(cellValue) ? cellValue : XEUtils.toNumber(cellValue)
2224
- } else if (sortType === 'number') {
2225
- return XEUtils.toNumber(cellValue)
2226
- } else if (sortType === 'string') {
2227
- return XEUtils.toValueString(cellValue)
2228
- }
2229
- return cellValue
2230
- }
2225
+ const { isRowGroupStatus } = reactData
2226
+ const { sortBy, sortType, aggFunc } = column
2227
+ return isRowGroupStatus && aggFunc
2228
+ ? (row: any) => {
2229
+ if (row.isAggregate) {
2230
+ const aggData = row.aggData
2231
+ const currAggData = aggData ? aggData[column.field] : null
2232
+ return currAggData ? currAggData.value : null
2233
+ }
2234
+ let cellValue
2235
+ if (sortBy) {
2236
+ cellValue = XEUtils.isFunction(sortBy) ? sortBy({ row, column }) : XEUtils.get(row, sortBy)
2237
+ } else {
2238
+ cellValue = tableMethods.getCellLabel(row, column)
2239
+ }
2240
+ if (!sortType || sortType === 'auto') {
2241
+ return isNaN(cellValue) ? cellValue : XEUtils.toNumber(cellValue)
2242
+ } else if (sortType === 'number') {
2243
+ return XEUtils.toNumber(cellValue)
2244
+ } else if (sortType === 'string') {
2245
+ return XEUtils.toValueString(cellValue)
2246
+ }
2247
+ return cellValue
2248
+ }
2249
+ : (row: any) => {
2250
+ let cellValue
2251
+ if (sortBy) {
2252
+ cellValue = XEUtils.isFunction(sortBy) ? sortBy({ row, column }) : XEUtils.get(row, sortBy)
2253
+ } else {
2254
+ cellValue = tableMethods.getCellLabel(row, column)
2255
+ }
2256
+ if (!sortType || sortType === 'auto') {
2257
+ return isNaN(cellValue) ? cellValue : XEUtils.toNumber(cellValue)
2258
+ } else if (sortType === 'number') {
2259
+ return XEUtils.toNumber(cellValue)
2260
+ } else if (sortType === 'string') {
2261
+ return XEUtils.toValueString(cellValue)
2262
+ }
2263
+ return cellValue
2264
+ }
2231
2265
  }
2232
2266
 
2233
2267
  const updateAfterListIndex = () => {
@@ -3583,8 +3617,11 @@ export default defineVxeComponent({
3583
3617
  }
3584
3618
 
3585
3619
  const handleeGroupSummary = (aggList: VxeTableDefines.AggregateRowInfo[]) => {
3620
+ const { fullColumnFieldData } = internalData
3586
3621
  const aggregateOpts = computeAggregateOpts.value
3622
+ const aggFuncColumns = computeAggFuncColumns.value
3587
3623
  const { mapChildrenField } = aggregateOpts
3624
+ const aggCalcMethod = aggregateOpts.calcValuesMethod || aggregateOpts.countMethod || aggregateOpts.aggregateMethod
3588
3625
  if (mapChildrenField) {
3589
3626
  XEUtils.lastEach(aggList, aggRow => {
3590
3627
  let count = 0
@@ -3599,6 +3636,67 @@ export default defineVxeComponent({
3599
3636
  })
3600
3637
  if ($xeTable.handlePivotTableAggregateData) {
3601
3638
  $xeTable.handlePivotTableAggregateData(aggList)
3639
+ } else {
3640
+ if (aggFuncColumns.length) {
3641
+ XEUtils.lastEach(aggList, aggRow => {
3642
+ const aggDtObj: Record<string, {
3643
+ type: string
3644
+ value: any
3645
+ label: any
3646
+ }> = {}
3647
+ const aggData = aggRow.aggData
3648
+ const groupField = aggRow.groupField
3649
+ const groupContent = aggRow.groupContent
3650
+ const childList = mapChildrenField ? (aggRow[mapChildrenField] || []) : []
3651
+ const childCount = aggRow.childCount
3652
+ const colRest = fullColumnFieldData[groupField] || {}
3653
+ aggFuncColumns.forEach(column => {
3654
+ const { field } = column
3655
+ const currAggData = aggData ? aggData[field] : null
3656
+ const ctParams = {
3657
+ $table: $xeTable,
3658
+ groupField,
3659
+ groupColumn: (colRest ? colRest.column : null) as VxeTableDefines.ColumnInfo,
3660
+ column,
3661
+ groupValue: groupContent,
3662
+ childList,
3663
+ childCount,
3664
+ aggValue: currAggData ? currAggData.value : 0,
3665
+
3666
+ /**
3667
+ * 已废弃
3668
+ * @deprecated
3669
+ */
3670
+ children: childList,
3671
+ /**
3672
+ * 已废弃
3673
+ * @deprecated
3674
+ */
3675
+ totalValue: childCount
3676
+ }
3677
+ let aggVal = 0
3678
+ // 如果下层同时也是分组
3679
+ if (childList.length && childList[0].isAggregate) {
3680
+ XEUtils.each(childList, (row: VxeTableDefines.AggregateRowInfo) => {
3681
+ if (row.isAggregate) {
3682
+ const currAggData = row.aggData[field]
3683
+ if (currAggData) {
3684
+ aggVal += currAggData.value
3685
+ }
3686
+ }
3687
+ })
3688
+ } else {
3689
+ aggVal = aggCalcMethod ? aggCalcMethod(ctParams) : aggRow.childCount
3690
+ }
3691
+ aggDtObj[field] = {
3692
+ type: 'count',
3693
+ value: aggVal,
3694
+ label: aggVal
3695
+ }
3696
+ })
3697
+ aggRow.aggData = aggDtObj
3698
+ })
3699
+ }
3602
3700
  }
3603
3701
  }
3604
3702
  }
@@ -4833,6 +4931,34 @@ export default defineVxeComponent({
4833
4931
  }
4834
4932
  }
4835
4933
 
4934
+ const handleColumnVisible = (visible: boolean) => {
4935
+ return function (fieldOrColumn: string | string[] | VxeTableDefines.ColumnInfo | VxeTableDefines.ColumnInfo[]) {
4936
+ let status = false
4937
+ const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
4938
+ cols.forEach(item => {
4939
+ const column = handleFieldOrColumn($xeTable, item)
4940
+ if (column) {
4941
+ if (column.children && column.children.length) {
4942
+ XEUtils.eachTree([column], (item) => {
4943
+ item.visible = visible
4944
+ item.renderVisible = visible
4945
+ })
4946
+ } else {
4947
+ column.visible = visible
4948
+ column.renderVisible = visible
4949
+ }
4950
+ if (!status) {
4951
+ status = true
4952
+ }
4953
+ }
4954
+ })
4955
+ if (status) {
4956
+ return $xeTable.handleCustom()
4957
+ }
4958
+ return nextTick()
4959
+ }
4960
+ }
4961
+
4836
4962
  tableMethods = {
4837
4963
  dispatchEvent,
4838
4964
  getEl () {
@@ -5283,10 +5409,15 @@ export default defineVxeComponent({
5283
5409
  if (!column) {
5284
5410
  return null
5285
5411
  }
5286
- const { formatter } = column
5412
+ const { editConfig } = props
5413
+ const { formatter, editRender, cellRender } = column
5414
+ // formatter > tableCellFormatter
5415
+ const renderOpts = formatter ? null : (editConfig && isEnableConf(editRender) ? editRender : (isEnableConf(cellRender) ? cellRender : null))
5416
+ const compConf = renderOpts ? renderer.get(renderOpts.name) : null
5417
+ const tcFormatter = compConf ? compConf.tableCellFormatter : null
5287
5418
  const cellValue = getCellValue(row, column)
5288
5419
  let cellLabel = cellValue
5289
- if (formatter) {
5420
+ if (formatter || tcFormatter) {
5290
5421
  let formatData
5291
5422
  const { fullAllDataRowIdData } = internalData
5292
5423
  const rowid = getRowid($xeTable, row)
@@ -5304,22 +5435,27 @@ export default defineVxeComponent({
5304
5435
  }
5305
5436
  }
5306
5437
  const formatParams = {
5438
+ $table: $xeTable,
5307
5439
  cellValue,
5308
5440
  row,
5309
5441
  rowIndex: $xeTable.getRowIndex(row),
5310
5442
  column,
5311
5443
  columnIndex: $xeTable.getColumnIndex(column)
5312
5444
  }
5313
- if (XEUtils.isString(formatter)) {
5314
- const gFormatOpts = formats.get(formatter)
5315
- const tcFormatMethod = gFormatOpts ? (gFormatOpts.tableCellFormatMethod || gFormatOpts.cellFormatMethod) : null
5316
- cellLabel = tcFormatMethod ? tcFormatMethod(formatParams) : ''
5317
- } else if (XEUtils.isArray(formatter)) {
5318
- const gFormatOpts = formats.get(formatter[0])
5319
- const tcFormatMethod = gFormatOpts ? (gFormatOpts.tableCellFormatMethod || gFormatOpts.cellFormatMethod) : null
5320
- cellLabel = tcFormatMethod ? tcFormatMethod(formatParams, ...formatter.slice(1)) : ''
5321
- } else {
5322
- cellLabel = formatter(formatParams)
5445
+ if (formatter) {
5446
+ if (XEUtils.isString(formatter)) {
5447
+ const gFormatOpts = formats.get(formatter)
5448
+ const tcFormatMethod = gFormatOpts ? (gFormatOpts.tableCellFormatMethod || gFormatOpts.cellFormatMethod) : null
5449
+ cellLabel = tcFormatMethod ? tcFormatMethod(formatParams) : ''
5450
+ } else if (XEUtils.isArray(formatter)) {
5451
+ const gFormatOpts = formats.get(formatter[0])
5452
+ const tcFormatMethod = gFormatOpts ? (gFormatOpts.tableCellFormatMethod || gFormatOpts.cellFormatMethod) : null
5453
+ cellLabel = tcFormatMethod ? tcFormatMethod(formatParams, ...formatter.slice(1)) : ''
5454
+ } else {
5455
+ cellLabel = `${formatter(formatParams)}`
5456
+ }
5457
+ } else if (renderOpts && tcFormatter) {
5458
+ cellLabel = `${tcFormatter(renderOpts, formatParams)}`
5323
5459
  }
5324
5460
  if (formatData) {
5325
5461
  formatData[colid] = { value: cellValue, label: cellLabel }
@@ -5365,6 +5501,7 @@ export default defineVxeComponent({
5365
5501
  }
5366
5502
  }
5367
5503
  const footerFormatParams = {
5504
+ $table: $xeTable,
5368
5505
  cellValue: itemValue,
5369
5506
  itemValue,
5370
5507
  row,
@@ -5819,43 +5956,11 @@ export default defineVxeComponent({
5819
5956
  /**
5820
5957
  * 隐藏指定列
5821
5958
  */
5822
- hideColumn (fieldOrColumn) {
5823
- let status = false
5824
- const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
5825
- cols.forEach(item => {
5826
- const column = handleFieldOrColumn($xeTable, item)
5827
- if (column && column.visible) {
5828
- column.visible = false
5829
- if (!status) {
5830
- status = true
5831
- }
5832
- }
5833
- })
5834
- if (status) {
5835
- return tablePrivateMethods.handleCustom()
5836
- }
5837
- return nextTick()
5838
- },
5959
+ hideColumn: handleColumnVisible(false),
5839
5960
  /**
5840
5961
  * 显示指定列
5841
5962
  */
5842
- showColumn (fieldOrColumn) {
5843
- let status = false
5844
- const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
5845
- cols.forEach(item => {
5846
- const column = handleFieldOrColumn($xeTable, item)
5847
- if (column && !column.visible) {
5848
- column.visible = true
5849
- if (!status) {
5850
- status = true
5851
- }
5852
- }
5853
- })
5854
- if (status) {
5855
- return tablePrivateMethods.handleCustom()
5856
- }
5857
- return nextTick()
5858
- },
5963
+ showColumn: handleColumnVisible(true),
5859
5964
  setColumnWidth (fieldOrColumn, width) {
5860
5965
  const { elemStore } = internalData
5861
5966
  let status = false
@@ -11523,6 +11628,7 @@ export default defineVxeComponent({
11523
11628
  }
11524
11629
  reactData.lastScrollTime = Date.now()
11525
11630
  const evntParams = {
11631
+ source: sourceType,
11526
11632
  scrollTop,
11527
11633
  scrollLeft,
11528
11634
  bodyHeight,
@@ -13625,6 +13731,7 @@ export default defineVxeComponent({
13625
13731
  if (resizeObserver) {
13626
13732
  resizeObserver.disconnect()
13627
13733
  }
13734
+ $xeTable.closeTooltip()
13628
13735
  tableMethods.closeFilter()
13629
13736
  if ($xeTable.closeMenu) {
13630
13737
  $xeTable.closeMenu()
@@ -286,9 +286,10 @@ VxeUI.setConfig({
286
286
  showResponseMsg: true,
287
287
  showActionMsg: true,
288
288
  response: {
289
- list: null,
289
+ list: 'list',
290
290
  result: 'result',
291
291
  total: 'page.total',
292
+ footerData: 'footerData',
292
293
  message: 'message'
293
294
  }
294
295
  // beforeItem: null,