23 lines
644 B
TypeScript
23 lines
644 B
TypeScript
// 创建 value 到 label 的映射
|
|
const statusMap = (status: { label: string; value: number }[]) =>
|
|
new Map(status?.map((item) => [item.value, item.label]));
|
|
|
|
const packageMap = (status: { id: number; name: string }[]) =>
|
|
new Map(status?.map((item) => [item.id, item.name]));
|
|
|
|
// 获取 label 的函数
|
|
export const getStatusLabel = (
|
|
status: { label: string; value: number }[],
|
|
value: number,
|
|
): string => {
|
|
return statusMap(status).get(value) || '';
|
|
};
|
|
|
|
// 获取 label 的函数
|
|
export const getpackageLabel = (
|
|
status: { id: number; name: string }[],
|
|
id: number,
|
|
): string => {
|
|
return packageMap(status).get(id) || '';
|
|
};
|