vxe-table 3.19.20 → 3.19.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 (38) hide show
  1. package/es/grid/src/grid.js +148 -33
  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/methods.js +176 -74
  6. package/es/table/src/table.js +12 -2
  7. package/es/ui/index.js +3 -2
  8. package/es/ui/src/log.js +1 -1
  9. package/lib/grid/src/grid.js +166 -48
  10. package/lib/grid/src/grid.min.js +1 -1
  11. package/lib/index.umd.js +367 -89
  12. package/lib/index.umd.min.js +1 -1
  13. package/lib/style.css +1 -1
  14. package/lib/table/render/index.js +140 -10
  15. package/lib/table/render/index.min.js +1 -1
  16. package/lib/table/src/cell.js +13 -7
  17. package/lib/table/src/cell.min.js +1 -1
  18. package/lib/table/src/methods.js +160 -56
  19. package/lib/table/src/methods.min.js +1 -1
  20. package/lib/table/src/table.js +15 -2
  21. package/lib/table/src/table.min.js +1 -1
  22. package/lib/ui/index.js +3 -2
  23. package/lib/ui/index.min.js +1 -1
  24. package/lib/ui/src/log.js +1 -1
  25. package/lib/ui/src/log.min.js +1 -1
  26. package/package.json +2 -2
  27. package/packages/grid/src/grid.ts +148 -35
  28. package/packages/table/render/index.ts +115 -4
  29. package/packages/table/src/cell.ts +10 -8
  30. package/packages/table/src/methods.ts +176 -72
  31. package/packages/table/src/table.ts +13 -2
  32. package/packages/ui/index.ts +2 -1
  33. /package/es/{iconfont.1764045838630.ttf → iconfont.1764380622607.ttf} +0 -0
  34. /package/es/{iconfont.1764045838630.woff → iconfont.1764380622607.woff} +0 -0
  35. /package/es/{iconfont.1764045838630.woff2 → iconfont.1764380622607.woff2} +0 -0
  36. /package/lib/{iconfont.1764045838630.ttf → iconfont.1764380622607.ttf} +0 -0
  37. /package/lib/{iconfont.1764045838630.woff → iconfont.1764380622607.woff} +0 -0
  38. /package/lib/{iconfont.1764045838630.woff2 → iconfont.1764380622607.woff2} +0 -0
@@ -21,6 +21,8 @@ const customStorageKey = 'VXE_CUSTOM_STORE'
21
21
  const maxYHeight = 5e6
22
22
  const maxXWidth = 5e6
23
23
 
