Merge branch 'Wren' into shiy-login
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// import { API_BASE_URL } from '../config/api-config';
|
||||
import { API_BASE_URL } from '../../config/api-config';
|
||||
|
||||
// 交叉评查任务状态枚举
|
||||
export enum CrossCheckingTaskStatus {
|
||||
@@ -510,9 +510,6 @@ export async function getCrossCheckingStats(): Promise<ApiResponse<{
|
||||
|
||||
// ==================== 新增:用户任务文档相关接口 ====================
|
||||
|
||||
// 导入API客户端
|
||||
import { post } from '../axios-client';
|
||||
|
||||
/**
|
||||
* 获取用户参与的所有任务及文档
|
||||
* @param userId 用户ID
|
||||
@@ -520,87 +517,35 @@ import { post } from '../axios-client';
|
||||
*/
|
||||
export async function getUserTaskDocuments(userId: number): Promise<ApiResponse<UserTaskInfo[]>> {
|
||||
try {
|
||||
console.log('开始调用用户任务API,用户ID:', userId);
|
||||
|
||||
// 导入API配置以显示当前使用的baseUrl
|
||||
const { API_BASE_URL } = await import('../../config/api-config');
|
||||
console.log('当前API基础URL:', API_BASE_URL);
|
||||
|
||||
// 调用真实的API接口
|
||||
console.log('调用API路径:', '/admin/cross_review/tasks/user_documents');
|
||||
console.log('完整API URL:', `${API_BASE_URL}/admin/cross_review/tasks/user_documents`);
|
||||
console.log('请求参数:', { user_id: userId });
|
||||
|
||||
const response = await post<UserTaskApiResponse>(
|
||||
'/admin/cross_review/tasks/user_documents',
|
||||
{ user_id: userId }
|
||||
);
|
||||
|
||||
console.log('API响应:', response);
|
||||
|
||||
// 如果API调用失败,尝试使用模拟数据作为回退
|
||||
if (response.error) {
|
||||
console.warn('API调用失败,使用模拟数据作为回退');
|
||||
// 返回模拟数据
|
||||
const mockUserTasks: UserTaskInfo[] = [
|
||||
{
|
||||
task_id: 1,
|
||||
task_status: 'completed',
|
||||
documents: [
|
||||
{ document_id: 1, document_name: '测试文档1', document_type_id: 1, document_type_name: '行政处罚' },
|
||||
{ document_id: 2, document_name: '测试文档2', document_type_id: 1, document_type_name: '行政处罚' }
|
||||
]
|
||||
},
|
||||
{
|
||||
task_id: 2,
|
||||
task_status: 'in_progress',
|
||||
documents: [
|
||||
{ document_id: 3, document_name: '测试文档3', document_type_id: 2, document_type_name: '行政许可' }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: mockUserTasks
|
||||
};
|
||||
}
|
||||
|
||||
if (response.error) {
|
||||
console.error('获取用户任务及文档失败:', response.error);
|
||||
// 拼接绝对路径,去除多余斜杠
|
||||
const base = API_BASE_URL.endsWith('/') ? API_BASE_URL.slice(0, -1) : API_BASE_URL;
|
||||
const url = `${base}/admin/cross_review/tasks/user_documents?user_id=${userId}`;
|
||||
console.log('最终请求URL:', url);
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ user_id: userId })
|
||||
});
|
||||
if (!response.ok) {
|
||||
return {
|
||||
success: false,
|
||||
error: response.error
|
||||
error: `HTTP ${response.status}: ${response.statusText}`
|
||||
};
|
||||
}
|
||||
|
||||
// 确保返回的数据是数组格式
|
||||
const result = await response.json();
|
||||
let userTasks: UserTaskInfo[] = [];
|
||||
|
||||
if (response.data) {
|
||||
// 检查响应数据的结构
|
||||
console.log('响应数据结构:', response.data);
|
||||
|
||||
// 根据实际API响应结构,数据在response.data.data中
|
||||
if (response.data.data && Array.isArray(response.data.data)) {
|
||||
userTasks = response.data.data;
|
||||
} else if (Array.isArray(response.data)) {
|
||||
// 备用方案:如果数据直接在response.data中
|
||||
userTasks = response.data;
|
||||
} else {
|
||||
console.warn('响应数据格式不正确:', response.data);
|
||||
userTasks = [];
|
||||
}
|
||||
if (Array.isArray(result.data)) {
|
||||
userTasks = result.data;
|
||||
} else if (Array.isArray(result)) {
|
||||
userTasks = result;
|
||||
} else {
|
||||
userTasks = [];
|
||||
}
|
||||
|
||||
console.log('解析后的用户任务数据:', userTasks);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: userTasks
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取用户任务及文档失败:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : '获取用户任务及文档失败'
|
||||
|
||||
@@ -216,7 +216,7 @@ export function ReviewTabs({ activeTab, onTabChange, children, fileInfo, onConfi
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<div className="tab-container w-full flex-1">
|
||||
<div className="tab-nav w-full flex justify-between">
|
||||
|
||||
Reference in New Issue
Block a user