Explorar el Código

fix(任务中心): 修复上传模板流程

- 修复响应字段名 documentId(原误用 id)
- 移除 ParseController 中更新文档状态的代码(避免 jsonb 类型冲突)
- 上传模板后不自动跳转编辑页面,等解析完成后用户自行进入
何文松 hace 1 mes
padre
commit
83d250c6d5

+ 1 - 6
backend/parse-service/src/main/java/com/lingyue/parse/controller/ParseController.java

@@ -82,12 +82,7 @@ public class ParseController {
             return AjaxResult.error("该文档正在解析中,请勿重复提交");
         }
         
-        // 更新文档状态为解析中
-        document.setStatus("parsing");
-        document.setParseStatus("processing");
-        documentRepository.updateById(document);
-        
-        // 提交解析任务
+        // 提交解析任务(状态由 ParseService 内部管理)
         parseTaskExecutor.submitParseTask(documentId, filePath);
         log.info("解析任务已提交: documentId={}, filePath={}", documentId, filePath);
         

+ 6 - 4
frontend/vue-demo/src/views/Home.vue

@@ -356,7 +356,7 @@ function beforeUpload(file) {
 
 function handleUploadSuccess(response) {
   if (response.code === 200) {
-    uploadTemplate.baseDocumentId = response.data.id
+    uploadTemplate.baseDocumentId = response.data.documentId
     ElMessage.success('文档上传成功')
   } else {
     ElMessage.error('上传失败: ' + (response.msg || '未知错误'))
@@ -380,7 +380,7 @@ async function handleUploadTemplate() {
   uploading.value = true
   try {
     const documentId = uploadTemplate.baseDocumentId
-    const template = await templateStore.createTemplate({
+    await templateStore.createTemplate({
       name: uploadTemplate.name,
       description: uploadTemplate.description || '',
       baseDocumentId: documentId
@@ -392,7 +392,7 @@ async function handleUploadTemplate() {
     // 触发文档解析
     try {
       await parseApi.startParse(documentId)
-      ElMessage.success('模板创建成功,正在解析文档...')
+      ElMessage.success('模板创建成功,正在解析文档,请在任务中心查看进度')
       // 打开任务中心并追踪此文档的解析任务
       taskCenterStore.notifyTaskStarted({ documentId })
     } catch (parseError) {
@@ -400,7 +400,9 @@ async function handleUploadTemplate() {
       ElMessage.warning('模板创建成功,但解析启动失败,请稍后手动触发')
     }
     
-    router.push(`/editor/${template.id}`)
+    // 刷新模板列表
+    await templateStore.fetchTemplates()
+    // 不自动跳转编辑页面,等解析完成后用户自行进入
   } catch (error) {
     ElMessage.error('创建失败: ' + error.message)
   } finally {