feat:项目管理-审计内容1-新增八项规定相关内容
This commit is contained in:
@@ -2,6 +2,51 @@ import request from '@/utils/request';
|
|||||||
import type { ApiResult } from '@/api';
|
import type { ApiResult } from '@/api';
|
||||||
import { MODULES_API_URL } from '@/config/setting';
|
import { MODULES_API_URL } from '@/config/setting';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成八项规定对比分析表
|
||||||
|
*/
|
||||||
|
export async function generateEightRegTable(data: {
|
||||||
|
kbIds?: string;
|
||||||
|
libraryIds?: string;
|
||||||
|
projectLibrary?: string;
|
||||||
|
history?: string;
|
||||||
|
suggestion?: string;
|
||||||
|
docList?: any[];
|
||||||
|
fileList?: any[];
|
||||||
|
}) {
|
||||||
|
const res = await request.post<ApiResult<any>>(
|
||||||
|
MODULES_API_URL + '/ai/auditContent1/generateEightRegTable',
|
||||||
|
data
|
||||||
|
);
|
||||||
|
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出八项规定对比分析表到Excel
|
||||||
|
*/
|
||||||
|
export async function exportEightRegTable(data: {
|
||||||
|
data?: any[];
|
||||||
|
companyName?: string;
|
||||||
|
auditTime?: string;
|
||||||
|
}) {
|
||||||
|
const res = await request.post(
|
||||||
|
MODULES_API_URL + '/ai/auditContent1/exportEightRegTable',
|
||||||
|
data,
|
||||||
|
{
|
||||||
|
responseType: 'blob'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (res.status === 200) {
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error('导出失败'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成重大经济决策调查表
|
* 生成重大经济决策调查表
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -179,6 +179,18 @@
|
|||||||
</template>
|
</template>
|
||||||
<template #extra>
|
<template #extra>
|
||||||
<a-space>
|
<a-space>
|
||||||
|
<!-- 添加导出八项规定按钮 -->
|
||||||
|
<a-button
|
||||||
|
v-if="item.extra1 && table1Title === '八项规定'"
|
||||||
|
type="primary"
|
||||||
|
@click="handleExportEightRegTable"
|
||||||
|
:loading="exportingEightReg"
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<DownloadOutlined />
|
||||||
|
</template>
|
||||||
|
导出八项规定
|
||||||
|
</a-button>
|
||||||
<!-- 添加导出重大经济决策调查表按钮 -->
|
<!-- 添加导出重大经济决策调查表按钮 -->
|
||||||
<a-button
|
<a-button
|
||||||
v-if="item.extra3 && table3Title === '重大经济决策调查表'"
|
v-if="item.extra3 && table3Title === '重大经济决策调查表'"
|
||||||
@@ -405,7 +417,9 @@
|
|||||||
generateTripleOneTable,
|
generateTripleOneTable,
|
||||||
generateDecisionTable,
|
generateDecisionTable,
|
||||||
exportTripleOneTable,
|
exportTripleOneTable,
|
||||||
exportDecisionTable
|
exportDecisionTable,
|
||||||
|
generateEightRegTable,
|
||||||
|
exportEightRegTable
|
||||||
} from '@/api/ai/auditContent';
|
} from '@/api/ai/auditContent';
|
||||||
|
|
||||||
import FileModal from '@/views/pwl/pwlProject/components/components/FileModal.vue';
|
import FileModal from '@/views/pwl/pwlProject/components/components/FileModal.vue';
|
||||||
@@ -418,7 +432,6 @@
|
|||||||
import {
|
import {
|
||||||
scrollToSection,
|
scrollToSection,
|
||||||
getScrollContainer,
|
getScrollContainer,
|
||||||
handleKeydown,
|
|
||||||
handleScroll,
|
handleScroll,
|
||||||
buildExportData,
|
buildExportData,
|
||||||
hasContent
|
hasContent
|
||||||
@@ -450,6 +463,7 @@
|
|||||||
// 存储两种表格的数据状态
|
// 存储两种表格的数据状态
|
||||||
const tripleOneTableData = ref([]);
|
const tripleOneTableData = ref([]);
|
||||||
const decisionTableData = ref([]);
|
const decisionTableData = ref([]);
|
||||||
|
const eightRegTableData = ref([]);
|
||||||
|
|
||||||
// 文档选择相关变量
|
// 文档选择相关变量
|
||||||
const showDocSelect = ref(false);
|
const showDocSelect = ref(false);
|
||||||
@@ -485,6 +499,7 @@
|
|||||||
// 添加导出状态
|
// 添加导出状态
|
||||||
const exportingTripleOne = ref(false);
|
const exportingTripleOne = ref(false);
|
||||||
const exportingDecisionTable = ref(false);
|
const exportingDecisionTable = ref(false);
|
||||||
|
const exportingEightReg = ref(false);
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'done'): void;
|
(e: 'done'): void;
|
||||||
@@ -681,6 +696,47 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* 导出八项规定表格 */
|
||||||
|
const handleExportEightRegTable = async () => {
|
||||||
|
const section = navigationItems.value[0];
|
||||||
|
if (!section.data || section.data.length === 0) {
|
||||||
|
message.warning('没有可导出的八项规定数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
exportingEightReg.value = true;
|
||||||
|
try {
|
||||||
|
// 构建导出数据
|
||||||
|
const exportData = {
|
||||||
|
data: section.data,
|
||||||
|
companyName: form.name || '未知公司',
|
||||||
|
auditTime: form.expirationTime || '未知时间'
|
||||||
|
};
|
||||||
|
|
||||||
|
const blob = await exportEightRegTable(exportData);
|
||||||
|
|
||||||
|
// 创建下载链接
|
||||||
|
const url = window.URL.createObjectURL(new Blob([blob]));
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = url;
|
||||||
|
link.setAttribute(
|
||||||
|
'download',
|
||||||
|
`八项规定对比分析表_${form.name || '未知公司'}.xlsx`
|
||||||
|
);
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
window.URL.revokeObjectURL(url);
|
||||||
|
|
||||||
|
message.success('八项规定表格导出成功');
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error('导出八项规定表格失败:', error);
|
||||||
|
message.error('导出失败: ' + (error.message || '未知错误'));
|
||||||
|
} finally {
|
||||||
|
exportingEightReg.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/* 导出三重一大表格 */
|
/* 导出三重一大表格 */
|
||||||
const handleExportTripleOne = async () => {
|
const handleExportTripleOne = async () => {
|
||||||
const section = navigationItems.value[2];
|
const section = navigationItems.value[2];
|
||||||
@@ -765,6 +821,23 @@
|
|||||||
|
|
||||||
/* AI生成内容 */
|
/* AI生成内容 */
|
||||||
const generateContent = async (sectionIndex: number, childIndex?: number) => {
|
const generateContent = async (sectionIndex: number, childIndex?: number) => {
|
||||||
|
// 特殊处理审计内容1(根据当前表格类型调用不同的生成方法)
|
||||||
|
if (sectionIndex === 0) {
|
||||||
|
const section: any = navigationItems.value[sectionIndex];
|
||||||
|
if (section.generateMethod) {
|
||||||
|
await section.generateMethod();
|
||||||
|
} else {
|
||||||
|
// 默认根据表格标题调用相应方法
|
||||||
|
if (table1Title.value === '八项规定') {
|
||||||
|
await generateContent1();
|
||||||
|
} else {
|
||||||
|
// 其他表格类型调用默认方法
|
||||||
|
await generateDefaultContent(sectionIndex, childIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 特殊处理审计内容3(根据当前表格类型调用不同的生成方法)
|
// 特殊处理审计内容3(根据当前表格类型调用不同的生成方法)
|
||||||
if (sectionIndex === 2) {
|
if (sectionIndex === 2) {
|
||||||
const section: any = navigationItems.value[sectionIndex];
|
const section: any = navigationItems.value[sectionIndex];
|
||||||
@@ -781,6 +854,12 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 其他章节的默认生成逻辑
|
||||||
|
await generateDefaultContent(sectionIndex, childIndex);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 默认内容生成方法
|
||||||
|
const generateDefaultContent = async (sectionIndex: number, childIndex?: number) => {
|
||||||
const section: any = navigationItems.value[sectionIndex];
|
const section: any = navigationItems.value[sectionIndex];
|
||||||
|
|
||||||
// 处理主项生成(当主项没有formCommit时)
|
// 处理主项生成(当主项没有formCommit时)
|
||||||
@@ -828,6 +907,70 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 八项规定生成方法
|
||||||
|
const generateContent1 = async () => {
|
||||||
|
const section: any = navigationItems.value[0];
|
||||||
|
section.generating = true;
|
||||||
|
|
||||||
|
// 构建history - 将当前已有的数据作为历史记录
|
||||||
|
const history =
|
||||||
|
section.data && section.data.length > 0
|
||||||
|
? JSON.stringify(section.data, null, 2)
|
||||||
|
: '';
|
||||||
|
|
||||||
|
// 获取用户输入的建议
|
||||||
|
const suggestion = section.suggestion || '';
|
||||||
|
|
||||||
|
console.log('生成八项规定参数:', {
|
||||||
|
kbIds: props.data?.kbId,
|
||||||
|
libraryIds: props.data?.libraryIds,
|
||||||
|
projectLibrary: props.data?.projectLibrary,
|
||||||
|
history: history ? `历史数据(${section.data.length}条)` : '无',
|
||||||
|
suggestion: suggestion || '无',
|
||||||
|
docList: checkedDirKeys.value,
|
||||||
|
fileList: selectedFileKeys.value
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 构建请求参数对象
|
||||||
|
const requestData = {
|
||||||
|
kbIds: props.data?.kbId || '',
|
||||||
|
libraryIds: props.data?.libraryIds || '',
|
||||||
|
projectLibrary: props.data?.projectLibrary || '',
|
||||||
|
history: history,
|
||||||
|
suggestion: suggestion,
|
||||||
|
docList: checkedDirKeys.value,
|
||||||
|
fileList: selectedFileKeys.value
|
||||||
|
};
|
||||||
|
|
||||||
|
// 调用八项规定生成接口
|
||||||
|
const result = await generateEightRegTable(requestData);
|
||||||
|
|
||||||
|
console.log('八项规定接口返回结果:', result);
|
||||||
|
|
||||||
|
if (result.code === 0 && result.data && result.data.success) {
|
||||||
|
const tableData = mapEightRegData(result.data.data);
|
||||||
|
|
||||||
|
// 保存到八项规定数据
|
||||||
|
eightRegTableData.value = tableData;
|
||||||
|
section.data = tableData;
|
||||||
|
|
||||||
|
// 生成成功后清空建议输入框
|
||||||
|
section.suggestion = '';
|
||||||
|
|
||||||
|
message.success(`成功生成 ${tableData.length} 条八项规定对比记录`);
|
||||||
|
} else {
|
||||||
|
const errorMsg = result.data?.error || result.message || '生成失败';
|
||||||
|
throw new Error(errorMsg);
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error('生成八项规定对比分析表失败:', error);
|
||||||
|
message.error('生成失败: ' + (error.message || '未知错误'));
|
||||||
|
} finally {
|
||||||
|
section.generating = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// 三重一大生成方法
|
// 三重一大生成方法
|
||||||
const generateContent3 = async () => {
|
const generateContent3 = async () => {
|
||||||
const section: any = navigationItems.value[2];
|
const section: any = navigationItems.value[2];
|
||||||
@@ -1002,8 +1145,8 @@
|
|||||||
section.generateMethod = generateContent3;
|
section.generateMethod = generateContent3;
|
||||||
} else if (title === '八项规定') {
|
} else if (title === '八项规定') {
|
||||||
section.columns = table1Columns.columns3;
|
section.columns = table1Columns.columns3;
|
||||||
section.data = table1Columns.columns3Data || [];
|
section.data = eightRegTableData.value || table1Columns.columns3Data || [];
|
||||||
section.generateMethod = generateContent3;
|
section.generateMethod = generateContent1;
|
||||||
} else {
|
} else {
|
||||||
section.columns = table1Columns.columns2;
|
section.columns = table1Columns.columns2;
|
||||||
section.data = decisionTableData.value || [];
|
section.data = decisionTableData.value || [];
|
||||||
@@ -1159,21 +1302,34 @@
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 八项规定数据映射函数
|
||||||
|
const mapEightRegData = (data: any[]) => {
|
||||||
|
return data.map((item, index) => ({
|
||||||
|
key: index,
|
||||||
|
title: item.title || '',
|
||||||
|
content: item.content || '',
|
||||||
|
testContent: item.testContent || '',
|
||||||
|
result: item.result || '待检查',
|
||||||
|
workPaperIndex: item.workPaperIndex || []
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
// 应用历史记录数据到指定章节
|
// 应用历史记录数据到指定章节
|
||||||
const applyHistoryData = (sectionIndex: number, data: any[], dataType: 'tripleOne' | 'decisionTable') => {
|
const applyHistoryData = (sectionIndex: number, data: any[], dataType: 'tripleOne' | 'decisionTable' | 'eightReg') => {
|
||||||
const section = navigationItems.value[sectionIndex];
|
const section = navigationItems.value[sectionIndex];
|
||||||
|
|
||||||
if (dataType === 'tripleOne') {
|
if (dataType === 'tripleOne') {
|
||||||
const tableData = mapTripleOneData(data);
|
const tableData = mapTripleOneData(data);
|
||||||
section.data = tableData;
|
section.data = tableData;
|
||||||
tripleOneTableData.value = tableData;
|
tripleOneTableData.value = tableData;
|
||||||
|
tripleOneData.value = data;
|
||||||
|
|
||||||
// 强制刷新当前显示的表格
|
// 强制刷新当前显示的表格
|
||||||
if (table3Title.value === '三重一大') {
|
if (table3Title.value === '三重一大') {
|
||||||
section.columns = table3Columns.columns0;
|
section.columns = table3Columns.columns0;
|
||||||
section.data = [...tableData];
|
section.data = [...tableData];
|
||||||
}
|
}
|
||||||
} else {
|
} else if (dataType === 'decisionTable') {
|
||||||
const tableData = mapDecisionTableData(data);
|
const tableData = mapDecisionTableData(data);
|
||||||
section.data = tableData;
|
section.data = tableData;
|
||||||
decisionTableData.value = tableData;
|
decisionTableData.value = tableData;
|
||||||
@@ -1183,6 +1339,16 @@
|
|||||||
section.columns = table3Columns.columns1;
|
section.columns = table3Columns.columns1;
|
||||||
section.data = [...tableData];
|
section.data = [...tableData];
|
||||||
}
|
}
|
||||||
|
} else if (dataType === 'eightReg') {
|
||||||
|
const tableData = mapEightRegData(data);
|
||||||
|
section.data = tableData;
|
||||||
|
eightRegTableData.value = tableData;
|
||||||
|
|
||||||
|
// 强制刷新当前显示的表格
|
||||||
|
if (table1Title.value === '八项规定') {
|
||||||
|
section.columns = table1Columns.columns3;
|
||||||
|
section.data = [...tableData];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1192,7 +1358,11 @@
|
|||||||
currentInterfaceName.value = '';
|
currentInterfaceName.value = '';
|
||||||
|
|
||||||
// 根据当前章节和表格类型确定接口名称
|
// 根据当前章节和表格类型确定接口名称
|
||||||
if (sectionIndex === 2) { // 审计内容3章节
|
if (sectionIndex === 0) { // 审计内容1章节
|
||||||
|
if (table1Title.value === '八项规定') {
|
||||||
|
currentInterfaceName.value = '/api/ai/auditContent1/generateEightRegTable';
|
||||||
|
}
|
||||||
|
} else if (sectionIndex === 2) { // 审计内容3章节
|
||||||
if (table3Title.value === '三重一大') {
|
if (table3Title.value === '三重一大') {
|
||||||
currentInterfaceName.value = '/api/ai/auditContent3/generateTripleOneTable';
|
currentInterfaceName.value = '/api/ai/auditContent3/generateTripleOneTable';
|
||||||
} else if (table3Title.value === '重大经济决策调查表') {
|
} else if (table3Title.value === '重大经济决策调查表') {
|
||||||
@@ -1215,7 +1385,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 根据接口名称确定数据类型
|
// 根据接口名称确定数据类型
|
||||||
if (record.interfaceName === '/api/ai/auditContent3/generateTripleOneTable') {
|
if (record.interfaceName === '/api/ai/auditContent1/generateEightRegTable') {
|
||||||
|
applyHistoryData(0, responseData.data, 'eightReg');
|
||||||
|
message.success('已应用选择的八项规定历史记录');
|
||||||
|
} else if (record.interfaceName === '/api/ai/auditContent3/generateTripleOneTable') {
|
||||||
applyHistoryData(2, responseData.data, 'tripleOne');
|
applyHistoryData(2, responseData.data, 'tripleOne');
|
||||||
message.success('已应用选择的三重一大历史记录');
|
message.success('已应用选择的三重一大历史记录');
|
||||||
} else if (record.interfaceName === '/api/ai/auditContent3/generateDecisionTable') {
|
} else if (record.interfaceName === '/api/ai/auditContent3/generateDecisionTable') {
|
||||||
|
|||||||
Reference in New Issue
Block a user