完成审计报告生成功能页面
This commit is contained in:
@@ -67,4 +67,120 @@ export async function generateAuditReport2(
|
||||
return res.data.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存审计报告到数据库
|
||||
*/
|
||||
export async function saveAuditReport(data: {
|
||||
projectId?: number;
|
||||
projectName?: string;
|
||||
caseIndex?: string;
|
||||
auditedTarget?: string;
|
||||
reportContent?: string;
|
||||
previewHtml?: string;
|
||||
sectionCount?: number;
|
||||
formCommit?: number;
|
||||
}) {
|
||||
const res = await request.post<ApiResult<any>>(
|
||||
MODULES_API_URL + '/ai/auditReport/save',
|
||||
data
|
||||
);
|
||||
|
||||
if (res.data.code === 0) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询审计报告
|
||||
*/
|
||||
export async function queryAuditReport(params: {
|
||||
projectId: number;
|
||||
formCommit: number;
|
||||
}) {
|
||||
const res = await request.post<ApiResult<any>>(
|
||||
MODULES_API_URL + '/ai/auditReport/query',
|
||||
null,
|
||||
{
|
||||
params
|
||||
}
|
||||
);
|
||||
|
||||
if (res.data.code === 0) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据项目 ID 查询审计报告和取证单数据
|
||||
* @param projectId 项目 ID
|
||||
* @param evidenceIds 勾选的取证单 ID 列表(可选)
|
||||
*/
|
||||
export async function queryAuditDataByProjectId(projectId: number, evidenceIds?: number[]) {
|
||||
console.log('=== 前端发起请求 ===');
|
||||
console.log('projectId:', projectId);
|
||||
console.log('evidenceIds:', evidenceIds);
|
||||
|
||||
const res = await request.post<ApiResult<any>>(
|
||||
MODULES_API_URL + '/ai/auditReport/queryAuditDataByProjectId',
|
||||
evidenceIds ? { evidenceIds } : {},
|
||||
{
|
||||
params: { projectId },
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=UTF-8'
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
console.log('=== 后端返回响应 ===', res);
|
||||
console.log('res.data.code:', res.data.code);
|
||||
console.log('res.data.message:', res.data.message);
|
||||
console.log('res.data.data:', res.data.data);
|
||||
|
||||
if (res.data.code === 0) {
|
||||
return res.data;
|
||||
}
|
||||
console.error('API 返回错误 - code:', res.data.code, ', message:', res.data.message);
|
||||
return Promise.reject(new Error(res.data.message || '操作失败'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据项目 ID 生成审计报告并下载
|
||||
*/
|
||||
export async function generateAuditReportByProjectId(projectId: number) {
|
||||
const res = await request.post(
|
||||
MODULES_API_URL + '/ai/auditReport/generateByProjectId',
|
||||
null,
|
||||
{
|
||||
params: { projectId },
|
||||
responseType: 'blob' // 处理二进制流响应
|
||||
}
|
||||
);
|
||||
|
||||
if (res.status === 200) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error('文件下载失败'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据项目 ID 和选中的取证单生成审计报告并下载
|
||||
*/
|
||||
export async function generateAuditReportWithEvidences(projectId: number, evidenceIds: number[]) {
|
||||
const res = await request.post(
|
||||
MODULES_API_URL + '/ai/auditReport/generateWithEvidences',
|
||||
{ evidenceIds },
|
||||
{
|
||||
params: { projectId },
|
||||
responseType: 'blob' // 处理二进制流响应
|
||||
}
|
||||
);
|
||||
|
||||
if (res.status === 200) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error('文件下载失败'));
|
||||
}
|
||||
Reference in New Issue
Block a user