测通完成评查,投票,意见列表,任务列表,任务关联文档列表的内容。剩余创建任务,提出意见的完善
This commit is contained in:
+28
-43
@@ -238,7 +238,7 @@ export async function action({ request }: ActionFunctionArgs) {
|
||||
return Response.json({ success: false, error: response.error }, { status: response.status || 500 });
|
||||
}
|
||||
|
||||
return Response.json({ success: true, data: response.data });
|
||||
return Response.json({ success: true, data: response.data, intent: "confirmReviewResults" });
|
||||
} catch (updateError) {
|
||||
console.error('调用updateReviewResult时发生异常:', updateError);
|
||||
return Response.json({
|
||||
@@ -258,15 +258,16 @@ export async function action({ request }: ActionFunctionArgs) {
|
||||
|
||||
if (response.error) {
|
||||
console.error('confirmReviewResults返回错误:', response.error);
|
||||
return Response.json({ success: false, error: response.error }, { status: response.status || 500 });
|
||||
return Response.json({ success: false, error: response.error, intent: "confirmReviewResults" }, { status: response.status || 500 });
|
||||
}
|
||||
|
||||
return Response.json({ success: true, data: response.data });
|
||||
return Response.json({ success: true, data: response.data, intent: "confirmReviewResults" });
|
||||
} catch (confirmError) {
|
||||
console.error('调用confirmReviewResults时发生异常:', confirmError);
|
||||
return Response.json({
|
||||
success: false,
|
||||
error: confirmError instanceof Error ? confirmError.message : '确认评查结果时发生未知错误'
|
||||
error: confirmError instanceof Error ? confirmError.message : '确认评查结果时发生未知错误',
|
||||
intent: "confirmReviewResults"
|
||||
}, { status: 500 });
|
||||
}
|
||||
}
|
||||
@@ -522,6 +523,27 @@ export default function ReviewDetails() {
|
||||
}
|
||||
}, [fetcher.state, fetcher.data, pendingUpdate, document, reviewData]);
|
||||
|
||||
// 监听fetcher状态变化 - 处理确认评查结果
|
||||
useEffect(() => {
|
||||
if (fetcher.state === "idle" && fetcher.data && !pendingUpdate) {
|
||||
const result = fetcher.data as { success: boolean; error?: string; intent?: string };
|
||||
|
||||
// 只处理confirmReviewResults的响应
|
||||
if (result.intent === 'confirmReviewResults') {
|
||||
setIsLoading(false);
|
||||
|
||||
if (result.success) {
|
||||
toastService.success('评查结果已确认,文档审核状态已更新');
|
||||
// 导航到文档列表页
|
||||
navigate('/documents');
|
||||
} else {
|
||||
console.error('确认评查结果失败:', result.error);
|
||||
toastService.error(`确认评查结果失败: ${result.error || '未知错误'}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [fetcher.state, fetcher.data, pendingUpdate, navigate]);
|
||||
|
||||
// 处理评审点状态变更
|
||||
const handleReviewPointStatusChange = async (reviewPointResultId: string, editAuditStatusId: string | number, newStatus: string, message: string) => {
|
||||
// 将字符串的布尔值转换为布尔类型
|
||||
@@ -569,53 +591,16 @@ export default function ReviewDetails() {
|
||||
// 显示加载状态
|
||||
setIsLoading(true);
|
||||
|
||||
// 使用 fetch 调用 action
|
||||
// 使用 Remix 的 useFetcher 调用 action
|
||||
const formData = new FormData();
|
||||
formData.append("intent", "confirmReviewResults");
|
||||
formData.append("documentId", document.id.toString());
|
||||
|
||||
const response = await fetch(window.location.pathname, {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
});
|
||||
|
||||
// 检查响应是否为JSON格式
|
||||
const contentType = response.headers.get("content-type");
|
||||
if (!contentType || !contentType.includes("application/json")) {
|
||||
console.error('服务器返回了非JSON响应,状态码:', response.status);
|
||||
const text = await response.text();
|
||||
console.error('响应内容:', text.substring(0, 500));
|
||||
|
||||
if (response.status === 401) {
|
||||
toastService.error('登录已过期,请重新登录');
|
||||
window.location.href = '/login';
|
||||
return;
|
||||
} else if (response.status >= 500) {
|
||||
toastService.error('服务器内部错误,请稍后重试');
|
||||
return;
|
||||
} else {
|
||||
toastService.error('请求失败,请检查网络连接');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
fetcher.submit(formData, { method: "POST" });
|
||||
|
||||
if (!result.success) {
|
||||
console.error('确认评查结果失败:', result.error);
|
||||
toastService.error(`确认评查结果失败: ${result.error}`);
|
||||
return;
|
||||
}
|
||||
|
||||
// 显示成功消息
|
||||
toastService.success('评查结果已确认,文档审核状态已更新');
|
||||
|
||||
// 导航到文档列表页
|
||||
navigate('/documents');
|
||||
} catch (error) {
|
||||
console.error('确认评查结果出错:', error);
|
||||
toastService.error(`确认评查结果失败: ${error instanceof Error ? error.message : '未知错误'}`);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user