添加交叉评查任务的文档列表,评查详情的意见列表
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { postgrestPost } from "../postgrest-client";
|
||||
// import { postgrestPost } from "../postgrest-client";
|
||||
import { API_BASE_URL } from "../../config/api-config";
|
||||
|
||||
/**
|
||||
@@ -39,6 +39,10 @@ export interface CrossCheckingOpinion {
|
||||
status: string;
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
is_vote: boolean; // 当前用户是否已投票
|
||||
voter_count: number; // 投票人数
|
||||
proposer_name: string; // 意见发起人姓名
|
||||
current_user_is_proposer: boolean; // 当前用户是否为意见发起人
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,25 +104,198 @@ export async function submitCrossCheckingOpinion(
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取交叉评查意见列表
|
||||
* 获取交叉评查意见列表(支持分页)
|
||||
* @param documentId 文档ID
|
||||
* @returns 意见列表
|
||||
* @param page 页码
|
||||
* @param pageSize 每页大小
|
||||
* @returns 意见列表和总数
|
||||
*/
|
||||
export async function getCrossCheckingOpinions(documentId: string | number): Promise<ApiResponse<CrossCheckingOpinion[]>> {
|
||||
export async function getCrossCheckingOpinions(
|
||||
documentId: string | number,
|
||||
page: number = 1,
|
||||
pageSize: number = 10
|
||||
): Promise<ApiResponse<{ opinions: CrossCheckingOpinion[], total: number }>> {
|
||||
try {
|
||||
const response = await postgrestPost('rpc/get_cross_checking_opinions', {
|
||||
p_document_id: documentId
|
||||
});
|
||||
// 模拟数据 - 后续替换为真实API调用
|
||||
const mockOpinions: CrossCheckingOpinion[] = [
|
||||
{
|
||||
id: 1,
|
||||
evaluation_point_id: 101,
|
||||
document_id: documentId,
|
||||
audit_point: "合同主体信息核查",
|
||||
found_issue: "合同签署方信息不完整",
|
||||
audit_opinion: "合同中缺少乙方的详细联系方式,建议补充完整的地址和联系电话",
|
||||
deduction_score: -2,
|
||||
status: "pending",
|
||||
created_at: "2024-01-15 10:30:00",
|
||||
is_vote: false,
|
||||
voter_count: 3,
|
||||
proposer_name: "张三",
|
||||
current_user_is_proposer: false
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
evaluation_point_id: 102,
|
||||
document_id: documentId,
|
||||
audit_point: "合同金额核查",
|
||||
found_issue: "合同金额与预算不符",
|
||||
audit_opinion: "合同总金额超出预算范围,需要重新评估或调整预算",
|
||||
deduction_score: -5,
|
||||
status: "approved",
|
||||
created_at: "2024-01-14 14:20:00",
|
||||
is_vote: true,
|
||||
voter_count: 5,
|
||||
proposer_name: "李四",
|
||||
current_user_is_proposer: true
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
evaluation_point_id: 103,
|
||||
document_id: documentId,
|
||||
audit_point: "合同条款审查",
|
||||
found_issue: "违约责任条款不明确",
|
||||
audit_opinion: "合同中违约责任的具体计算方式和赔偿标准需要进一步明确",
|
||||
deduction_score: -3,
|
||||
status: "rejected",
|
||||
created_at: "2024-01-13 09:15:00",
|
||||
is_vote: false,
|
||||
voter_count: 2,
|
||||
proposer_name: "王五",
|
||||
current_user_is_proposer: false
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
evaluation_point_id: 103,
|
||||
document_id: documentId,
|
||||
audit_point: "合同条款审查",
|
||||
found_issue: "违约责任条款不明确",
|
||||
audit_opinion: "合同中违约责任的具体计算方式和赔偿标准需要进一步明确",
|
||||
deduction_score: -3,
|
||||
status: "rejected",
|
||||
created_at: "2024-01-13 09:15:00",
|
||||
is_vote: false,
|
||||
voter_count: 2,
|
||||
proposer_name: "王五",
|
||||
current_user_is_proposer: false
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
evaluation_point_id: 103,
|
||||
document_id: documentId,
|
||||
audit_point: "合同条款审查",
|
||||
found_issue: "违约责任条款不明确",
|
||||
audit_opinion: "合同中违约责任的具体计算方式和赔偿标准需要进一步明确",
|
||||
deduction_score: -3,
|
||||
status: "rejected",
|
||||
created_at: "2024-01-13 09:15:00",
|
||||
is_vote: false,
|
||||
voter_count: 2,
|
||||
proposer_name: "王五",
|
||||
current_user_is_proposer: false
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
evaluation_point_id: 103,
|
||||
document_id: documentId,
|
||||
audit_point: "合同条款审查",
|
||||
found_issue: "违约责任条款不明确",
|
||||
audit_opinion: "合同中违约责任的具体计算方式和赔偿标准需要进一步明确",
|
||||
deduction_score: -3,
|
||||
status: "rejected",
|
||||
created_at: "2024-01-13 09:15:00",
|
||||
is_vote: false,
|
||||
voter_count: 2,
|
||||
proposer_name: "王五",
|
||||
current_user_is_proposer: false
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
evaluation_point_id: 103,
|
||||
document_id: documentId,
|
||||
audit_point: "合同条款审查",
|
||||
found_issue: "违约责任条款不明确",
|
||||
audit_opinion: "合同中违约责任的具体计算方式和赔偿标准需要进一步明确",
|
||||
deduction_score: -3,
|
||||
status: "rejected",
|
||||
created_at: "2024-01-13 09:15:00",
|
||||
is_vote: false,
|
||||
voter_count: 2,
|
||||
proposer_name: "王五",
|
||||
current_user_is_proposer: false
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
evaluation_point_id: 103,
|
||||
document_id: documentId,
|
||||
audit_point: "合同条款审查",
|
||||
found_issue: "违约责任条款不明确",
|
||||
audit_opinion: "合同中违约责任的具体计算方式和赔偿标准需要进一步明确",
|
||||
deduction_score: -3,
|
||||
status: "rejected",
|
||||
created_at: "2024-01-13 09:15:00",
|
||||
is_vote: false,
|
||||
voter_count: 2,
|
||||
proposer_name: "王五",
|
||||
current_user_is_proposer: false
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
evaluation_point_id: 103,
|
||||
document_id: documentId,
|
||||
audit_point: "合同条款审查",
|
||||
found_issue: "违约责任条款不明确",
|
||||
audit_opinion: "合同中违约责任的具体计算方式和赔偿标准需要进一步明确",
|
||||
deduction_score: -3,
|
||||
status: "rejected",
|
||||
created_at: "2024-01-13 09:15:00",
|
||||
is_vote: false,
|
||||
voter_count: 2,
|
||||
proposer_name: "王五",
|
||||
current_user_is_proposer: false
|
||||
},
|
||||
{
|
||||
id: 10,
|
||||
evaluation_point_id: 103,
|
||||
document_id: documentId,
|
||||
audit_point: "合同条款审查",
|
||||
found_issue: "违约责任条款不明确",
|
||||
audit_opinion: "合同中违约责任的具体计算方式和赔偿标准需要进一步明确",
|
||||
deduction_score: -3,
|
||||
status: "rejected",
|
||||
created_at: "2024-01-13 09:15:00",
|
||||
is_vote: false,
|
||||
voter_count: 2,
|
||||
proposer_name: "王五",
|
||||
current_user_is_proposer: false
|
||||
},
|
||||
{
|
||||
id: 11,
|
||||
evaluation_point_id: 103,
|
||||
document_id: documentId,
|
||||
audit_point: "合同条款审查",
|
||||
found_issue: "违约责任条款不明确",
|
||||
audit_opinion: "合同中违约责任的具体计算方式和赔偿标准需要进一步明确",
|
||||
deduction_score: -3,
|
||||
status: "rejected",
|
||||
created_at: "2024-01-13 09:15:00",
|
||||
is_vote: false,
|
||||
voter_count: 2,
|
||||
proposer_name: "王五",
|
||||
current_user_is_proposer: false
|
||||
},
|
||||
];
|
||||
|
||||
if (response.error) {
|
||||
return {
|
||||
error: response.error,
|
||||
status: response.status || 500
|
||||
};
|
||||
}
|
||||
// 模拟分页
|
||||
const total = mockOpinions.length;
|
||||
const startIndex = (page - 1) * pageSize;
|
||||
const endIndex = startIndex + pageSize;
|
||||
const paginatedOpinions = mockOpinions.slice(startIndex, endIndex);
|
||||
|
||||
return {
|
||||
data: (response.data as CrossCheckingOpinion[]) || []
|
||||
data: {
|
||||
opinions: paginatedOpinions,
|
||||
total: total
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取交叉评查意见失败:', error);
|
||||
@@ -128,3 +305,61 @@ export async function getCrossCheckingOpinions(documentId: string | number): Pro
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 意见操作类型
|
||||
*/
|
||||
export type OpinionActionType = 'agree' | 'disagree' | 'withdraw_vote' | 'withdraw_opinion';
|
||||
|
||||
/**
|
||||
* 意见操作请求参数
|
||||
*/
|
||||
export interface OpinionActionRequest {
|
||||
opinionId: string | number;
|
||||
action: OpinionActionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行意见操作(赞同、反对、撤销投票、撤销意见)
|
||||
* @param actionData 操作数据
|
||||
* @returns 操作结果
|
||||
*/
|
||||
export async function performOpinionAction(
|
||||
actionData: OpinionActionRequest
|
||||
): Promise<ApiResponse<{ success: boolean; message: string }>> {
|
||||
try {
|
||||
// 模拟API调用延迟
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
|
||||
let message = '';
|
||||
switch (actionData.action) {
|
||||
case 'agree':
|
||||
message = '已赞同该意见';
|
||||
break;
|
||||
case 'disagree':
|
||||
message = '已反对该意见';
|
||||
break;
|
||||
case 'withdraw_vote':
|
||||
message = '已撤销投票';
|
||||
break;
|
||||
case 'withdraw_opinion':
|
||||
message = '已撤销意见';
|
||||
break;
|
||||
default:
|
||||
throw new Error('无效的操作类型');
|
||||
}
|
||||
|
||||
return {
|
||||
data: {
|
||||
success: true,
|
||||
message: message
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('执行意见操作失败:', error);
|
||||
return {
|
||||
error: error instanceof Error ? error.message : '操作失败',
|
||||
status: 500
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ const mockTasks: CrossCheckingTask[] = [
|
||||
status: CrossCheckingTaskStatus.COMPLETED,
|
||||
score: 95,
|
||||
operation: '查看结果',
|
||||
documentIds: [1, 2, 3, 4, 5]
|
||||
documentIds: [1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, 1365, 1366, 1367, 1368, 1369, 1370,1371,1372,1373,1374]
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
@@ -148,7 +148,7 @@ const mockTasks: CrossCheckingTask[] = [
|
||||
*/
|
||||
export async function getCrossCheckingTasks(params: TaskListParams = {}): Promise<ApiResponse<TaskListResponse>> {
|
||||
try {
|
||||
// 模拟API延迟
|
||||
// TODO 这个需要对接获取交叉评查任务列表的接口 模拟API延迟
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
|
||||
const {
|
||||
@@ -296,15 +296,24 @@ export async function deleteCrossCheckingTask(taskId: number): Promise<ApiRespon
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取任务详情
|
||||
* 获取任务详情及相关文档
|
||||
* @param taskId 任务ID
|
||||
* @returns 任务详情
|
||||
* @param documentIds 指定的文档ID数组,用于筛选任务包含的文档
|
||||
* @param page 页码,默认为1
|
||||
* @param pageSize 每页大小,默认为10
|
||||
* @returns 任务详情和文档列表
|
||||
*/
|
||||
export async function getCrossCheckingTaskDetail(taskId: number): Promise<ApiResponse<CrossCheckingTask>> {
|
||||
export async function getCrossCheckingTaskDetail(
|
||||
taskId: number,
|
||||
documentIds: number[],
|
||||
page: number = 1,
|
||||
pageSize: number = 10
|
||||
): Promise<ApiResponse<{
|
||||
task: CrossCheckingTask;
|
||||
files: import('../evaluation_points/rules-files').ReviewFileUI[];
|
||||
total: number;
|
||||
}>> {
|
||||
try {
|
||||
// 模拟API延迟
|
||||
await new Promise(resolve => setTimeout(resolve, 300));
|
||||
|
||||
const task = mockTasks.find(t => t.id === taskId);
|
||||
if (!task) {
|
||||
return {
|
||||
@@ -313,9 +322,39 @@ export async function getCrossCheckingTaskDetail(taskId: number): Promise<ApiRes
|
||||
};
|
||||
}
|
||||
|
||||
let files: import('../evaluation_points/rules-files').ReviewFileUI[] = [];
|
||||
let total = 0;
|
||||
|
||||
// 如果提供了documentIds,则调用getReviewFiles获取相关文档
|
||||
if (documentIds && documentIds.length > 0) {
|
||||
const { getReviewFiles } = await import('../evaluation_points/rules-files');
|
||||
|
||||
const reviewFilesResponse = await getReviewFiles({
|
||||
page: page,
|
||||
pageSize: pageSize,
|
||||
sortOrder: 'upload_time_desc'
|
||||
}, documentIds);
|
||||
|
||||
if (reviewFilesResponse.error) {
|
||||
return {
|
||||
success: false,
|
||||
error: reviewFilesResponse.error
|
||||
};
|
||||
}
|
||||
|
||||
files = reviewFilesResponse.data?.files || [];
|
||||
total = reviewFilesResponse.data?.total || 0;
|
||||
}
|
||||
|
||||
console.log('files', files);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: task
|
||||
data: {
|
||||
task,
|
||||
files,
|
||||
total
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取任务详情失败:', error);
|
||||
|
||||
Reference in New Issue
Block a user