feat(pwl): 接入生成报告接口功能
This commit is contained in:
38
src/api/ai/auditReport/index.ts
Normal file
38
src/api/ai/auditReport/index.ts
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import request from '@/utils/request';
|
||||||
|
import type { ApiResult, PageResult } from '@/api';
|
||||||
|
import type { AuditReport, AuditReportParam } from './model';
|
||||||
|
import { MODULES_API_URL } from '@/config/setting';
|
||||||
|
import {User} from "@/api/system/user/model";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成审计报告-单一模块
|
||||||
|
*/
|
||||||
|
export async function generateAuditReport(data: AuditReport) {
|
||||||
|
const res = await request.post<ApiResult<unknown>>(
|
||||||
|
MODULES_API_URL + '/ai/auditReport/generate',
|
||||||
|
data
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成并下载审计报告
|
||||||
|
*/
|
||||||
|
export async function downloadAuditReport(req: AuditReport) {
|
||||||
|
const res = await request.post(
|
||||||
|
MODULES_API_URL + '/ai/auditReport/download',
|
||||||
|
req,
|
||||||
|
{
|
||||||
|
responseType: 'blob' // 处理二进制流响应
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (res.status === 200) {
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error('文件下载失败'));
|
||||||
|
}
|
||||||
39
src/api/ai/auditReport/model/index.ts
Normal file
39
src/api/ai/auditReport/model/index.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import type { PageParam } from '@/api';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审计报告
|
||||||
|
*/
|
||||||
|
export interface AuditReport {
|
||||||
|
// 审计标题
|
||||||
|
from0?: string;
|
||||||
|
// 审计依据
|
||||||
|
from1?: string;
|
||||||
|
// 审计目标
|
||||||
|
from2?: string;
|
||||||
|
// 审计对象和范围
|
||||||
|
from3?: string;
|
||||||
|
// 被审计单位基本情况-单位概况
|
||||||
|
from41?: string;
|
||||||
|
// 被审计单位基本情况-机构和人员相关情况
|
||||||
|
from42?: string;
|
||||||
|
// 审计内容和重点及审计方法
|
||||||
|
from5?: string;
|
||||||
|
// 知识库ID
|
||||||
|
kbId?: string;
|
||||||
|
// 生成模块:AuditReportEnum.code
|
||||||
|
formCommit?: number;
|
||||||
|
// 历史内容
|
||||||
|
history?: string;
|
||||||
|
// 修改建议
|
||||||
|
suggestion?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审计报告搜索条件
|
||||||
|
*/
|
||||||
|
export interface AuditReportParam extends PageParam {
|
||||||
|
id?: number;
|
||||||
|
type?: string;
|
||||||
|
itemYear?: string;
|
||||||
|
keywords?: string;
|
||||||
|
}
|
||||||
@@ -106,6 +106,8 @@ export interface OaCompany {
|
|||||||
createTime?: string;
|
createTime?: string;
|
||||||
// 修改时间
|
// 修改时间
|
||||||
updateTime?: string;
|
updateTime?: string;
|
||||||
|
// 知识库id
|
||||||
|
kbId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -95,6 +95,8 @@ export interface PwlProject {
|
|||||||
createTime?: string;
|
createTime?: string;
|
||||||
// 修改时间
|
// 修改时间
|
||||||
updateTime?: string;
|
updateTime?: string;
|
||||||
|
// 知识库id
|
||||||
|
kbId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -457,6 +457,7 @@ const chooseType = (data: DictData) => {
|
|||||||
const onCompany = (item: OaCompany) => {
|
const onCompany = (item: OaCompany) => {
|
||||||
console.log('选择的公司:', item);
|
console.log('选择的公司:', item);
|
||||||
form.name = item.companyName;
|
form.name = item.companyName;
|
||||||
|
form.kbId = item.kbId;
|
||||||
console.log('设置后的form.name:', form.name);
|
console.log('设置后的form.name:', form.name);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
<a-card style="margin-bottom: 20px; text-align: center; background: transparent" :bordered="false">
|
<a-card style="margin-bottom: 20px; text-align: center; background: transparent" :bordered="false">
|
||||||
<a-space>
|
<a-space>
|
||||||
<a-button type="primary" size="large">
|
<a-button type="primary" size="large" @click="handleGenerateAll" :loading="generatingAll">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<UngroupOutlined/>
|
<UngroupOutlined/>
|
||||||
</template>
|
</template>
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
</template>
|
</template>
|
||||||
加载草稿
|
加载草稿
|
||||||
</a-button>
|
</a-button>
|
||||||
<a-button size="large">
|
<a-button size="large" @click="handleExport">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<UploadOutlined/>
|
<UploadOutlined/>
|
||||||
</template>
|
</template>
|
||||||
@@ -144,6 +144,16 @@
|
|||||||
class="content-textarea"
|
class="content-textarea"
|
||||||
style="margin-top: 16px"
|
style="margin-top: 16px"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<div style="margin-top: 12px">
|
||||||
|
<div style="color: #666; margin-bottom: 8px; font-size: 13px">优化建议:</div>
|
||||||
|
<a-textarea
|
||||||
|
v-model:value="item.suggestion"
|
||||||
|
:rows="3"
|
||||||
|
placeholder="请输入优化建议..."
|
||||||
|
class="suggestion-textarea"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</a-card>
|
</a-card>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -168,6 +178,7 @@ import {
|
|||||||
RobotOutlined,
|
RobotOutlined,
|
||||||
QuestionCircleOutlined
|
QuestionCircleOutlined
|
||||||
} from '@ant-design/icons-vue';
|
} from '@ant-design/icons-vue';
|
||||||
|
import {generateAuditReport, downloadAuditReport} from "@/api/ai/auditReport";
|
||||||
|
|
||||||
const useForm = Form.useForm;
|
const useForm = Form.useForm;
|
||||||
|
|
||||||
@@ -180,6 +191,8 @@ const props = defineProps<{
|
|||||||
|
|
||||||
// 是否显示最大化切换按钮
|
// 是否显示最大化切换按钮
|
||||||
const maxAble = ref(true);
|
const maxAble = ref(true);
|
||||||
|
// 添加生成状态
|
||||||
|
const generatingAll = ref(false);
|
||||||
// 当前选中的章节
|
// 当前选中的章节
|
||||||
const currentSection = ref(0);
|
const currentSection = ref(0);
|
||||||
|
|
||||||
@@ -202,6 +215,8 @@ const navigationItems = ref([
|
|||||||
(五)XXX有限公司各项管理制度;
|
(五)XXX有限公司各项管理制度;
|
||||||
|
|
||||||
(六)双方签订的审计业务约定书。`,
|
(六)双方签订的审计业务约定书。`,
|
||||||
|
suggestion: '',
|
||||||
|
formCommit: 1,
|
||||||
rows: 10,
|
rows: 10,
|
||||||
generating: false
|
generating: false
|
||||||
},
|
},
|
||||||
@@ -212,6 +227,8 @@ const navigationItems = ref([
|
|||||||
description: '点击"AI生成"按钮让AI为您生成该部分内容,或直接在下方编辑',
|
description: '点击"AI生成"按钮让AI为您生成该部分内容,或直接在下方编辑',
|
||||||
placeholder: '请输入审计目标内容...',
|
placeholder: '请输入审计目标内容...',
|
||||||
content: `通过对XXX同志、XXX同志任职期间所负责公司资产、负债情况的真实性、合法性和效益性及其相关经济活动进行审计,查清其任职期间公司财经政策指导和财务收支工作目标完成情况,重大决策执行及交接情况,遵守国家财经法规情况及公司资产保值增值情况,分清其经济责任,评价其工作业绩,对其任职期间履行经济责任情况作出客观公正的评价。`,
|
content: `通过对XXX同志、XXX同志任职期间所负责公司资产、负债情况的真实性、合法性和效益性及其相关经济活动进行审计,查清其任职期间公司财经政策指导和财务收支工作目标完成情况,重大决策执行及交接情况,遵守国家财经法规情况及公司资产保值增值情况,分清其经济责任,评价其工作业绩,对其任职期间履行经济责任情况作出客观公正的评价。`,
|
||||||
|
suggestion: '',
|
||||||
|
formCommit: 2,
|
||||||
rows: 6,
|
rows: 6,
|
||||||
generating: false
|
generating: false
|
||||||
},
|
},
|
||||||
@@ -222,16 +239,32 @@ const navigationItems = ref([
|
|||||||
description: '点击"AI生成"按钮让AI为您生成该部分内容,或直接在下方编辑',
|
description: '点击"AI生成"按钮让AI为您生成该部分内容,或直接在下方编辑',
|
||||||
placeholder: '请输入审计对象和范围内容...',
|
placeholder: '请输入审计对象和范围内容...',
|
||||||
content: '',
|
content: '',
|
||||||
|
suggestion: '',
|
||||||
|
formCommit: 3,
|
||||||
rows: 8,
|
rows: 8,
|
||||||
generating: false
|
generating: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
number: '四',
|
number: '四',
|
||||||
name: '被审计单位基本情况',
|
name: '被审计单位基本情况'+'|'+'(一)单位概况',
|
||||||
title: '4、被审计单位基本情况',
|
title: '4、被审计单位基本情况',
|
||||||
description: '点击"AI生成"按钮让AI为您生成该部分内容,或直接在下方编辑',
|
description: '点击"AI生成"按钮让AI为您生成该部分内容,或直接在下方编辑',
|
||||||
placeholder: '请输入被审计单位基本情况内容...',
|
placeholder: '请输入被审计单位基本情况内容...',
|
||||||
content: '',
|
content: '',
|
||||||
|
suggestion: '',
|
||||||
|
formCommit: 41,
|
||||||
|
rows: 10,
|
||||||
|
generating: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
number: '四',
|
||||||
|
name: '被审计单位基本情况'+'|'+'(二)机构和人员相关情况',
|
||||||
|
title: '4、被审计单位基本情况',
|
||||||
|
description: '点击"AI生成"按钮让AI为您生成该部分内容,或直接在下方编辑',
|
||||||
|
placeholder: '请输入被审计单位基本情况内容...',
|
||||||
|
content: '',
|
||||||
|
suggestion: '',
|
||||||
|
formCommit: 42,
|
||||||
rows: 10,
|
rows: 10,
|
||||||
generating: false
|
generating: false
|
||||||
},
|
},
|
||||||
@@ -242,6 +275,8 @@ const navigationItems = ref([
|
|||||||
description: '点击"AI生成"按钮让AI为您生成该部分内容,或直接在下方编辑',
|
description: '点击"AI生成"按钮让AI为您生成该部分内容,或直接在下方编辑',
|
||||||
placeholder: '请输入审计内容和重点及审计方法内容...',
|
placeholder: '请输入审计内容和重点及审计方法内容...',
|
||||||
content: '',
|
content: '',
|
||||||
|
suggestion: '',
|
||||||
|
formCommit: 5,
|
||||||
rows: 12,
|
rows: 12,
|
||||||
generating: false
|
generating: false
|
||||||
},
|
},
|
||||||
@@ -252,6 +287,8 @@ const navigationItems = ref([
|
|||||||
description: '点击"AI生成"按钮让AI为您生成该部分内容,或直接在下方编辑',
|
description: '点击"AI生成"按钮让AI为您生成该部分内容,或直接在下方编辑',
|
||||||
placeholder: '请输入重要风险的识别及应对内容...',
|
placeholder: '请输入重要风险的识别及应对内容...',
|
||||||
content: '',
|
content: '',
|
||||||
|
suggestion: '',
|
||||||
|
formCommit: 6,
|
||||||
rows: 10,
|
rows: 10,
|
||||||
generating: false
|
generating: false
|
||||||
},
|
},
|
||||||
@@ -262,6 +299,8 @@ const navigationItems = ref([
|
|||||||
description: '点击"AI生成"按钮让AI为您生成该部分内容,或直接在下方编辑',
|
description: '点击"AI生成"按钮让AI为您生成该部分内容,或直接在下方编辑',
|
||||||
placeholder: '请输入审计技术方法内容...',
|
placeholder: '请输入审计技术方法内容...',
|
||||||
content: '',
|
content: '',
|
||||||
|
suggestion: '',
|
||||||
|
formCommit: 7,
|
||||||
rows: 8,
|
rows: 8,
|
||||||
generating: false
|
generating: false
|
||||||
},
|
},
|
||||||
@@ -272,6 +311,8 @@ const navigationItems = ref([
|
|||||||
description: '点击"AI生成"按钮让AI为您生成该部分内容,或直接在下方编辑',
|
description: '点击"AI生成"按钮让AI为您生成该部分内容,或直接在下方编辑',
|
||||||
placeholder: '请输入工作步骤与时间安排内容...',
|
placeholder: '请输入工作步骤与时间安排内容...',
|
||||||
content: '',
|
content: '',
|
||||||
|
suggestion: '',
|
||||||
|
formCommit: 8,
|
||||||
rows: 10,
|
rows: 10,
|
||||||
generating: false
|
generating: false
|
||||||
},
|
},
|
||||||
@@ -282,6 +323,8 @@ const navigationItems = ref([
|
|||||||
description: '点击"AI生成"按钮让AI为您生成该部分内容,或直接在下方编辑',
|
description: '点击"AI生成"按钮让AI为您生成该部分内容,或直接在下方编辑',
|
||||||
placeholder: '请输入审计工作的组织实施内容...',
|
placeholder: '请输入审计工作的组织实施内容...',
|
||||||
content: '',
|
content: '',
|
||||||
|
suggestion: '',
|
||||||
|
formCommit: 9,
|
||||||
rows: 8,
|
rows: 8,
|
||||||
generating: false
|
generating: false
|
||||||
}
|
}
|
||||||
@@ -385,6 +428,8 @@ const form = reactive<PwlProject>({
|
|||||||
createTime: undefined,
|
createTime: undefined,
|
||||||
// 修改时间
|
// 修改时间
|
||||||
updateTime: undefined,
|
updateTime: undefined,
|
||||||
|
// 知识库id
|
||||||
|
kbId: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 请求状态
|
// 请求状态
|
||||||
@@ -414,19 +459,66 @@ const getScrollContainer = () => {
|
|||||||
return document.querySelector('.ant-modal-body');
|
return document.querySelector('.ant-modal-body');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* 批量生成全部内容 */
|
||||||
|
const handleGenerateAll = async () => {
|
||||||
|
generatingAll.value = true;
|
||||||
|
try {
|
||||||
|
// 使用Promise.all进行并行生成
|
||||||
|
await Promise.all(navigationItems.value.map((_, index) => generateContent(index)));
|
||||||
|
message.success('全部内容生成完成');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('批量生成失败:', error);
|
||||||
|
message.error('部分内容生成失败,请检查');
|
||||||
|
} finally {
|
||||||
|
generatingAll.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 导出审计报告 */
|
||||||
|
const handleExport = async () => {
|
||||||
|
try {
|
||||||
|
const blob = await downloadAuditReport({
|
||||||
|
from0: form.code,
|
||||||
|
from1: navigationItems.value[0].content,
|
||||||
|
from2: navigationItems.value[1].content,
|
||||||
|
from3: navigationItems.value[2].content,
|
||||||
|
from41: navigationItems.value[3].content,
|
||||||
|
from42: navigationItems.value[4].content,
|
||||||
|
from5: navigationItems.value[5].content,
|
||||||
|
});
|
||||||
|
|
||||||
|
// 创建下载链接
|
||||||
|
const url = window.URL.createObjectURL(new Blob([blob]));
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = url;
|
||||||
|
link.setAttribute('download', `审计报告_${form.name}.docx`);
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('导出失败:', error);
|
||||||
|
message.error('文档导出失败');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/* AI生成内容 */
|
/* AI生成内容 */
|
||||||
const generateContent = async (index: number) => {
|
const generateContent = async (index: number) => {
|
||||||
const item = navigationItems.value[index];
|
const item = navigationItems.value[index];
|
||||||
item.generating = true;
|
item.generating = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 这里可以调用AI接口生成内容
|
// 调用生成接口
|
||||||
// 模拟AI生成过程
|
const result = await generateAuditReport({
|
||||||
await new Promise(resolve => setTimeout(resolve, 2000));
|
kbId: form.kbId || '',
|
||||||
|
formCommit: item.formCommit,
|
||||||
|
history: item.content || '',
|
||||||
|
suggestion: item.suggestion || '',
|
||||||
|
// ...form, // 传递表单数据
|
||||||
|
// moduleId: index + 1, // 假设章节对应模块ID
|
||||||
|
// section: item.name // 当前生成章节名称
|
||||||
|
});
|
||||||
|
|
||||||
// 根据不同章节生成不同的示例内容
|
item.content = result; // 直接使用接口返回内容
|
||||||
const sampleContent = getSampleContent(index);
|
|
||||||
item.content = sampleContent;
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('AI生成失败:', error);
|
console.error('AI生成失败:', error);
|
||||||
|
|||||||
Reference in New Issue
Block a user