mirror of
https://github.com/vbenjs/gf-vben-admin.git
synced 2025-01-23 20:00:19 +08:00
feat(table): updateTableDataRecord support functional rowKey
This commit is contained in:
parent
f62f378f42
commit
448a4c2809
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user