vxe-table 4.7.25 → 4.7.26

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.
@@ -1283,7 +1283,7 @@ var _default = exports.default = (0, _vue.defineComponent)({
1283
1283
  column
1284
1284
  }) : _xeUtils.default.get(row, sortBy);
1285
1285
  } else {
1286
- cellValue = tablePrivateMethods.getCellLabel(row, column);
1286
+ cellValue = tableMethods.getCellLabel(row, column);
1287
1287
  }
1288
1288
  if (!sortType || sortType === 'auto') {
1289
1289
  return isNaN(cellValue) ? cellValue : _xeUtils.default.toNumber(cellValue);
@@ -3499,6 +3499,91 @@ var _default = exports.default = (0, _vue.defineComponent)({
3499
3499
  }
3500
3500
  return (0, _vue.nextTick)();
3501
3501
  },
3502
+ getCellElement(row, fieldOrColumn) {
3503
+ const column = (0, _util.handleFieldOrColumn)($xeTable, fieldOrColumn);
3504
+ if (!column) {
3505
+ return null;
3506
+ }
3507
+ const rowid = (0, _util.getRowid)($xeTable, row);
3508
+ const tableBody = refTableBody.value;
3509
+ const leftBody = refTableLeftBody.value;
3510
+ const rightBody = refTableRightBody.value;
3511
+ let bodyElem;
3512
+ if (column) {
3513
+ if (column.fixed) {
3514
+ if (column.fixed === 'left') {
3515
+ if (leftBody) {
3516
+ bodyElem = leftBody.$el;
3517
+ }
3518
+ } else {
3519
+ if (rightBody) {
3520
+ bodyElem = rightBody.$el;
3521
+ }
3522
+ }
3523
+ }
3524
+ if (!bodyElem) {
3525
+ bodyElem = tableBody.$el;
3526
+ }
3527
+ if (bodyElem) {
3528
+ return bodyElem.querySelector(`.vxe-body--row[rowid="${rowid}"] .${column.id}`);
3529
+ }
3530
+ }
3531
+ return null;
3532
+ },
3533
+ getCellLabel(row, fieldOrColumn) {
3534
+ const column = (0, _util.handleFieldOrColumn)($xeTable, fieldOrColumn);
3535
+ if (!column) {
3536
+ return null;
3537
+ }
3538
+ const formatter = column.formatter;
3539
+ const cellValue = (0, _util.getCellValue)(row, column);
3540
+ let cellLabel = cellValue;
3541
+ if (formatter) {
3542
+ let formatData;
3543
+ const {
3544
+ fullAllDataRowIdData
3545
+ } = internalData;
3546
+ const rowid = (0, _util.getRowid)($xeTable, row);
3547
+ const colid = column.id;
3548
+ const rest = fullAllDataRowIdData[rowid];
3549
+ if (rest) {
3550
+ formatData = rest.formatData;
3551
+ if (!formatData) {
3552
+ formatData = fullAllDataRowIdData[rowid].formatData = {};
3553
+ }
3554
+ if (rest && formatData[colid]) {
3555
+ if (formatData[colid].value === cellValue) {
3556
+ return formatData[colid].label;
3557
+ }
3558
+ }
3559
+ }
3560
+ const formatParams = {
3561
+ cellValue,
3562
+ row,
3563
+ rowIndex: tableMethods.getRowIndex(row),
3564
+ column,
3565
+ columnIndex: tableMethods.getColumnIndex(column)
3566
+ };
3567
+ if (_xeUtils.default.isString(formatter)) {
3568
+ const gFormatOpts = formats.get(formatter);
3569
+ const tcFormatMethod = gFormatOpts ? gFormatOpts.tableCellFormatMethod || gFormatOpts.cellFormatMethod : null;
3570
+ cellLabel = tcFormatMethod ? tcFormatMethod(formatParams) : '';
3571
+ } else if (_xeUtils.default.isArray(formatter)) {
3572
+ const gFormatOpts = formats.get(formatter[0]);
3573
+ const tcFormatMethod = gFormatOpts ? gFormatOpts.tableCellFormatMethod || gFormatOpts.cellFormatMethod : null;
3574
+ cellLabel = tcFormatMethod ? tcFormatMethod(formatParams, ...formatter.slice(1)) : '';
3575
+ } else {
3576
+ cellLabel = formatter(formatParams);
3577
+ }
3578
+ if (formatData) {
3579
+ formatData[colid] = {
3580
+ value: cellValue,
3581
+ label: cellLabel
3582
+ };
3583
+ }
3584
+ }
3585
+ return cellLabel;
3586
+ },
3502
3587
  /**
3503
3588
  * 检查是否为临时行数据
3504
3589
  * @param {Row} row 行对象
@@ -3564,6 +3649,13 @@ var _default = exports.default = (0, _vue.defineComponent)({
3564
3649
  const columns = internalData.visibleColumn;
3565
3650
  return _xeUtils.default.isUndefined(columnIndex) ? columns.slice(0) : columns[columnIndex];
3566
3651
  },
3652
+ /**
3653
+ * 根据列获取列的唯一主键
3654
+ */
3655
+ getColid(fieldOrColumn) {
3656
+ const column = (0, _util.handleFieldOrColumn)($xeTable, fieldOrColumn);
3657
+ return column ? column.id : null;
3658
+ },
3567
3659
  /**
3568
3660
  * 根据列的唯一主键获取列
3569
3661
  * @param {String} colid 列主键
@@ -5067,7 +5159,7 @@ var _default = exports.default = (0, _vue.defineComponent)({
5067
5159
  const type = 'change';
5068
5160
  if ($xeTable.hasCellRules) {
5069
5161
  if ($xeTable.hasCellRules(type, row, column)) {
5070
- const cell = tablePrivateMethods.getCell(row, column);
5162
+ const cell = tableMethods.getCellElement(row, column);
5071
5163
  if (cell) {
5072
5164
  return $xeTable.validCellRules(type, row, column, cellValue).then(() => {
5073
5165
  if (customVal && validStore.visible) {
@@ -7282,82 +7374,12 @@ var _default = exports.default = (0, _vue.defineComponent)({
7282
7374
  }
7283
7375
  internalData.hoverRow = null;
7284
7376
  },
7377
+ /**
7378
+ * 已废弃,被 getCellElement 替换
7379
+ * @deprecated
7380
+ */
7285
7381
  getCell(row, column) {
7286
- const rowid = (0, _util.getRowid)($xeTable, row);
7287
- const tableBody = refTableBody.value;
7288
- const leftBody = refTableLeftBody.value;
7289
- const rightBody = refTableRightBody.value;
7290
- let bodyElem;
7291
- if (column) {
7292
- if (column.fixed) {
7293
- if (column.fixed === 'left') {
7294
- if (leftBody) {
7295
- bodyElem = leftBody.$el;
7296
- }
7297
- } else {
7298
- if (rightBody) {
7299
- bodyElem = rightBody.$el;
7300
- }
7301
- }
7302
- }
7303
- if (!bodyElem) {
7304
- bodyElem = tableBody.$el;
7305
- }
7306
- if (bodyElem) {
7307
- return bodyElem.querySelector(`.vxe-body--row[rowid="${rowid}"] .${column.id}`);
7308
- }
7309
- }
7310
- return null;
7311
- },
7312
- getCellLabel(row, column) {
7313
- const formatter = column.formatter;
7314
- const cellValue = (0, _util.getCellValue)(row, column);
7315
- let cellLabel = cellValue;
7316
- if (formatter) {
7317
- let formatData;
7318
- const {
7319
- fullAllDataRowIdData
7320
- } = internalData;
7321
- const rowid = (0, _util.getRowid)($xeTable, row);
7322
- const colid = column.id;
7323
- const rest = fullAllDataRowIdData[rowid];
7324
- if (rest) {
7325
- formatData = rest.formatData;
7326
- if (!formatData) {
7327
- formatData = fullAllDataRowIdData[rowid].formatData = {};
7328
- }
7329
- if (rest && formatData[colid]) {
7330
- if (formatData[colid].value === cellValue) {
7331
- return formatData[colid].label;
7332
- }
7333
- }
7334
- }
7335
- const formatParams = {
7336
- cellValue,
7337
- row,
7338
- rowIndex: tableMethods.getRowIndex(row),
7339
- column,
7340
- columnIndex: tableMethods.getColumnIndex(column)
7341
- };
7342
- if (_xeUtils.default.isString(formatter)) {
7343
- const gFormatOpts = formats.get(formatter);
7344
- const tcFormatMethod = gFormatOpts ? gFormatOpts.tableCellFormatMethod || gFormatOpts.cellFormatMethod : null;
7345
- cellLabel = tcFormatMethod ? tcFormatMethod(formatParams) : '';
7346
- } else if (_xeUtils.default.isArray(formatter)) {
7347
- const gFormatOpts = formats.get(formatter[0]);
7348
- const tcFormatMethod = gFormatOpts ? gFormatOpts.tableCellFormatMethod || gFormatOpts.cellFormatMethod : null;
7349
- cellLabel = tcFormatMethod ? tcFormatMethod(formatParams, ...formatter.slice(1)) : '';
7350
- } else {
7351
- cellLabel = formatter(formatParams);
7352
- }
7353
- if (formatData) {
7354
- formatData[colid] = {
7355
- value: cellValue,
7356
- label: cellLabel
7357
- };
7358
- }
7359
- }
7360
- return cellLabel;
7382
+ return tableMethods.getCellElement(row, column);
7361
7383
  },
7362
7384
  findRowIndexOf(list, row) {
7363
7385
  return row ? _xeUtils.default.findIndexOf(list, item => $xeTable.eqRow(item, row)) : -1;