tl
This commit is contained in:
@@ -103,7 +103,9 @@ export interface FillResult {
|
|||||||
field: string;
|
field: string;
|
||||||
value: any;
|
value: any;
|
||||||
source: string;
|
source: string;
|
||||||
|
confidence?: number;
|
||||||
}>;
|
}>;
|
||||||
|
source_doc_count?: number;
|
||||||
error?: string;
|
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;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行表格填写
|
* 执行表格填写
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ type TemplateField = {
|
|||||||
name: string;
|
name: string;
|
||||||
field_type: string;
|
field_type: string;
|
||||||
required: boolean;
|
required: boolean;
|
||||||
|
hint?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const TemplateFill: React.FC = () => {
|
const TemplateFill: React.FC = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user