clean code

This commit is contained in:
Chen Lily 2024-03-05 14:17:16 +08:00
parent 6de4987360
commit baec3a3959

View File

@ -1539,14 +1539,13 @@ export class Grid {
/** /**
* 重新填充Grid单元格数据 * 重新填充Grid单元格数据
* @param {boolean} [force] - 忽略 `value` 的判断进行强制刷新
*/ */
refresh(force) { refresh() {
if (this._var.refs.body == null) { if (this._var.refs.body == null) {
throw new Error('body has not been created.'); throw new Error('body has not been created.');
} }
const widths = {}; const widths = {};
this._fillRows(this._tableRows, this.columns, widths, force); this._fillRows(this._tableRows, this.columns, widths);
if (this._var.needResize && widths.flag) { if (this._var.needResize && widths.flag) {
this._var.needResize = false; this._var.needResize = false;
this.columns.forEach((col, i) => { this.columns.forEach((col, i) => {
@ -2507,10 +2506,9 @@ export class Grid {
* @private * @private
* @param {HTMLTableRowElement[]} rows * @param {HTMLTableRowElement[]} rows
* @param {GridColumnDefinition[]} cols * @param {GridColumnDefinition[]} cols
* @param {any} widths * @param {any} [widths]
* @param {boolean} [force]
*/ */
_fillRows(rows, cols, widths, force) { _fillRows(rows, cols, widths) {
const startIndex = this._var.startIndex; const startIndex = this._var.startIndex;
const selectedIndexes = this._var.selectedIndexes; const selectedIndexes = this._var.selectedIndexes;
const offset = this.expandable ? 1 : 0; const offset = this.expandable ? 1 : 0;
@ -2673,7 +2671,7 @@ export class Grid {
type.setEditing(element, virtualRow.editing); type.setEditing(element, virtualRow.editing);
} }
} }
if (force || val !== virtualCell.value) { if (val !== virtualCell.value) {
virtualCell.value = val; virtualCell.value = val;
type.setValue(element, val, vals, col, this); type.setValue(element, val, vals, col, this);
} }
@ -2789,6 +2787,7 @@ export class Grid {
* @private * @private
* @param {number} index * @param {number} index
* @param {number} width * @param {number} width
* @param {boolean} [freeze]
*/ */
_changeColumnWidth(index, width, freeze) { _changeColumnWidth(index, width, freeze) {
const col = this.columns[index]; const col = this.columns[index];