新增联合上传模板和源文档功能
新增 upload-joint 接口支持模板文件和源文档的一键式联合上传处理, 包括异步文档解析和MongoDB存储功能;前端新增对应API调用方法和UI界 面,优化表格填写流程,支持拖拽上传和实时预览功能。
This commit is contained in:
@@ -656,6 +656,46 @@ export const backendApi = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 联合上传模板和源文档
|
||||
*/
|
||||
async uploadTemplateAndSources(
|
||||
templateFile: File,
|
||||
sourceFiles: File[]
|
||||
): Promise<{
|
||||
success: boolean;
|
||||
template_id: string;
|
||||
filename: string;
|
||||
file_type: string;
|
||||
fields: TemplateField[];
|
||||
field_count: number;
|
||||
source_file_paths: string[];
|
||||
source_filenames: string[];
|
||||
task_id: string;
|
||||
}> {
|
||||
const formData = new FormData();
|
||||
formData.append('template_file', templateFile);
|
||||
sourceFiles.forEach(file => formData.append('source_files', file));
|
||||
|
||||
const url = `${BACKEND_BASE_URL}/templates/upload-joint`;
|
||||
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json();
|
||||
throw new Error(error.detail || '联合上传失败');
|
||||
}
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error('联合上传失败:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 执行表格填写
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user