fix: 1. 重新对齐交叉评查的接口。

2. 确认评查结果的接口对接。 3. 新增评查点适配省级创建的响应数据和其他用户创建的单条响应数据。  4. 文档列表的文档类型通过通用的查询接口查询文档类型。优化加载状态的时机。
This commit is contained in:
2025-12-11 11:16:50 +08:00
parent ba517d7b9c
commit d8bba607fc
18 changed files with 3435 additions and 1086 deletions
+76 -31
View File
@@ -2,6 +2,7 @@ import { postgrestGet, postgrestDelete, postgrestPut, postgrestPost } from '../p
import { getDocumentTypes } from '../document-types/document-types';
import { formatDate } from '../../utils';
import { API_BASE_URL } from '~/config/api-config';
import type { DocumentType } from './files-upload';
/**
* 从不同格式的 API 响应中提取数据
@@ -76,10 +77,10 @@ export interface DocumentUI {
pageCount?: number;
ocrResult?: unknown;
// 结果统计字段
pass_count: number | null; // 通过数量
warning_count: number | null; // 警告数量
error_count: number | null; // 错误数量
manual_count: number | null; // 人工审核数量
pass_count?: number | null; // 通过数量
warning_count?: number | null; // 警告数量
error_count?: number | null; // 错误数量
manual_count?: number | null; // 人工审核数量
// 消息详情字段
warning_messages?: string[]; // 警告消息列表
error_messages?: string[]; // 错误消息列表
@@ -336,54 +337,98 @@ export async function getDocument(id: string, userId: string, frontendJWT?: stri
* @param id 文档ID
* @returns 文档详情
*/
export async function getDocumentWithNoUserId(id: string, frontendJWT?: string): Promise<{
data?: DocumentUI;
// export async function getDocumentWithNoUserId(id: string, frontendJWT?: string): Promise<{
// data?: DocumentUI;
// error?: string;
// status?: number;
// }> {
// try {
// if (!id) {
// return { error: '文档ID不能为空', status: 400 };
// }
// // console.log("get单个文档id", id)
// const response = await postgrestGet<Document[]>(
// '/api/postgrest/proxy/documents',
// {
// filter: {
// 'id': `eq.${id}`,
// },
// limit: 1,
// token: frontendJWT
// }
// );
// if (response.error) {
// return { error: response.error, status: response.status };
// }
// // console.log("respose", response)
// const extractedData = extractApiData<Document[]>(response.data);
// if (!extractedData || extractedData.length === 0) {
// return { error: '文档不存在', status: 404 };
// }
// // console.log('extractedData', extractedData);
// const documentUI = await convertToUIDocument(extractedData[0], frontendJWT);
// return { data: documentUI };
// } catch (error) {
// console.error('获取文档详情失败:', error);
// return {
// error: error instanceof Error ? error.message : '获取文档详情失败',
// status: 500
// };
// }
// }
/**
* 获取文档类型列表(按IDs过滤版本)
* @param ids 文档类型ID数组(必填)
* @param frontendJWT JWT token(可选)
* @returns 文档类型列表
*/
export async function getDocumentTypesByIds(ids: number[], frontendJWT?: string): Promise<{
data?: { types: DocumentType[], total: number };
error?: string;
status?: number;
}> {
try {
if (!id) {
return { error: '文档ID不能为空', status: 400 };
if (!ids || ids.length === 0) {
return { data: { types: [], total: 0 } };
}
// console.log("get单个文档id", id)
const response = await postgrestGet<Document[]>(
'/api/postgrest/proxy/documents',
const response = await postgrestGet<DocumentType[]>(
'/api/postgrest/proxy/document_types',
{
filter: {
'id': `eq.${id}`,
'id': `in.(${ids.join(',')})`
},
limit: 1,
token: frontendJWT
}
);
});
if (response.error) {
return { error: response.error, status: response.status };
}
// console.log("respose", response)
const extractedData = extractApiData<Document[]>(response.data);
if (!extractedData || extractedData.length === 0) {
return { error: '文档不存在', status: 404 };
const extractedData = extractApiData<DocumentType[]>(response.data);
if (!extractedData) {
return { error: '获取文档类型列表失败', status: 500 };
}
// console.log('extractedData', extractedData);
const documentUI = await convertToUIDocument(extractedData[0], frontendJWT);
return { data: documentUI };
return { data: { types: extractedData, total: extractedData.length } };
} catch (error) {
console.error('获取文档详情失败:', error);
console.error('获取文档类型列表失败:', error);
return {
error: error instanceof Error ? error.message : '获取文档详情失败',
error: error instanceof Error ? error.message : '获取文档类型列表失败',
status: 500
};
}
}
/**
* 更新文档信息
* @param id 文档ID