24
+ const sourceType = 'table'
25
+
24
26
  let crossTableDragRowObj: {
25
27
  $oldTable: VxeTableConstructor & VxeTablePrivateMethods
26
28
  $newTable: (VxeTableConstructor & VxeTablePrivateMethods) | null
@@ -2552,23 +2554,48 @@ const calcCellHeight = ($xeTable: VxeTableConstructor) => {
2552
2554
  }
2553
2555
 
2554
2556
  function getOrderField ($xeTable: VxeTableConstructor, column: VxeTableDefines.ColumnInfo) {
2555
- const { sortBy, sortType } = column
2556
- return (row: any) => {
2557
- let cellValue
2558
- if (sortBy) {
2559
- cellValue = XEUtils.isFunction(sortBy) ? sortBy({ row, column }) : XEUtils.get(row, sortBy)
2560
- } else {
2561
- cellValue = $xeTable.getCellLabel(row, column)
2562
- }
2563
- if (!sortType || sortType === 'auto') {
2564
- return isNaN(cellValue) ? cellValue : XEUtils.toNumber(cellValue)
2565
- } else if (sortType === 'number') {
2566
- return XEUtils.toNumber(cellValue)
2567
- } else if (sortType === 'string') {
2568
- return XEUtils.toValueString(cellValue)
2569
- }
2570
- return cellValue
2571
- }
2557
+ const reactData = $xeTable as unknown as TableReactData
2558
+
2559
+ const { isRowGroupStatus } = reactData
2560
+ const { sortBy, sortType, aggFunc } = column
2561
+ return isRowGroupStatus && aggFunc
2562
+ ? (row: any) => {
2563
+ if (row.isAggregate) {
2564
+ const aggData = row.aggData
2565
+ const currAggData = aggData ? aggData[column.field] : null
2566
+ return currAggData ? currAggData.value : null
2567
+ }
2568
+ let cellValue
2569
+ if (sortBy) {
2570
+ cellValue = XEUtils.isFunction(sortBy) ? sortBy({ row, column }) : XEUtils.get(row, sortBy)
2571
+ } else {
2572
+ cellValue = $xeTable.getCellLabel(row, column)
2573
+ }
2574
+ if (!sortType || sortType === 'auto') {
2575
+ return isNaN(cellValue) ? cellValue : XEUtils.toNumber(cellValue)
2576
+ } else if (sortType === 'number') {
2577
+ return XEUtils.toNumber(cellValue)
2578
+ } else if (sortType === 'string') {
2579
+ return XEUtils.toValueString(cellValue)
2580
+ }
2581
+ return cellValue
2582
+ }
2583
+ : (row: any) => {
2584
+ let cellValue
2585
+ if (sortBy) {
2586
+ cellValue = XEUtils.isFunction(sortBy) ? sortBy({ row, column }) : XEUtils.get(row, sortBy)
2587
+ } else {
2588
+ cellValue = $xeTable.getCellLabel(row, column)
2589
+ }
2590
+ if (!sortType || sortType === 'auto') {
2591
+ return isNaN(cellValue) ? cellValue : XEUtils.toNumber(cellValue)
2592
+ } else if (sortType === 'number') {
2593
+ return XEUtils.toNumber(cellValue)
2594
+ } else if (sortType === 'string') {
2595
+ return XEUtils.toValueString(cellValue)
2596
+ }
2597
+ return cellValue
2598
+ }
2572
2599
  }
2573
2600
 
2574
2601
  function handleTargetEnterEvent ($xeTable: VxeTableConstructor, isClear: boolean) {
@@ -3149,8 +3176,13 @@ function handleUpdateRowGroup ($xeTable: VxeTableConstructor & VxeTablePrivateMe
3149
3176
  }
3150
3177
 
3151
3178
  function handleeGroupSummary ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, aggList: VxeTableDefines.AggregateRowInfo[]) {
3179
+ const internalData = $xeTable as unknown as TableInternalData
3180
+
3181
+ const { fullColumnFieldData } = internalData
3152
3182
  const aggregateOpts = $xeTable.computeAggregateOpts
3183
+ const aggFuncColumns = $xeTable.computeAggFuncColumns
3153
3184
  const { mapChildrenField } = aggregateOpts
3185
+ const aggCalcMethod = aggregateOpts.calcValuesMethod || aggregateOpts.countMethod || aggregateOpts.aggregateMethod
3154
3186
  if (mapChildrenField) {
3155
3187
  XEUtils.lastEach(aggList, aggRow => {
3156
3188
  let count = 0
@@ -3165,6 +3197,65 @@ function handleeGroupSummary ($xeTable: VxeTableConstructor & VxeTablePrivateMet
3165
3197
  })
3166
3198
  if ($xeTable.handlePivotTableAggregateData) {
3167
3199
  $xeTable.handlePivotTableAggregateData(aggList)
3200
+ } else {
3201
+ XEUtils.lastEach(aggList, aggRow => {
3202
+ const aggDtObj: Record<string, {
3203
+ type: string
3204
+ value: any
3205
+ label: any
3206
+ }> = {}
3207
+ const aggData = aggRow.aggData
3208
+ const groupField = aggRow.groupField
3209
+ const groupContent = aggRow.groupContent
3210
+ const childList = mapChildrenField ? (aggRow[mapChildrenField] || []) : []
3211
+ const childCount = aggRow.childCount
3212
+ const colRest = fullColumnFieldData[groupField] || {}
3213
+ aggFuncColumns.forEach(column => {
3214
+ const { field } = column
3215
+ const currAggData = aggData ? aggData[field] : null
3216
+ const ctParams = {
3217
+ $table: $xeTable,
3218
+ groupField,
3219
+ groupColumn: (colRest ? colRest.column : null) as VxeTableDefines.ColumnInfo,
3220
+ column,
3221
+ groupValue: groupContent,
3222
+ childList,
3223
+ childCount,
3224
+ aggValue: currAggData ? currAggData.value : 0,
3225
+
3226
+ /**
3227
+ * 已废弃
3228
+ * @deprecated
3229
+ */
3230
+ children: childList,
3231
+ /**
3232
+ * 已废弃
3233
+ * @deprecated
3234
+ */
3235
+ totalValue: childCount
3236
+ }
3237
+ let aggVal = 0
3238
+ // 如果下层同时也是分组
3239
+ if (childList.length && childList[0].isAggregate) {
3240
+ XEUtils.each(childList, (row: VxeTableDefines.AggregateRowInfo) => {
3241
+ if (row.isAggregate) {
3242
+ const currAggData = row.aggData[field]
3243
+ if (currAggData) {
3244
+ aggVal += currAggData.value
3245
+ }
3246
+ }
3247
+ })
3248
+ } else {
3249
+ aggVal = aggCalcMethod ? aggCalcMethod(ctParams) : aggRow.childCount
3250
+ }
3251
+ aggDtObj[field] = {
3252
+ type: 'count',
3253
+ value: aggVal,
3254
+ label: aggVal
3255
+ }
3256
+ })
3257
+ aggRow.aggData = aggDtObj
3258
+ })
3168
3259
  }
3169
3260
  }
3170
3261
  }
@@ -4278,7 +4369,37 @@ function handleRowExpandScroll ($xeTable: VxeTableConstructor & VxeTablePrivateM
4278
4369
  }
4279
4370
  }
4280
4371
 
4281
- const Methods = {
4372
+ function handleColumnVisible (this: any, visible: boolean) {
4373
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
4374
+
4375
+ return function (fieldOrColumn: string | string[] | VxeTableDefines.ColumnInfo | VxeTableDefines.ColumnInfo[]) {
4376
+ let status = false
4377
+ const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
4378
+ cols.forEach(item => {
4379
+ const column = handleFieldOrColumn($xeTable, item)
4380
+ if (column) {
4381
+ if (column.children && column.children.length) {
4382
+ XEUtils.eachTree([column], (item) => {
4383
+ item.visible = visible
4384
+ item.renderVisible = visible
4385
+ })
4386
+ } else {
4387
+ column.visible = visible
4388
+ column.renderVisible = visible
4389
+ }
4390
+ if (!status) {
4391
+ status = true
4392
+ }
4393
+ }
4394
+ })
4395
+ if (status) {
4396
+ return $xeTable.handleCustom()
4397
+ }
4398
+ return $xeTable.$nextTick()
4399
+ }
4400
+ }
4401
+
4402
+ const tableMethods = {
4282
4403
  callSlot (slotFunc: any, params: any, h: any, vNodes: any) {
4283
4404
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
4284
4405
  // const slots = $xeTable.$scopedSlots
@@ -5096,16 +5217,22 @@ const Methods = {
5096
5217
  },
5097
5218
  getCellLabel (row: any, fieldOrColumn: string | VxeTableDefines.ColumnInfo) {
5098
5219
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
5220
+ const props = $xeTable
5099
5221
  const internalData = $xeTable as unknown as TableInternalData
5100
5222
 
5101
- const column = handleFieldOrColumn(this, fieldOrColumn)
5223
+ const column = handleFieldOrColumn($xeTable, fieldOrColumn)
5102
5224
  if (!column) {
5103
5225
  return null
5104
5226
  }
5105
- const formatter = column.formatter
5227
+ const { editConfig } = props
5228
+ const { formatter, editRender, cellRender } = column
5229
+ // formatter > tableCellFormatter
5230
+ const renderOpts = formatter ? null : (editConfig && isEnableConf(editRender) ? editRender : (isEnableConf(cellRender) ? cellRender : null))
5231
+ const compConf = renderOpts ? renderer.get(renderOpts.name) : null
5232
+ const tcFormatter = compConf ? compConf.tableCellFormatter : null
5106
5233
  const cellValue = getCellValue(row, column)
5107
5234
  let cellLabel = cellValue
5108
- if (formatter) {
5235
+ if (formatter || tcFormatter) {
5109
5236
  let formatData
5110
5237
  const { fullAllDataRowIdData } = internalData
5111
5238
  const rowid = getRowid($xeTable, row)
@@ -5122,17 +5249,28 @@ const Methods = {
5122
5249
  }
5123
5250
  }
5124
5251
  }
5125
- const formatParams = { cellValue, row, rowIndex: this.getRowIndex(row), column, columnIndex: this.getColumnIndex(column) }
5126
- if (XEUtils.isString(formatter)) {
5127
- const gFormatOpts = formats.get(formatter)
5128
- const tcFormatMethod = gFormatOpts ? (gFormatOpts.tableCellFormatMethod || gFormatOpts.cellFormatMethod) : null
5129
- cellLabel = tcFormatMethod ? tcFormatMethod(formatParams) : ''
5130
- } else if (XEUtils.isArray(formatter)) {
5131
- const gFormatOpts = formats.get(formatter[0])
5132
- const tcFormatMethod = gFormatOpts ? (gFormatOpts.tableCellFormatMethod || gFormatOpts.cellFormatMethod) : null
5133
- cellLabel = tcFormatMethod ? tcFormatMethod(formatParams, ...formatter.slice(1)) : ''
5134
- } else {
5135
- cellLabel = formatter(formatParams)
5252
+ const formatParams = {
5253
+ $table: $xeTable,
5254
+ cellValue,
5255
+ row,
5256
+ rowIndex: $xeTable.getRowIndex(row),
5257
+ column,
5258
+ columnIndex: $xeTable.getColumnIndex(column)
5259
+ }
5260
+ if (formatter) {
5261
+ if (XEUtils.isString(formatter)) {
5262
+ const gFormatOpts = formats.get(formatter)
5263
+ const tcFormatMethod = gFormatOpts ? (gFormatOpts.tableCellFormatMethod || gFormatOpts.cellFormatMethod) : null
5264
+ cellLabel = tcFormatMethod ? tcFormatMethod(formatParams) : ''
5265
+ } else if (XEUtils.isArray(formatter)) {
5266
+ const gFormatOpts = formats.get(formatter[0])
5267
+ const tcFormatMethod = gFormatOpts ? (gFormatOpts.tableCellFormatMethod || gFormatOpts.cellFormatMethod) : null
5268
+ cellLabel = tcFormatMethod ? tcFormatMethod(formatParams, ...formatter.slice(1)) : ''
5269
+ } else {
5270
+ cellLabel = formatter(formatParams)
5271
+ }
5272
+ } else if (renderOpts && tcFormatter) {
5273
+ cellLabel = `${tcFormatter(renderOpts, formatParams)}`
5136
5274
  }
5137
5275
  if (formatData) {
5138
5276
  formatData[colid] = { value: cellValue, label: cellLabel }
@@ -5182,6 +5320,7 @@ const Methods = {
5182
5320
  }
5183
5321
  }
5184
5322
  const footerFormatParams = {
5323
+ $table: $xeTable,
5185
5324
  cellValue: itemValue,
5186
5325
  itemValue,
5187
5326
  row,
@@ -5747,47 +5886,11 @@ const Methods = {
5747
5886
  /**
5748
5887
  * 隐藏指定列
5749
5888
  */
5750
- hideColumn (fieldOrColumn: string | string[] | VxeTableDefines.ColumnInfo | VxeTableDefines.ColumnInfo[]) {
5751
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
5752
-
5753
- let status = false
5754
- const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
5755
- cols.forEach(item => {
5756
- const column = handleFieldOrColumn($xeTable, item)
5757
- if (column && column.visible) {
5758
- column.visible = false
5759
- if (!status) {
5760
- status = true
5761
- }
5762
- }
5763
- })
5764
- if (status) {
5765
- return $xeTable.handleCustom()
5766
- }
5767
- return $xeTable.$nextTick()
5768
- },
5889
+ hideColumn: handleColumnVisible(false),
5769
5890
  /**
5770
5891
  * 显示指定列
5771
5892
  */
5772
- showColumn (fieldOrColumn: string | string[] | VxeTableDefines.ColumnInfo | VxeTableDefines.ColumnInfo[]) {
5773
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
5774
-
5775
- let status = false
5776
- const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
5777
- cols.forEach(item => {
5778
- const column = handleFieldOrColumn($xeTable, item)
5779
- if (column && !column.visible) {
5780
- column.visible = true
5781
- if (!status) {
5782
- status = true
5783
- }
5784
- }
5785
- })
5786
- if (status) {
5787
- return $xeTable.handleCustom()
5788
- }
5789
- return $xeTable.$nextTick()
5790
- },
5893
+ showColumn: handleColumnVisible(true),
5791
5894
  setColumnWidth (fieldOrColumn: VxeColumnPropTypes.Field | VxeTableDefines.ColumnInfo | VxeColumnPropTypes.Field[] | VxeTableDefines.ColumnInfo[], width: number | string) {
5792
5895
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
5793
5896
  const internalData = $xeTable as unknown as TableInternalData
@@ -11203,6 +11306,7 @@ const Methods = {
11203
11306
  }
11204
11307
  reactData.lastScrollTime = Date.now()
11205
11308
  const evntParams = {
11309
+ source: sourceType,
11206
11310
  scrollTop,
11207
11311
  scrollLeft,
11208
11312
  bodyHeight,
@@ -12455,7 +12559,7 @@ const Methods = {
12455
12559
  const funcs = 'setFilter,openFilter,clearFilter,saveFilter,saveFilterByEvent,resetFilter,resetFilterByEvent,saveFilterPanel,saveFilterPanelByEvent,resetFilterPanel,resetFilterPanelByEvent,getCheckedFilters,updateFilterOptionStatus,closeMenu,setActiveCellArea,getActiveCellArea,getCellAreas,clearCellAreas,copyCellArea,cutCellArea,pasteCellArea,getCopyCellArea,getCopyCellAreas,clearCopyCellArea,setCellAreas,openFNR,openFind,openReplace,closeFNR,getSelectedCell,clearSelected,insert,insertAt,insertNextAt,insertChild,insertChildAt,insertChildNextAt,remove,removeCheckboxRow,removeRadioRow,removeCurrentRow,getRecordset,getInsertRecords,getRemoveRecords,getUpdateRecords,clearEdit,clearActived,getEditRecord,getEditCell,getActiveRecord,isEditByRow,isActiveByRow,setEditRow,setActiveRow,setEditCell,setActiveCell,setSelectCell,clearValidate,fullValidate,validate,fullValidateField,validateField,openExport,closeExport,openPrint,closePrint,getPrintHtml,exportData,openImport,closeImport,importData,saveFile,readFile,importByFile,print,getCustomVisible,openCustom,closeCustom,toggleCustom,saveCustom,cancelCustom,resetCustom,toggleCustomAllCheckbox,setCustomAllCheckbox'.split(',')
12456
12560
 
12457
12561
  funcs.forEach(name => {
12458
- Methods[name] = function (...args: any[]) {
12562
+ tableMethods[name] = function (...args: any[]) {
12459
12563
  // if (!this[`_${name}`]) {
12460
12564
  // if ('openExport,openPrint,exportData,openImport,importData,saveFile,readFile,importByFile,print'.split(',').includes(name)) {
12461
12565
  // errLog('vxe.error.reqModule', ['Export'])
@@ -12473,4 +12577,4 @@ funcs.forEach(name => {
12473
12577
  }
12474
12578
  })
12475
12579
 
12476
- export default Methods
12580
+ export default tableMethods
@@ -1554,6 +1554,16 @@ export default {
1554
1554
  })
1555
1555
  return rgColumns
1556
1556
  },
1557
+ computeAggFuncColumns () {
1558
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1559
+ const reactData = $xeTable as unknown as TableReactData
1560
+
1561
+ const { rowGroupList, tableColumn } = reactData
1562
+ if (rowGroupList.length) {
1563
+ return tableColumn.filter(column => column.field && column.aggFunc)
1564
+ }
1565
+ return []
1566
+ },
1557
1567
  tabsResizeFlag () {
1558
1568
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1559
1569
  const $xeTabs = $xeTable.$xeTabs
@@ -2145,8 +2155,9 @@ export default {
2145
2155
  if (this.$resize) {
2146
2156
  this.$resize.disconnect()
2147
2157
  }
2148
- this.closeFilter()
2149
- this.closeMenu()
2158
+ $xeTable.closeTooltip()
2159
+ $xeTable.closeFilter()
2160
+ $xeTable.closeMenu()
2150
2161
 
2151
2162
  globalEvents.off($xeTable, 'paste')
2152
2163
  globalEvents.off($xeTable, 'copy')
@@ -287,9 +287,10 @@ VxeUI.setConfig({
287
287
  showResponseMsg: true,
288
288
  showActionMsg: true,
289
289
  response: {
290
- list: null,
290
+ list: 'list',
291
291
  result: 'result',
292
292
  total: 'page.total',
293
+ footerData: 'footerData',
293
294
  message: 'message'
294
295
  }
295
296
  // beforeItem: null,