73 lines
2.5 KiB
TypeScript
73 lines
2.5 KiB
TypeScript
/**
|
||
* 报价模板列表行类型(对接主账 list 摘要)。
|
||
* placeholderCount 语义改为 mappingPointCount(映射点数)。
|
||
*/
|
||
|
||
/**
|
||
* 列表行类型。分类字段已从运营页移除(筛选项/列/表单均不展示);
|
||
* 主账库仍可存 category,由服务端按业务默认,前端不再读写。
|
||
*/
|
||
export type TemplateRow = {
|
||
id: string;
|
||
name: string;
|
||
bizType: "空运" | "海运" | "陆运";
|
||
fileLabel: string;
|
||
fileName: string;
|
||
format: "excel" | "pdf";
|
||
parseStatus: string;
|
||
/** 已映射字段点数(原 mock 占位符数) */
|
||
mappingPointCount: number;
|
||
keywords: string[];
|
||
isDefault: boolean;
|
||
status: "enabled" | "disabled";
|
||
useCount: number;
|
||
createdAt: string;
|
||
operator: string;
|
||
mode?: "auto" | "manual";
|
||
versionId?: string;
|
||
currentVersion?: number;
|
||
parseMessage?: string;
|
||
unmappedRequired?: string[];
|
||
unmappedLabels?: string[];
|
||
/** 表上有、对照清单未映射上的中文说明(智能体 mappingGaps) */
|
||
mappingGaps?: string[];
|
||
/** 列表提示:未解析条数(主账合并口径) */
|
||
unparsedHintCount?: number;
|
||
objectKey?: string;
|
||
};
|
||
|
||
/** 将主账 list 记录规范为页面行 */
|
||
export function mapApiRow(raw: any): TemplateRow {
|
||
const created =
|
||
typeof raw.createdAt === "string"
|
||
? raw.createdAt.slice(0, 10)
|
||
: raw.createTime
|
||
? String(raw.createTime).slice(0, 10)
|
||
: "";
|
||
return {
|
||
id: String(raw.id || ""),
|
||
name: raw.name || "",
|
||
bizType: (raw.bizType || "海运") as TemplateRow["bizType"],
|
||
fileLabel: raw.fileLabel || raw.name || "",
|
||
fileName: raw.fileName || "",
|
||
format: raw.format === "pdf" ? "pdf" : "excel",
|
||
parseStatus: raw.parseStatus || "",
|
||
mappingPointCount: Number(raw.mappingPointCount || 0),
|
||
keywords: Array.isArray(raw.keywords) ? raw.keywords : [],
|
||
isDefault: Boolean(raw.isDefault),
|
||
status: raw.status === "enabled" ? "enabled" : "disabled",
|
||
useCount: Number(raw.useCount || 0),
|
||
createdAt: created,
|
||
operator: raw.operator || "",
|
||
mode: raw.mode === "manual" ? "manual" : "auto",
|
||
versionId: raw.versionId || undefined,
|
||
currentVersion: raw.currentVersion,
|
||
parseMessage: raw.parseMessage,
|
||
unmappedRequired: Array.isArray(raw.unmappedRequired) ? raw.unmappedRequired.map(String) : [],
|
||
unmappedLabels: Array.isArray(raw.unmappedLabels) ? raw.unmappedLabels.map(String) : [],
|
||
mappingGaps: Array.isArray(raw.mappingGaps) ? raw.mappingGaps.map(String) : [],
|
||
unparsedHintCount: Number(raw.unparsedHintCount || 0),
|
||
objectKey: raw.objectKey,
|
||
};
|
||
}
|