diff --git a/src/api/ai/aiHistory/index.ts b/src/api/ai/aiHistory/index.ts new file mode 100644 index 0000000..d665b5b --- /dev/null +++ b/src/api/ai/aiHistory/index.ts @@ -0,0 +1,129 @@ +import request from '@/utils/request'; +import type { ApiResult, PageResult } from '@/api'; +import type { AiHistory, AiHistoryParam } from './model'; +import { MODULES_API_URL } from '@/config/setting'; + +/** + * 分页查询AI审计历史记录表 + */ +export async function pageAiHistory(params: AiHistoryParam) { + const res = await request.get>>( + `${MODULES_API_URL}/ai/history/page`, + { params } + ); + if (res.data.code === 0) { + return res.data.data; + } + return Promise.reject(new Error(res.data.message)); +} + +/** + * 查询AI审计历史记录表列表 + */ +export async function listAiHistory(params?: AiHistoryParam) { + const res = await request.get>( + `${MODULES_API_URL}/ai/history`, + { params } + ); + if (res.data.code === 0 && res.data.data) { + return res.data.data; + } + return Promise.reject(new Error(res.data.message)); +} + +/** + * 根据id查询AI审计历史记录表 + */ +export async function getAiHistory(id: number) { + const res = await request.get>( + `${MODULES_API_URL}/ai/history/${id}` + ); + if (res.data.code === 0 && res.data.data) { + return res.data.data; + } + return Promise.reject(new Error(res.data.message)); +} + +/** + * 添加AI审计历史记录表 + */ +export async function addAiHistory(data: AiHistory) { + const res = await request.post>( + `${MODULES_API_URL}/ai/history`, + data + ); + if (res.data.code === 0) { + return res.data.message; + } + return Promise.reject(new Error(res.data.message)); +} + +/** + * 修改AI审计历史记录表 + */ +export async function updateAiHistory(data: AiHistory) { + const res = await request.put>( + `${MODULES_API_URL}/ai/history`, + data + ); + if (res.data.code === 0) { + return res.data.message; + } + return Promise.reject(new Error(res.data.message)); +} + +/** + * 删除AI审计历史记录表 + */ +export async function removeAiHistory(id?: number) { + const res = await request.delete>( + `${MODULES_API_URL}/ai/history/${id}` + ); + if (res.data.code === 0) { + return res.data.message; + } + return Promise.reject(new Error(res.data.message)); +} + +/** + * 批量添加AI审计历史记录表 + */ +export async function addAiHistoryBatch(data: AiHistory[]) { + const res = await request.post>( + `${MODULES_API_URL}/ai/history/batch`, + data + ); + if (res.data.code === 0) { + return res.data.message; + } + return Promise.reject(new Error(res.data.message)); +} + +/** + * 批量修改AI审计历史记录表 + */ +export async function updateAiHistoryBatch(data: { list: AiHistory[] }) { + const res = await request.put>( + `${MODULES_API_URL}/ai/history/batch`, + data + ); + if (res.data.code === 0) { + return res.data.message; + } + return Promise.reject(new Error(res.data.message)); +} + +/** + * 批量删除AI审计历史记录表 + */ +export async function removeAiHistoryBatch(ids: number[]) { + const res = await request.delete>( + `${MODULES_API_URL}/ai/history/batch`, + { data: ids } + ); + if (res.data.code === 0) { + return res.data.message; + } + return Promise.reject(new Error(res.data.message)); +} + diff --git a/src/api/ai/aiHistory/model/index.ts b/src/api/ai/aiHistory/model/index.ts new file mode 100644 index 0000000..f2a7ffe --- /dev/null +++ b/src/api/ai/aiHistory/model/index.ts @@ -0,0 +1,41 @@ +import type { PageParam } from '@/api'; + +/** + * AI审计历史记录表 + */ +export interface AiHistory { + // 主键ID + id?: number; + // 请求哈希值 + requestHash?: string; + // 接口名称 + interfaceName?: string; + // 用户ID + userId?: number; + // 用户名 + username?: string; + // 状态, 0正常, 1冻结 + status?: number; + // 是否删除, 0否, 1是 + deleted?: number; + // 租户id + tenantId?: number; + // 创建时间 + createTime?: string; + // 修改时间 + updateTime?: string; +} + +/** + * AI审计历史记录表搜索条件 + */ +export interface AiHistoryParam extends PageParam { + id?: number; + requestHash?: string; + interfaceName?: string; + userId?: number; + username?: string; + status?: number; + deleted?: number; + tenantId?: number; +} diff --git a/src/views/pwl/pwlProject/components/components/HistoryModal.vue b/src/views/pwl/pwlProject/components/components/HistoryModal.vue index cba7372..e786fea 100644 --- a/src/views/pwl/pwlProject/components/components/HistoryModal.vue +++ b/src/views/pwl/pwlProject/components/components/HistoryModal.vue @@ -1,271 +1,286 @@ + + \ No newline at end of file diff --git a/src/views/pwl/pwlProject/components/reportContent.vue b/src/views/pwl/pwlProject/components/reportContent.vue index 76f6f0f..24990af 100644 --- a/src/views/pwl/pwlProject/components/reportContent.vue +++ b/src/views/pwl/pwlProject/components/reportContent.vue @@ -237,13 +237,11 @@ 共生成 - {{ - item.count - }} + {{ item.data ? item.data.length : 0 }} 条数据 - 历史记录 + 历史记录 @@ -468,6 +466,9 @@ // 文档管理相关变量 const currentCompanyId = ref(); + // 历史记录接口相关变量 + const currentInterfaceName = ref(''); + // 添加计算属性检查是否已生成三重一大数据 const hasTripleOneData = computed(() => { const section = navigationItems.value[2]; @@ -869,16 +870,7 @@ console.log('三重一大接口返回结果:', result); if (result.code === 0 && result.data && result.data.success) { - const tableData = result.data.data.map((item, index) => ({ - key: index, - category: item.category || '', - policyContent: item.policyContent || '', - groupSystem: item.groupSystem || '', - companyFormulation: item.companyFormulation || '', - checkEvidence: item.checkEvidence || '', - testResult: item.testResult || '待检查', - workPaperIndex: item.workPaperIndex || [] - })); + const tableData = mapTripleOneData(result.data.data); // 保存到三重一大数据 tripleOneTableData.value = tableData; @@ -949,18 +941,7 @@ console.log('重大经济决策调查表接口返回结果:', result); if (result.code === 0 && result.data && result.data.success) { - const tableData = result.data.data.map((item, index) => ({ - key: index, - index: index + 1, - name: item.decisionItem || '', - meetingTime: item.meetingTime || '', - decisionAmount: item.decisionAmount || '', - procedure: item.procedure || '', - executionStatus: item.executionStatus || '否', - goods: item.executionEffect?.good || '否', - normal: item.executionEffect?.normal || '否', - bad: item.executionEffect?.bad || '否' - })); + const tableData = mapDecisionTableData(result.data.data); console.log('生成的表格数据:', tableData); @@ -1149,12 +1130,106 @@ } ); + // 数据映射工具函数 + const mapTripleOneData = (data: any[]) => { + return data.map((item, index) => ({ + key: index, + category: item.category || '', + policyContent: item.policyContent || '', + groupSystem: item.groupSystem || '', + companyFormulation: item.companyFormulation || '', + checkEvidence: item.checkEvidence || '', + testResult: item.testResult || '待检查', + workPaperIndex: item.workPaperIndex || [] + })); + }; + + const mapDecisionTableData = (data: any[]) => { + return data.map((item, index) => ({ + key: index, + index: index + 1, + name: item.decisionItem || item.name || '', + meetingTime: item.meetingTime || '', + decisionAmount: item.decisionAmount || '', + procedure: item.procedure || '', + executionStatus: item.executionStatus || '否', + goods: item.executionEffect?.good || item.goods || '否', + normal: item.executionEffect?.normal || item.normal || '否', + bad: item.executionEffect?.bad || item.bad || '否' + })); + }; + + // 应用历史记录数据到指定章节 + const applyHistoryData = (sectionIndex: number, data: any[], dataType: 'tripleOne' | 'decisionTable') => { + const section = navigationItems.value[sectionIndex]; + + if (dataType === 'tripleOne') { + const tableData = mapTripleOneData(data); + section.data = tableData; + tripleOneTableData.value = tableData; + + // 强制刷新当前显示的表格 + if (table3Title.value === '三重一大') { + section.columns = table3Columns.columns0; + section.data = [...tableData]; + } + } else { + const tableData = mapDecisionTableData(data); + section.data = tableData; + decisionTableData.value = tableData; + + // 强制刷新当前显示的表格 + if (table3Title.value === '重大经济决策调查表') { + section.columns = table3Columns.columns1; + section.data = [...tableData]; + } + } + }; + const showHistory = ref(false); - const clickedItem = ref(); - const openHistory = (item) => { - clickedItem.value = item; + const openHistory = (sectionIndex: number) => { + // 重置接口名称 + currentInterfaceName.value = ''; + + // 根据当前章节和表格类型确定接口名称 + if (sectionIndex === 2) { // 审计内容3章节 + if (table3Title.value === '三重一大') { + currentInterfaceName.value = '/api/ai/auditContent3/generateTripleOneTable'; + } else if (table3Title.value === '重大经济决策调查表') { + currentInterfaceName.value = '/api/ai/auditContent3/generateDecisionTable'; + } + } + showHistory.value = true; }; + + // 历史记录选择处理方法 + const handleHistorySelect = (record: any) => { + // 关闭历史记录弹窗 + showHistory.value = false; + + try { + const responseData = JSON.parse(record.responseData); + if (!responseData.success || !responseData.data) { + throw new Error('历史记录数据格式错误'); + } + + // 根据接口名称确定数据类型 + if (record.interfaceName === '/api/ai/auditContent3/generateTripleOneTable') { + applyHistoryData(2, responseData.data, 'tripleOne'); + message.success('已应用选择的三重一大历史记录'); + } else if (record.interfaceName === '/api/ai/auditContent3/generateDecisionTable') { + applyHistoryData(2, responseData.data, 'decisionTable'); + message.success('已应用选择的重大经济决策调查表历史记录'); + } else { + message.warning('不支持的历史记录类型'); + } + } catch (error) { + console.error('解析历史记录数据失败:', error); + message.error('历史记录数据解析失败'); + } + }; +