vxe-table 3.19.34 → 3.19.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 (38) hide show
  1. package/es/style.css +1 -1
  2. package/es/table/module/edit/mixin.js +29 -15
  3. package/es/table/src/cell.js +53 -23
  4. package/es/table/src/methods.js +0 -13
  5. package/es/table/src/props.js +2 -0
  6. package/es/table/src/table.js +5 -0
  7. package/es/ui/index.js +4 -1
  8. package/es/ui/src/log.js +1 -1
  9. package/lib/index.umd.js +107 -41
  10. package/lib/index.umd.min.js +1 -1
  11. package/lib/style.css +1 -1
  12. package/lib/table/module/edit/mixin.js +31 -15
  13. package/lib/table/module/edit/mixin.min.js +1 -1
  14. package/lib/table/src/cell.js +63 -23
  15. package/lib/table/src/cell.min.js +1 -1
  16. package/lib/table/src/methods.js +0 -18
  17. package/lib/table/src/methods.min.js +1 -1
  18. package/lib/table/src/props.js +2 -0
  19. package/lib/table/src/props.min.js +1 -1
  20. package/lib/table/src/table.js +5 -0
  21. package/lib/table/src/table.min.js +1 -1
  22. package/lib/ui/index.js +4 -1
  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 +1 -1
  27. package/packages/table/module/edit/mixin.ts +29 -15
  28. package/packages/table/src/cell.ts +53 -23
  29. package/packages/table/src/methods.ts +0 -16
  30. package/packages/table/src/props.ts +2 -0
  31. package/packages/table/src/table.ts +6 -0
  32. package/packages/ui/index.ts +3 -0
  33. /package/es/{iconfont.1766711835500.ttf → iconfont.1766978388668.ttf} +0 -0
  34. /package/es/{iconfont.1766711835500.woff → iconfont.1766978388668.woff} +0 -0
  35. /package/es/{iconfont.1766711835500.woff2 → iconfont.1766978388668.woff2} +0 -0
  36. /package/lib/{iconfont.1766711835500.ttf → iconfont.1766978388668.ttf} +0 -0
  37. /package/lib/{iconfont.1766711835500.woff → iconfont.1766978388668.woff} +0 -0
  38. /package/lib/{iconfont.1766711835500.woff2 → iconfont.1766978388668.woff2} +0 -0
@@ -88,7 +88,7 @@ function insertTreeRow($xeTable, newRecords, isAppend) {
88
88
  }
89
89
  // function insertGroupRow ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, newRecords: any[], isAppend: boolean) {
90
90
  // }
