优化交叉评查详情页面
This commit is contained in:
@@ -0,0 +1,130 @@
|
||||
import { postgrestPost } from "../postgrest-client";
|
||||
import { API_BASE_URL } from "../../config/api-config";
|
||||
|
||||
/**
|
||||
* 提出意见的请求参数接口
|
||||
*/
|
||||
export interface SubmitOpinionRequest {
|
||||
reviewPointResultId: string | number;
|
||||
documentId: string | number;
|
||||
auditPoint: string;
|
||||
foundIssue: string;
|
||||
auditOpinion: string;
|
||||
deductionScore: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提出意见的响应接口
|
||||
*/
|
||||
export interface SubmitOpinionResponse {
|
||||
success: boolean;
|
||||
message: string;
|
||||
data?: {
|
||||
id: string | number;
|
||||
created_at: string;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 交叉评查意见数据接口
|
||||
*/
|
||||
export interface CrossCheckingOpinion {
|
||||
id: string | number;
|
||||
evaluation_point_id: string | number;
|
||||
document_id: string | number;
|
||||
audit_point: string;
|
||||
found_issue: string;
|
||||
audit_opinion: string;
|
||||
deduction_score: number;
|
||||
status: string;
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* API响应格式
|
||||
*/
|
||||
export interface ApiResponse<T> {
|
||||
data?: T;
|
||||
error?: string;
|
||||
status?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交交叉评查意见
|
||||
* @param opinionData 意见数据
|
||||
* @returns 提交结果
|
||||
*/
|
||||
export async function submitCrossCheckingOpinion(
|
||||
opinionData: SubmitOpinionRequest
|
||||
): Promise<ApiResponse<SubmitOpinionResponse>> {
|
||||
try {
|
||||
const requestData = {
|
||||
proposer_user_id: 1,
|
||||
evaluation_result_id: opinionData.reviewPointResultId,
|
||||
// document_id: opinionData.documentId,
|
||||
// audit_point: opinionData.auditPoint,
|
||||
// found_issue: opinionData.foundIssue,
|
||||
proposed_score: opinionData.deductionScore,
|
||||
reason: opinionData.auditOpinion
|
||||
};
|
||||
|
||||
const response = await fetch(`${API_BASE_URL}/admin/cross_review/proposals`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(data.message || '提交失败');
|
||||
}
|
||||
|
||||
return {
|
||||
data: {
|
||||
success: true,
|
||||
message: '意见提交成功',
|
||||
data: data
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('提交交叉评查意见失败:', error);
|
||||
return {
|
||||
error: error instanceof Error ? error.message : '提交意见失败',
|
||||
status: 500
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取交叉评查意见列表
|
||||
* @param documentId 文档ID
|
||||
* @returns 意见列表
|
||||
*/
|
||||
export async function getCrossCheckingOpinions(documentId: string | number): Promise<ApiResponse<CrossCheckingOpinion[]>> {
|
||||
try {
|
||||
const response = await postgrestPost('rpc/get_cross_checking_opinions', {
|
||||
p_document_id: documentId
|
||||
});
|
||||
|
||||
if (response.error) {
|
||||
return {
|
||||
error: response.error,
|
||||
status: response.status || 500
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
data: (response.data as CrossCheckingOpinion[]) || []
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取交叉评查意见失败:', error);
|
||||
return {
|
||||
error: error instanceof Error ? error.message : '获取意见列表失败',
|
||||
status: 500
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user