This commit is contained in:
ttt
2026-04-08 20:45:02 +08:00
parent 4eda6cf758
commit b2ebd3e12d
2 changed files with 36 additions and 0 deletions

View File

@@ -103,7 +103,9 @@ export interface FillResult {
field: string;
value: any;
source: string;
confidence?: number;
}>;
source_doc_count?: number;
error?: string;
}
@@ -621,6 +623,39 @@ export const backendApi = {
}
},
/**
* 从已上传的模板提取字段定义
*/
async extractTemplateFields(
templateId: string,
fileType: string = 'xlsx'
): Promise<{
success: boolean;
fields: TemplateField[];
}> {
const url = `${BACKEND_BASE_URL}/templates/fields`;
try {
const response = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
template_id: templateId,
file_type: fileType,
}),
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.detail || '提取字段失败');
}
return await response.json();
} catch (error) {
console.error('提取字段失败:', error);
throw error;
}
},
/**
* 执行表格填写
*/

View File

@@ -46,6 +46,7 @@ type TemplateField = {
name: string;
field_type: string;
required: boolean;
hint?: string;
};
const TemplateFill: React.FC = () => {