添加交叉评查任务的文档列表,评查详情的意见列表
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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user