feat:项目管理-审计内容-取证单生成
This commit is contained in:
@@ -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