feat:项目管理-审计内容-取证单生成
This commit is contained in:
@@ -742,3 +742,39 @@ export async function exportDefault1Table(data: {
|
||||
}
|
||||
return Promise.reject(new Error('导出失败'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成取证单
|
||||
*/
|
||||
export async function generateAuditEvidence(data: {
|
||||
// 基础信息
|
||||
caseIndex?: string; // 案引号
|
||||
projectName?: string; // 项目名称
|
||||
auditedTarget?: string; // 被审计单位或个人
|
||||
auditMatter?: string; // 审计事项
|
||||
summaryTitle?: string; // 标题
|
||||
auditRecord?: string; // 审计记录
|
||||
auditFinding?: string; // 审计发现
|
||||
evidenceBasis?: string; // 定性依据
|
||||
handling?: string; // 处理
|
||||
suggestion?: string; // 建议
|
||||
attachment?: string; // 附件
|
||||
auditors?: string; // 审计人员
|
||||
compileDate?: string; // 编制日期
|
||||
providerOpinion?: string; // 证据提供单位意见
|
||||
providerDate?: string; // 证据提供日期
|
||||
attachmentPages?: string; // 附件页数
|
||||
feedbackDeadline?: string; // 反馈期限
|
||||
|
||||
history?: string; // 历史内容(用于工作流生成)
|
||||
}) {
|
||||
const res = await request.post<ApiResult<any>>(
|
||||
MODULES_API_URL + '/ai/auditEvidence/generate',
|
||||
data
|
||||
);
|
||||
|
||||
if (res.data.code === 0) {
|
||||
return res.data;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
@@ -295,28 +295,61 @@
|
||||
const form = reactive(defaultForm());
|
||||
|
||||
const applyBaseInfo = () => {
|
||||
console.log('applyBaseInfo called, selectedRows:', props.selectedRows);
|
||||
console.log('baseInfo:', props.baseInfo);
|
||||
|
||||
// 重置表单为默认值
|
||||
Object.assign(form, defaultForm(), props.baseInfo || {});
|
||||
|
||||
// 如果有传入的selectedRows,直接使用第一个对象的数据(生成取证单时通常只有一个)
|
||||
if (props.selectedRows && props.selectedRows.length > 0) {
|
||||
const firstRow: any = props.selectedRows[0] || {};
|
||||
form.summaryTitle =
|
||||
firstRow.title || firstRow.name || form.summaryTitle || '';
|
||||
form.auditRecord =
|
||||
firstRow.auditRecord ||
|
||||
firstRow.auditContent ||
|
||||
firstRow.content ||
|
||||
form.auditRecord ||
|
||||
'';
|
||||
form.auditFinding =
|
||||
firstRow.auditFinding || firstRow.testResult || form.auditFinding || '';
|
||||
const evidenceData = props.selectedRows[0] || {};
|
||||
console.log('Evidence data from selectedRows:', evidenceData);
|
||||
|
||||
// 直接将后端返回的数据映射到表单字段
|
||||
form.caseIndex = evidenceData.caseIndex || form.caseIndex || '';
|
||||
form.projectName = evidenceData.projectName || form.projectName || '';
|
||||
form.auditedTarget = evidenceData.auditedTarget || form.auditedTarget || '';
|
||||
form.auditMatter = evidenceData.auditMatter || form.auditMatter || '';
|
||||
form.summaryTitle = evidenceData.summaryTitle || form.summaryTitle || '';
|
||||
form.auditRecord = evidenceData.auditRecord || form.auditRecord || '';
|
||||
form.auditFinding = evidenceData.auditFinding || form.auditFinding || '';
|
||||
form.evidenceBasis = evidenceData.evidenceBasis || form.evidenceBasis || '';
|
||||
form.handling = evidenceData.handling || form.handling || '';
|
||||
form.suggestion = evidenceData.suggestion || form.suggestion || '';
|
||||
form.auditors = evidenceData.auditors || form.auditors || '';
|
||||
form.compileDate = evidenceData.compileDate || form.compileDate || '';
|
||||
form.providerOpinion = evidenceData.providerOpinion || form.providerOpinion || '';
|
||||
form.providerDate = evidenceData.providerDate || form.providerDate || '';
|
||||
form.attachmentPages = evidenceData.attachmentPages || form.attachmentPages || '';
|
||||
form.feedbackDeadline = evidenceData.feedbackDeadline || form.feedbackDeadline || '';
|
||||
|
||||
// 处理attachment字段(数组转字符串)
|
||||
if (evidenceData.attachment) {
|
||||
form.attachment = Array.isArray(evidenceData.attachment)
|
||||
? evidenceData.attachment.join('\n')
|
||||
: evidenceData.attachment;
|
||||
}
|
||||
|
||||
// 特殊处理:如果evidenceData中有title字段,也填充到summaryTitle
|
||||
if (evidenceData.title && !form.summaryTitle) {
|
||||
form.summaryTitle = evidenceData.title;
|
||||
}
|
||||
}
|
||||
|
||||
// 设置默认编制日期(如果没有的话)
|
||||
if (!form.compileDate) {
|
||||
const now = new Date();
|
||||
form.compileDate = `${now.getFullYear()}-${String(
|
||||
now.getMonth() + 1
|
||||
now.getMonth() + 1
|
||||
).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
// 确保页码字段有值
|
||||
if (!form.pageIndex) form.pageIndex = '1';
|
||||
if (!form.pageTotal) form.pageTotal = '1';
|
||||
|
||||
console.log('Form data after applyBaseInfo:', JSON.stringify(form, null, 2));
|
||||
};
|
||||
|
||||
watch(
|
||||
@@ -329,7 +362,18 @@
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.baseInfo,
|
||||
() => props.baseInfo,
|
||||
() => {
|
||||
if (props.visible) {
|
||||
applyBaseInfo();
|
||||
}
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
|
||||
|
||||
watch(
|
||||
() => props.selectedRows,
|
||||
() => {
|
||||
if (props.visible) {
|
||||
applyBaseInfo();
|
||||
|
||||
@@ -218,6 +218,13 @@
|
||||
<a-button @click="openEvidenceModal(index)"
|
||||
>导出取证单</a-button
|
||||
>
|
||||
<a-button
|
||||
type="primary"
|
||||
@click="generateEvidence(index)"
|
||||
:loading="generatingEvidenceStates[getTableKey(index)]"
|
||||
>
|
||||
生成取证单
|
||||
</a-button>
|
||||
<template v-if="item.tableOptions.length > 0">
|
||||
<div class="flex items-center">
|
||||
<span class="mr-2">切换表格:</span>
|
||||
@@ -570,6 +577,9 @@
|
||||
// ========== 保存状态管理 ==========
|
||||
const savingStates = reactive({});
|
||||
|
||||
// ========== 生成取证单状态管理 ==========
|
||||
const generatingEvidenceStates = reactive({});
|
||||
|
||||
// ========== 编辑相关状态 ==========
|
||||
const editModalVisible = ref(false);
|
||||
const editingRecord = ref<any>(null);
|
||||
@@ -915,6 +925,152 @@
|
||||
}
|
||||
};
|
||||
|
||||
/* 生成取证单 */
|
||||
const generateEvidence = async (sectionIndex: number) => {
|
||||
const tableInfo = getTableInfo(sectionIndex);
|
||||
if (!tableInfo) {
|
||||
message.error('表格配置不存在');
|
||||
return;
|
||||
}
|
||||
|
||||
const { section, currentTable, tableKey } = tableInfo;
|
||||
|
||||
// 设置生成状态
|
||||
generatingEvidenceStates[tableKey] = true;
|
||||
|
||||
try {
|
||||
// 获取当前表格的生成数据
|
||||
const generationData = getTableGenerationData(tableKey);
|
||||
|
||||
// 构建history参数,使用当前表格的responseData内容
|
||||
let historyData = '';
|
||||
if (generationData && generationData.responseData) {
|
||||
historyData = JSON.stringify(generationData.responseData, null, 2);
|
||||
} else if (section.data && section.data.length > 0) {
|
||||
// 如果没有生成数据,使用当前表格数据
|
||||
historyData = JSON.stringify({
|
||||
success: true,
|
||||
data: section.data,
|
||||
data_source: currentTable.value
|
||||
}, null, 2);
|
||||
}
|
||||
|
||||
// 检查history是否为空 - 新增的验证逻辑
|
||||
if (!historyData || historyData.trim() === '') {
|
||||
message.error('无法生成取证单:没有找到相关的审计数据,请先生成表格内容');
|
||||
return;
|
||||
}
|
||||
|
||||
// 调用generateAuditEvidence API
|
||||
const requestData = {
|
||||
// 基础信息
|
||||
caseIndex: (form as any).code || props.data?.code || '',
|
||||
projectName: form.name || props.data?.name || '',
|
||||
auditedTarget: (form as any).nickname || (props.data as any)?.nickname || '',
|
||||
auditMatter: currentTable.title || section?.title || section?.name || '',
|
||||
summaryTitle: section?.title || section?.name || '',
|
||||
auditRecord: '',
|
||||
auditFinding: '',
|
||||
evidenceBasis: '',
|
||||
handling: '',
|
||||
suggestion: section.suggestion || '',
|
||||
attachment: '',
|
||||
auditors: '',
|
||||
compileDate: new Date().toISOString().split('T')[0], // 当前日期
|
||||
providerOpinion: '',
|
||||
providerDate: '',
|
||||
attachmentPages: '',
|
||||
feedbackDeadline: '',
|
||||
|
||||
// 历史内容(用于工作流生成)
|
||||
history: historyData,
|
||||
|
||||
// 项目相关参数
|
||||
projectId: props.data?.id || '',
|
||||
kbIds: props.data?.kbId || '',
|
||||
libraryIds: props.data?.libraryIds || '',
|
||||
projectLibrary: props.data?.projectLibrary || '',
|
||||
docList: checkedDirKeys.value,
|
||||
fileList: selectedFileKeys.value,
|
||||
|
||||
// 重大经济决策调查表需要三重一大数据
|
||||
...(currentTable.value === 'decisionTable'
|
||||
? { data: tripleOneData.value }
|
||||
: {}),
|
||||
// 预算管理审计表需要国资管理数据
|
||||
...(currentTable.value === 'budgetManage'
|
||||
? { data: stateAssetsData.value }
|
||||
: {}),
|
||||
// 预算执行情况审计表需要预算管理审计的数据
|
||||
...(currentTable.value === 'budgetExecution'
|
||||
? { data: tableData['auditContent5_budgetManage'] }
|
||||
: {}),
|
||||
|
||||
// 用户信息(后端会自动设置,这里可以留空或传空字符串)
|
||||
userName: ''
|
||||
};
|
||||
|
||||
const apiResult = await auditContentApi.generateAuditEvidence(requestData);
|
||||
|
||||
if (apiResult.code === 0 && apiResult.data?.success) {
|
||||
message.success('取证单生成成功');
|
||||
|
||||
console.log('生成的取证单数据:', apiResult.data);
|
||||
|
||||
// 自动打开取证单预览弹窗并填充数据
|
||||
evidenceBaseInfo.caseIndex = apiResult.data.caseIndex || (form as any).code || props.data?.code || '';
|
||||
evidenceBaseInfo.projectName = apiResult.data.projectName || form.name || props.data?.name || '';
|
||||
evidenceBaseInfo.auditedTarget = apiResult.data.auditedTarget || (form as any).nickname || (props.data as any)?.nickname || '';
|
||||
evidenceBaseInfo.auditMatter = apiResult.data.auditMatter || currentTable.title || section?.title || section?.name || '';
|
||||
|
||||
// 将生成的取证单数据作为选中的行数据传入,包含所有字段
|
||||
const evidenceData = {
|
||||
// 基础信息字段
|
||||
caseIndex: apiResult.data.caseIndex || '',
|
||||
projectName: apiResult.data.projectName || '',
|
||||
auditedTarget: apiResult.data.auditedTarget || '',
|
||||
auditMatter: apiResult.data.auditMatter || '',
|
||||
summaryTitle: apiResult.data.summaryTitle || '',
|
||||
auditRecord: apiResult.data.auditRecord || '',
|
||||
auditFinding: apiResult.data.auditFinding || '',
|
||||
evidenceBasis: apiResult.data.evidenceBasis || '',
|
||||
handling: apiResult.data.handling || '',
|
||||
suggestion: apiResult.data.suggestion || '',
|
||||
auditors: apiResult.data.auditors || '',
|
||||
compileDate: apiResult.data.compileDate || '',
|
||||
providerOpinion: apiResult.data.providerOpinion || '',
|
||||
providerDate: apiResult.data.providerDate || '',
|
||||
attachmentPages: apiResult.data.attachmentPages || '',
|
||||
feedbackDeadline: apiResult.data.feedbackDeadline || '',
|
||||
|
||||
// 处理附件字段,如果是数组则转换为字符串
|
||||
attachment: Array.isArray(apiResult.data.attachment)
|
||||
? apiResult.data.attachment.join('\n')
|
||||
: apiResult.data.attachment || '',
|
||||
|
||||
// 确保页码字段有默认值
|
||||
pageIndex: '1',
|
||||
pageTotal: '1',
|
||||
|
||||
// 保留其他可能的字段(如success、processing_time、generated_time等)
|
||||
success: apiResult.data.success,
|
||||
processing_time: apiResult.data.processing_time,
|
||||
generated_time: apiResult.data.generated_time
|
||||
};
|
||||
|
||||
evidenceSelectedRows.value = [evidenceData];
|
||||
evidenceModalVisible.value = true;
|
||||
} else {
|
||||
throw new Error(apiResult.data?.error || apiResult.message || '生成取证单失败');
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('生成取证单失败:', error);
|
||||
message.error(`生成取证单失败: ${error.message || '未知错误'}`);
|
||||
} finally {
|
||||
generatingEvidenceStates[tableKey] = false;
|
||||
}
|
||||
};
|
||||
|
||||
/* 通用表格导出方法 */
|
||||
const handleExportTable = async (sectionIndex: number) => {
|
||||
const tableInfo = getTableInfo(sectionIndex);
|
||||
@@ -1612,6 +1768,8 @@
|
||||
delete exportStates[tableKey];
|
||||
if (savingStates[tableKey] !== undefined)
|
||||
delete savingStates[tableKey];
|
||||
if (generatingEvidenceStates[tableKey] !== undefined)
|
||||
delete generatingEvidenceStates[tableKey];
|
||||
|
||||
if (option.value === 'tripleOne') {
|
||||
tripleOneData.value = null;
|
||||
@@ -1771,6 +1929,10 @@
|
||||
Object.keys(selectedRowKeysMap).forEach((key) => {
|
||||
delete selectedRowKeysMap[key as any];
|
||||
});
|
||||
// 清空生成取证单状态
|
||||
Object.keys(generatingEvidenceStates).forEach((key) => {
|
||||
delete generatingEvidenceStates[key as any];
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user