vxe-table 4.15.0-beta.13 → 4.15.0-beta.15

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 (33) hide show
  1. package/es/style.css +1 -1
  2. package/es/table/module/custom/hook.js +11 -2
  3. package/es/table/src/columnInfo.js +1 -0
  4. package/es/table/src/table.js +73 -32
  5. package/es/table/src/util.js +9 -0
  6. package/es/ui/index.js +1 -1
  7. package/es/ui/src/log.js +1 -1
  8. package/lib/index.umd.js +40 -16
  9. package/lib/index.umd.min.js +1 -1
  10. package/lib/style.css +1 -1
  11. package/lib/table/module/custom/hook.js +15 -2
  12. package/lib/table/module/custom/hook.min.js +1 -1
  13. package/lib/table/src/columnInfo.js +1 -0
  14. package/lib/table/src/columnInfo.min.js +1 -1
  15. package/lib/table/src/table.js +12 -12
  16. package/lib/table/src/table.min.js +1 -1
  17. package/lib/table/src/util.js +10 -0
  18. package/lib/table/src/util.min.js +1 -1
  19. package/lib/ui/index.js +1 -1
  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 +1 -1
  24. package/packages/table/module/custom/hook.ts +11 -2
  25. package/packages/table/src/columnInfo.ts +1 -0
  26. package/packages/table/src/table.ts +76 -33
  27. package/packages/table/src/util.ts +10 -0
  28. /package/es/{iconfont.1753775832074.ttf → iconfont.1753843924271.ttf} +0 -0
  29. /package/es/{iconfont.1753775832074.woff → iconfont.1753843924271.woff} +0 -0
  30. /package/es/{iconfont.1753775832074.woff2 → iconfont.1753843924271.woff2} +0 -0
  31. /package/lib/{iconfont.1753775832074.ttf → iconfont.1753843924271.ttf} +0 -0
  32. /package/lib/{iconfont.1753775832074.woff → iconfont.1753843924271.woff} +0 -0
  33. /package/lib/{iconfont.1753775832074.woff2 → iconfont.1753843924271.woff2} +0 -0
@@ -1,6 +1,7 @@
1
1
  import { nextTick } from 'vue';
2
2
  import { VxeUI } from '../../../ui';
3
3
  import XEUtils from 'xe-utils';
4
+ import { getColumnList } from '../../src/util';
4
5
  const tableCustomMethodKeys = ['openCustom', 'closeCustom', 'toggleCustom', 'saveCustom', 'cancelCustom', 'resetCustom', 'toggleCustomAllCheckbox', 'setCustomAllCheckbox'];
