feat(assets): migrate asset views and reconcile inventory drilldowns
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
/** Stable aggregate identity shared by summary and permission-filtered detail. */
|
||||
export function inventoryKey(row: {
|
||||
region: string;
|
||||
city: string;
|
||||
brand: string;
|
||||
type: string;
|
||||
model: string;
|
||||
}) {
|
||||
return JSON.stringify([row.region, row.city, row.brand, row.type, row.model]);
|
||||
}
|
||||
export function inventoryOperation(
|
||||
status?: string | null,
|
||||
): "available" | "awaiting" | "unclassified" {
|
||||
if (["3", "可运营"].includes((status || "").trim())) return "available";
|
||||
if (["4", "待运营"].includes((status || "").trim())) return "awaiting";
|
||||
return "unclassified";
|
||||
}
|
||||
export interface InventoryCounts {
|
||||
quantity: number;
|
||||
available: number;
|
||||
awaiting: number;
|
||||
unclassified: number;
|
||||
abnormal: number;
|
||||
pending: number;
|
||||
abnormalTypes: Record<string, number>;
|
||||
}
|
||||
export const emptyInventoryCounts = (): InventoryCounts => ({
|
||||
quantity: 0,
|
||||
available: 0,
|
||||
awaiting: 0,
|
||||
unclassified: 0,
|
||||
abnormal: 0,
|
||||
pending: 0,
|
||||
abnormalTypes: {},
|
||||
});
|
||||
|
||||
/** Normalize only known color aliases; preserve meaningful multi-color descriptions. */
|
||||
export function inventoryColor(value?: string | null): string {
|
||||
const color = value?.trim() || "";
|
||||
if (!color) return "未标注颜色";
|
||||
return /^(红|白|黑|蓝|绿|灰|黄|银|橙)(色|车)?$/.test(color)
|
||||
? `${color[0]}色`
|
||||
: color;
|
||||
}
|
||||
Reference in New Issue
Block a user