vxe-table 4.17.20 → 4.17.21

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 +3 -3
  5. package/es/table/src/table.js +27 -14
  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 +310 -64
  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 +6 -3
  16. package/lib/table/src/cell.min.js +1 -1
  17. package/lib/table/src/table.js +5 -4
  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 +3 -3
  27. package/packages/table/src/table.ts +26 -12
  28. package/packages/ui/index.ts +2 -1
  29. /package/es/{iconfont.1764045862093.ttf → iconfont.1764298161293.ttf} +0 -0
  30. /package/es/{iconfont.1764045862093.woff → iconfont.1764298161293.woff} +0 -0
  31. /package/es/{iconfont.1764045862093.woff2 → iconfont.1764298161293.woff2} +0 -0
  32. /package/lib/{iconfont.1764045862093.ttf → iconfont.1764298161293.ttf} +0 -0
  33. /package/lib/{iconfont.1764045862093.woff → iconfont.1764298161293.woff} +0 -0
  34. /package/lib/{iconfont.1764045862093.woff2 → iconfont.1764298161293.woff2} +0 -0
@@ -532,9 +532,8 @@ function oldSelectEditRender(renderOpts, params) {
532
532
  h(getOldComponent(renderOpts), Object.assign(Object.assign({}, getCellEditProps(renderOpts, params, cellValue, { options, optionProps, optionGroups, optionGroupProps })), getEditOns(renderOpts, params)))
533
533
  ];
534
534
  }
535
- function getSelectCellValue(renderOpts, { row, column }) {
535
+ function handleSelectCellValue(cellValue, renderOpts) {
536
536
  const { options, optionGroups, optionProps = {}, optionGroupProps = {}, props = {} } = renderOpts;
537
- const cellValue = XEUtils.get(row, column.field);
538
537
  let selectItem;
539
538
  const labelProp = optionProps.label || 'label';
540
539
  const valueProp = optionProps.value || 'value';
@@ -571,13 +570,16 @@ function getSelectCellValue(renderOpts, { row, column }) {
571
570
  }
572
571
  return '';
573
572
  }
573
+ function getSelectCellValue(renderOpts, { row, column }) {
574
+ const cellValue = XEUtils.get(row, column.field);
575
+ return handleSelectCellValue(cellValue, renderOpts);
576
+ }
574
577
  function handleExportSelectMethod(params) {
575
578
  const { row, column, options } = params;
576
579
  return options.original ? getCellValue(row, column) : getSelectCellValue(column.editRender || column.cellRender, params);
577
580
  }
578
- function getTreeSelectCellValue(renderOpts, { row, column }) {
581
+ function handleTreeSelectCellValue(cellValue, renderOpts) {
579
582
  const { options, optionProps = {} } = renderOpts;
580
- const cellValue = XEUtils.get(row, column.field);
581
583
  const labelProp = optionProps.label || 'label';
582
584
  const valueProp = optionProps.value || 'value';
583
585
  const childrenProp = optionProps.children || 'children';
@@ -593,6 +595,10 @@ function getTreeSelectCellValue(renderOpts, { row, column }) {
593
595
  }
594
596
  return '';
595
597
  }
598
+ function getTreeSelectCellValue(renderOpts, { row, column }) {
599
+ const cellValue = XEUtils.get(row, column.field);
600
+ return handleTreeSelectCellValue(cellValue, renderOpts);
601
+ }
596
602
  function handleExportTreeSelectMethod(params) {
597
603
  const { row, column, options } = params;
598
604
  return options.original ? getCellValue(row, column) : getTreeSelectCellValue(column.editRender || column.cellRender, params);
@@ -654,6 +660,91 @@ function handleNumberCell(renderOpts, params) {
654
660
  }
655
661
  : {});
656
662
  }
663
+ function handleFormatSelect(renderOpts, params) {
664
+ const { cellValue } = params;
665
+ return handleSelectCellValue(cellValue, renderOpts);
666
+ }
667
+ function handleSetSelectValue(renderOpts, params) {
668
+ const { row, column, cellValue } = params;
669
+ const { field } = column;
670
+ if (field) {
671
+ const { options, optionGroups, optionProps = {}, optionGroupProps = {}, props } = renderOpts;
672
+ if (isEmptyValue(cellValue)) {
673
+ XEUtils.set(row, field, props && props.multiple ? [] : null);
674
+ return;
675
+ }
676
+ const isMultiVal = XEUtils.indexOf(`${cellValue}`, ',') > -1;
677
+ const labelProp = optionProps.label || 'label';
678
+ const valueProp = optionProps.value || 'value';
679
+ const labelMpas = {};
680
+ if (optionGroups && optionGroups.length) {
681
+ const groupOptions = optionGroupProps.options || 'options';
682
+ for (let i = 0; i < optionGroups.length; i++) {
683
+ const opts = optionGroups[i][groupOptions] || {};
684
+ for (let j = 0; j < opts.length; j++) {
685
+ const item = opts[j];
686
+ if (isMultiVal) {
687
+ labelMpas[item[labelProp]] = item;
688
+ /* eslint-disable eqeqeq */
689
+ }
690
+ else if (item[labelProp] == cellValue) {
691
+ XEUtils.set(row, field, item[valueProp]);
692
+ return;
693
+ }
694
+ }
695
+ }
696
+ }
697
+ else {
698
+ if (options) {
699
+ for (let i = 0; i < options.length; i++) {
700
+ const item = options[i];
701
+ if (isMultiVal) {
702
+ labelMpas[item[labelProp]] = item;
703
+ /* eslint-disable eqeqeq */
704
+ }
705
+ else if (item[labelProp] == cellValue) {
706
+ XEUtils.set(row, field, item[valueProp]);
707
+ return;
708
+ }
709
+ }
710
+ }
711
+ }
712
+ if (isMultiVal) {
713
+ XEUtils.set(row, field, (isMultiVal
714
+ ? cellValue.split(',')
715
+ : [cellValue]).map((label) => {
716
+ const item = labelMpas[label];
717
+ return item ? item[valueProp] : label;
718
+ }));
719
+ }
720
+ else {
721
+ XEUtils.set(row, field, cellValue);
722
+ }
723
+ }
724
+ }
725
+ function handleFormatTreeSelect(renderOpts, params) {
726
+ const { cellValue } = params;
727
+ return handleTreeSelectCellValue(cellValue, renderOpts);
728
+ }
729
+ function handleSetTreeSelectValue(renderOpts, params) {
730
+ const { row, column, cellValue } = params;
731
+ const { field } = column;
732
+ if (field) {
733
+ const { options, optionProps = {} } = renderOpts;
734
+ const labelProp = optionProps.label || 'label';
735
+ const valueProp = optionProps.value || 'value';
736
+ const childrenProp = optionProps.children || 'children';
737
+ const matchRest = XEUtils.findTree(options || [], item => XEUtils.get(item, labelProp) === cellValue, { children: childrenProp });
738
+ if (matchRest) {
739
+ const selectItem = matchRest.item;
740
+ if (selectItem) {
741
+ XEUtils.set(row, field, selectItem[valueProp]);
742
+ return;
743
+ }
744
+ }
745
+ XEUtils.set(row, field, cellValue);
746
+ }
747
+ }
657
748
  /**
658
749
  * 表格 - 渲染器
659
750
  */
@@ -681,6 +772,9 @@ renderer.mixin({
681
772
  return h('select', Object.assign(Object.assign({ key: oIndex, class: 'vxe-default-select' }, getNativeAttrs(renderOpts)), getNativeFilterOns(renderOpts, params, option)), renderOpts.optionGroups ? renderNativeOptgroups(renderOpts, params, renderNativeOptions) : renderNativeOptions(renderOpts.options, renderOpts, params));
682
773
  });
683
774
  },
