修复系统概览数据不准确的查询。修复交叉评查意见列表的数量查询。优化全局消息提示的层级。优化提交意见进行局部更新。
This commit is contained in:
+18
-6
@@ -20,6 +20,9 @@ export type QueryParams = Record<string, string | number | boolean | undefined>;
|
||||
// const API_BASE_URL = 'http://172.18.0.100:3000';
|
||||
// const API_BASE_URL = 'http://172.16.0.119:9000/admin';
|
||||
|
||||
// 调试:打印当前API_BASE_URL的值
|
||||
console.log('🔍 axios-client.ts - API_BASE_URL.value:', API_BASE_URL.value);
|
||||
|
||||
// 文档URL前缀 (从配置文件导入)
|
||||
// export const DOCUMENT_URL = 'http://nas.7bm.co:9000/docauditai/';
|
||||
export { DOCUMENT_URL };
|
||||
@@ -32,7 +35,7 @@ const DEFAULT_TIMEOUT = 30000; // 增加到30秒
|
||||
|
||||
// 创建 axios 实例
|
||||
const axiosInstance = axios.create({
|
||||
baseURL: API_BASE_URL,
|
||||
baseURL: API_BASE_URL.value === '/api' ? '' : API_BASE_URL.value, // 如果是相对路径,则不设置baseURL
|
||||
timeout: DEFAULT_TIMEOUT, // 增加超时时间
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -97,10 +100,17 @@ function buildUrl(endpoint: string, params?: QueryParams): string {
|
||||
if (endpoint.startsWith('http')) {
|
||||
fullUrl = endpoint;
|
||||
} else {
|
||||
// 确保API_BASE_URL格式正确
|
||||
const baseUrl = API_BASE_URL.endsWith('/') ? API_BASE_URL.slice(0, -1) : API_BASE_URL;
|
||||
const path = endpoint.startsWith('/') ? endpoint : `/${endpoint}`;
|
||||
fullUrl = `${baseUrl}${path}`;
|
||||
// 处理相对路径的情况
|
||||
if (API_BASE_URL.value === '/api') {
|
||||
// 如果是相对路径,直接使用endpoint
|
||||
const path = endpoint.startsWith('/') ? endpoint : `/${endpoint}`;
|
||||
fullUrl = path;
|
||||
} else {
|
||||
// 确保API_BASE_URL格式正确
|
||||
const baseUrl = API_BASE_URL.value.endsWith('/') ? API_BASE_URL.value.slice(0, -1) : API_BASE_URL.value;
|
||||
const path = endpoint.startsWith('/') ? endpoint : `/${endpoint}`;
|
||||
fullUrl = `${baseUrl}${path}`;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -189,6 +199,8 @@ export async function apiRequest<T>(
|
||||
if (USE_MOCK_DATA) {
|
||||
return getMockResponse<T>(endpoint);
|
||||
}
|
||||
|
||||
console.log('api-base-url-----------',API_BASE_URL.value)
|
||||
|
||||
try {
|
||||
// 构建 URL
|
||||
@@ -387,4 +399,4 @@ export async function downloadFile(path: string): Promise<Blob> {
|
||||
console.error('下载文件失败:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ function extractApiData<T>(responseData: unknown): T | null {
|
||||
export interface SubmitOpinionRequest {
|
||||
reviewPointResultId: string | number;
|
||||
documentId: string | number;
|
||||
evaluationPointId: number; // 必须是数字ID
|
||||
evaluationPointId: number | null; // 必须是数字ID
|
||||
auditOpinion: string;
|
||||
deductionScore: number;
|
||||
}
|
||||
@@ -60,6 +60,7 @@ export interface CrossCheckingOpinion {
|
||||
problem_message: string;
|
||||
proposer_id: number;
|
||||
created_at: string;
|
||||
status: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,7 +133,7 @@ export async function submitCrossCheckingOpinion(
|
||||
evaluation_result_id: opinionData.reviewPointResultId
|
||||
};
|
||||
|
||||
const response = await fetch(`${API_BASE_URL}/admin/cross_review/proposals`, {
|
||||
const response = await fetch(`${API_BASE_URL.value}/admin/cross_review/proposals`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -188,7 +189,7 @@ export async function getCrossCheckingOpinions(
|
||||
// 如果没传userId,默认用1
|
||||
const realUserId = userId ?? 1;
|
||||
// 实际后端API调用,拼接API_BASE_URL
|
||||
const response = await fetch(`${API_BASE_URL}/admin/cross_review/proposals/document`, {
|
||||
const response = await fetch(`${API_BASE_URL.value}/admin/cross_review/proposals/document`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -225,6 +226,7 @@ export async function getCrossCheckingOpinions(
|
||||
problem_message?: string;
|
||||
proposer_id: number;
|
||||
created_at: string;
|
||||
status: string;
|
||||
}
|
||||
|
||||
// 适配后端返回结构,使用新字段
|
||||
@@ -241,7 +243,8 @@ export async function getCrossCheckingOpinions(
|
||||
can_vote: item.can_vote ?? false,
|
||||
problem_message: item.problem_message || '',
|
||||
proposer_id: item.proposer_id,
|
||||
created_at: item.created_at
|
||||
created_at: item.created_at,
|
||||
status: item.status
|
||||
})) : [];
|
||||
|
||||
return {
|
||||
@@ -300,24 +303,24 @@ export async function performOpinionAction(
|
||||
switch (actionData.action) {
|
||||
case 'agree':
|
||||
message = '已赞同该意见';
|
||||
endpoint = `${API_BASE_URL}/admin/cross_review/proposals/${actionData.opinionId}/votes`;
|
||||
endpoint = `${API_BASE_URL.value}/admin/cross_review/proposals/${actionData.opinionId}/votes`;
|
||||
requestBody = { vote_type: 'agree', voter_id: userInfo?.user_id };
|
||||
break;
|
||||
case 'disagree':
|
||||
message = '已反对该意见';
|
||||
endpoint = `${API_BASE_URL}/admin/cross_review/proposals/${actionData.opinionId}/votes`;
|
||||
endpoint = `${API_BASE_URL.value}/admin/cross_review/proposals/${actionData.opinionId}/votes`;
|
||||
requestBody = { vote_type: 'disagree', voter_id: userInfo?.user_id };
|
||||
break;
|
||||
case 'withdraw_vote':
|
||||
message = '已撤销投票';
|
||||
// 撤销投票的接口,根据实际API调整
|
||||
endpoint = `${API_BASE_URL}/admin/cross_review/proposals/${actionData.opinionId}/votes`;
|
||||
endpoint = `${API_BASE_URL.value}/admin/cross_review/proposals/${actionData.opinionId}/votes`;
|
||||
requestBody = { vote_type: 'cancel', voter_id: userInfo?.user_id };
|
||||
break;
|
||||
case 'withdraw_opinion':
|
||||
message = '已撤销意见';
|
||||
// 撤销意见的接口,根据实际API调整
|
||||
endpoint = `${API_BASE_URL}/admin/cross_review/proposals/${actionData.opinionId}`;
|
||||
endpoint = `${API_BASE_URL.value}/admin/cross_review/proposals/${actionData.opinionId}`;
|
||||
requestBody = {};
|
||||
break;
|
||||
default:
|
||||
@@ -412,7 +415,7 @@ export async function checkProposalVotes(
|
||||
document_id: documentId
|
||||
};
|
||||
|
||||
const response = await fetch(`${API_BASE_URL}/admin/cross_review/proposals/document/check_pending_votes`, {
|
||||
const response = await fetch(`${API_BASE_URL.value}/admin/cross_review/proposals/document/check_pending_votes`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
@@ -389,7 +389,7 @@ export async function getCrossCheckingStats(userInfo?: { user_id?: number; [key:
|
||||
export async function getUserTaskDocuments(page: number = 1, pageSize: number = 10, jwtToken?: string): Promise<ApiResponse<UserTaskApiResponse>> {
|
||||
try {
|
||||
// 拼接绝对路径,去除多余斜杠
|
||||
const base = API_BASE_URL.endsWith('/') ? API_BASE_URL.slice(0, -1) : API_BASE_URL;
|
||||
const base = API_BASE_URL.value.endsWith('/') ? API_BASE_URL.value.slice(0, -1) : API_BASE_URL.value;
|
||||
const url = `${base}/admin/cross_review/tasks/user_tasks`;
|
||||
|
||||
const response = await fetch(url, {
|
||||
@@ -436,7 +436,7 @@ export async function getUserTaskDocuments(page: number = 1, pageSize: number =
|
||||
export async function getTaskDocuments(taskId: number, page: number = 1, pageSize: number = 10, jwtToken?: string): Promise<ApiResponse<TaskDocumentApiResponse>> {
|
||||
try {
|
||||
// 拼接绝对路径,去除多余斜杠
|
||||
const base = API_BASE_URL.endsWith('/') ? API_BASE_URL.slice(0, -1) : API_BASE_URL;
|
||||
const base = API_BASE_URL.value.endsWith('/') ? API_BASE_URL.value.slice(0, -1) : API_BASE_URL.value;
|
||||
const url = `${base}/admin/cross_review/tasks/${taskId}/documents`;
|
||||
// console.log('最终请求URL:', url);
|
||||
|
||||
|
||||
@@ -324,7 +324,8 @@ export async function getReviewPoints(fileId: string, request: Request) {
|
||||
const scoringProposalsParams: PostgrestParams = {
|
||||
select: '*',
|
||||
filter: {
|
||||
'document_id': `eq.${fileId}`
|
||||
'document_id': `eq.${fileId}`,
|
||||
'deleted_at': `is.null`
|
||||
}
|
||||
};
|
||||
const scoringProposalsResponse = await postgrestGet('cross_scoring_proposals', scoringProposalsParams);
|
||||
|
||||
+12
-7
@@ -105,8 +105,8 @@ export async function getHomeData(reviewType?: string | null,userId?: string | n
|
||||
const startOfLastMonth = dayjs().subtract(1, 'month').startOf('month').format('YYYY-MM-DD HH:mm:ss');
|
||||
const endOfLastMonth = dayjs().subtract(1, 'month').endOf('month').format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
console.log('传入的 reviewType', reviewType);
|
||||
console.log('传入的 userId', userId);
|
||||
// console.log('传入的 reviewType', reviewType);
|
||||
// console.log('传入的 userId', userId);
|
||||
|
||||
// 基于 reviewType 构建类型过滤条件
|
||||
const typeFilter = buildTypeFilter(reviewType || null);
|
||||
@@ -181,7 +181,7 @@ export async function getHomeData(reviewType?: string | null,userId?: string | n
|
||||
select: 'count',
|
||||
filter: {
|
||||
and: `(audit_status.neq.0,audit_status.neq.2)`,
|
||||
updated_at: `gte.${startOfThisMonth}`,
|
||||
upload_time: `gte.${startOfThisMonth}`,
|
||||
is_test_document: `eq.false`,
|
||||
user_id: `eq.${userId}`
|
||||
}
|
||||
@@ -212,8 +212,8 @@ export async function getHomeData(reviewType?: string | null,userId?: string | n
|
||||
const lastMonthReviewedParams: PostgrestParams = {
|
||||
select: 'count',
|
||||
filter: {
|
||||
or: `(audit_status.eq.1,audit_status.eq.-1)`,
|
||||
and: `(updated_at.gte.${startOfLastMonth},updated_at.lte.${endOfLastMonth})`,
|
||||
// or: `(audit_status.eq.1,audit_status.eq.-1)`,
|
||||
and: `(upload_time.gte.${startOfLastMonth},upload_time.lte.${endOfLastMonth},audit_status.neq.0,audit_status.neq.2)`,
|
||||
is_test_document: `eq.false`,
|
||||
user_id: `eq.${userId}`
|
||||
}
|
||||
@@ -226,7 +226,7 @@ export async function getHomeData(reviewType?: string | null,userId?: string | n
|
||||
if (!lastMonthReviewedParams.filter) {
|
||||
lastMonthReviewedParams.filter = {};
|
||||
}
|
||||
lastMonthReviewedParams.filter.or = lastMonthReviewedParams.filter.or + ',' + typeFilter;
|
||||
lastMonthReviewedParams.filter.or = typeFilter;
|
||||
} else {
|
||||
const [field, op, value] = typeFilter.split('.');
|
||||
if (!lastMonthReviewedParams.filter) {
|
||||
@@ -243,6 +243,8 @@ export async function getHomeData(reviewType?: string | null,userId?: string | n
|
||||
);
|
||||
// 上月已审核文件数量
|
||||
const lastMonthReviewed = lastMonthReviewedCount[0]?.count || 0;
|
||||
// console.log('上月已审核文件查询参数', lastMonthReviewedParams);
|
||||
// console.log('上月已审核文件数量', lastMonthReviewed);
|
||||
|
||||
// 计算同比增长
|
||||
let reviewGrowthValue = 0;
|
||||
@@ -285,8 +287,11 @@ export async function getHomeData(reviewType?: string | null,userId?: string | n
|
||||
'获取本月审核通过数量失败',
|
||||
[]
|
||||
);
|
||||
// console.log('本月审核通过数量查询参数', thisMonthTotalParams);
|
||||
// 本月审核通过数量
|
||||
const thisMonthPassTotal = thisMonthTotalCount[0]?.count || 0;
|
||||
// console.log('本月审核通过数量', thisMonthPassTotal);
|
||||
// console.log('本月已审核文件数量', monthlyReviewedFiles);
|
||||
|
||||
// 本月审核通过率
|
||||
const monthlyPassRate = (thisMonthPassTotal > 0 && monthlyReviewedFiles > 0)
|
||||
@@ -298,7 +303,7 @@ export async function getHomeData(reviewType?: string | null,userId?: string | n
|
||||
select: 'count',
|
||||
filter: {
|
||||
audit_status: `eq.1`,
|
||||
and: `(updated_at.gte.${startOfLastMonth},updated_at.lte.${endOfLastMonth})`,
|
||||
and: `(upload_time.gte.${startOfLastMonth},upload_time.lte.${endOfLastMonth})`,
|
||||
is_test_document: `eq.false`,
|
||||
user_id: `eq.${userId}`
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ export class TokenManager {
|
||||
private oauthClient: OAuthClient;
|
||||
|
||||
constructor() {
|
||||
this.oauthClient = new OAuthClient(OAUTH_CONFIG);
|
||||
this.oauthClient = new OAuthClient(OAUTH_CONFIG.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,4 +151,4 @@ export class TokenManager {
|
||||
}
|
||||
|
||||
// 导出单例实例
|
||||
export const tokenManager = new TokenManager();
|
||||
export const tokenManager = new TokenManager();
|
||||
@@ -57,7 +57,7 @@ export async function getOrganizationTree(includeUsers: boolean = true, jwtToken
|
||||
|
||||
if (jwtToken) {
|
||||
// 如果提供了JWT Token,则使用fetch并携带Authorization头
|
||||
const url = `${API_BASE_URL}/admin/users/organizations?include_users=${includeUsers}`;
|
||||
const url = `${API_BASE_URL.value}/admin/users/organizations?include_users=${includeUsers}`;
|
||||
const response = await fetch(url, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${jwtToken}`,
|
||||
|
||||
Reference in New Issue
Block a user