提交 448a4c28 编写于 作者: 无木

feat(table): updateTableDataRecord support functional rowKey

上级 f62f378f
......@@ -155,12 +155,16 @@ export function useDataSource(
): Recordable | undefined {
if (!dataSourceRef.value || dataSourceRef.value.length == 0) return;
const rowKeyName = unref(getRowKey);
if (typeof rowKeyName !== 'string') {
if (!rowKeyName) {
return;
}
const row = dataSourceRef.value.find(
(r) => Reflect.has(r, rowKeyName as string) && r[rowKeyName as string] === rowKey
);
const row = dataSourceRef.value.find((r) => {
if (typeof rowKeyName === 'function') {
return (rowKeyName(r) as string) === rowKey;
} else {
return Reflect.has(r, rowKeyName) && r[rowKeyName] === rowKey;
}
});
if (row) {
for (const field in row) {
if (Reflect.has(record, field)) row[field] = record[field];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册