5
6
  VxeUI.hooks.add('tableCustomModule', {
6
7
  setupTable($xeTable) {
@@ -102,7 +103,7 @@ VxeUI.hooks.add('tableCustomModule', {
102
103
  });
103
104
  reactData.isCustomStatus = true;
104
105
  return $xeTable.saveCustomStore('confirm').then(() => {
105
- if (allowGroup && allowValues && $xeTable.handlePivotTableAggregateData) {
106
+ if (allowGroup && !!$xeTable.handlePivotTableAggregateData) {
106
107
  if (rowGroupList.length !== aggHandleFields.length || rowGroupList.some((conf, i) => conf.field !== aggHandleFields[i])) {
107
108
  // 更新数据分组
108
109
  if (aggHandleFields.length) {
@@ -112,7 +113,7 @@ VxeUI.hooks.add('tableCustomModule', {
112
113
  $xeTable.clearRowGroups();
113
114
  }
114
115
  }
115
- else {
116
+ else if (allowValues) {
116
117
  // 更新聚合函数
117
118
  $xeTable.handleUpdateAggData();
118
119
  }
@@ -202,6 +203,7 @@ VxeUI.hooks.add('tableCustomModule', {
202
203
  sort: options === true,
203
204
  aggFunc: options === true
204
205
  }, options);
206
+ const allCols = [];
205
207
  XEUtils.eachTree(collectColumn, (column) => {
206
208
  if (opts.resizable) {
207
209
  column.resizeWidth = 0;
@@ -211,6 +213,7 @@ VxeUI.hooks.add('tableCustomModule', {
211
213
  }
212
214
  if (opts.sort) {
213
215
  column.renderSortNumber = column.sortNumber;
216
+ column.parentId = column.defaultParentId;
214
217
  }
215
218
  if (!checkMethod || checkMethod({ $table: $xeTable, column })) {
216
219
  column.visible = column.defaultVisible;
@@ -220,7 +223,13 @@ VxeUI.hooks.add('tableCustomModule', {
220
223
  column.renderAggFn = column.defaultAggFunc;
221
224
  }
222
225
  column.renderResizeWidth = column.renderWidth;
226
+ allCols.push(column);
223
227
  });
228
+ if (opts.sort) {
229
+ const newCollectCols = XEUtils.toArrayTree(XEUtils.orderBy(allCols, 'renderSortNumber'), { key: 'id', parentKey: 'parentId', children: 'children' });
230
+ internalData.collectColumn = newCollectCols;
231
+ internalData.tableFullColumn = getColumnList(newCollectCols);
232
+ }
224
233
  reactData.isCustomStatus = false;
225
234
  $xeTable.saveCustomStore('reset');
226
235
  return $xeTable.handleCustom().then(() => {
@@ -112,6 +112,7 @@ export class ColumnInfo {
112
112
  parentId: null,
113
113
  visible,
114
114
  // 内部属性(一旦被使用,将导致不可升级版本)
115
+ defaultParentId: null,
115
116
  halfVisible: false,
116
117
  defaultVisible: visible,
117
118
  defaultFixed: _vm.fixed,
@@ -4,7 +4,7 @@ import XEUtils from 'xe-utils';
4
4
  import { initTpImg, getTpImg, isPx, isScale, hasClass, addClass, removeClass, getEventTargetNode, getPaddingTopBottomSize, setScrollTop, setScrollLeft, toCssUnit, hasControlKey } from '../../ui/src/dom';
5
5
  import { getLastZIndex, nextZIndex, hasChildrenList, getFuncText, isEnableConf, formatText, eqEmptyValue } from '../../ui/src/utils';
6
6
  import { VxeUI } from '../../ui';
7
- import { getRowUniqueId, clearTableAllStatus, toFilters, hasDeepKey, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getRefElem, getColReMinWidth, createHandleUpdateRowId, createHandleGetRowId, getCalcHeight, getCellRestHeight } from './util';
7
+ import { getRowUniqueId, clearTableAllStatus, getColumnList, toFilters, hasDeepKey, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getRefElem, getColReMinWidth, createHandleUpdateRowId, createHandleGetRowId, getCalcHeight, getCellRestHeight } from './util';
8
8
  import { getSlotVNs } from '../../ui/src/vn';
9
9
  import { moveRowAnimateToTb, clearRowAnimate, moveColAnimateToLr, clearColAnimate } from './anime';
10
10
  import { warnLog, errLog } from '../../ui/src/log';
@@ -1416,11 +1416,31 @@ export default defineVxeComponent({
1416
1416
  return num;
1417
1417
  };
1418
1418
  const handleCustomRestore = (storeData) => {
1419
- let { collectColumn } = internalData;
1420
- const { resizableData, sortData, visibleData, fixedData } = storeData;
1421
- let hasCustomSort = false;
1419
+ const { collectColumn } = internalData;
1420
+ let { resizableData, sortData, visibleData, fixedData } = storeData;
1422
1421
  // 处理还原
1423
1422
  if (resizableData || sortData || visibleData || fixedData) {
1423
+ const sortColMaps = {};
1424
+ // 转换兼容老版本数据
1425
+ if (sortData) {
1426
+ if (!XEUtils.isArray(sortData)) {
1427
+ const sortRests = [];
1428
+ XEUtils.each(sortData, (index, colKey) => {
1429
+ sortRests.push({ key: colKey, index });
1430
+ });
1431
+ sortData = XEUtils.orderBy(sortRests, { field: 'index', order: 'asc' }).map(item => ({ k: item.key }));
1432
+ }
1433
+ let colNum = 1;
1434
+ XEUtils.eachTree(sortData, (sObj, index, sOjs, path, pSObj) => {
1435
+ sortColMaps[sObj.k] = {
1436
+ key: sObj.k,
1437
+ sNum: colNum++,
1438
+ pKey: pSObj ? pSObj.k : null
1439
+ };
1440
+ }, { children: 'c' });
1441
+ }
1442
+ const colKeyMaps = {};
1443
+ const allCols = [];
1424
1444
  XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
1425
1445
  const colKey = column.getKey();
1426
1446
  // 支持一级
@@ -1428,10 +1448,6 @@ export default defineVxeComponent({
1428
1448
  if (fixedData && fixedData[colKey] !== undefined) {
1429
1449
  column.fixed = fixedData[colKey];
1430
1450
  }
1431
- if (sortData && XEUtils.isNumber(sortData[colKey])) {
1432
- hasCustomSort = true;
1433
- column.renderSortNumber = sortData[colKey];
1434
- }
1435
1451
  }
1436
1452
  if (resizableData && XEUtils.isNumber(resizableData[colKey])) {
1437
1453
  column.resizeWidth = resizableData[colKey];
@@ -1439,12 +1455,23 @@ export default defineVxeComponent({
1439
1455
  if (visibleData && XEUtils.isBoolean(visibleData[colKey])) {
1440
1456
  column.visible = visibleData[colKey];
1441
1457
  }
1458
+ colKeyMaps[colKey] = column;
1459
+ allCols.push(column);
1442
1460
  });
1443
1461
  // 如果自定义了顺序
1444
- if (hasCustomSort) {
1445
- collectColumn = XEUtils.orderBy(collectColumn, 'renderSortNumber');
1446
- internalData.collectColumn = collectColumn;
1447
- internalData.tableFullColumn = getColumnList(collectColumn);
1462
+ if (sortData) {
1463
+ allCols.forEach(column => {
1464
+ const colKey = column.getKey();
1465
+ const scItem = sortColMaps[colKey];
1466
+ if (scItem) {
1467
+ const parentColumn = scItem.pKey ? colKeyMaps[scItem.pKey] : null;
1468
+ column.parentId = parentColumn ? parentColumn.id : null;
1469
+ column.renderSortNumber = scItem.sNum;
1470
+ }
1471
+ });
1472
+ const newCollectCols = XEUtils.toArrayTree(XEUtils.orderBy(allCols, 'renderSortNumber'), { key: 'id', parentKey: 'parentId', children: 'children' });
1473
+ internalData.collectColumn = newCollectCols;
1474
+ internalData.tableFullColumn = getColumnList(newCollectCols);
1448
1475
  }
1449
1476
  reactData.isCustomStatus = true;
1450
1477
  }
@@ -3476,14 +3503,6 @@ export default defineVxeComponent({
3476
3503
  }
3477
3504
  $xeTable.closeTooltip();
3478
3505
  };
3479
- // 获取所有的列,排除分组
3480
- const getColumnList = (columns) => {
3481
- const result = [];
3482
- columns.forEach((column) => {
3483
- result.push(...(column.children && column.children.length ? getColumnList(column.children) : [column]));
3484
- });
3485
- return result;
3486
- };
3487
3506
  const parseColumns = (isReset) => {
3488
3507
  // const { showOverflow } = props
3489
3508
  // const rowOpts = computeRowOpts.value
@@ -3614,21 +3633,25 @@ export default defineVxeComponent({
3614
3633
  }
3615
3634
  return $xeTable.updateFooter();
3616
3635
  };
3617
- const initColumnSort = () => {
3636
+ const initColumnHierarchy = () => {
3618
3637
  const { collectColumn } = internalData;
3619
- collectColumn.forEach((column, index) => {
3620
- const sortIndex = index + 1;
3638
+ let sortIndex = 1;
3639
+ XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
3640
+ const parentId = parentColumn ? parentColumn.id : null;
3641
+ column.parentId = parentId;
3642
+ column.defaultParentId = parentId;
3621
3643
  column.sortNumber = sortIndex;
3622
3644
  column.renderSortNumber = sortIndex;
3645
+ sortIndex++;
3623
3646
  });
3624
3647
  };
3625
- const handleColumn = (collectColumn) => {
3648
+ const handleInitColumn = (collectColumn) => {
3626
3649
  const expandOpts = computeExpandOpts.value;
3627
3650
  internalData.collectColumn = collectColumn;
3628
3651
  const tableFullColumn = getColumnList(collectColumn);
3629
3652
  internalData.tableFullColumn = tableFullColumn;
3630
3653
  reactData.isColLoading = true;
3631
- initColumnSort();
3654
+ initColumnHierarchy();
3632
3655
  return Promise.resolve(restoreCustomStorage()).then(() => {
3633
3656
  const { scrollXLoad, scrollYLoad, expandColumn } = reactData;
3634
3657
  cacheColumnMap();
@@ -4351,7 +4374,7 @@ export default defineVxeComponent({
4351
4374
  loadColumn(columns) {
4352
4375
  const { lastScrollLeft, lastScrollTop } = internalData;
4353
4376
  const collectColumn = XEUtils.mapTree(columns, column => reactive(Cell.createColumn($xeTable, column)));
4354
- return handleColumn(collectColumn).then(() => {
4377
+ return handleInitColumn(collectColumn).then(() => {
4355
4378
  let targetScrollLeft = lastScrollLeft;
4356
4379
  let targetScrollTop = lastScrollTop;
4357
4380
  const virtualXOpts = computeVirtualXOpts.value;
@@ -6778,7 +6801,7 @@ export default defineVxeComponent({
6778
6801
  const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom);
6779
6802
  const isCustomAggFunc = hangleStorageDefaultValue(storageOpts.aggFunc, isAllCustom);
6780
6803
  const resizableData = {};
6781
- const sortData = {};
6804
+ const sortData = [];
6782
6805
  const visibleData = {};
6783
6806
  const fixedData = {};
6784
6807
  const aggFuncData = {};
@@ -6800,18 +6823,36 @@ export default defineVxeComponent({
6800
6823
  let hasFixed = 0;
6801
6824
  let hasVisible = 0;
6802
6825
  let hasAggFunc = 0;
6826
+ const sortMaps = {};
6803
6827
  XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
6804
6828
  const colKey = column.getKey();
6805
6829
  if (!colKey) {
6806
6830
  errLog('vxe.error.reqProp', [`${column.getTitle() || column.type || ''} -> column.field=?`]);
6807
6831
  return;
6808
6832
  }
6809
- // 只支持一级
6810
- if (!parentColumn) {
6833
+ if (parentColumn) {
6834
+ if (isCustomSort) {
6835
+ const pColKey = parentColumn.getKey();
6836
+ const psObj = sortMaps[pColKey];
6837
+ hasSort = 1;
6838
+ if (psObj) {
6839
+ const sObj = { k: colKey };
6840
+ sortMaps[colKey] = sObj;
6841
+ if (!psObj.c) {
6842
+ psObj.c = [];
6843
+ }
6844
+ psObj.c.push(sObj);
6845
+ }
6846
+ }
6847
+ }
6848
+ else {
6811
6849
  if (isCustomSort) {
6812
6850
  hasSort = 1;
6813
- sortData[colKey] = column.renderSortNumber;
6851
+ const sObj = { k: colKey };
6852
+ sortMaps[colKey] = sObj;
6853
+ sortData.push(sObj);
6814
6854
  }
6855
+ // 只支持一级
6815
6856
  if (isCustomFixed && column.fixed !== column.defaultFixed) {
6816
6857
  hasFixed = 1;
6817
6858
  fixedData[colKey] = column.fixed;
@@ -8310,7 +8351,7 @@ export default defineVxeComponent({
8310
8351
  const storeData = type === 'reset'
8311
8352
  ? {
8312
8353
  resizableData: {},
8313
- sortData: {},
8354
+ sortData: [],
8314
8355
  visibleData: {},
8315
8356
  fixedData: {}
8316
8357
  }
@@ -11585,7 +11626,7 @@ export default defineVxeComponent({
11585
11626
  staticColumnFlag.value++;
11586
11627
  });
11587
11628
  watch(staticColumnFlag, () => {
11588
- handleColumn(XEUtils.clone(reactData.staticColumns));
11629
+ nextTick(() => handleInitColumn(XEUtils.clone(reactData.staticColumns)));
11589
11630
  });
11590
11631
  const tableColumnFlag = ref(0);
11591
11632
  watch(() => reactData.tableColumn.length, () => {
@@ -291,6 +291,14 @@ export function getColReMinWidth(params) {
291
291
  export function isColumnInfo(column) {
292
292
  return column && (column.constructor === ColumnInfo || column instanceof ColumnInfo);
293
293
  }
294
+ // 获取所有的列,排除分组
295
+ export function getColumnList(columns) {
296
+ const result = [];
297
+ columns.forEach((column) => {
298
+ result.push(...(column.children && column.children.length ? getColumnList(column.children) : [column]));
299
+ });
300
+ return result;
301
+ }
294
302
  export function createColumn($xeTable, options, renderOptions) {
295
303
  return isColumnInfo(options) ? options : reactive(new ColumnInfo($xeTable, options, renderOptions));
296
304
  }
@@ -317,6 +325,7 @@ export function assembleColumn($xeTable, elem, column, colgroup) {
317
325
  const parentColumn = colgroup ? colgroup.columnConfig : null;
318
326
  const parentCols = parentColumn ? parentColumn.children : staticColumns;
319
327
  if (parentElem && parentCols) {
328
+ column.defaultParentId = parentColumn ? parentColumn.id : null;
320
329
  parentCols.splice(XEUtils.arrayIndexOf(parentElem.children, elem), 0, column);
321
330
  reactData.staticColumns = staticColumns.slice(0);
322
331
  }
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.15.0-beta.13";
3
+ export const version = "4.15.0-beta.15";
4
4
  VxeUI.version = version;
5
5
  VxeUI.tableVersion = version;
6
6
  VxeUI.setConfig({
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.15.0-beta.13"}`;
3
+ const version = `table v${"4.15.0-beta.15"}`;
4
4
  export const warnLog = log.create('warn', version);
5
5
  export const errLog = log.create('error', version);