91
- function handleInsertRowAt($xeTable, records, targetRow, isInsertNextRow) {
91
+ function handleInsertRowAt($xeTable, records, targetRowOrRowid, isInsertNextRow) {
92
92
  const props = $xeTable;
93
93
  const reactData = $xeTable;
94
94
  const internalData = $xeTable;
@@ -101,6 +101,13 @@ function handleInsertRowAt($xeTable, records, targetRow, isInsertNextRow) {
101
101
  if (!XEUtils.isArray(records)) {
102
102
  records = [records];
103
103
  }
104
+ let targetRow = targetRowOrRowid;
105
+ if (XEUtils.isString(targetRowOrRowid) || XEUtils.isNumber(targetRowOrRowid)) {
106
+ const rowRest = fullAllDataRowIdData[targetRowOrRowid];
107
+ if (rowRest) {
108
+ targetRow = rowRest.row;
109
+ }
110
+ }
104
111
  const newRecords = $xeTable.defineField(records.map(record => Object.assign(treeConfig && transform ? { [mapChildrenField]: [], [childrenField]: [] } : {}, record)));
105
112
  let treeRecords = [];
106
113
  if (treeConfig && transform) {
@@ -312,16 +319,25 @@ function handleInsertRowAt($xeTable, records, targetRow, isInsertNextRow) {
312
319
  };
313
320
  });
314
321
  }
315
- function handleInsertChildRowAt($xeTable, records, parentRow, targetRow, isInsertNextRow) {
322
+ function handleInsertChildRowAt($xeTable, records, parentRowOrParentId, targetRowOrRowid, isInsertNextRow) {
316
323
  const props = $xeTable;
324
+ const internalData = $xeTable;
317
325
  const { treeConfig } = props;
326
+ const { fullAllDataRowIdData } = internalData;
318
327
  const treeOpts = $xeTable.computeTreeOpts;
319
328
  const { transform, rowField, parentField } = treeOpts;
320
329
  if (treeConfig && transform) {
321
330
  if (!XEUtils.isArray(records)) {
322
331
  records = [records];
323
332
  }
324
- return handleInsertRowAt($xeTable, records.map((item) => Object.assign({}, item, { [parentField]: parentRow[rowField] })), targetRow, isInsertNextRow);
333
+ let parentRow = parentRowOrParentId;
334
+ if (XEUtils.isString(parentRowOrParentId) || XEUtils.isNumber(parentRowOrParentId)) {
335
+ const rowRest = fullAllDataRowIdData[parentRowOrParentId];
336
+ if (rowRest) {
337
+ parentRow = rowRest.row;
338
+ }
339
+ }
340
+ return handleInsertRowAt($xeTable, records.map((item) => Object.assign({}, item, { [parentField]: parentRow[rowField] })), targetRowOrRowid, isInsertNextRow);
325
341
  }
326
342
  else {
327
343
  errLog('vxe.error.errProp', ['tree-config.transform=false', 'tree-config.transform=true']);
@@ -509,24 +525,22 @@ export default {
509
525
  * 如果 row 为空则从插入到顶部
510
526
  * 如果 row 为 -1 则从插入到底部
511
527
  * 如果 row 为有效行则插入到该行的位置
512
- * @param {Object/Array} records 新的数据
513
- * @param {Row} targetRow 指定行
514
528
  * @returns
515
529
  */
516
- _insertAt(records, targetRow) {
517
- return handleInsertRowAt(this, records, targetRow);
530
+ _insertAt(records, targetRowOrRowid) {
531
+ return handleInsertRowAt(this, records, targetRowOrRowid);
518
532
  },
519
- _insertNextAt(records, targetRow) {
520
- return handleInsertRowAt(this, records, targetRow, true);
533
+ _insertNextAt(records, targetRowOrRowid) {
534
+ return handleInsertRowAt(this, records, targetRowOrRowid, true);
521
535
  },
522
- _insertChild(records, parentRow) {
523
- return handleInsertChildRowAt(this, records, parentRow, null);
536
+ _insertChild(records, parentRowOrParentId) {
537
+ return handleInsertChildRowAt(this, records, parentRowOrParentId, null);
524
538
  },
525
- _insertChildAt(records, parentRow, targetRow) {
526
- return handleInsertChildRowAt(this, records, parentRow, targetRow);
539
+ _insertChildAt(records, parentRowOrParentId, targetRowOrRowid) {
540
+ return handleInsertChildRowAt(this, records, parentRowOrParentId, targetRowOrRowid);
527
541
  },
528
- _insertChildNextAt(records, parentRow, targetRow) {
529
- return handleInsertChildRowAt(this, records, parentRow, targetRow, true);
542
+ _insertChildNextAt(records, parentRowOrParentId, targetRowOrRowid) {
543
+ return handleInsertChildRowAt(this, records, parentRowOrParentId, targetRowOrRowid, true);
530
544
  },
531
545
  /**
532
546
  * 删除指定行数据
@@ -217,11 +217,17 @@ function renderTitleContent(h, params, content) {
217
217
  }
218
218
  function getFooterContent(h, params) {
219
219
  const { $table, column, row } = params;
220
+ const tableProps = $table;
221
+ const { editConfig } = tableProps;
220
222
  const { slots, editRender, cellRender } = column;
221
- const renderOpts = editRender || cellRender;
222
- if (slots && slots.footer) {
223
- return $table.callSlot(slots.footer, params, h);
223
+ const footerSlot = slots ? slots.footer : null;
224
+ if (footerSlot) {
225
+ return $table.callSlot(footerSlot, params, h);
224
226
  }
227
+ const isEnableEdit = editConfig && isEnableConf(editConfig);
228
+ const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null;
229
+ const cellRenderOpts = isEnableConf(cellRender) ? cellRender : null;
230
+ const renderOpts = editRenderOpts || cellRenderOpts;
225
231
  const itemValue = $table.getFooterCellLabel(row, column);
226
232
  if (renderOpts) {
227
233
  const compConf = renderer.get(renderOpts.name);
@@ -266,7 +272,9 @@ function renderCellHandle(h, params) {
266
272
  case 'html':
267
273
  return isDeepCell ? Cell.renderDeepHTMLCell(h, params) : Cell.renderHTMLCell(h, params);
268
274
  }
269
- if (editConfig && isEnableConf(editOpts) && editRender) {
275
+ const isEnableEdit = editConfig && isEnableConf(editConfig);
276
+ const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null;
277
+ if (editRenderOpts) {
270
278
  return editOpts.mode === 'cell' ? (isDeepCell ? Cell.renderDeepCellEdit(h, params) : Cell.renderCellEdit(h, params)) : (isDeepCell ? Cell.renderDeepRowEdit(h, params) : Cell.renderRowEdit(h, params));
271
279
  }
272
280
  return isDeepCell ? Cell.renderDeepCell(h, params) : Cell.renderDefaultCell(h, params);
@@ -275,7 +283,6 @@ function renderHeaderHandle(h, params) {
275
283
  const { column, $table } = params;
276
284
  const tableProps = $table;
277
285
  const { editConfig } = tableProps;
278
- const editOpts = $table.computeEditOpts;
279
286
  const { type, filters, sortable, editRender } = column;
280
287
  switch (type) {
281
288
  case 'seq':
@@ -296,7 +303,9 @@ function renderHeaderHandle(h, params) {
296
303
  }
297
304
  break;
298
305
  }
299
- if (editConfig && isEnableConf(editOpts) && editRender) {
306
+ const isEnableEdit = editConfig && isEnableConf(editConfig);
307
+ const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null;
308
+ if (editRenderOpts) {
300
309
  return Cell.renderEditHeader(h, params);
301
310
  }
302
311
  else if (filters && sortable) {
@@ -331,11 +340,17 @@ export const Cell = {
331
340
  */
332
341
  renderHeaderTitle(h, params) {
333
342
  const { $table, column } = params;
343
+ const tableProps = $table;
344
+ const { editConfig } = tableProps;
334
345
  const { slots, editRender, cellRender } = column;
335
- const renderOpts = editRender || cellRender;
336
- if (slots && slots.header) {
337
- return renderTitleContent(h, params, $table.callSlot(slots.header, params, h));
346
+ const headerSlot = slots ? slots.header : null;
347
+ if (headerSlot) {
348
+ return renderTitleContent(h, params, $table.callSlot(headerSlot, params, h));
338
349
  }
350
+ const isEnableEdit = editConfig && isEnableConf(editConfig);
351
+ const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null;
352
+ const cellRenderOpts = isEnableConf(cellRender) ? cellRender : null;
353
+ const renderOpts = editRenderOpts || cellRenderOpts;
339
354
  if (renderOpts) {
340
355
  const compConf = renderer.get(renderOpts.name);
341
356
  const rtHeader = compConf ? (compConf.renderTableHeader || compConf.renderHeader) : null;
@@ -356,7 +371,9 @@ export const Cell = {
356
371
  const { isRowGroupStatus } = tableReactData;
357
372
  const { editConfig } = tableProps;
358
373
  const { field, slots, editRender, cellRender, rowGroupNode, aggFunc, formatter } = column;
359
- const renderOpts = editConfig && isEnableConf(editRender) ? editRender : (isEnableConf(cellRender) ? cellRender : null);
374
+ const isEnableEdit = editConfig && isEnableConf(editConfig);
375
+ const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null;
376
+ const cellRenderOpts = isEnableConf(cellRender) ? cellRender : null;
360
377
  const defaultSlot = slots ? slots.default : null;
361
378
  const gcSlot = slots ? (slots.groupContent || slots['group-content']) : null;
362
379
  const gvSlot = slots ? (slots.groupValues || slots['group-values']) : null;
@@ -427,25 +444,24 @@ export const Cell = {
427
444
  if (defaultSlot) {
428
445
  return renderCellBaseVNs(h, params, $table.callSlot(defaultSlot, params, h));
429
446
  }
447
+ const renderOpts = editRenderOpts || cellRenderOpts;
430
448
  // formatter > (renderTableCell | renderTableDefault)
431
449
  if (renderOpts && !formatter) {
432
450
  const compConf = renderer.get(renderOpts.name);
433
- const rtDefault = compConf ? (compConf.renderTableDefault || compConf.renderDefault) : null;
434
- const rtCell = compConf ? (compConf.renderTableCell || compConf.renderCell) : null;
435
- const renderFn = editRender ? rtCell : rtDefault;
451
+ const renderFn = editRenderOpts ? (compConf.renderTableCell || compConf.renderCell) : (compConf.renderTableDefault || compConf.renderDefault);
436
452
  if (renderFn) {
437
- return renderCellBaseVNs(h, params, getSlotVNs(renderFn.call($table, h, renderOpts, Object.assign({ $type: editRender ? 'edit' : 'cell' }, params))));
453
+ return renderCellBaseVNs(h, params, getSlotVNs(renderFn.call($table, h, renderOpts, Object.assign({ $type: editRenderOpts ? 'edit' : 'cell' }, params))));
438
454
  }
439
455
  }
440
456
  cellValue = $table.getCellLabel(row, column);
441
457
  }
442
- const cellPlaceholder = editRender ? editRender.placeholder : '';
458
+ const cellPlaceholder = editRenderOpts ? editRenderOpts.placeholder : '';
443
459
  return renderCellBaseVNs(h, params, [
444
460
  h('span', {
445
461
  class: 'vxe-cell--label'
446
462
  }, [
447
463
  // 如果设置占位符
448
- editRender && eqEmptyValue(cellValue)
464
+ editRenderOpts && eqEmptyValue(cellValue)
449
465
  ? h('span', {
450
466
  class: 'vxe-cell--placeholder'
451
467
  }, formatText(getFuncText(cellPlaceholder), 1))
@@ -1088,6 +1104,8 @@ export const Cell = {
1088
1104
  const { editConfig, editRules } = tableProps;
1089
1105
  const editOpts = $table.computeEditOpts;
1090
1106
  const { sortable, filters, editRender } = column;
1107
+ const isEnableEdit = editConfig && isEnableConf(editConfig);
1108
+ const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null;
1091
1109
  let isRequired = false;
1092
1110
  if (editRules) {
1093
1111
  const columnRules = XEUtils.get(editRules, column.field);
@@ -1096,7 +1114,7 @@ export const Cell = {
1096
1114
  }
1097
1115
  }
1098
1116
  let editIconVNs = [];
1099
- if (isEnableConf(editConfig)) {
1117
+ if (isEnableEdit) {
1100
1118
  const { showAsterisk, showIcon, icon } = editOpts;
1101
1119
  editIconVNs = [
1102
1120
  isRequired && showAsterisk
@@ -1108,7 +1126,7 @@ export const Cell = {
1108
1126
  })
1109
1127
  ])
1110
1128
  : renderEmptyElement($table),
1111
- isEnableConf(editRender) && showIcon
1129
+ editRenderOpts && showIcon
1112
1130
  ? h('i', {
1113
1131
  class: 'vxe-cell--edit-icon'
1114
1132
  }, XEUtils.isFunction(icon)
@@ -1128,11 +1146,15 @@ export const Cell = {
1128
1146
  // 行格编辑模式
1129
1147
  renderRowEdit(h, params) {
1130
1148
  const { $table, column } = params;
1149
+ const tableProps = $table;
1131
1150
  const tableReactData = $table;
1151
+ const { editConfig } = tableProps;
1132
1152
  const { editStore } = tableReactData;
1133
1153
  const { actived } = editStore;
1134
1154
  const { editRender } = column;
1135
- return Cell.runRenderer(h, params, this, isEnableConf(editRender) && actived && actived.row === params.row);
1155
+ const isEnableEdit = editConfig && isEnableConf(editConfig);
1156
+ const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null;
1157
+ return Cell.runRenderer(h, params, !!(editRenderOpts && actived && actived.row === params.row));
1136
1158
  },
1137
1159
  renderDeepRowEdit(h, params) {
1138
1160
  return Cell.renderDeepNodeBtn(h, params, Cell.renderRowEdit(h, params));
@@ -1140,29 +1162,37 @@ export const Cell = {
1140
1162
  // 单元格编辑模式
1141
1163
  renderCellEdit(h, params) {
1142
1164
  const { $table, column } = params;
1165
+ const tableProps = $table;
1143
1166
  const tableReactData = $table;
1167
+ const { editConfig } = tableProps;
1144
1168
  const { editStore } = tableReactData;
1145
1169
  const { actived } = editStore;
1146
1170
  const { editRender } = column;
1147
- return Cell.runRenderer(h, params, this, isEnableConf(editRender) && actived && actived.row === params.row && actived.column === params.column);
1171
+ const isEnableEdit = editConfig && isEnableConf(editConfig);
1172
+ const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null;
1173
+ return Cell.runRenderer(h, params, !!(editRenderOpts && actived && actived.row === params.row && actived.column === params.column));
1148
1174
  },
1149
1175
  renderDeepCellEdit(h, params) {
1150
1176
  return Cell.renderDeepNodeBtn(h, params, Cell.renderCellEdit(h, params));
1151
1177
  },
1152
1178
  runRenderer(h, params, _vm, isEdit) {
1153
1179
  const { $table, row, column } = params;
1180
+ const tableProps = $table;
1154
1181
  const tableReactData = $table;
1182
+ const { editConfig } = tableProps;
1155
1183
  const { isRowGroupStatus } = tableReactData;
1156
1184
  const { slots, field, editRender, formatter } = column;
1157
- const compConf = renderer.get(editRender.name);
1158
- const rtEdit = compConf ? (compConf.renderTableEdit || compConf.renderEdit) : null;
1185
+ const isEnableEdit = editConfig && isEnableConf(editConfig);
1186
+ const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null;
1159
1187
  const defaultSlot = slots ? slots.default : null;
1160
1188
  const gcSlot = slots ? (slots.groupContent || slots['group-content']) : null;
1161
1189
  const cellParams = Object.assign({ $type: '', isEdit }, params);
1162
- if (isEdit) {
1190
+ if (isEdit && editRenderOpts) {
1163
1191
  if (slots && slots.edit) {
1164
1192
  return $table.callSlot(slots.edit, cellParams, h);
1165
1193
  }
1194
+ const compConf = renderer.get(editRender.name);
1195
+ const rtEdit = compConf ? (compConf.renderTableEdit || compConf.renderEdit) : null;
1166
1196
  if (rtEdit) {
1167
1197
  return getSlotVNs(rtEdit.call($table, h, editRender, cellParams));
1168
1198
  }
@@ -5594,19 +5594,6 @@ const tableMethods = {
5594
5594
  const { treeConfig } = props;
5595
5595
  const { tableFullData, tableFullTreeData } = internalData;
5596
5596
  if (treeConfig) {
5597
- const treeOpts = $xeTable.computeTreeOpts;
5598
- const { transform, mapChildrenField, rowField, parentField } = treeOpts;
5599
- const childrenField = treeOpts.children || treeOpts.childrenField;
5600
- if (transform) {
5601
- return XEUtils.toArrayTree(XEUtils.toTreeArray(tableFullTreeData, {
5602
- children: mapChildrenField
5603
- }), {
5604
- key: rowField,
5605
- parentKey: parentField,
5606
- children: childrenField,
5607
- mapChildren: mapChildrenField
5608
- });
5609
- }
5610
5597
  return tableFullTreeData.slice(0);
5611
5598
  }
5612
5599
  return tableFullData.slice(0);
@@ -290,6 +290,8 @@ export const tableProps = {
290
290
  virtualYConfig: Object,
291
291
  // 滚动条配置项
292
292
  scrollbarConfig: Object,
293
+ // 可撤销配置项
294
+ undoHistoryConfig: Object,
293
295
  // (即将废弃)优化相关
294
296
  animat: { type: Boolean, default: () => getConfig().table.animat },
295
297
  // (可能会被废弃的参数,不要使用)
@@ -1463,6 +1463,11 @@ export default {
1463
1463
  }
1464
1464
  return [];
1465
1465
  },
1466
+ computeUndoHistoryOpts() {
1467
+ const $xeTable = this;
1468
+ const props = $xeTable;
1469
+ return Object.assign({}, getConfig().table.undoHistoryConfig, props.undoHistoryConfig);
1470
+ },
1466
1471
  tabsResizeFlag() {
1467
1472
  const $xeTable = this;
1468
1473
  const $xeTabs = $xeTable.$xeTabs;
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 = "3.19.34";
3
+ export const version = "3.19.36";
4
4
  VxeUI.version = version;
5
5
  VxeUI.tableVersion = version;
6
6
  VxeUI.setConfig({
@@ -255,6 +255,9 @@ VxeUI.setConfig({
255
255
  // position: 'right',
256
256
  visible: true
257
257
  }
258
+ },
259
+ undoHistoryConfig: {
260
+ isEditRow: true
258
261
  }
259
262
  },
260
263
  grid: {
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${"3.19.34"}`;
3
+ const version = `table v${"3.19.36"}`;
4
4
  export const warnLog = log.create('warn', version);
5
5
  export const errLog = log.create('error', version);