fix not show selected transaction category / account / tag

This commit is contained in:
MaysWind
2025-01-06 21:58:52 +08:00
parent 6365805715
commit e0198da52c
+5 -5
View File
@@ -303,7 +303,7 @@ export function getItemByKeyValue<T>(src: Record<string, T>[] | Record<string, R
return null; return null;
} }
export function getNameByKeyValue<T>(src: Record<string, T>[] | Record<string, Record<string, T>>, value: T, keyField: string, nameField: string, defaultName: T): T { export function getNameByKeyValue<T>(src: Record<string, T>[] | Record<string, Record<string, T>>, value: T, keyField: string | null, nameField: string, defaultName: T): T {
if (isArray(src)) { if (isArray(src)) {
const arr = src as Record<string, T>[]; const arr = src as Record<string, T>[];
@@ -339,11 +339,11 @@ export function getNameByKeyValue<T>(src: Record<string, T>[] | Record<string, R
return option[nameField]; return option[nameField];
} }
} }
} else if (isNumber(value)) { } else if (isString(value)) {
const index = value as number; const key = value as string;
if (obj[index]) { if (obj[key]) {
const option = obj[index]; const option = obj[key];
return option[nameField]; return option[nameField];
} }