perf(component): 优化table 组件的insertTableDataRecord的方法,增加批量插入的功能。 (#2481)
Co-authored-by: huangwentao <huangwentao@dianchu.com>
This commit is contained in:
parent
aabafe8610
commit
31042de6bc
|
|
@ -13,7 +13,7 @@ import {
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
import { useTimeoutFn } from '/@/hooks/core/useTimeout';
|
import { useTimeoutFn } from '/@/hooks/core/useTimeout';
|
||||||
import { buildUUID } from '/@/utils/uuid';
|
import { buildUUID } from '/@/utils/uuid';
|
||||||
import { isFunction, isBoolean } from '/@/utils/is';
|
import { isFunction, isBoolean, isObject } from '/@/utils/is';
|
||||||
import { get, cloneDeep, merge } from 'lodash-es';
|
import { get, cloneDeep, merge } from 'lodash-es';
|
||||||
import { FETCH_SETTING, ROW_KEY, PAGE_SIZE } from '../const';
|
import { FETCH_SETTING, ROW_KEY, PAGE_SIZE } from '../const';
|
||||||
|
|
||||||
|
|
@ -206,10 +206,14 @@ export function useDataSource(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function insertTableDataRecord(record: Recordable, index: number): Recordable | undefined {
|
function insertTableDataRecord(
|
||||||
|
record: Recordable | Recordable[],
|
||||||
|
index: number,
|
||||||
|
): Recordable | undefined {
|
||||||
// if (!dataSourceRef.value || dataSourceRef.value.length == 0) return;
|
// if (!dataSourceRef.value || dataSourceRef.value.length == 0) return;
|
||||||
index = index ?? dataSourceRef.value?.length;
|
index = index ?? dataSourceRef.value?.length;
|
||||||
unref(dataSourceRef).splice(index, 0, record);
|
const _record = isObject(record) ? [record as Recordable] : (record as Recordable[]);
|
||||||
|
unref(dataSourceRef).splice(index, 0, ..._record);
|
||||||
return unref(dataSourceRef);
|
return unref(dataSourceRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ export interface TableActionType {
|
||||||
setTableData: <T = Recordable>(values: T[]) => void;
|
setTableData: <T = Recordable>(values: T[]) => void;
|
||||||
updateTableDataRecord: (rowKey: string | number, record: Recordable) => Recordable | void;
|
updateTableDataRecord: (rowKey: string | number, record: Recordable) => Recordable | void;
|
||||||
deleteTableDataRecord: (rowKey: string | number | string[] | number[]) => void;
|
deleteTableDataRecord: (rowKey: string | number | string[] | number[]) => void;
|
||||||
insertTableDataRecord: (record: Recordable, index?: number) => Recordable | void;
|
insertTableDataRecord: (record: Recordable | Recordable[], index?: number) => Recordable | void;
|
||||||
findTableDataRecord: (rowKey: string | number) => Recordable | void;
|
findTableDataRecord: (rowKey: string | number) => Recordable | void;
|
||||||
getColumns: (opt?: GetColumnsParams) => BasicColumn[];
|
getColumns: (opt?: GetColumnsParams) => BasicColumn[];
|
||||||
setColumns: (columns: BasicColumn[] | string[]) => void;
|
setColumns: (columns: BasicColumn[] | string[]) => void;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue