Compare commits
2 Commits
a14a1f0ee1
...
5fc3a7a254
| Author | SHA1 | Date | |
|---|---|---|---|
| 5fc3a7a254 | |||
| add399e126 |
@@ -2,6 +2,19 @@ import { postgrestGet, postgrestPut } from "../postgrest-client";
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { API_BASE_URL } from '../../config/api-config';
|
import { API_BASE_URL } from '../../config/api-config';
|
||||||
|
|
||||||
|
interface ResultEnvelope<T> {
|
||||||
|
code?: number;
|
||||||
|
msg?: string;
|
||||||
|
data?: T;
|
||||||
|
}
|
||||||
|
|
||||||
|
function unwrapResultEnvelope<T>(payload: unknown): T {
|
||||||
|
if (payload && typeof payload === 'object' && 'data' in (payload as ResultEnvelope<T>)) {
|
||||||
|
return ((payload as ResultEnvelope<T>).data ?? null) as T;
|
||||||
|
}
|
||||||
|
return payload as T;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从不同格式的 API 响应中提取数据
|
* 从不同格式的 API 响应中提取数据
|
||||||
* @param responseData API 响应数据
|
* @param responseData API 响应数据
|
||||||
@@ -86,8 +99,7 @@ async function safeGetJWT(jwtToken?: string): Promise<string> {
|
|||||||
/**
|
/**
|
||||||
* 检查用户是否有权确认完成文档评查
|
* 检查用户是否有权确认完成文档评查
|
||||||
*
|
*
|
||||||
* 🔥 接口文档: auth_doc/交叉评查接口文档.md 接口11
|
* 📍 API地址: GET /api/v3/cross-review/tasks/{task_id}/can-confirm
|
||||||
* 📍 API地址: GET /api/v2/cross_review/tasks/{task_id}/can-confirm
|
|
||||||
*
|
*
|
||||||
* @param taskId 任务ID
|
* @param taskId 任务ID
|
||||||
* @param frontendJWT JWT token
|
* @param frontendJWT JWT token
|
||||||
@@ -100,10 +112,8 @@ export async function findIsProposer(taskId: string | number, userId: number | u
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 调用新的接口检查用户是否有权确认完成
|
const response = await axios.get<ResultEnvelope<{ canConfirm?: boolean; can_confirm?: boolean }>>(
|
||||||
// GET /api/v2/cross_review/tasks/{task_id}/can-confirm
|
`${API_BASE_URL}/api/v3/cross-review/tasks/${taskId}/can-confirm`,
|
||||||
const response = await axios.get(
|
|
||||||
`${API_BASE_URL}/api/v2/cross_review/tasks/${taskId}/can-confirm`,
|
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@@ -112,12 +122,8 @@ export async function findIsProposer(taskId: string | number, userId: number | u
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const data = response.data;
|
const data = response.data?.data || response.data;
|
||||||
// console.log('[findIsProposer] 检查权限响应:', data);
|
return data?.canConfirm === true || data?.can_confirm === true;
|
||||||
|
|
||||||
// 返回 can_confirm 字段,表示是否有权确认完成
|
|
||||||
// 有权限的用户:任务创建者(assigner_id) 或 主要负责人(principal_user_ids)
|
|
||||||
return data?.can_confirm === true;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[findIsProposer] 检查权限失败:', error);
|
console.error('[findIsProposer] 检查权限失败:', error);
|
||||||
|
|
||||||
@@ -147,26 +153,29 @@ export async function submitCrossCheckingOpinion(
|
|||||||
const token = await safeGetJWT(jwtToken);
|
const token = await safeGetJWT(jwtToken);
|
||||||
|
|
||||||
const requestData = {
|
const requestData = {
|
||||||
document_id: opinionData.documentId,
|
documentId: Number(opinionData.documentId),
|
||||||
evaluation_point_id: Number(opinionData.evaluationPointId), // 强制转数字
|
evaluationPointId: Number(opinionData.evaluationPointId),
|
||||||
proposed_score: opinionData.deductionScore,
|
deductionScore: opinionData.deductionScore,
|
||||||
reason: opinionData.auditOpinion,
|
auditOpinion: opinionData.auditOpinion,
|
||||||
proposer_id: userInfo?.user_id,
|
reviewPointResultId: Number(opinionData.reviewPointResultId)
|
||||||
evaluation_result_id: opinionData.reviewPointResultId
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await axios.post(`${API_BASE_URL}/api/v2/cross_review/proposals`, requestData, {
|
const response = await axios.post<ResultEnvelope<{ proposalId?: number; createdAt?: string }>>(`${API_BASE_URL}/api/v3/cross-review/proposals`, requestData, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization': `Bearer ${token}`
|
'Authorization': `Bearer ${token}`
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const data = unwrapResultEnvelope<{ proposalId?: number; createdAt?: string }>(response.data);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
success: true,
|
success: true,
|
||||||
message: '意见提交成功',
|
message: '意见提交成功',
|
||||||
data: response.data
|
data: {
|
||||||
|
id: data?.proposalId,
|
||||||
|
created_at: data?.createdAt || new Date().toISOString()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -213,64 +222,80 @@ export async function getCrossCheckingOpinions(
|
|||||||
// 如果没传userId,默认用1
|
// 如果没传userId,默认用1
|
||||||
const realUserId = userId ?? 1;
|
const realUserId = userId ?? 1;
|
||||||
// 实际后端API调用,拼接API_BASE_URL
|
// 实际后端API调用,拼接API_BASE_URL
|
||||||
const response = await axios.post(`${API_BASE_URL}/api/v2/cross_review/proposals/document`, {
|
const response = await axios.get<ResultEnvelope<{
|
||||||
// user_id: realUserId,
|
total: number;
|
||||||
document_id: documentId, // 如果后端需要document_id可以加上
|
page: number;
|
||||||
|
pageSize: number;
|
||||||
|
items: Array<{
|
||||||
|
proposalId: string | number;
|
||||||
|
evaluationPointName: string;
|
||||||
|
proposedScore: number;
|
||||||
|
reason: string;
|
||||||
|
proposer: string;
|
||||||
|
votes?: Array<{ voter: string; voteType: string }>;
|
||||||
|
agreeVoters?: string[];
|
||||||
|
disagreeVoters?: string[];
|
||||||
|
pendingVoters?: string[];
|
||||||
|
canVote?: boolean;
|
||||||
|
problemMessage?: string;
|
||||||
|
proposerId: number;
|
||||||
|
createdAt: string;
|
||||||
|
status: string;
|
||||||
|
}>;
|
||||||
|
}>>(`${API_BASE_URL}/api/v3/cross-review/documents/${documentId}/proposals`, {
|
||||||
|
params: {
|
||||||
page,
|
page,
|
||||||
page_size: pageSize
|
pageSize
|
||||||
}, {
|
},
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Authorization': `Bearer ${token}`
|
'Authorization': `Bearer ${token}`
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = response.data;
|
const pageData = unwrapResultEnvelope<{
|
||||||
// console.log('最原始的返回data', data);
|
total: number;
|
||||||
// 处理新的数据结构,支持分页
|
page: number;
|
||||||
const responseData = data.data || data;
|
pageSize: number;
|
||||||
const pagination = data.pagination;
|
items: Array<{
|
||||||
|
proposalId: string | number;
|
||||||
// 定义后端返回的数据项类型
|
evaluationPointName: string;
|
||||||
interface ProposalItem {
|
proposedScore: number;
|
||||||
proposal_id: string | number;
|
|
||||||
evaluation_point_name: string;
|
|
||||||
proposed_score: number;
|
|
||||||
reason: string;
|
reason: string;
|
||||||
proposer: string;
|
proposer: string;
|
||||||
votes?: Array<{ voter: string; vote_type: string }>;
|
votes?: Array<{ voter: string; voteType: string }>;
|
||||||
agree_voters?: string[];
|
agreeVoters?: string[];
|
||||||
disagree_voters?: string[];
|
disagreeVoters?: string[];
|
||||||
pending_voters?: string[];
|
pendingVoters?: string[];
|
||||||
can_vote?: boolean;
|
canVote?: boolean;
|
||||||
problem_message?: string;
|
problemMessage?: string;
|
||||||
proposer_id: number;
|
proposerId: number;
|
||||||
created_at: string;
|
createdAt: string;
|
||||||
status: string;
|
status: string;
|
||||||
}
|
}>;
|
||||||
|
}>(response.data);
|
||||||
|
|
||||||
// 适配后端返回结构,使用新字段
|
// 定义后端返回的数据项类型
|
||||||
const opinions: CrossCheckingOpinion[] = Array.isArray(responseData) ? responseData.map((item: ProposalItem) => ({
|
const opinions: CrossCheckingOpinion[] = Array.isArray(pageData?.items) ? pageData.items.map((item) => ({
|
||||||
proposal_id: item.proposal_id,
|
proposal_id: item.proposalId,
|
||||||
evaluation_point_name: item.evaluation_point_name,
|
evaluation_point_name: item.evaluationPointName,
|
||||||
proposed_score: item.proposed_score,
|
proposed_score: item.proposedScore,
|
||||||
reason: item.reason,
|
reason: item.reason,
|
||||||
proposer: item.proposer,
|
proposer: item.proposer,
|
||||||
votes: item.votes || [],
|
votes: (item.votes || []).map((vote) => ({ voter: vote.voter, vote_type: vote.voteType })),
|
||||||
agree_voters: item.agree_voters || [],
|
agree_voters: item.agreeVoters || [],
|
||||||
disagree_voters: item.disagree_voters || [],
|
disagree_voters: item.disagreeVoters || [],
|
||||||
pending_voters: item.pending_voters || [],
|
pending_voters: item.pendingVoters || [],
|
||||||
can_vote: item.can_vote ?? false,
|
can_vote: item.canVote ?? false,
|
||||||
problem_message: item.problem_message || '',
|
problem_message: item.problemMessage || '',
|
||||||
proposer_id: item.proposer_id,
|
proposer_id: item.proposerId,
|
||||||
created_at: item.created_at,
|
created_at: item.createdAt,
|
||||||
status: item.status
|
status: item.status
|
||||||
})) : [];
|
})) : [];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
opinions,
|
opinions,
|
||||||
total: pagination?.total || opinions.length
|
total: pageData?.total || opinions.length
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -335,31 +360,29 @@ export async function performOpinionAction(
|
|||||||
switch (actionData.action) {
|
switch (actionData.action) {
|
||||||
case 'agree':
|
case 'agree':
|
||||||
message = '已赞同该意见';
|
message = '已赞同该意见';
|
||||||
endpoint = `${API_BASE_URL}/api/v2/cross_review/proposals/${actionData.opinionId}/votes`;
|
endpoint = `${API_BASE_URL}/api/v3/cross-review/proposals/${actionData.opinionId}/votes`;
|
||||||
requestBody = { vote_type: 'agree', voter_id: userInfo?.user_id };
|
requestBody = { voteType: 'agree' };
|
||||||
break;
|
break;
|
||||||
case 'disagree':
|
case 'disagree':
|
||||||
message = '已反对该意见';
|
message = '已反对该意见';
|
||||||
endpoint = `${API_BASE_URL}/api/v2/cross_review/proposals/${actionData.opinionId}/votes`;
|
endpoint = `${API_BASE_URL}/api/v3/cross-review/proposals/${actionData.opinionId}/votes`;
|
||||||
requestBody = { vote_type: 'disagree', voter_id: userInfo?.user_id };
|
requestBody = { voteType: 'disagree' };
|
||||||
break;
|
break;
|
||||||
case 'withdraw_vote':
|
case 'withdraw_vote':
|
||||||
message = '已撤销投票';
|
message = '已撤销投票';
|
||||||
// 撤销投票的接口,根据实际API调整
|
endpoint = `${API_BASE_URL}/api/v3/cross-review/proposals/${actionData.opinionId}/votes`;
|
||||||
endpoint = `${API_BASE_URL}/api/v2/cross_review/proposals/${actionData.opinionId}/votes`;
|
requestBody = { voteType: 'cancel' };
|
||||||
requestBody = { vote_type: 'cancel', voter_id: userInfo?.user_id };
|
|
||||||
break;
|
break;
|
||||||
case 'withdraw_opinion':
|
case 'withdraw_opinion':
|
||||||
message = '已撤销意见';
|
message = '已撤销意见';
|
||||||
// 撤销意见的接口,根据实际API调整
|
endpoint = `${API_BASE_URL}/api/v3/cross-review/proposals/${actionData.opinionId}`;
|
||||||
endpoint = `${API_BASE_URL}/api/v2/cross_review/proposals/${actionData.opinionId}`;
|
|
||||||
requestBody = {};
|
requestBody = {};
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error('无效的操作类型');
|
throw new Error('无效的操作类型');
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = actionData.action === 'withdraw_opinion'
|
await (actionData.action === 'withdraw_opinion'
|
||||||
? await axios.delete(endpoint, {
|
? await axios.delete(endpoint, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@@ -371,11 +394,7 @@ export async function performOpinionAction(
|
|||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization': `Bearer ${token}`
|
'Authorization': `Bearer ${token}`
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
|
|
||||||
const data = response.data;
|
|
||||||
|
|
||||||
console.log('返回的意见列表数据',data);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
@@ -412,8 +431,7 @@ export async function performOpinionAction(
|
|||||||
* @param frontendJWT JWT token
|
* @param frontendJWT JWT token
|
||||||
* @returns 完成评查结果
|
* @returns 完成评查结果
|
||||||
*
|
*
|
||||||
* 🔥 接口文档: auth_doc/交叉评查接口文档(1).md 接口10
|
* 📍 API地址: POST /api/v3/cross-review/tasks/{task_id}/documents/{document_id}/complete
|
||||||
* 📍 API地址: POST /admin/v2/cross_review/tasks/{task_id}/documents/{document_id}/complete
|
|
||||||
*/
|
*/
|
||||||
export async function confirmReviewResults(
|
export async function confirmReviewResults(
|
||||||
taskId: string | number,
|
taskId: string | number,
|
||||||
@@ -428,10 +446,13 @@ export async function confirmReviewResults(
|
|||||||
return { error: '文档ID不能为空', status: 400 };
|
return { error: '文档ID不能为空', status: 400 };
|
||||||
}
|
}
|
||||||
|
|
||||||
// 调用后端API确认文档审核完成
|
const response = await axios.post<ResultEnvelope<{
|
||||||
// 接口: POST /admin/v2/cross_review/tasks/{task_id}/documents/{document_id}/complete
|
taskId?: number;
|
||||||
const response = await axios.post(
|
documentId?: number;
|
||||||
`${API_BASE_URL}/admin/v2/cross_review/tasks/${taskId}/documents/${documentId}/complete`,
|
taskStatus?: string;
|
||||||
|
auditStatus?: number;
|
||||||
|
}>>(
|
||||||
|
`${API_BASE_URL}/api/v3/cross-review/tasks/${taskId}/documents/${documentId}/complete`,
|
||||||
{}, // 无需请求体
|
{}, // 无需请求体
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
@@ -441,15 +462,16 @@ export async function confirmReviewResults(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const data = response.data;
|
const data = response.data?.data || response.data;
|
||||||
|
|
||||||
// 检查响应是否成功
|
if (data) {
|
||||||
if (data?.success || data?.code === 0) {
|
|
||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
task_id: data.task_id || taskId,
|
task_id: data.taskId || taskId,
|
||||||
document_id: data.document_id || documentId,
|
document_id: data.documentId || documentId,
|
||||||
message: data.message || '文档评查已完成'
|
task_status: data.taskStatus,
|
||||||
|
audit_status: data.auditStatus,
|
||||||
|
message: '文档评查已完成'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -457,7 +479,7 @@ export async function confirmReviewResults(
|
|||||||
// 数据为空或格式不正确
|
// 数据为空或格式不正确
|
||||||
console.error('❌ [confirmReviewResults] API响应数据异常:', data);
|
console.error('❌ [confirmReviewResults] API响应数据异常:', data);
|
||||||
return {
|
return {
|
||||||
error: data?.message || '确认文档审核失败',
|
error: '确认文档审核失败',
|
||||||
status: 500
|
status: 500
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -491,26 +513,30 @@ export async function checkProposalVotes(
|
|||||||
// 获取JWT token
|
// 获取JWT token
|
||||||
const token = await safeGetJWT(jwtToken);
|
const token = await safeGetJWT(jwtToken);
|
||||||
|
|
||||||
const requestData = {
|
const response = await axios.get<ResultEnvelope<{
|
||||||
document_id: documentId
|
hasPendingVotes?: boolean;
|
||||||
};
|
pendingProposals?: Array<{ evaluationPointName: string; pendingVotersNum: number }>;
|
||||||
|
}>>(`${API_BASE_URL}/api/v3/cross-review/documents/${documentId}/pending-votes`, {
|
||||||
const response = await axios.post(`${API_BASE_URL}/api/v2/cross_review/proposals/document/check_pending_votes`, requestData, {
|
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Authorization': `Bearer ${token}`
|
'Authorization': `Bearer ${token}`
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = response.data;
|
const data = unwrapResultEnvelope<{
|
||||||
|
hasPendingVotes?: boolean;
|
||||||
console.log("检查投票数据",data);
|
pendingProposals?: Array<{ evaluationPointName: string; pendingVotersNum: number }>;
|
||||||
|
}>(response.data);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
success: true,
|
success: true,
|
||||||
message: '检查成功',
|
message: '检查成功',
|
||||||
data: data
|
data: {
|
||||||
|
pending_proposals: (data?.pendingProposals || []).map((item) => ({
|
||||||
|
evaluation_point_name: item.evaluationPointName,
|
||||||
|
pending_voters_num: item.pendingVotersNum
|
||||||
|
}))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -533,4 +559,3 @@ export async function checkProposalVotes(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -199,19 +199,13 @@ export async function uploadCrossCheckingDocument(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量上传并自动分配交叉评查任务(新接口适配)
|
* 旧的一体化“上传并分配任务”接口适配。
|
||||||
* @param files 文件列表
|
*
|
||||||
* @param typeId 文档类型ID
|
* 现在创建交叉评查任务已改为:
|
||||||
* @param priority 优先级
|
* 1. 先上传文档
|
||||||
* @param documentNumber 文档编号
|
* 2. 再调用 `createCrossReviewTask()` 创建 v3 任务
|
||||||
* @param remark 备注
|
*
|
||||||
* @param isTestDocument 是否为测试文档
|
* 这里先保留兼容实现,避免影响可能的旧调用方。
|
||||||
* @param assignUserIds 需要分配的用户ID数组
|
|
||||||
* @param taskName 任务名称
|
|
||||||
* @param docType 文档类型(如 XZCF、XZXK)
|
|
||||||
* @param taskType 任务类型(如 市局间交叉评查、区局间交叉评查)
|
|
||||||
* @param token JWT Token
|
|
||||||
* @param principalUserIds 负责人ID数组(包含主要负责人和额外负责人)
|
|
||||||
*/
|
*/
|
||||||
export async function batchUploadAndAssignCrossCheckingFiles(
|
export async function batchUploadAndAssignCrossCheckingFiles(
|
||||||
files: CrossCheckingUploadedFile[],
|
files: CrossCheckingUploadedFile[],
|
||||||
@@ -286,16 +280,15 @@ export async function batchUploadAndAssignCrossCheckingFiles(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建交叉评查任务
|
* 创建交叉评查任务(v3)。
|
||||||
* @param taskData 任务数据
|
* 先由前端完成文档上传,再将上传成功后的 documentIds 挂到任务上。
|
||||||
* @param token JWT Token
|
|
||||||
* @returns 创建结果
|
|
||||||
*/
|
*/
|
||||||
export async function createCrossReviewTask(taskData: {
|
export async function createCrossReviewTask(taskData: {
|
||||||
documentIds: number[];
|
documentIds: number[];
|
||||||
userIds: number[];
|
userIds: number[];
|
||||||
assignerId: number;
|
principalUserIds?: number[];
|
||||||
taskName: string;
|
taskName: string;
|
||||||
|
docTypeId?: number;
|
||||||
docType: string;
|
docType: string;
|
||||||
taskType?: string;
|
taskType?: string;
|
||||||
}, token: string | null = null): Promise<{
|
}, token: string | null = null): Promise<{
|
||||||
@@ -305,12 +298,13 @@ export async function createCrossReviewTask(taskData: {
|
|||||||
}> {
|
}> {
|
||||||
try {
|
try {
|
||||||
const requestBody = {
|
const requestBody = {
|
||||||
document_ids: taskData.documentIds,
|
documentIds: taskData.documentIds,
|
||||||
user_ids: taskData.userIds,
|
memberUserIds: taskData.userIds,
|
||||||
assigner_id: taskData.assignerId,
|
principalUserIds: taskData.principalUserIds || [],
|
||||||
task_name: taskData.taskName,
|
taskName: taskData.taskName,
|
||||||
doc_type: taskData.docType,
|
docTypeId: taskData.docTypeId,
|
||||||
task_type: taskData.taskType || '市局间交叉评查'
|
docTypeCode: taskData.docType,
|
||||||
|
taskType: taskData.taskType || 'CITY'
|
||||||
};
|
};
|
||||||
|
|
||||||
// console.log('[创建任务] 请求数据:', requestBody);
|
// console.log('[创建任务] 请求数据:', requestBody);
|
||||||
@@ -323,7 +317,7 @@ export async function createCrossReviewTask(taskData: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const response = await axios.post(
|
const response = await axios.post(
|
||||||
`${API_BASE_URL}/admin/cross_review/tasks/assign`,
|
`${API_BASE_URL}/api/v3/cross-review/tasks`,
|
||||||
requestBody,
|
requestBody,
|
||||||
{ headers }
|
{ headers }
|
||||||
);
|
);
|
||||||
@@ -376,7 +370,7 @@ export function formatFileSize(bytes: number): string {
|
|||||||
/**
|
/**
|
||||||
* 向已有任务上传新文档
|
* 向已有任务上传新文档
|
||||||
*
|
*
|
||||||
* POST /api/v2/cross_review/tasks/{task_id}/upload_documents
|
* POST /api/v3/cross-review/tasks/{task_id}/documents/upload
|
||||||
*
|
*
|
||||||
* @param params 上传参数
|
* @param params 上传参数
|
||||||
* @returns 上传结果
|
* @returns 上传结果
|
||||||
@@ -396,10 +390,9 @@ export async function uploadDocumentToTask(params: {
|
|||||||
console.log('[上传文档到任务] 开始上传:', { taskId, fileName: file.name });
|
console.log('[上传文档到任务] 开始上传:', { taskId, fileName: file.name });
|
||||||
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
// 添加文件(使用 files 字段名)
|
formData.append('file', file, file.name);
|
||||||
formData.append('files', file, file.name);
|
|
||||||
|
|
||||||
const uploadEndpoint = `/api/v2/cross_review/tasks/${taskId}/upload_documents`;
|
const uploadEndpoint = `/api/v3/cross-review/tasks/${taskId}/documents/upload`;
|
||||||
const uploadUrl = API_BASE_URL + uploadEndpoint;
|
const uploadUrl = API_BASE_URL + uploadEndpoint;
|
||||||
|
|
||||||
const headers: Record<string, string> = {};
|
const headers: Record<string, string> = {};
|
||||||
@@ -410,10 +403,9 @@ export async function uploadDocumentToTask(params: {
|
|||||||
const response = await axios.post(uploadUrl, formData, { headers });
|
const response = await axios.post(uploadUrl, formData, { headers });
|
||||||
const result = response.data;
|
const result = response.data;
|
||||||
|
|
||||||
// 新接口响应格式: { code: 0, success: true, message: "...", data: {...} }
|
|
||||||
if (result && (result.success || result.code === 0)) {
|
if (result && (result.success || result.code === 0)) {
|
||||||
console.log('[上传文档到任务] 上传成功:', result.message);
|
console.log('[上传文档到任务] 上传成功:', result.message);
|
||||||
return { success: true, data: result.data };
|
return { success: true, data: result.data || result };
|
||||||
} else {
|
} else {
|
||||||
console.error('[上传文档到任务] 上传失败:', result.detail || result.message);
|
console.error('[上传文档到任务] 上传失败:', result.detail || result.message);
|
||||||
return { success: false, error: result.detail || result.message || '上传失败' };
|
return { success: false, error: result.detail || result.message || '上传失败' };
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ export interface UserTaskApiResponse {
|
|||||||
items: UserTaskInfo[];
|
items: UserTaskInfo[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 任务文档接口类型定义(旧版,保留兼容)
|
// 任务文档接口类型定义(任务详情页兼容结构)
|
||||||
export interface TaskDocument {
|
export interface TaskDocument {
|
||||||
document_id: number;
|
document_id: number;
|
||||||
file_name: string;
|
file_name: string;
|
||||||
@@ -289,6 +289,156 @@ export interface ApiResponse<T> {
|
|||||||
status?: number;
|
status?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ResultEnvelope<T> {
|
||||||
|
code?: number;
|
||||||
|
msg?: string;
|
||||||
|
data?: T;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface V3UserTaskItem {
|
||||||
|
taskId: number;
|
||||||
|
taskName: string;
|
||||||
|
taskType: string;
|
||||||
|
docTypeId?: number | null;
|
||||||
|
docTypeCode?: string | null;
|
||||||
|
status: string;
|
||||||
|
progress?: number;
|
||||||
|
totalDocuments?: number;
|
||||||
|
completedDocuments?: number;
|
||||||
|
createdAt?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface V3UserTaskPage {
|
||||||
|
total: number;
|
||||||
|
page: number;
|
||||||
|
pageSize: number;
|
||||||
|
items: V3UserTaskItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface V3TaskDocumentItem {
|
||||||
|
documentId: number;
|
||||||
|
name: string;
|
||||||
|
documentNumber?: string | null;
|
||||||
|
typeId?: number | null;
|
||||||
|
processingStatus?: string | null;
|
||||||
|
versionNo?: number;
|
||||||
|
isLatestVersion?: boolean;
|
||||||
|
auditStatus?: number;
|
||||||
|
createdAt?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface V3TaskDocumentPage {
|
||||||
|
taskId: number;
|
||||||
|
total: number;
|
||||||
|
page: number;
|
||||||
|
pageSize: number;
|
||||||
|
items: V3TaskDocumentItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
function unwrapResultEnvelope<T>(payload: unknown): T {
|
||||||
|
if (payload && typeof payload === 'object' && 'data' in (payload as ResultEnvelope<T>)) {
|
||||||
|
return ((payload as ResultEnvelope<T>).data ?? null) as T;
|
||||||
|
}
|
||||||
|
return payload as T;
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapProcessingStatus(status?: string | null): CrossReviewDocumentWithVersion['status'] {
|
||||||
|
switch (status) {
|
||||||
|
case 'processed':
|
||||||
|
case 'Processed':
|
||||||
|
return 'Processed';
|
||||||
|
case 'failed':
|
||||||
|
case 'Failed':
|
||||||
|
return 'Failed';
|
||||||
|
case 'cutting':
|
||||||
|
case 'Cutting':
|
||||||
|
return 'Cutting';
|
||||||
|
case 'extracting':
|
||||||
|
case 'Extractioning':
|
||||||
|
return 'Extractioning';
|
||||||
|
case 'evaluating':
|
||||||
|
case 'Evaluationing':
|
||||||
|
return 'Evaluationing';
|
||||||
|
case 'waiting':
|
||||||
|
case 'Waiting':
|
||||||
|
default:
|
||||||
|
return 'Waiting';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapV3TaskToUserTaskInfo(item: V3UserTaskItem): UserTaskInfo {
|
||||||
|
return {
|
||||||
|
task_id: item.taskId,
|
||||||
|
task_name: item.taskName,
|
||||||
|
task_status: item.status,
|
||||||
|
doc_type: item.docTypeCode || undefined,
|
||||||
|
task_created_at: item.createdAt,
|
||||||
|
task_type: item.taskType,
|
||||||
|
progress: item.progress,
|
||||||
|
total_documents: item.totalDocuments
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapV3DocumentToTaskDocument(item: V3TaskDocumentItem): TaskDocument {
|
||||||
|
return {
|
||||||
|
document_id: item.documentId,
|
||||||
|
file_name: item.name || '',
|
||||||
|
status: mapProcessingStatus(item.processingStatus),
|
||||||
|
path: '',
|
||||||
|
file_code: item.documentNumber || '',
|
||||||
|
file_type_name: item.typeId ? `类型${item.typeId}` : '',
|
||||||
|
file_type_id: item.typeId || 0,
|
||||||
|
file_size: 0,
|
||||||
|
upload_time: item.createdAt || '',
|
||||||
|
created_at: item.createdAt || '',
|
||||||
|
evaluations_status: 0,
|
||||||
|
audit_status: item.auditStatus || 0,
|
||||||
|
created_by_user_id: 0,
|
||||||
|
issues: [],
|
||||||
|
final_score: 0,
|
||||||
|
score_summary: '',
|
||||||
|
score_percent: null,
|
||||||
|
pass_count: 0,
|
||||||
|
warning_count: 0,
|
||||||
|
fail_count: 0,
|
||||||
|
manual_count: 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapV3DocumentToVersionedDocument(item: V3TaskDocumentItem): CrossReviewDocumentWithVersion {
|
||||||
|
const typeName = item.typeId ? `类型${item.typeId}` : '未知类型';
|
||||||
|
return {
|
||||||
|
id: item.documentId,
|
||||||
|
name: item.name || '',
|
||||||
|
path: '',
|
||||||
|
version_number: item.versionNo || 1,
|
||||||
|
created_at: item.createdAt || '',
|
||||||
|
status: mapProcessingStatus(item.processingStatus),
|
||||||
|
file_size: 0,
|
||||||
|
document_number: item.documentNumber || null,
|
||||||
|
type_id: item.typeId || 0,
|
||||||
|
type_name: typeName,
|
||||||
|
upload_time: item.createdAt || '',
|
||||||
|
audit_status: (item.auditStatus || 0) as 0 | 1,
|
||||||
|
total_evaluation_points: 0,
|
||||||
|
pass_count: 0,
|
||||||
|
warning_count: 0,
|
||||||
|
error_count: 0,
|
||||||
|
manual_count: 0,
|
||||||
|
issue_count: 0,
|
||||||
|
warning_messages: [],
|
||||||
|
error_messages: [],
|
||||||
|
issue_messages: [],
|
||||||
|
manual_messages: [],
|
||||||
|
final_score: 0,
|
||||||
|
full_score: 100,
|
||||||
|
score_summary: '',
|
||||||
|
score_percent: 0,
|
||||||
|
total_versions: 1,
|
||||||
|
history_versions: []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// 任务列表查询参数
|
// 任务列表查询参数
|
||||||
export interface TaskListParams {
|
export interface TaskListParams {
|
||||||
page?: number;
|
page?: number;
|
||||||
@@ -321,10 +471,7 @@ export interface TaskListResponse {
|
|||||||
*/
|
*/
|
||||||
export async function getCrossCheckingTasks(params: TaskListParams = {}, userInfo?: { user_id?: number; [key: string]: unknown }, jwtToken?: string): Promise<ApiResponse<TaskListResponse>> {
|
export async function getCrossCheckingTasks(params: TaskListParams = {}, userInfo?: { user_id?: number; [key: string]: unknown }, jwtToken?: string): Promise<ApiResponse<TaskListResponse>> {
|
||||||
try {
|
try {
|
||||||
// console.log('开始调用getCrossCheckingTasks,参数:', params);
|
const userTasksResponse = await getUserTaskDocuments(params, jwtToken);
|
||||||
|
|
||||||
// 调用用户任务API,获取当前用户参与的任务
|
|
||||||
const userTasksResponse = await getUserTaskDocuments(params.page || 1, params.pageSize || 10, jwtToken);
|
|
||||||
|
|
||||||
// console.log('getUserTaskDocuments响应:', JSON.stringify(userTasksResponse,null,2));
|
// console.log('getUserTaskDocuments响应:', JSON.stringify(userTasksResponse,null,2));
|
||||||
|
|
||||||
@@ -347,7 +494,7 @@ export async function getCrossCheckingTasks(params: TaskListParams = {}, userInf
|
|||||||
startDate: userTask.task_created_at ? new Date(userTask.task_created_at).toISOString().split('T')[0] : new Date().toISOString().split('T')[0],
|
startDate: userTask.task_created_at ? new Date(userTask.task_created_at).toISOString().split('T')[0] : new Date().toISOString().split('T')[0],
|
||||||
taskType: userTask.task_type, // 保持默认任务类型
|
taskType: userTask.task_type, // 保持默认任务类型
|
||||||
docType: userTask.doc_type || '未知类型', // 使用API返回的文档类型
|
docType: userTask.doc_type || '未知类型', // 使用API返回的文档类型
|
||||||
evaluationRegion: userTask.evaluation_region || [], // 保持默认评查地区
|
evaluationRegion: userTask.evaluation_region || [],
|
||||||
progress: userTask.progress || 0, // 使用API返回的进度
|
progress: userTask.progress || 0, // 使用API返回的进度
|
||||||
status: userTask.task_status || 'pending', // 使用API返回的任务状态
|
status: userTask.task_status || 'pending', // 使用API返回的任务状态
|
||||||
score: userTask.task_status === 'completed' ? 85 : 0, // 默认分数
|
score: userTask.task_status === 'completed' ? 85 : 0, // 默认分数
|
||||||
@@ -391,7 +538,7 @@ export async function getCrossCheckingTasks(params: TaskListParams = {}, userInf
|
|||||||
const lowerKeyword = keyword.toLowerCase();
|
const lowerKeyword = keyword.toLowerCase();
|
||||||
filteredTasks = filteredTasks.filter(task =>
|
filteredTasks = filteredTasks.filter(task =>
|
||||||
task.taskName.toLowerCase().includes(lowerKeyword) ||
|
task.taskName.toLowerCase().includes(lowerKeyword) ||
|
||||||
task.evaluationRegion.toLowerCase().includes(lowerKeyword)
|
task.evaluationRegion.join(',').toLowerCase().includes(lowerKeyword)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -525,7 +672,7 @@ export async function getCrossCheckingStats(userInfo?: { user_id?: number; [key:
|
|||||||
console.log('开始调用getCrossCheckingStats');
|
console.log('开始调用getCrossCheckingStats');
|
||||||
|
|
||||||
// 获取用户任务数据来计算统计(默认获取第一页数据进行统计)
|
// 获取用户任务数据来计算统计(默认获取第一页数据进行统计)
|
||||||
const userTasksResponse = await getUserTaskDocuments(1, 100, jwtToken); // 获取前100个任务用于统计
|
const userTasksResponse = await getUserTaskDocuments({ page: 1, pageSize: 100 }, jwtToken);
|
||||||
|
|
||||||
if (!userTasksResponse.success || !userTasksResponse.data) {
|
if (!userTasksResponse.success || !userTasksResponse.data) {
|
||||||
console.error('获取用户任务失败:', userTasksResponse.error);
|
console.error('获取用户任务失败:', userTasksResponse.error);
|
||||||
@@ -568,25 +715,49 @@ export async function getCrossCheckingStats(userInfo?: { user_id?: number; [key:
|
|||||||
* @param jwtToken JWT token
|
* @param jwtToken JWT token
|
||||||
* @returns 用户任务列表
|
* @returns 用户任务列表
|
||||||
*/
|
*/
|
||||||
export async function getUserTaskDocuments(page: number = 1, pageSize: number = 10, jwtToken?: string): Promise<ApiResponse<UserTaskApiResponse>> {
|
export async function getUserTaskDocuments(params: TaskListParams = {}, jwtToken?: string): Promise<ApiResponse<UserTaskApiResponse>> {
|
||||||
try {
|
try {
|
||||||
// 拼接绝对路径,去除多余斜杠
|
|
||||||
const base = API_BASE_URL.endsWith('/') ? API_BASE_URL.slice(0, -1) : API_BASE_URL;
|
const base = API_BASE_URL.endsWith('/') ? API_BASE_URL.slice(0, -1) : API_BASE_URL;
|
||||||
const url = `${base}/admin/v2/cross_review/tasks/user_tasks`;
|
const url = `${base}/api/v3/cross-review/tasks/query`;
|
||||||
|
|
||||||
const response = await axios.post(url, {
|
const page = params.page || 1;
|
||||||
page: page,
|
const pageSize = params.pageSize || 10;
|
||||||
page_size: pageSize
|
const requestBody: Record<string, unknown> = {
|
||||||
}, {
|
page,
|
||||||
|
pageSize
|
||||||
|
};
|
||||||
|
|
||||||
|
if (params.keyword?.trim()) {
|
||||||
|
requestBody.keyword = params.keyword.trim();
|
||||||
|
}
|
||||||
|
if (params.status && params.status !== 'all') {
|
||||||
|
requestBody.status = params.status;
|
||||||
|
}
|
||||||
|
if (params.taskType && params.taskType !== 'all') {
|
||||||
|
requestBody.taskType = params.taskType;
|
||||||
|
}
|
||||||
|
if (params.docType && params.docType !== 'all') {
|
||||||
|
requestBody.docTypeCode = params.docType;
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await axios.post<ResultEnvelope<V3UserTaskPage>>(url, requestBody, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization': `Bearer ${jwtToken || ''}`
|
'Authorization': `Bearer ${jwtToken || ''}`
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const pageData = unwrapResultEnvelope<V3UserTaskPage>(response.data);
|
||||||
|
const items = Array.isArray(pageData?.items) ? pageData.items.map(mapV3TaskToUserTaskInfo) : [];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
data: response.data
|
data: {
|
||||||
|
total: pageData?.total || 0,
|
||||||
|
page: pageData?.page || page,
|
||||||
|
page_size: pageData?.pageSize || pageSize,
|
||||||
|
items
|
||||||
|
}
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (axios.isAxiosError(error)) {
|
if (axios.isAxiosError(error)) {
|
||||||
@@ -603,7 +774,7 @@ export async function getUserTaskDocuments(page: number = 1, pageSize: number =
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取指定任务的文档列表(旧版接口,保留兼容)
|
* 获取指定任务的文档列表(兼容任务详情使用)
|
||||||
* @param taskId 任务ID
|
* @param taskId 任务ID
|
||||||
* @param page 页码
|
* @param page 页码
|
||||||
* @param pageSize 每页大小
|
* @param pageSize 每页大小
|
||||||
@@ -612,24 +783,30 @@ 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>> {
|
export async function getTaskDocuments(taskId: number, page: number = 1, pageSize: number = 10, jwtToken?: string): Promise<ApiResponse<TaskDocumentApiResponse>> {
|
||||||
try {
|
try {
|
||||||
// 拼接绝对路径,去除多余斜杠
|
|
||||||
const base = API_BASE_URL.endsWith('/') ? API_BASE_URL.slice(0, -1) : API_BASE_URL;
|
const base = API_BASE_URL.endsWith('/') ? API_BASE_URL.slice(0, -1) : API_BASE_URL;
|
||||||
const url = `${base}/admin/v2/cross_review/tasks/${taskId}/documents`;
|
const url = `${base}/api/v3/cross-review/tasks/${taskId}/documents`;
|
||||||
// console.log('最终请求URL:', url);
|
|
||||||
|
|
||||||
const response = await axios.post(url, {
|
const response = await axios.get<ResultEnvelope<V3TaskDocumentPage>>(url, {
|
||||||
page: page,
|
params: {
|
||||||
page_size: pageSize
|
page,
|
||||||
}, {
|
pageSize
|
||||||
|
},
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Authorization': `Bearer ${jwtToken || ''}`
|
'Authorization': `Bearer ${jwtToken || ''}`
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const pageData = unwrapResultEnvelope<V3TaskDocumentPage>(response.data);
|
||||||
|
const items = Array.isArray(pageData?.items) ? pageData.items.map(mapV3DocumentToTaskDocument) : [];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
data: response.data
|
data: {
|
||||||
|
total: pageData?.total || 0,
|
||||||
|
page: pageData?.page || page,
|
||||||
|
page_size: pageData?.pageSize || pageSize,
|
||||||
|
items
|
||||||
|
}
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (axios.isAxiosError(error)) {
|
if (axios.isAxiosError(error)) {
|
||||||
@@ -646,9 +823,9 @@ export async function getTaskDocuments(taskId: number, page: number = 1, pageSiz
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取任务下文档列表(支持版本归纳)- 新版接口
|
* 获取任务下文档列表(支持版本归纳)
|
||||||
*
|
*
|
||||||
* POST /api/v2/cross_review/tasks/{task_id}/documents
|
* GET /api/v3/cross-review/tasks/{task_id}/documents
|
||||||
*
|
*
|
||||||
* 同一任务内同名且同类型的文档会被归纳为版本组,最新上传的为当前版本,其余为历史版本。
|
* 同一任务内同名且同类型的文档会被归纳为版本组,最新上传的为当前版本,其余为历史版本。
|
||||||
*
|
*
|
||||||
@@ -661,18 +838,16 @@ export async function getTaskDocumentsWithVersions(
|
|||||||
const { taskId, page = 1, pageSize = 10, keyword, jwtToken } = params;
|
const { taskId, page = 1, pageSize = 10, keyword, jwtToken } = params;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 拼接绝对路径,去除多余斜杠
|
|
||||||
const base = API_BASE_URL.endsWith('/') ? API_BASE_URL.slice(0, -1) : API_BASE_URL;
|
const base = API_BASE_URL.endsWith('/') ? API_BASE_URL.slice(0, -1) : API_BASE_URL;
|
||||||
const url = `${base}/api/v2/cross_review/tasks/${taskId}/documents`;
|
const url = `${base}/api/v3/cross-review/tasks/${taskId}/documents`;
|
||||||
|
|
||||||
// 构建请求体
|
|
||||||
const queryParams: {
|
const queryParams: {
|
||||||
page: number;
|
page: number;
|
||||||
page_size: number;
|
pageSize: number;
|
||||||
keyword?: string;
|
keyword?: string;
|
||||||
} = {
|
} = {
|
||||||
page,
|
page,
|
||||||
page_size: pageSize
|
pageSize
|
||||||
};
|
};
|
||||||
|
|
||||||
// 只有当 keyword 有值时才添加
|
// 只有当 keyword 有值时才添加
|
||||||
@@ -680,16 +855,25 @@ export async function getTaskDocumentsWithVersions(
|
|||||||
queryParams.keyword = keyword.trim();
|
queryParams.keyword = keyword.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await axios.get<CrossReviewDocumentListResponse>(url, {
|
const response = await axios.get<ResultEnvelope<V3TaskDocumentPage>>(url, {
|
||||||
params: queryParams,
|
params: queryParams,
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': `Bearer ${jwtToken || ''}`
|
'Authorization': `Bearer ${jwtToken || ''}`
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const pageData = unwrapResultEnvelope<V3TaskDocumentPage>(response.data);
|
||||||
|
const documents = Array.isArray(pageData?.items) ? pageData.items.map(mapV3DocumentToVersionedDocument) : [];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
data: response.data
|
data: {
|
||||||
|
total: pageData?.total || 0,
|
||||||
|
page: pageData?.page || page,
|
||||||
|
page_size: pageData?.pageSize || pageSize,
|
||||||
|
total_pages: Math.ceil((pageData?.total || 0) / (pageData?.pageSize || pageSize || 1)),
|
||||||
|
documents
|
||||||
|
}
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (axios.isAxiosError(error)) {
|
if (axios.isAxiosError(error)) {
|
||||||
|
|||||||
@@ -25,15 +25,18 @@ interface ReviewTabsProps {
|
|||||||
auditStatus?: number;
|
auditStatus?: number;
|
||||||
type?: string;
|
type?: string;
|
||||||
comparisonId?: number;
|
comparisonId?: number;
|
||||||
|
backTo?: string;
|
||||||
};
|
};
|
||||||
onConfirmResults: () => void;
|
onConfirmResults: () => void;
|
||||||
onExportReport?: () => void;
|
onExportReport?: () => void;
|
||||||
jwtToken?: string | null;
|
jwtToken?: string | null;
|
||||||
|
showConfirmButton?: boolean;
|
||||||
|
showCompareTab?: boolean;
|
||||||
/** 下载前保存文档的回调,返回 true 表示保存成功可以继续下载 */
|
/** 下载前保存文档的回调,返回 true 表示保存成功可以继续下载 */
|
||||||
onSaveBeforeDownload?: () => Promise<boolean>;
|
onSaveBeforeDownload?: () => Promise<boolean>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ReviewTabs({ activeTab, onTabChange, children, fileInfo, onConfirmResults, onExportReport, jwtToken, onSaveBeforeDownload }: ReviewTabsProps) {
|
export function ReviewTabs({ activeTab, onTabChange, children, fileInfo, onConfirmResults, onExportReport, jwtToken, showConfirmButton = true, showCompareTab = true, onSaveBeforeDownload }: ReviewTabsProps) {
|
||||||
const [isNavigating, setIsNavigating] = useState(false);
|
const [isNavigating, setIsNavigating] = useState(false);
|
||||||
const [isReuploadModalOpen, setIsReuploadModalOpen] = useState(false);
|
const [isReuploadModalOpen, setIsReuploadModalOpen] = useState(false);
|
||||||
const [selectedTemplateFiles, setSelectedTemplateFiles] = useState<File[]>([]);
|
const [selectedTemplateFiles, setSelectedTemplateFiles] = useState<File[]>([]);
|
||||||
@@ -54,11 +57,15 @@ export function ReviewTabs({ activeTab, onTabChange, children, fileInfo, onConfi
|
|||||||
|
|
||||||
// 根据来源页面返回
|
// 根据来源页面返回
|
||||||
const previousRoute = fileInfo.previousRoute || 'documents';
|
const previousRoute = fileInfo.previousRoute || 'documents';
|
||||||
const returnTo = previousRoute === 'documents'
|
const returnTo = fileInfo.backTo || (
|
||||||
|
previousRoute === 'documents'
|
||||||
? "/documents/list"
|
? "/documents/list"
|
||||||
: previousRoute === 'filesUpload'
|
: previousRoute === 'filesUpload'
|
||||||
? "/files/upload"
|
? "/files/upload"
|
||||||
: "/rules-files";
|
: previousRoute === 'crossChecking'
|
||||||
|
? "/cross-checking"
|
||||||
|
: "/rules-files"
|
||||||
|
);
|
||||||
navigate(returnTo);
|
navigate(returnTo);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
revalidator.revalidate();
|
revalidator.revalidate();
|
||||||
@@ -266,7 +273,7 @@ export function ReviewTabs({ activeTab, onTabChange, children, fileInfo, onConfi
|
|||||||
>
|
>
|
||||||
<i className="ri-lightbulb-line"></i> AI智能分析
|
<i className="ri-lightbulb-line"></i> AI智能分析
|
||||||
</button> */}
|
</button> */}
|
||||||
{fileInfo.type?.toString().includes('1') && (
|
{showCompareTab && fileInfo.type?.toString().includes('1') && (
|
||||||
<button
|
<button
|
||||||
className={`tab-nav-item ${activeTab === 'filecompare' ? 'active' : ''}`}
|
className={`tab-nav-item ${activeTab === 'filecompare' ? 'active' : ''}`}
|
||||||
onClick={() => onTabChange('filecompare')}
|
onClick={() => onTabChange('filecompare')}
|
||||||
@@ -328,12 +335,22 @@ export function ReviewTabs({ activeTab, onTabChange, children, fileInfo, onConfi
|
|||||||
<i className="ri-file-copy-line mr-1"></i> 导出评查报告
|
<i className="ri-file-copy-line mr-1"></i> 导出评查报告
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
{showConfirmButton && (
|
||||||
<button
|
<button
|
||||||
className={`ant-btn ant-btn-primary my-2 flex items-center ${fileInfo.auditStatus === 1 ? 'hidden' : ''}`}
|
className={`ant-btn ant-btn-primary my-2 flex items-center ${fileInfo.auditStatus === 1 ? 'hidden' : ''}`}
|
||||||
onClick={onConfirmResults}
|
onClick={onConfirmResults}
|
||||||
>
|
>
|
||||||
<i className="ri-check-double-line mr-1"></i> 确认评查结果
|
<i className="ri-check-double-line mr-1"></i> 确认评查结果
|
||||||
</button>
|
</button>
|
||||||
|
)}
|
||||||
|
{showConfirmButton && (
|
||||||
|
<button
|
||||||
|
className={`ant-btn ant-btn-primary my-2 flex items-center ${fileInfo.auditStatus === 1 ? 'hidden' : ''}`}
|
||||||
|
onClick={onConfirmResults}
|
||||||
|
>
|
||||||
|
<i className="ri-check-double-line mr-1"></i> 确认评查结果
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -25,24 +25,26 @@
|
|||||||
import { type MetaFunction, type LoaderFunctionArgs, type ActionFunctionArgs } from "@remix-run/node";
|
import { type MetaFunction, type LoaderFunctionArgs, type ActionFunctionArgs } from "@remix-run/node";
|
||||||
import React, { useState, useEffect, useCallback, useRef, useMemo } from "react";
|
import React, { useState, useEffect, useCallback, useRef, useMemo } from "react";
|
||||||
import { useNavigate, useLoaderData } from "@remix-run/react";
|
import { useNavigate, useLoaderData } from "@remix-run/react";
|
||||||
import crossCheckingStyles from "~/styles/cross-checking-result.css?url";
|
import reviewsStyles from "~/styles/reviews.css?url";
|
||||||
import { getReviewPoints, updateReviewResult, getReviewPoints_fromApi} from "~/api/evaluation_points/reviews";
|
import { updateReviewResult, getReviewPoints_fromApi, getUnifiedEvaluationResults } from "~/api/evaluation_points/reviews";
|
||||||
|
import { postgrestGet } from "~/api/postgrest-client";
|
||||||
import { toastService } from "~/components/ui/Toast";
|
import { toastService } from "~/components/ui/Toast";
|
||||||
import { confirmReviewResults, checkProposalVotes, findIsProposer } from "~/api/cross-checking/cross-file-result";
|
import { confirmReviewResults, checkProposalVotes, findIsProposer } from "~/api/cross-checking/cross-file-result";
|
||||||
import { usePermission } from "~/hooks/usePermission";
|
import { usePermission } from "~/hooks/usePermission";
|
||||||
|
|
||||||
// 导入交叉评查详情页面组件
|
// 复用新版评查详情页外壳,保留交叉评查提案面板
|
||||||
import {
|
import {
|
||||||
FileInfo,
|
ReviewTabs,
|
||||||
FilePreview,
|
FilePreview,
|
||||||
ReviewPointsList
|
FileDetails,
|
||||||
} from "~/components/cross-checking";
|
} from "~/components/reviews";
|
||||||
|
import { ReviewPointsList, type CharPosition } from "~/components/cross-checking";
|
||||||
|
|
||||||
// 导入文档对比组件
|
// 导入文档对比组件
|
||||||
import { ComparePreview } from "~/components/reviews/previewComponents/ComparePreview";
|
import { ComparePreview } from "~/components/reviews/previewComponents/ComparePreview";
|
||||||
|
|
||||||
// 从ReviewPointsList组件中导入ReviewPoint类型和CharPosition类型
|
// 从ReviewPointsList组件中导入ReviewPoint类型
|
||||||
import { type ReviewPoint, type CharPosition } from '~/components/cross-checking';
|
import { type ReviewPoint } from '~/components/cross-checking';
|
||||||
import { messageService } from "~/components/ui/MessageModal";
|
import { messageService } from "~/components/ui/MessageModal";
|
||||||
import { loadingBarService } from "~/components/ui/LoadingBar";
|
import { loadingBarService } from "~/components/ui/LoadingBar";
|
||||||
import { Breadcrumb } from "~/components/layout/Breadcrumb";
|
import { Breadcrumb } from "~/components/layout/Breadcrumb";
|
||||||
@@ -177,7 +179,7 @@ export const meta: MetaFunction = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function links() {
|
export function links() {
|
||||||
return [{ rel: "stylesheet", href: crossCheckingStyles }];
|
return [{ rel: "stylesheet", href: reviewsStyles }];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const handle = {
|
export const handle = {
|
||||||
@@ -229,15 +231,102 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
|||||||
|
|
||||||
// console.log(`✅ [Loader] 用户 ${userInfo.user_id} (${accessCheck.userRole}) 访问文档 ${id} - 权限验证通过`);
|
// console.log(`✅ [Loader] 用户 ${userInfo.user_id} (${accessCheck.userRole}) 访问文档 ${id} - 权限验证通过`);
|
||||||
|
|
||||||
|
async function patchPointCodes(points: Array<Record<string, any>>, jwt: string) {
|
||||||
|
try {
|
||||||
|
const pointIds = points.map((point) => point.pointId).filter(Boolean);
|
||||||
|
if (pointIds.length === 0) return;
|
||||||
|
|
||||||
|
const response = await postgrestGet<any>('/api/postgrest/proxy/evaluation_points', {
|
||||||
|
select: 'id,code',
|
||||||
|
filter: { id: `in.(${[...new Set(pointIds)].join(',')})` },
|
||||||
|
token: jwt,
|
||||||
|
});
|
||||||
|
|
||||||
|
const raw = response.data;
|
||||||
|
const pointList = Array.isArray(raw) ? raw : (raw?.data && Array.isArray(raw.data) ? raw.data : []);
|
||||||
|
const codeMap: Record<string, string> = {};
|
||||||
|
|
||||||
|
pointList.forEach((point: any) => {
|
||||||
|
if (point.code) {
|
||||||
|
codeMap[String(point.id)] = point.code;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
points.forEach((point) => {
|
||||||
|
point.pointCode = codeMap[String(point.pointId)] || point.pointCode || '';
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('[CrossChecking Loader] patchPointCodes error:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const isProposer = await findIsProposer(taskId, userInfo?.user_id, frontendJWT);
|
||||||
|
const unifiedData = await getUnifiedEvaluationResults(id, request);
|
||||||
|
|
||||||
|
if (!('error' in unifiedData) && unifiedData.flow_type === 'graphrag') {
|
||||||
|
const reviewData = await getReviewPoints_fromApi(id, request);
|
||||||
|
const existingPoints = ('data' in reviewData && !('error' in reviewData)) ? reviewData.data : [];
|
||||||
|
const notApplicablePoints = (unifiedData.results || [])
|
||||||
|
.filter((result: any) => result.result_type === 'not_applicable')
|
||||||
|
.map((result: any) => ({
|
||||||
|
id: `na-${result.evaluation_point_id}`,
|
||||||
|
documentId: id,
|
||||||
|
pointId: result.evaluation_point_id,
|
||||||
|
editAuditStatusId: '',
|
||||||
|
editAuditStatus: '',
|
||||||
|
editAuditStatusMessage: '',
|
||||||
|
title: '该评查点未涉及',
|
||||||
|
pointName: result.name || '',
|
||||||
|
pointCode: result.code || '',
|
||||||
|
groupName: '',
|
||||||
|
status: 'notApplicable',
|
||||||
|
content: {},
|
||||||
|
contentPage: {},
|
||||||
|
suggestion: result.ai_suggestion || '该评查点未涉及',
|
||||||
|
result: null,
|
||||||
|
score: result.score || 0,
|
||||||
|
finalScore: null,
|
||||||
|
machineScore: 0,
|
||||||
|
postAction: '',
|
||||||
|
}));
|
||||||
|
const allReviewPoints = [...existingPoints, ...notApplicablePoints];
|
||||||
|
await patchPointCodes(allReviewPoints as Array<Record<string, any>>, frontendJWT);
|
||||||
|
|
||||||
|
return Response.json({
|
||||||
|
previousRoute,
|
||||||
|
document: ('document' in reviewData && !('error' in reviewData)) ? reviewData.document : null,
|
||||||
|
reviewPoints: allReviewPoints,
|
||||||
|
reviewInfo: {
|
||||||
|
reviewTime: unifiedData.evaluated_at,
|
||||||
|
reviewModel: 'GraphRAG',
|
||||||
|
ruleGroup: '',
|
||||||
|
result: '',
|
||||||
|
issueCount: unifiedData.summary?.total_points || 0
|
||||||
|
},
|
||||||
|
statistics: {
|
||||||
|
total: unifiedData.summary?.total_points || 0,
|
||||||
|
success: unifiedData.summary?.passed_count || 0,
|
||||||
|
warning: unifiedData.summary?.failed_count || 0,
|
||||||
|
error: 0,
|
||||||
|
score: unifiedData.summary?.total_score || 0
|
||||||
|
},
|
||||||
|
comparison_document: ('comparison_document' in reviewData && !('error' in reviewData)) ? reviewData.comparison_document : null,
|
||||||
|
scoring_proposals: ('scoring_proposals' in reviewData && !('error' in reviewData)) ? (reviewData.scoring_proposals || []) : [],
|
||||||
|
userInfo,
|
||||||
|
jwtToken: frontendJWT,
|
||||||
|
isProposer,
|
||||||
|
taskId,
|
||||||
|
taskName,
|
||||||
|
flowType: 'graphrag'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 对接接口,新的获取评查点结果的方法
|
// 对接接口,新的获取评查点结果的方法
|
||||||
const reviewData = await getReviewPoints_fromApi(id, request)
|
const reviewData = await getReviewPoints_fromApi(id, request);
|
||||||
|
|
||||||
// 获取评查点数据,传递request对象 旧获取评查点结果的方法
|
// 获取评查点数据,传递request对象 旧获取评查点结果的方法
|
||||||
// const reviewData = await getReviewPoints(id, request);
|
// const reviewData = await getReviewPoints(id, request);
|
||||||
|
|
||||||
// 获取当前登录用户是否是负责人
|
|
||||||
const isProposer = await findIsProposer(taskId, userInfo?.user_id, frontendJWT);
|
|
||||||
|
|
||||||
// console.log("documentData-------",JSON.stringify(documentData.data,null,2));
|
// console.log("documentData-------",JSON.stringify(documentData.data,null,2));
|
||||||
// console.log("reviewData-------",JSON.stringify('data' in reviewData ? reviewData.data : '',null,2));
|
// console.log("reviewData-------",JSON.stringify('data' in reviewData ? reviewData.data : '',null,2));
|
||||||
// console.log("reviewData-------",JSON.stringify(reviewData,null,2));
|
// console.log("reviewData-------",JSON.stringify(reviewData,null,2));
|
||||||
@@ -249,6 +338,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
|||||||
|
|
||||||
// 确保reviewData有效且具有预期的属性
|
// 确保reviewData有效且具有预期的属性
|
||||||
if ('document' in reviewData && 'data' in reviewData && 'reviewInfo' in reviewData && 'stats' in reviewData) {
|
if ('document' in reviewData && 'data' in reviewData && 'reviewInfo' in reviewData && 'stats' in reviewData) {
|
||||||
|
await patchPointCodes(reviewData.data as Array<Record<string, any>>, frontendJWT);
|
||||||
// console.log("reviewData-------",JSON.stringify(reviewData.data));
|
// console.log("reviewData-------",JSON.stringify(reviewData.data));
|
||||||
return Response.json({
|
return Response.json({
|
||||||
previousRoute: previousRoute,
|
previousRoute: previousRoute,
|
||||||
@@ -262,7 +352,8 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
|||||||
jwtToken: frontendJWT, // 传递JWT token
|
jwtToken: frontendJWT, // 传递JWT token
|
||||||
isProposer: isProposer,
|
isProposer: isProposer,
|
||||||
taskId: taskId, // 传递任务ID
|
taskId: taskId, // 传递任务ID
|
||||||
taskName: taskName // 传递任务名称
|
taskName: taskName, // 传递任务名称
|
||||||
|
flowType: 'legacy'
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.error("返回的评查数据格式不正确",JSON.stringify(reviewData,null,2));
|
console.error("返回的评查数据格式不正确",JSON.stringify(reviewData,null,2));
|
||||||
@@ -338,12 +429,7 @@ export default function CrossCheckingResult() {
|
|||||||
const { document, reviewPoints, statistics, reviewInfo, comparison_document, scoring_proposals, jwtToken, userInfo, isProposer, taskId, taskName } = loaderData;
|
const { document, reviewPoints, statistics, reviewInfo, comparison_document, scoring_proposals, jwtToken, userInfo, isProposer, taskId, taskName } = loaderData;
|
||||||
const [isLoading, setIsLoading] = useState(false); // 已经通过loader加载了数据,不需要再显示加载状态
|
const [isLoading, setIsLoading] = useState(false); // 已经通过loader加载了数据,不需要再显示加载状态
|
||||||
|
|
||||||
// 视图切换状态:'review' = 评查结果视图, 'compare' = 结构比对视图
|
const [activeTab, setActiveTab] = useState<string>('preview');
|
||||||
const [viewMode, setViewMode] = useState<'review' | 'compare'>('review');
|
|
||||||
|
|
||||||
|
|
||||||
// 判断是否有模板可以进行结构比对
|
|
||||||
const hasTemplateForCompare = Boolean(comparison_document?.template_contract_path?.trim());
|
|
||||||
|
|
||||||
// 权限控制
|
// 权限控制
|
||||||
const { hasPermission } = usePermission();
|
const { hasPermission } = usePermission();
|
||||||
@@ -377,6 +463,12 @@ export default function CrossCheckingResult() {
|
|||||||
setLocalScoringProposals(scoring_proposals || []);
|
setLocalScoringProposals(scoring_proposals || []);
|
||||||
}, [scoring_proposals]);
|
}, [scoring_proposals]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!comparison_document?.template_contract_path?.trim() && activeTab === 'filecompare') {
|
||||||
|
setActiveTab('preview');
|
||||||
|
}
|
||||||
|
}, [activeTab, comparison_document?.template_contract_path]);
|
||||||
|
|
||||||
// 处理意见提交成功的回调
|
// 处理意见提交成功的回调
|
||||||
const handleOpinionSubmitted = useCallback((newProposal: ScoringProposal) => {
|
const handleOpinionSubmitted = useCallback((newProposal: ScoringProposal) => {
|
||||||
setLocalScoringProposals(prev => [...prev, newProposal]);
|
setLocalScoringProposals(prev => [...prev, newProposal]);
|
||||||
@@ -697,7 +789,7 @@ export default function CrossCheckingResult() {
|
|||||||
isProcessingRef.current = false;
|
isProcessingRef.current = false;
|
||||||
toastService.error(`确认评查结果失败: ${error instanceof Error ? error.message : '未知错误'}`);
|
toastService.error(`确认评查结果失败: ${error instanceof Error ? error.message : '未知错误'}`);
|
||||||
}
|
}
|
||||||
}, [document, jwtToken, navigate]);
|
}, [document, jwtToken, navigate, taskId, taskName]);
|
||||||
|
|
||||||
// 构建自定义面包屑项 - 使用 useMemo 缓存
|
// 构建自定义面包屑项 - 使用 useMemo 缓存
|
||||||
const breadcrumbItems = useMemo(() => {
|
const breadcrumbItems = useMemo(() => {
|
||||||
@@ -716,7 +808,7 @@ export default function CrossCheckingResult() {
|
|||||||
}, [document?.id, loaderData.previousRoute]);
|
}, [document?.id, loaderData.previousRoute]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="cross-checking-result-container">
|
<div className="review-container">
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<div className="flex justify-center items-center p-12">
|
<div className="flex justify-center items-center p-12">
|
||||||
<div className="loading-spinner"></div>
|
<div className="loading-spinner"></div>
|
||||||
@@ -753,90 +845,35 @@ export default function CrossCheckingResult() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* 返回按钮 */}
|
<ReviewTabs
|
||||||
<button
|
activeTab={activeTab}
|
||||||
type="button"
|
onTabChange={setActiveTab}
|
||||||
onClick={() => {
|
fileInfo={{
|
||||||
// 返回到交叉评查列表页,并带上任务信息以自动打开模态框
|
id: document?.id,
|
||||||
const params = new URLSearchParams({
|
previousRoute: loaderData.previousRoute,
|
||||||
|
path: document?.path,
|
||||||
|
auditStatus: document?.auditStatus,
|
||||||
|
type: document?.type || document?.type_id,
|
||||||
|
comparisonId: comparison_document?.id ? Number(comparison_document.id) : undefined,
|
||||||
|
backTo: `/cross-checking?${new URLSearchParams({
|
||||||
openModal: 'true',
|
openModal: 'true',
|
||||||
taskId: taskId || '',
|
taskId: taskId || '',
|
||||||
taskName: taskName || '任务详情'
|
taskName: taskName || '任务详情'
|
||||||
});
|
}).toString()}`
|
||||||
navigate(`/cross-checking?${params.toString()}`);
|
|
||||||
}}
|
}}
|
||||||
className="inline-flex items-center px-3 py-1.5 text-sm font-medium text-gray-600 border border-gray-400 rounded-md hover:bg-gray-100 hover:text-gray-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-300 mr-3"
|
onConfirmResults={() => {
|
||||||
>
|
void handleConfirmResults();
|
||||||
<i className="ri-arrow-left-line mr-1.5"></i>
|
|
||||||
返回任务
|
|
||||||
</button>
|
|
||||||
|
|
||||||
{/* 结构比对/查看评查结果按钮 - 仅当文档类型包含"合同"且有模板时显示 */}
|
|
||||||
{hasTemplateForCompare && (
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={() => setViewMode(viewMode === 'review' ? 'compare' : 'review')}
|
|
||||||
className="inline-flex items-center px-3 py-1.5 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 mr-2"
|
|
||||||
>
|
|
||||||
{viewMode === 'review' ? (
|
|
||||||
<>
|
|
||||||
<i className="ri-file-copy-2-line mr-1.5"></i>
|
|
||||||
结构比对
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<i className="ri-file-list-3-line mr-1.5"></i>
|
|
||||||
查看评查结果
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* 完成评查按钮 - 需要 isProposer 且拥有 cross_review:document:complete 权限 */}
|
|
||||||
{isProposer && canCompleteDocument && (
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={(event) => {
|
|
||||||
// 立即阻止所有默认行为
|
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
// 异步调用处理函数
|
|
||||||
void handleConfirmResults(event);
|
|
||||||
}}
|
}}
|
||||||
disabled={isLoading}
|
jwtToken={jwtToken}
|
||||||
className="inline-flex items-center px-3 py-1.5 text-sm font-medium text-white bg-green-800 border border-transparent rounded-md hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-800 disabled:opacity-50 disabled:cursor-not-allowed"
|
showConfirmButton={Boolean(isProposer && canCompleteDocument)}
|
||||||
|
showCompareTab={Boolean(comparison_document?.template_contract_path?.trim())}
|
||||||
>
|
>
|
||||||
{isLoading ? (
|
{activeTab === 'preview' && (
|
||||||
<>
|
<div className="flex flex-col lg:flex-row space-y-4 lg:space-y-0 lg:space-x-4">
|
||||||
<i className="ri-loader-4-line ri-spin animate-spin mr-1.5"></i>
|
|
||||||
处理中...
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<i className="ri-check-double-line mr-1.5"></i>
|
|
||||||
完成评查
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 文件信息和操作按钮 */}
|
|
||||||
{/* <FileInfo
|
|
||||||
fileInfo={{
|
|
||||||
...reviewData.fileInfo,
|
|
||||||
previousRoute: loaderData.previousRoute
|
|
||||||
}}
|
|
||||||
onConfirmResults={handleConfirmResults}
|
|
||||||
/> */}
|
|
||||||
|
|
||||||
{/* 根据视图模式切换内容 */}
|
|
||||||
{viewMode === 'review' ? (
|
|
||||||
/* 评查结果视图 */
|
|
||||||
<div className="flex flex-col lg:flex-row space-y-4 lg:space-y-0 lg:space-x-4 lg:justify-between">
|
|
||||||
{/* 左侧:文件预览 */}
|
{/* 左侧:文件预览 */}
|
||||||
<div className="w-full lg:w-[62%]">
|
<div className="w-full lg:w-[65%]">
|
||||||
<FilePreview
|
<FilePreview
|
||||||
fileContent={document}
|
fileContent={document}
|
||||||
reviewPoints={reviewData.reviewPoints}
|
reviewPoints={reviewData.reviewPoints}
|
||||||
@@ -845,6 +882,7 @@ export default function CrossCheckingResult() {
|
|||||||
charPositions={charPositions}
|
charPositions={charPositions}
|
||||||
highlightValue={highlightValue}
|
highlightValue={highlightValue}
|
||||||
aiSuggestionReplace={aiSuggestionReplace}
|
aiSuggestionReplace={aiSuggestionReplace}
|
||||||
|
userInfo={loaderData.userInfo}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -869,8 +907,9 @@ export default function CrossCheckingResult() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
)}
|
||||||
/* 结构比对视图 */
|
|
||||||
|
{activeTab === 'filecompare' && (
|
||||||
<div className="w-full" style={{
|
<div className="w-full" style={{
|
||||||
height: 'calc(100vh - 120px)',
|
height: 'calc(100vh - 120px)',
|
||||||
minHeight: '600px',
|
minHeight: '600px',
|
||||||
@@ -883,6 +922,15 @@ export default function CrossCheckingResult() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{activeTab === 'fileinfo' && (
|
||||||
|
<FileDetails
|
||||||
|
fileInfo={reviewData.fileInfo}
|
||||||
|
contractInfo={reviewData.contractInfo}
|
||||||
|
reviewInfo={reviewData.reviewInfo}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</ReviewTabs>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
type CrossCheckingUploadedFile,
|
type CrossCheckingUploadedFile,
|
||||||
generateFileId,
|
generateFileId,
|
||||||
formatFileSize,
|
formatFileSize,
|
||||||
batchUploadAndAssignCrossCheckingFiles,
|
uploadCrossCheckingDocument,
|
||||||
createCrossReviewTask
|
createCrossReviewTask
|
||||||
} from "~/api/cross-checking/cross-files-upload";
|
} from "~/api/cross-checking/cross-files-upload";
|
||||||
import {
|
import {
|
||||||
@@ -302,8 +302,7 @@ export default function CrossCheckingUpload() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 第一步:上传文件并自动分配任务(新接口)
|
// 第一步:先上传文档到平台,再用 v3 接口创建交叉评查任务
|
||||||
// console.log("开始批量上传文件并分配任务:", filesToUpload.length, "个,案卷类型:", selectedDocType.name);
|
|
||||||
|
|
||||||
// 提取用户ID(从选中的组织架构中获取用户)
|
// 提取用户ID(从选中的组织架构中获取用户)
|
||||||
const userIds = groupChecked.filter(id => {
|
const userIds = groupChecked.filter(id => {
|
||||||
@@ -316,23 +315,6 @@ export default function CrossCheckingUpload() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// const requireParam = {
|
|
||||||
// filesToUpload: filesToUpload,
|
|
||||||
// selectedDocTypeId: selectedDocTypeId,
|
|
||||||
// priority: priority,
|
|
||||||
// documentNumber: documentNumber,
|
|
||||||
// remark: remark,
|
|
||||||
// isTestDocument: isTestDocument,
|
|
||||||
// userIds: userIds,
|
|
||||||
// taskInfo_name: taskInfo.name,
|
|
||||||
// selectedDocType_name: selectedDocType.code,
|
|
||||||
// taskInfo_type: taskInfo.type,
|
|
||||||
// frontendJWT
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // console.log("requireParam", requireParam)
|
|
||||||
// return;
|
|
||||||
|
|
||||||
// 构建负责人ID数组:当前用户(主要负责人)+ 额外负责人
|
// 构建负责人ID数组:当前用户(主要负责人)+ 额外负责人
|
||||||
const principalUserIds: number[] = [];
|
const principalUserIds: number[] = [];
|
||||||
// 添加当前用户作为主要负责人
|
// 添加当前用户作为主要负责人
|
||||||
@@ -347,37 +329,63 @@ export default function CrossCheckingUpload() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 使用文档类型名称作为 doc_type
|
const uploadSuccesses: Array<{ file: CrossCheckingUploadedFile; documentId: number }> = [];
|
||||||
const uploadResult = await batchUploadAndAssignCrossCheckingFiles(
|
const uploadFailures: Array<{ file: CrossCheckingUploadedFile; error: string }> = [];
|
||||||
filesToUpload,
|
|
||||||
selectedDocTypeId, // 使用选中的文档类型ID
|
for (const fileInfo of filesToUpload) {
|
||||||
|
const binaryData = await fileInfo.file.arrayBuffer();
|
||||||
|
const uploadResponse = await uploadCrossCheckingDocument(
|
||||||
|
binaryData,
|
||||||
|
fileInfo.name,
|
||||||
|
fileInfo.type,
|
||||||
|
selectedDocTypeId,
|
||||||
priority,
|
priority,
|
||||||
documentNumber,
|
documentNumber,
|
||||||
remark,
|
remark,
|
||||||
isTestDocument,
|
isTestDocument,
|
||||||
userIds,
|
null,
|
||||||
taskInfo.name,
|
false,
|
||||||
selectedDocType.code, // 使用文档类型code
|
frontendJWT
|
||||||
taskInfo.type, // 使用任务类型(市局间交叉评查 或 区局间交叉评查)
|
|
||||||
frontendJWT,
|
|
||||||
principalUserIds, // 负责人ID数组
|
|
||||||
attributeType // 合同类型
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (uploadResponse.error || !uploadResponse.data?.result?.id) {
|
||||||
|
uploadFailures.push({
|
||||||
|
file: fileInfo,
|
||||||
|
error: uploadResponse.error || '上传后未返回文档ID'
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// return;
|
uploadSuccesses.push({
|
||||||
|
file: fileInfo,
|
||||||
|
documentId: uploadResponse.data.result.id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const { successes, failures } = uploadResult;
|
if (uploadFailures.length > 0) {
|
||||||
|
toastService.error(`文件上传失败:${uploadFailures[0].error}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (failures.length > 0) {
|
const createTaskResult = await createCrossReviewTask({
|
||||||
toastService.error(`文件上传或任务分配失败:${failures[0].error}`);
|
documentIds: uploadSuccesses.map(item => item.documentId),
|
||||||
|
userIds,
|
||||||
|
principalUserIds,
|
||||||
|
taskName: taskInfo.name,
|
||||||
|
docTypeId: selectedDocTypeId,
|
||||||
|
docType: selectedDocType.code,
|
||||||
|
taskType: taskInfo.type
|
||||||
|
}, frontendJWT);
|
||||||
|
|
||||||
|
if (!createTaskResult.success) {
|
||||||
|
toastService.error(createTaskResult.error || '创建交叉评查任务失败');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 任务创建成功
|
// 任务创建成功
|
||||||
toastService.success("交叉评查任务创建成功!");
|
toastService.success("交叉评查任务创建成功!");
|
||||||
messageService.success(
|
messageService.success(
|
||||||
`任务创建完成!\n任务名称:${taskInfo.name}\n上传文件:${successes.length} 个\n评查人员:${userIds.length} 人`,
|
`任务创建完成!\n任务名称:${taskInfo.name}\n上传文件:${uploadSuccesses.length} 个\n评查人员:${userIds.length} 人`,
|
||||||
{
|
{
|
||||||
title: '任务创建成功',
|
title: '任务创建成功',
|
||||||
confirmText: '确定',
|
confirmText: '确定',
|
||||||
|
|||||||
@@ -185,6 +185,28 @@ function fallbackDependencyOption(value: string, optionMap?: Map<string, Depende
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resolveRuleDependencies(
|
||||||
|
rule: RuleSummary | undefined,
|
||||||
|
rulesById: Map<string, RuleSummary>,
|
||||||
|
visited = new Set<string>(),
|
||||||
|
): string[] {
|
||||||
|
if (!rule) return [];
|
||||||
|
const key = rule.ruleId || rule.id;
|
||||||
|
if (visited.has(key)) return [];
|
||||||
|
visited.add(key);
|
||||||
|
|
||||||
|
const merged = new Set<string>((rule.dependencies || []).filter(Boolean));
|
||||||
|
|
||||||
|
(rule.subRuleIds || []).forEach((ruleId) => {
|
||||||
|
const referenced = rulesById.get(ruleId);
|
||||||
|
resolveRuleDependencies(referenced, rulesById, visited).forEach((dependency) => {
|
||||||
|
if (dependency) merged.add(dependency);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return Array.from(merged);
|
||||||
|
}
|
||||||
|
|
||||||
function makeId(prefix: string): string {
|
function makeId(prefix: string): string {
|
||||||
return `${prefix}-${Date.now()}`;
|
return `${prefix}-${Date.now()}`;
|
||||||
}
|
}
|
||||||
@@ -571,29 +593,36 @@ export default function RulesTestDetail() {
|
|||||||
'ai_rule',
|
'ai_rule',
|
||||||
'rule_group'
|
'rule_group'
|
||||||
]), [rules]);
|
]), [rules]);
|
||||||
|
const rulesById = useMemo(() => new Map(rules.map(rule => [rule.ruleId || rule.id, rule])), [rules]);
|
||||||
const selectedDependencyOptions = useMemo(() => {
|
const selectedDependencyOptions = useMemo(() => {
|
||||||
return ruleDraft.dependencies.map(value => dependencyOptionMap.get(value) || fallbackDependencyOption(value, dependencyOptionMap));
|
return ruleDraft.dependencies.map(value => dependencyOptionMap.get(value) || fallbackDependencyOption(value, dependencyOptionMap));
|
||||||
}, [dependencyOptionMap, ruleDraft.dependencies]);
|
}, [dependencyOptionMap, ruleDraft.dependencies]);
|
||||||
|
const resolvedCurrentDependencies = useMemo(() => {
|
||||||
|
return resolveRuleDependencies(currentRule, rulesById);
|
||||||
|
}, [currentRule, rulesById]);
|
||||||
|
const currentRuleWithResolvedDependencies = useMemo(() => (
|
||||||
|
currentRule ? { ...currentRule, dependencies: resolvedCurrentDependencies } : undefined
|
||||||
|
), [currentRule, resolvedCurrentDependencies]);
|
||||||
const currentDependencyRows = useMemo(() => {
|
const currentDependencyRows = useMemo(() => {
|
||||||
return (currentRule?.dependencies || []).map(value => dependencyOptionMap.get(value) || fallbackDependencyOption(value, dependencyOptionMap));
|
return resolvedCurrentDependencies.map(value => dependencyOptionMap.get(value) || fallbackDependencyOption(value, dependencyOptionMap));
|
||||||
}, [currentRule, dependencyOptionMap]);
|
}, [dependencyOptionMap, resolvedCurrentDependencies]);
|
||||||
const currentRuleFields = useMemo(
|
const currentRuleFields = useMemo(
|
||||||
() => fields.filter((field) => matchesCurrentRuleDependency(currentRule, [field.name])),
|
() => fields.filter((field) => matchesCurrentRuleDependency(currentRuleWithResolvedDependencies, [field.name])),
|
||||||
[currentRule, fields],
|
[currentRuleWithResolvedDependencies, fields],
|
||||||
);
|
);
|
||||||
const currentRuleSubDocuments = useMemo(
|
const currentRuleSubDocuments = useMemo(
|
||||||
() => subDocuments.filter((document) => matchesCurrentRuleDependency(currentRule, [document.name, document.id])),
|
() => subDocuments.filter((document) => matchesCurrentRuleDependency(currentRuleWithResolvedDependencies, [document.name, document.id])),
|
||||||
[currentRule, subDocuments],
|
[currentRuleWithResolvedDependencies, subDocuments],
|
||||||
);
|
);
|
||||||
const currentRuleVisualElements = useMemo(
|
const currentRuleVisualElements = useMemo(
|
||||||
() => visualElements.filter((item) => matchesCurrentRuleDependency(currentRule, [
|
() => visualElements.filter((item) => matchesCurrentRuleDependency(currentRuleWithResolvedDependencies, [
|
||||||
item.id,
|
item.id,
|
||||||
item.name,
|
item.name,
|
||||||
`visual.${item.id}`,
|
`visual.${item.id}`,
|
||||||
`visual.${item.name || item.id}`,
|
`visual.${item.name || item.id}`,
|
||||||
item.type,
|
item.type,
|
||||||
])),
|
])),
|
||||||
[currentRule, visualElements],
|
[currentRuleWithResolvedDependencies, visualElements],
|
||||||
);
|
);
|
||||||
const dialogDependencyOptions = useMemo(() => {
|
const dialogDependencyOptions = useMemo(() => {
|
||||||
const selectedValues = new Set(ruleDraft.dependencies);
|
const selectedValues = new Set(ruleDraft.dependencies);
|
||||||
@@ -644,7 +673,6 @@ export default function RulesTestDetail() {
|
|||||||
const fullYamlText = serializedYamlResult.yamlText;
|
const fullYamlText = serializedYamlResult.yamlText;
|
||||||
const isSmartRuleDraft = ruleDraft.type === 'ai_rule' || ruleDraft.checkTypes.includes('ai');
|
const isSmartRuleDraft = ruleDraft.type === 'ai_rule' || ruleDraft.checkTypes.includes('ai');
|
||||||
const isRuleGroupDraft = ruleDraft.type === 'rule_group';
|
const isRuleGroupDraft = ruleDraft.type === 'rule_group';
|
||||||
const rulesById = useMemo(() => new Map(rules.map(rule => [rule.ruleId || rule.id, rule])), [rules]);
|
|
||||||
const saveButtonBusy = saveFetcher.state !== 'idle';
|
const saveButtonBusy = saveFetcher.state !== 'idle';
|
||||||
const latestDraftVersion = useMemo(
|
const latestDraftVersion = useMemo(
|
||||||
() => versionItems.find((item) => !['published', 'rollback'].includes(item.status)),
|
() => versionItems.find((item) => !['published', 'rollback'].includes(item.status)),
|
||||||
@@ -1362,7 +1390,7 @@ export default function RulesTestDetail() {
|
|||||||
|
|
||||||
<Card
|
<Card
|
||||||
className="ant-card"
|
className="ant-card"
|
||||||
title={`依赖字段 (${currentRule.dependencies.length}项)`}
|
title={`依赖字段 (${resolvedCurrentDependencies.length}项)`}
|
||||||
>
|
>
|
||||||
<Table
|
<Table
|
||||||
className="rules-test-table"
|
className="rules-test-table"
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ function parseRules(source: string): RuleSummary[] {
|
|||||||
for (let index = start + 1; index < lines.length; index += 1) {
|
for (let index = start + 1; index < lines.length; index += 1) {
|
||||||
const line = lines[index];
|
const line = lines[index];
|
||||||
const lineIndent = line.match(/^\s*/)?.[0].length || 0;
|
const lineIndent = line.match(/^\s*/)?.[0].length || 0;
|
||||||
if (line.trim() && lineIndent <= baseIndent) {
|
if (line.trim() && lineIndent <= baseIndent && !/^\s*-\s+/.test(line)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const match = line.match(/^\s*-\s+(.+)$/);
|
const match = line.match(/^\s*-\s+(.+)$/);
|
||||||
@@ -313,7 +313,7 @@ function parseRules(source: string): RuleSummary[] {
|
|||||||
values.push(stripYamlValue(match[1]));
|
values.push(stripYamlValue(match[1]));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (line.trim() && lineIndent <= indent) break;
|
if (line.trim() && lineIndent <= indent && !/^\s*-\s+/.test(line)) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return values;
|
return values;
|
||||||
@@ -331,7 +331,7 @@ function parseRules(source: string): RuleSummary[] {
|
|||||||
for (let index = start + 1; index < lines.length; index += 1) {
|
for (let index = start + 1; index < lines.length; index += 1) {
|
||||||
const line = lines[index];
|
const line = lines[index];
|
||||||
const lineIndent = line.match(/^\s*/)?.[0].length || 0;
|
const lineIndent = line.match(/^\s*/)?.[0].length || 0;
|
||||||
if (line.trim() && lineIndent <= baseIndent) {
|
if (line.trim() && lineIndent <= baseIndent && !/^\s*-\s+/.test(line)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const match = line.match(/^\s*-\s+(.+)$/);
|
const match = line.match(/^\s*-\s+(.+)$/);
|
||||||
@@ -342,6 +342,19 @@ function parseRules(source: string): RuleSummary[] {
|
|||||||
return values;
|
return values;
|
||||||
};
|
};
|
||||||
const readStageScalar = (block: string, key: string): string => stripYamlValue(block.match(new RegExp(`^\\s+${key}:\\s*(.+)$`, 'm'))?.[1] || '');
|
const readStageScalar = (block: string, key: string): string => stripYamlValue(block.match(new RegExp(`^\\s+${key}:\\s*(.+)$`, 'm'))?.[1] || '');
|
||||||
|
const readStagePairValues = (block: string): string[] => {
|
||||||
|
const lines = block.split('\n');
|
||||||
|
const values: string[] = [];
|
||||||
|
|
||||||
|
for (let index = 0; index < lines.length; index += 1) {
|
||||||
|
const match = lines[index].match(/^\s+(?:source|target|ref_field):\s*(.+)$/);
|
||||||
|
if (match) {
|
||||||
|
values.push(stripYamlValue(match[1]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return values;
|
||||||
|
};
|
||||||
const summarizeStage = (stageBlock: string): string => {
|
const summarizeStage = (stageBlock: string): string => {
|
||||||
const fields = readStageList(stageBlock, 'fields');
|
const fields = readStageList(stageBlock, 'fields');
|
||||||
const field = readStageScalar(stageBlock, 'field');
|
const field = readStageScalar(stageBlock, 'field');
|
||||||
@@ -376,11 +389,22 @@ function parseRules(source: string): RuleSummary[] {
|
|||||||
const ruleId = stripYamlValue(ruleBlock.match(/^\s*-\s+rule_id:\s*(.+)$/m)?.[1] || '');
|
const ruleId = stripYamlValue(ruleBlock.match(/^\s*-\s+rule_id:\s*(.+)$/m)?.[1] || '');
|
||||||
const name = stripYamlValue(ruleBlock.match(/^\s+name:\s*(.+)$/m)?.[1] || '未命名规则');
|
const name = stripYamlValue(ruleBlock.match(/^\s+name:\s*(.+)$/m)?.[1] || '未命名规则');
|
||||||
const checkTypes = Array.from(new Set(Array.from(ruleBlock.matchAll(/^\s+(?:check|type):\s*(.+)$/gm)).map(match => stripYamlValue(match[1]))));
|
const checkTypes = Array.from(new Set(Array.from(ruleBlock.matchAll(/^\s+(?:check|type):\s*(.+)$/gm)).map(match => stripYamlValue(match[1]))));
|
||||||
const stageDependencies = Array.from(ruleBlock.matchAll(/^\s+(?:field|number|chinese|left|right|left_field|right_field|target|element|seal_id|signature_id):\s*(.+)$/gm))
|
const stageDependencies = Array.from(ruleBlock.matchAll(/^\s+(?:field|number|chinese|left|right|left_field|right_field|target|element|seal_id|signature_id|ref_field):\s*(.+)$/gm))
|
||||||
.map(match => normalizeDependency(match[1]));
|
.map(match => normalizeDependency(match[1]));
|
||||||
|
const stageFieldDependencies = splitBlocks(ruleBlock, /^\s{4,}-\s+id:\s*/)
|
||||||
|
.flatMap(stageBlock => [
|
||||||
|
...readStageList(stageBlock, 'fields'),
|
||||||
|
...readStagePairValues(stageBlock),
|
||||||
|
])
|
||||||
|
.map(normalizeDependency);
|
||||||
const prompts = readPrompts(ruleBlock);
|
const prompts = readPrompts(ruleBlock);
|
||||||
const promptDependencies = readPromptDependencies(prompts).map(normalizeDependency);
|
const promptDependencies = readPromptDependencies(prompts).map(normalizeDependency);
|
||||||
const dependencies = Array.from(new Set([...readExplicitDependencies(ruleBlock), ...stageDependencies, ...promptDependencies]));
|
const dependencies = Array.from(new Set([
|
||||||
|
...readExplicitDependencies(ruleBlock),
|
||||||
|
...stageDependencies,
|
||||||
|
...stageFieldDependencies,
|
||||||
|
...promptDependencies,
|
||||||
|
]));
|
||||||
const scope = Array.from(new Set(Array.from(ruleBlock.matchAll(/^\s{4,}-\s*([^:\n]+)$/gm)).map(match => stripYamlValue(match[1])).filter(value => !/^\d+$/.test(value))));
|
const scope = Array.from(new Set(Array.from(ruleBlock.matchAll(/^\s{4,}-\s*([^:\n]+)$/gm)).map(match => stripYamlValue(match[1])).filter(value => !/^\d+$/.test(value))));
|
||||||
const subRules = readSubRules(ruleBlock);
|
const subRules = readSubRules(ruleBlock);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,179 @@
|
|||||||
|
# 交叉评查 v3 迁移收口说明
|
||||||
|
|
||||||
|
## 当前主链路状态
|
||||||
|
|
||||||
|
目前交叉评查的主流程已经切到新版本链路:
|
||||||
|
|
||||||
|
1. 创建任务页先上传文档,再调用 `POST /api/v3/cross-review/tasks` 创建任务
|
||||||
|
2. 任务列表走 `POST /api/v3/cross-review/tasks/query`
|
||||||
|
3. 任务文档列表走 `GET /api/v3/cross-review/tasks/{taskId}/documents`
|
||||||
|
4. 交叉评查详情页使用新版评查详情页外壳
|
||||||
|
5. 提案、投票、待投票检查走 `v3 cross-review` 接口
|
||||||
|
6. 完成评查走 `POST /api/v3/cross-review/tasks/{taskId}/documents/{documentId}/complete`
|
||||||
|
|
||||||
|
## 本次已完成的前端收口
|
||||||
|
|
||||||
|
### 1. 创建任务
|
||||||
|
|
||||||
|
文件:
|
||||||
|
|
||||||
|
- `app/routes/cross-checking.upload.tsx`
|
||||||
|
- `app/api/cross-checking/cross-files-upload.ts`
|
||||||
|
|
||||||
|
现状:
|
||||||
|
|
||||||
|
- 不再把“上传文件 + 自动分配任务”作为主链路
|
||||||
|
- 改为先上传文档,再使用上传成功返回的 `documentId` 创建任务
|
||||||
|
- 创建任务请求体已经对齐后端 `v3` DTO:
|
||||||
|
- `taskName`
|
||||||
|
- `taskType`
|
||||||
|
- `docTypeId`
|
||||||
|
- `docTypeCode`
|
||||||
|
- `memberUserIds`
|
||||||
|
- `principalUserIds`
|
||||||
|
- `documentIds`
|
||||||
|
|
||||||
|
### 2. 任务页
|
||||||
|
|
||||||
|
文件:
|
||||||
|
|
||||||
|
- `app/api/cross-checking/cross-files.ts`
|
||||||
|
- `app/routes/cross-checking._index.tsx`
|
||||||
|
|
||||||
|
现状:
|
||||||
|
|
||||||
|
- 任务列表、统计、文档列表均已接新接口
|
||||||
|
- 返回任务页后仍保留 `openModal + taskId + taskName` 的 reopen 机制
|
||||||
|
|
||||||
|
### 3. 详情页
|
||||||
|
|
||||||
|
文件:
|
||||||
|
|
||||||
|
- `app/routes/cross-checking.result.tsx`
|
||||||
|
- `app/components/reviews/ReviewTabs.tsx`
|
||||||
|
|
||||||
|
现状:
|
||||||
|
|
||||||
|
- 页面外壳切到新版评查详情页
|
||||||
|
- 优先复用新版预览、tab、文件信息组件
|
||||||
|
- 交叉评查特有的提案面板仍保留,作为业务差异层
|
||||||
|
|
||||||
|
### 4. 提案与投票
|
||||||
|
|
||||||
|
文件:
|
||||||
|
|
||||||
|
- `app/api/cross-checking/cross-file-result.ts`
|
||||||
|
|
||||||
|
现状:
|
||||||
|
|
||||||
|
- 已切到以下新接口:
|
||||||
|
- `POST /api/v3/cross-review/proposals`
|
||||||
|
- `POST /api/v3/cross-review/proposals/{proposalId}/votes`
|
||||||
|
- `DELETE /api/v3/cross-review/proposals/{proposalId}`
|
||||||
|
- `GET /api/v3/cross-review/documents/{documentId}/proposals`
|
||||||
|
- `GET /api/v3/cross-review/documents/{documentId}/pending-votes`
|
||||||
|
|
||||||
|
## 边支能力迁移状态
|
||||||
|
|
||||||
|
结合最新后端实现,交叉评查的边支能力里,“向已有任务补传文档”也已经切到新版本链路。
|
||||||
|
|
||||||
|
### 1. 向已有任务补传文档
|
||||||
|
|
||||||
|
文件:
|
||||||
|
|
||||||
|
- `app/api/cross-checking/cross-files-upload.ts`
|
||||||
|
|
||||||
|
接口:
|
||||||
|
|
||||||
|
- `POST /api/v3/cross-review/tasks/{taskId}/documents/upload`
|
||||||
|
|
||||||
|
调用位置:
|
||||||
|
|
||||||
|
- `app/components/cross-checking/DocumentListModal.tsx`
|
||||||
|
|
||||||
|
当前实现:
|
||||||
|
|
||||||
|
- 前端改为直接上传 `file`
|
||||||
|
- 后端不再走旧 `cross_review` 边支上传逻辑
|
||||||
|
- 改为复用 `leaudit` 文档上传与抽取链路,再把新文档挂到交叉评查任务下
|
||||||
|
- 上传成功后任务状态会回到 `in_progress`
|
||||||
|
|
||||||
|
说明:
|
||||||
|
|
||||||
|
- 这条能力已经不再依赖旧版 `v2 cross_review upload_documents`
|
||||||
|
- 文档抽取、后续评查点生成与新版主链路保持一致
|
||||||
|
|
||||||
|
## 仍保留旧接口的支链路
|
||||||
|
|
||||||
|
以下能力当前仍是旧接口,尚未迁到 `v3`:
|
||||||
|
|
||||||
|
### 1. 任务文档追加附件
|
||||||
|
|
||||||
|
文件:
|
||||||
|
|
||||||
|
- `app/api/cross-checking/cross-files.ts`
|
||||||
|
|
||||||
|
接口:
|
||||||
|
|
||||||
|
- `POST /api/v2/cross_review/tasks/{task_id}/documents/{document_id}/append_attachments`
|
||||||
|
|
||||||
|
调用位置:
|
||||||
|
|
||||||
|
- `app/components/cross-checking/DocumentListModal.tsx`
|
||||||
|
|
||||||
|
说明:
|
||||||
|
|
||||||
|
- 该能力主要服务合同场景的版本追加
|
||||||
|
- 当前仍可继续保留旧接口,等后端 `v3` 能力明确后再迁
|
||||||
|
|
||||||
|
### 2. 合同模板上传
|
||||||
|
|
||||||
|
文件:
|
||||||
|
|
||||||
|
- `app/api/cross-checking/cross-files.ts`
|
||||||
|
|
||||||
|
接口:
|
||||||
|
|
||||||
|
- 复用上传服务 `/upload_contract_template`
|
||||||
|
|
||||||
|
调用位置:
|
||||||
|
|
||||||
|
- `app/components/cross-checking/DocumentListModal.tsx`
|
||||||
|
|
||||||
|
说明:
|
||||||
|
|
||||||
|
- 该能力不属于 `cross-review` 专属接口,暂不要求迁到 `v3 cross-review`
|
||||||
|
|
||||||
|
## 建议的后续迁移优先级
|
||||||
|
|
||||||
|
### P1
|
||||||
|
|
||||||
|
- 追加附件:`appendTaskDocumentAttachments()`
|
||||||
|
|
||||||
|
原因:
|
||||||
|
|
||||||
|
- 业务价值高,但更多是合同场景增强功能
|
||||||
|
- 可以在主链路稳定后迁
|
||||||
|
|
||||||
|
### P2
|
||||||
|
|
||||||
|
- 历史兼容 helper 清理
|
||||||
|
- 旧注释、旧命名继续清理
|
||||||
|
|
||||||
|
原因:
|
||||||
|
|
||||||
|
- 不影响业务,但能减少后续误接老接口的概率
|
||||||
|
|
||||||
|
## 当前结论
|
||||||
|
|
||||||
|
可以认为交叉评查的核心业务链路已经完成 `v3` 迁移:
|
||||||
|
|
||||||
|
- 创建任务
|
||||||
|
- 任务列表
|
||||||
|
- 文档列表
|
||||||
|
- 详情展示
|
||||||
|
- 提案投票
|
||||||
|
- 完成评查
|
||||||
|
- 已有任务补传文档
|
||||||
|
|
||||||
|
剩余工作主要集中在“追加附件”这条旧边支能力,以及后续兼容代码清理。
|
||||||
Reference in New Issue
Block a user