fix: reconnect cross checking upload flow
This commit is contained in:
@@ -946,33 +946,24 @@ export async function updateDocumentAuditStatus(id: string, auditStatus: number,
|
||||
*/
|
||||
export async function getCrossCheckingDocumentTypes(jwtToken?: string): Promise<ApiResponse<DocumentType[]>> {
|
||||
try {
|
||||
// console.log('[getCrossCheckingDocumentTypes] 开始获取交叉评查文档类型');
|
||||
|
||||
const response = await postgrestGet<DocumentType>('/api/postgrest/proxy/document_types',{
|
||||
select: 'id,name,code,evaluation_point_groups_ids',
|
||||
filter: {
|
||||
evaluation_point_groups_ids: 'not.is.null'
|
||||
},
|
||||
token: jwtToken
|
||||
const response = await axios.get<{ data?: Array<{
|
||||
id: number;
|
||||
name: string;
|
||||
code: string;
|
||||
isEnabled?: boolean;
|
||||
ruleSetIds?: number[];
|
||||
}> }>(`${API_BASE_URL}/api/document-types`, {
|
||||
headers: jwtToken ? { Authorization: `Bearer ${jwtToken}` } : undefined,
|
||||
});
|
||||
|
||||
if (response.error) {
|
||||
console.error('[getCrossCheckingDocumentTypes] 获取失败:', response.error);
|
||||
return {
|
||||
success: false,
|
||||
error: response.error
|
||||
};
|
||||
}
|
||||
|
||||
// 进一步过滤,确保 evaluation_point_groups_ids 是非空数组
|
||||
const dataArray = Array.isArray(response.data) ? response.data : [];
|
||||
const filteredData = dataArray.filter(
|
||||
(item: DocumentType) => item.evaluation_point_groups_ids &&
|
||||
Array.isArray(item.evaluation_point_groups_ids) &&
|
||||
item.evaluation_point_groups_ids.length > 0
|
||||
);
|
||||
|
||||
// console.log('[getCrossCheckingDocumentTypes] 获取成功,共', filteredData.length, '个文档类型');
|
||||
const rawItems = Array.isArray(response.data?.data) ? response.data.data : [];
|
||||
const filteredData = rawItems
|
||||
.filter((item) => item && item.isEnabled !== false)
|
||||
.map((item) => ({
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
code: item.code,
|
||||
}))
|
||||
.sort((a, b) => a.name.localeCompare(b.name, 'zh-CN'));
|
||||
|
||||
return {
|
||||
success: true,
|
||||
|
||||
Reference in New Issue
Block a user