775
+ tableCellFormatter: handleFormatSelect,
776
+ tableCellCopyMethod: handleFormatSelect,
777
+ tableCellPasteMethod: handleSetSelectValue,
684
778
  tableFilterDefaultMethod: handleFilterMethod,
685
779
  tableExportMethod: handleExportSelectMethod
686
780
  },
@@ -907,6 +1001,9 @@ renderer.mixin({
907
1001
  const optionValue = option.data;
908
1002
  return h(getDefaultComponent(renderOpts), Object.assign(Object.assign({}, getCellEditFilterProps(renderOpts, params, optionValue, { options, optionProps, optionGroups, optionGroupProps })), getFloatingFilterOns(renderOpts, params, option)));
909
1003
  },
1004
+ tableCellFormatter: handleFormatSelect,
1005
+ tableCellCopyMethod: handleFormatSelect,
1006
+ tableCellPasteMethod: handleSetSelectValue,
910
1007
  tableFilterDefaultMethod: handleFilterMethod,
911
1008
  tableExportMethod: handleExportSelectMethod
912
1009
  },
@@ -944,6 +1041,9 @@ renderer.mixin({
944
1041
  renderTableDefault(renderOpts, params) {
945
1042
  return getCellLabelVNs(renderOpts, params, getSelectCellValue(renderOpts, params));
946
1043
  },
1044
+ tableCellFormatter: handleFormatSelect,
1045
+ tableCellCopyMethod: handleFormatSelect,
1046
+ tableCellPasteMethod: handleSetSelectValue,
947
1047
  tableFilterDefaultMethod: handleFilterMethod,
948
1048
  tableExportMethod: handleExportSelectMethod
949
1049
  },
@@ -953,6 +1053,9 @@ renderer.mixin({
953
1053
  renderTableCell(renderOpts, params) {
954
1054
  return getCellLabelVNs(renderOpts, params, getTreeSelectCellValue(renderOpts, params));
955
1055
  },
1056
+ tableCellFormatter: handleFormatTreeSelect,
1057
+ tableCellCopyMethod: handleFormatTreeSelect,
1058
+ tableCellPasteMethod: handleSetTreeSelectValue,
956
1059
  tableExportMethod: handleExportTreeSelectMethod
957
1060
  },
958
1061
  /**
@@ -968,6 +1071,9 @@ renderer.mixin({
968
1071
  renderTableDefault(renderOpts, params) {
969
1072
  return getCellLabelVNs(renderOpts, params, getTreeSelectCellValue(renderOpts, params));
970
1073
  },
1074
+ tableCellFormatter: handleFormatTreeSelect,
1075
+ tableCellCopyMethod: handleFormatTreeSelect,
1076
+ tableCellPasteMethod: handleSetTreeSelectValue,
971
1077
  tableExportMethod: handleExportTreeSelectMethod
972
1078
  },
973
1079
  VxeTableSelect: {
@@ -976,6 +1082,9 @@ renderer.mixin({
976
1082
  renderTableCell(renderOpts, params) {
977
1083
  return getCellLabelVNs(renderOpts, params, getTreeSelectCellValue(renderOpts, params));
978
1084
  },
1085
+ tableCellFormatter: handleFormatTreeSelect,
1086
+ tableCellCopyMethod: handleFormatTreeSelect,
1087
+ tableCellPasteMethod: handleSetTreeSelectValue,
979
1088
  tableExportMethod: handleExportTreeSelectMethod
980
1089
  },
981
1090
  VxeColorPicker: {
@@ -465,7 +465,7 @@ export const Cell = {
465
465
  const { rowGroupExpandedFlag } = tableReactData;
466
466
  const { rowGroupExpandedMaps } = tableInternalData;
467
467
  const aggregateOpts = computeAggregateOpts.value;
468
- const { mode, padding, indent } = aggregateOpts;
468
+ const { mode, padding, indent, showIcon, iconOpen, iconClose } = aggregateOpts;
469
469
  const rowid = getRowid($table, row);
470
470
  const isExpand = !!rowGroupExpandedFlag && !!rowGroupExpandedMaps[rowid];
471
471
  return h('div', {
@@ -478,7 +478,7 @@ export const Cell = {
478
478
  }
479
479
  : undefined
480
480
  }, [
481
- row.isAggregate
481
+ showIcon && row.isAggregate
482
482
  ? h('span', {
483
483
  class: 'vxe-row-group--node-btn',
484
484
  onClick(evnt) {
@@ -486,7 +486,7 @@ export const Cell = {
486
486
  }
487
487
  }, [
488
488
  h('i', {
489
- class: isExpand ? getIcon().TABLE_ROW_GROUP_OPEN : getIcon().TABLE_ROW_GROUP_CLOSE
489
+ class: isExpand ? (iconOpen || getIcon().TABLE_ROW_GROUP_OPEN) : (iconClose || getIcon().TABLE_ROW_GROUP_CLOSE)
490
490
  })
491
491
  ])
492
492
  : renderEmptyElement($table),
@@ -33,6 +33,7 @@ const supportMaxRow = 5e6;
33
33
  const customStorageKey = 'VXE_CUSTOM_STORE';
34
34
  const maxYHeight = 5e6;
35
35
  const maxXWidth = 5e6;
36
+ const sourceType = 'table';
36
37
  let crossTableDragRowObj = null;
37
38
  export default defineVxeComponent({
38
39
  name: 'VxeTable',
@@ -5091,10 +5092,15 @@ export default defineVxeComponent({
5091
5092
  if (!column) {
5092
5093
  return null;
5093
5094
  }
5094
- const { formatter } = column;
5095
+ const { editConfig } = props;
5096
+ const { formatter, editRender, cellRender } = column;
5097
+ // formatter > tableCellFormatter
5098
+ const renderOpts = formatter ? null : (editConfig && isEnableConf(editRender) ? editRender : (isEnableConf(cellRender) ? cellRender : null));
5099
+ const compConf = renderOpts ? renderer.get(renderOpts.name) : null;
5100
+ const tcFormatter = compConf ? compConf.tableCellFormatter : null;
5095
5101
  const cellValue = getCellValue(row, column);
5096
5102
  let cellLabel = cellValue;
5097
- if (formatter) {
5103
+ if (formatter || tcFormatter) {
5098
5104
  let formatData;
5099
5105
  const { fullAllDataRowIdData } = internalData;
5100
5106
  const rowid = getRowid($xeTable, row);
@@ -5112,24 +5118,30 @@ export default defineVxeComponent({
5112
5118
  }
5113
5119
  }
5114
5120
  const formatParams = {
5121
+ $table: $xeTable,
5115
5122
  cellValue,
5116
5123
  row,
5117
5124
  rowIndex: $xeTable.getRowIndex(row),
5118
5125
  column,
5119
5126
  columnIndex: $xeTable.getColumnIndex(column)
5120
5127
  };
5121
- if (XEUtils.isString(formatter)) {
5122
- const gFormatOpts = formats.get(formatter);
5123
- const tcFormatMethod = gFormatOpts ? (gFormatOpts.tableCellFormatMethod || gFormatOpts.cellFormatMethod) : null;
5124
- cellLabel = tcFormatMethod ? tcFormatMethod(formatParams) : '';
5125
- }
5126
- else if (XEUtils.isArray(formatter)) {
5127
- const gFormatOpts = formats.get(formatter[0]);
5128
- const tcFormatMethod = gFormatOpts ? (gFormatOpts.tableCellFormatMethod || gFormatOpts.cellFormatMethod) : null;
5129
- cellLabel = tcFormatMethod ? tcFormatMethod(formatParams, ...formatter.slice(1)) : '';
5128
+ if (formatter) {
5129
+ if (XEUtils.isString(formatter)) {
5130
+ const gFormatOpts = formats.get(formatter);
5131
+ const tcFormatMethod = gFormatOpts ? (gFormatOpts.tableCellFormatMethod || gFormatOpts.cellFormatMethod) : null;
5132
+ cellLabel = tcFormatMethod ? tcFormatMethod(formatParams) : '';
5133
+ }
5134
+ else if (XEUtils.isArray(formatter)) {
5135
+ const gFormatOpts = formats.get(formatter[0]);
5136
+ const tcFormatMethod = gFormatOpts ? (gFormatOpts.tableCellFormatMethod || gFormatOpts.cellFormatMethod) : null;
5137
+ cellLabel = tcFormatMethod ? tcFormatMethod(formatParams, ...formatter.slice(1)) : '';
5138
+ }
5139
+ else {
5140
+ cellLabel = `${formatter(formatParams)}`;
5141
+ }
5130
5142
  }
5131
- else {
5132
- cellLabel = formatter(formatParams);
5143
+ else if (renderOpts && tcFormatter) {
5144
+ cellLabel = `${tcFormatter(renderOpts, formatParams)}`;
5133
5145
  }
5134
5146
  if (formatData) {
5135
5147
  formatData[colid] = { value: cellValue, label: cellLabel };
@@ -5176,6 +5188,7 @@ export default defineVxeComponent({
5176
5188
  }
5177
5189
  }
5178
5190
  const footerFormatParams = {
5191
+ $table: $xeTable,
5179
5192
  cellValue: itemValue,
5180
5193
  itemValue,
5181
5194
  row,
@@ -11355,7 +11368,7 @@ export default defineVxeComponent({
11355
11368
  internalData.lastScrollTop = scrollTop;
11356
11369
  }
11357
11370
  reactData.lastScrollTime = Date.now();
11358
- const evntParams = Object.assign({ scrollTop,
11371
+ const evntParams = Object.assign({ source: sourceType, scrollTop,
11359
11372
  scrollLeft,
11360
11373
  bodyHeight,
11361
11374
  bodyWidth,
package/es/ui/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { VxeUI } from '@vxe-ui/core';
2
2
  import { getFuncText } from './src/utils';
3
- export const version = "4.17.20";
3
+ export const version = "4.17.21";
4
4
  VxeUI.version = version;
5
5
  VxeUI.tableVersion = version;
6
6
  VxeUI.setConfig({
@@ -279,9 +279,10 @@ VxeUI.setConfig({
279
279
  showResponseMsg: true,
280
280
  showActionMsg: true,
281
281
  response: {
282
- list: null,
282
+ list: 'list',
283
283
  result: 'result',
284
284
  total: 'page.total',
285
+ footerData: 'footerData',
285
286
  message: 'message'
286
287
  }
287
288
  // beforeItem: null,
package/es/ui/src/log.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { VxeUI } from '@vxe-ui/core';
2
2
  const { log } = VxeUI;
3
- const version = `table v${"4.17.20"}`;
3
+ const version = `table v${"4.17.21"}`;
4
4
  export const warnLog = log.create('warn', version);
5
5
  export const errLog = log.create('error', version);