feat(pwl):添加报告关联资料库

This commit is contained in:
2025-09-28 18:50:29 +08:00
parent 26859ac169
commit f74c5e8c71
7 changed files with 596 additions and 251 deletions

View File

@@ -50,6 +50,8 @@ export interface AuditReport {
from90?: string;
// 知识库ID
kbId?: string;
// 知识库Ids
kbIds?: string;
// 生成模块:AuditReportEnum.code
formCommit?: number;
// 历史内容

View File

@@ -97,6 +97,8 @@ export interface PwlProject {
updateTime?: string;
// 知识库id
kbId?: string;
// 资料库库Ids
libraryIds?: string;
}
/**

View File

@@ -104,3 +104,16 @@ export async function getPwlProjectLibrary(id: number) {
}
return Promise.reject(new Error(res.data.message));
}
/**
* 根据ids查询材料库资料库表
*/
export async function getPwlProjectLibraryByIds(ids: string) {
const res = await request.get<ApiResult<PwlProjectLibrary[]>>(
MODULES_API_URL + '/pwl/pwl-project-library/byIds/' + ids
);
if (res.data.code === 0 && res.data.data) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}

View File

@@ -48,6 +48,35 @@
v-model:value="form.code"
/>
</a-form-item>
<!-- 行业库 -->
<a-form-item label="行业库" name="bizLibIds">
<a-select
show-search
:allow-clear="true"
optionFilterProp="label"
v-model:value="form.bizLibIds"
mode="multiple"
style="width: 100%"
placeholder="选择行业库"
:options="bizLibList"
></a-select>
</a-form-item>
<!-- 公共库 -->
<a-form-item label="公共库" name="pubLibIds">
<a-select
show-search
:allow-clear="true"
optionFilterProp="label"
v-model:value="form.pubLibIds"
mode="multiple"
style="width: 100%"
placeholder="选择公共库"
:options="pubLibList"
></a-select>
</a-form-item>
<a-divider orientation="left" style="margin-top: 50px">项目信息</a-divider>
<a-form-item label="开票单位/汇款人" name="itemName">
<a-input
@@ -278,6 +307,8 @@ import {hasRole} from "@/utils/permission";
import SelectCompany from "@/components/SelectCompany/index.vue";
import {Company} from "@/api/system/company/model";
import {OaCompany} from "@/api/oa/oaCompany/model";
import {listPwlProjectLibrary} from '@/api/pwl/pwlProjectLibrary';
// 是否是修改
const isUpdate = ref(false);
@@ -286,6 +317,12 @@ const useForm = Form.useForm;
const themeStore = useThemeStore();
const {styleResponsive} = storeToRefs(themeStore);
// 资料库响应式数据
const bizLibList = ref<any[]>([]);
const pubLibList = ref<any[]>([]);
// 存储完整的资料库数据,用于查找名称
const allLibraries = ref<any[]>([]);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
@@ -350,6 +387,11 @@ const form = reactive<PwlProject>({
signUser: [],
saleUserId: [],
saleUser: [],
bizLibIds: [], // 修改为bizLibIds
bizLibName: [],
pubLibIds: [], // 修改为pubLibIds
pubLibName: [],
libraryIds: undefined, // 新增libraryIds字段
comments: undefined,
electron: undefined,
paper: undefined,
@@ -359,7 +401,7 @@ const form = reactive<PwlProject>({
tenantId: undefined,
createTime: undefined,
updateTime: undefined,
sortNumber: 100
sortNumber: 100,
});
/* 更新visible */
@@ -495,6 +537,8 @@ const handleSaleUser = (userId: number, item: User[]) => {
});
console.log(userId)
}
// 获取用户列表
const fetchUsers = () => {
pageUsers({keywords: keywords.value,limit: 100}).then(res => {
userList.value = res?.list.map(d => {
@@ -505,6 +549,39 @@ const fetchUsers = () => {
})
};
// 获取资料库列表
const fetchLibraries = () => {
return listPwlProjectLibrary().then(res => {
allLibraries.value = res;
// 过滤行业库 (type='biz')
bizLibList.value = res
.filter(item => item.type === 'biz')
.map(item => ({
label: item.name,
value: String(item.id) // 将 ID 转换为字符串
}));
// 过滤公共库 (type='pub')
pubLibList.value = res
.filter(item => item.type === 'pub')
.map(item => ({
label: item.name,
value: String(item.id) // 将 ID 转换为字符串
}));
return res;
});
};
// 根据ID获取资料库名称
const getLibraryNamesByIds = (ids: string[]) => {
return ids.map(id => {
const library = allLibraries.value.find(lib => lib.id == id);
return library ? library.name : '';
}).filter(name => name !== '');
};
const {resetFields} = useForm(form, rules);
/* 保存编辑 */
@@ -516,6 +593,13 @@ const save = () => {
.validate()
.then(() => {
loading.value = true;
// 合并行业库和公共库的ID到libraryIds
const allLibraryIds = [
...(form.bizLibIds || []),
...(form.pubLibIds || [])
]
const formData = {
...form,
draftUserId: JSON.stringify(form.draftUserId),
@@ -526,7 +610,9 @@ const save = () => {
signUser: JSON.stringify(Array.from(new Set(signUser.value))),
saleUserId: JSON.stringify(form.saleUserId),
saleUser: JSON.stringify(Array.from(new Set(saleUser.value))),
libraryIds: allLibraryIds.join(','), // 保存为逗号分隔的字符串
};
if (!hasRole('superAdmin')) {
form.payPrice = undefined;
}
@@ -557,11 +643,63 @@ const save = () => {
});
};
// 设置资料库回显
const setLibraryEcho = () => {
if (props.data?.libraryIds) {
// 如果是字符串,按逗号分割成数组
if (typeof props.data.libraryIds === 'string') {
const libraryIdsArray = props.data.libraryIds.split(',').filter(id => id.trim() !== '');
// 清空当前的选择
form.bizLibIds = [];
form.pubLibIds = [];
// 根据资料库类型分别设置回显
libraryIdsArray.forEach(id => {
// 检查是否在行业库列表中
const isBizLib = bizLibList.value.some(lib => lib.value === String(id)); // 转换为字符串比较
// 检查是否在公共库列表中
const isPubLib = pubLibList.value.some(lib => lib.value === String(id)); // 转换为字符串比较
if (isBizLib) {
form.bizLibIds.push(String(id)); // 确保存储为字符串
}
if (isPubLib) {
form.pubLibIds.push(String(id)); // 确保存储为字符串
}
});
} else {
// 如果是数组,直接使用相同的逻辑
form.bizLibIds = [];
form.pubLibIds = [];
props.data.libraryIds.forEach(id => {
const isBizLib = bizLibList.value.some(lib => lib.value === String(id));
const isPubLib = pubLibList.value.some(lib => lib.value === String(id));
if (isBizLib) {
form.bizLibIds.push(String(id));
}
if (isPubLib) {
form.pubLibIds.push(String(id));
}
});
}
} else {
form.bizLibIds = [];
form.pubLibIds = [];
}
};
watch(
() => props.visible,
(visible) => {
fetchUsers();
async (visible) => {
if (visible) {
fetchUsers();
// 等待资料库列表加载完成后再设置回显
await fetchLibraries();
images.value = [];
if (props.data) {
assignObject(form, props.data);
@@ -572,9 +710,11 @@ watch(
status: 'done'
})
}
// 处理底稿人员
if (props.data.draftUserId) {
form.draftUserId = JSON.parse(props.data.draftUserId);
}else {
} else {
form.draftUserId = [];
}
if (props.data.draftUser) {
@@ -582,12 +722,14 @@ watch(
arr.map(d => {
draftUser.value.push(d);
})
}else {
} else {
draftUser.value = [];
}
// 处理参与成员
if (props.data.userIds) {
form.userIds = JSON.parse(props.data.userIds) || [];
}else {
} else {
form.userIds = [];
}
if (props.data.users) {
@@ -595,12 +737,14 @@ watch(
arr.map(d => {
users.value.push(d);
})
}else {
} else {
users.value = [];
}
// 处理签字注会
if (props.data.signUserId) {
form.signUserId = JSON.parse(props.data.signUserId) || [];
}else {
} else {
form.signUserId = [];
}
if (props.data.signUser) {
@@ -608,25 +752,34 @@ watch(
arr.map(d => {
signUser.value.push(d);
})
}else {
} else {
signUser.value = [];
}
// 处理展业人员
if (props.data.saleUserId) {
form.saleUserId = JSON.parse(props.data.saleUserId) || [];
}else {
} else {
form.saleUserId = [];
}
if (props.data.draftUser) {
let arr = JSON.parse(props.data.draftUser) || [];
if (props.data.saleUser) {
const arr = JSON.parse(props.data.saleUser) || [];
arr.map(d => {
draftUser.value.push(d);
saleUser.value.push(d);
})
}else {
draftUser.value = [];
} else {
saleUser.value = [];
}
// 设置资料库回显
setLibraryEcho();
isUpdate.value = true;
} else {
isUpdate.value = false;
// 新增时清空资料库选择
form.bizLibIds = [];
form.pubLibIds = [];
}
} else {
resetFields();

View File

@@ -248,6 +248,7 @@ import {
QuestionCircleOutlined
} from '@ant-design/icons-vue';
import {generateAuditReport, downloadAuditReport} from "@/api/ai/auditReport";
import {getPwlProjectLibraryByIds} from '@/api/pwl/pwlProjectLibrary';
const useForm = Form.useForm;
@@ -265,6 +266,9 @@ const generatingAll = ref(false);
// 当前选中的章节
const currentSection = ref(0);
// 存储拼接后的 kbIds
const combinedKbIds = ref('');
// 九大审计项目导航配置
const navigationItems = ref([
{
@@ -800,6 +804,7 @@ const generateContent = async (sectionIndex: number, childIndex?: number) => {
try {
const result = await generateAuditReport({
kbId: form.kbId || '',
kbIds: combinedKbIds.value,
formCommit: formCommit,
history: item.content || '',
suggestion: item.suggestion || '',
@@ -885,16 +890,35 @@ onUnmounted(() => {
watch(
() => props.visible,
(visible) => {
async (visible) => {
if (visible) {
if (props.data) {
loading.value = true;
assignObject(form, props.data);
// 获取知识库并拼接 kbIds
if (props.data.libraryIds?.length > 0) {
try {
const result = await getPwlProjectLibraryByIds(props.data.libraryIds);
const kbIds = result.map(lib => lib.kbId).filter(kbId => kbId);
if (form.kbId) {
kbIds.unshift(form.kbId);
}
combinedKbIds.value = kbIds.join(',');
} catch (error) {
console.error('获取知识库失败:', error);
combinedKbIds.value = form.kbId || '';
}
} else {
combinedKbIds.value = form.kbId || '';
}
// 重置到第一个章节
currentSection.value = 0;
}
} else {
resetFields();
combinedKbIds.value = ''; // 关闭时清空
}
}
);

View File

@@ -27,10 +27,16 @@
</a-form-item>
<a-form-item label="类型" name="type">
<a-select
<DictSelect
dict-code="LibraryType"
:width="200"
:show-search="true"
placeholder="项目类型"
v-model:value="form.type"
placeholder="请选择资料库类型"
:options="typeOptions"
:field-names="{
label: 'dictDataName',
value: 'dictDataCode'
}"
/>
</a-form-item>
@@ -122,6 +128,7 @@
import { FileRecord } from '@/api/system/file/model';
import SelectDocsBook from '@/components/SelectDocsBook/index.vue';
import SelectFile from '@/components/SelectFile/index.vue';
import DictSelect from "@/components/DictSelect/index.vue";
// 是否是修改
const isUpdate = ref(false);

View File

@@ -22,8 +22,8 @@
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'type'">
<a-tag v-if="record.type === 'biz'" color="blue">项目案例</a-tag>
<a-tag v-if="record.type === 'pub'" color="green">公共知识</a-tag>
<a-tag v-if="record.type === 'biz'" color="blue">行业</a-tag>
<a-tag v-if="record.type === 'pub'" color="green">公共库</a-tag>
<span v-if="!record.type || (record.type !== 'biz' && record.type !== 'pub')">未设置</span>
</template>
<template v-if="column.key === 'image'">
@@ -37,6 +37,13 @@
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<!-- 文档管理按钮 -->
<a
:class="{ 'disabled-text': !record.kbId }"
:style="!record.kbId ? 'cursor: not-allowed; color: #999' : ''"
@click="record.kbId && openDocManage(record)"
>文档管理</a>
<a-divider type="vertical"/>
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
@@ -51,6 +58,48 @@
<!-- 编辑弹窗 -->
<PwlProjectLibraryEdit v-model:visible="showEdit" :data="current" @done="reload" />
<!-- 文档管理弹窗 -->
<a-modal
v-model:visible="showDocManage"
:title="`文档管理 - ${currentKbName}`"
width="800px"
:footer="null"
>
<div style="margin-bottom: 16px;">
<a-button type="primary" @click="openImport">新增文档</a-button>
</div>
<a-table
:dataSource="docList"
:columns="docColumns"
:loading="docLoading"
rowKey="id"
:pagination="{
current: currentPage,
pageSize: 10,
total: total,
showSizeChanger: false,
showTotal: (total) => `共 ${total} 条`
}"
@change="(pag) => { currentPage = pag.current; loadDocuments(); }"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<a-space>
<a-popconfirm
title="确定要删除此文档吗?"
@confirm="deleteDoc(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</a-table>
</a-modal>
<!-- 导入弹窗 -->
<Import v-model:visible="showImport" @done="loadDocuments" :kbId="currentKbId"/>
</div>
</div>
</template>
@@ -60,6 +109,7 @@
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import {toDateString} from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
@@ -68,6 +118,8 @@
import PwlProjectLibraryEdit from './components/pwlProjectLibraryEdit.vue';
import { pagePwlProjectLibrary, removePwlProjectLibrary, removeBatchPwlProjectLibrary } from '@/api/pwl/pwlProjectLibrary';
import type { PwlProjectLibrary, PwlProjectLibraryParam } from '@/api/pwl/pwlProjectLibrary/model';
import Import from '@/views/oa/oaCompany/components/Import.vue';
import {getKnowledgeBaseDocuments, deleteKnowledgeBaseDocument} from '@/api/ai/knowledgeBase';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -83,6 +135,43 @@
// 加载状态
const loading = ref(true);
// 文档管理相关响应式变量
const showDocManage = ref(false); // 是否显示文档管理弹窗
const showImport = ref(false); // 是否显示导入弹窗
// 新增分页状态变量
const currentPage = ref(1);
const total = ref(0);
// 文档管理相关变量
const currentKbId = ref(''); // 当前知识库ID
const currentKbName = ref(''); // 当前知识库名称
const docList = ref<any[]>([]); // 文档列表数据
const docLoading = ref(false); // 文档加载状态
// 文档表格列配置
const docColumns = ref([
{
title: '文件名',
dataIndex: 'name', // 改为接口返回的name字段
key: 'fileName',
},
{
title: '文件大小',
dataIndex: 'size', // 改为接口返回的size字段
key: 'fileSize',
},
{
title: '上传时间',
dataIndex: 'gmtModified', // 改为接口返回的gmtModified字段
key: 'createTime',
customRender: ({ text }) => toDateString(text) // 添加时间格式化
},
{
title: '操作',
key: 'action',
width: 100,
}
]);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
@@ -186,6 +275,61 @@
showMove.value = true;
};
// 打开文档管理弹窗
const openDocManage = (record: PwlProjectLibrary) => {
currentKbId.value = record.kbId; // 使用record中的kbId
currentKbName.value = record.name; // 使用单位名称作为知识库名称
currentPage.value = 1;
showDocManage.value = true;
loadDocuments();
};
// 加载文档列表
const loadDocuments = async () => {
docLoading.value = true;
try {
const response = await getKnowledgeBaseDocuments(
currentKbId.value,
10,
currentPage.value
);
docList.value = Array.isArray(response?.list) ? response.list : [];
total.value = response?.count || 0;
} catch (error) {
message.error('加载文档列表失败');
console.error('加载文档错误:', error);
} finally {
docLoading.value = false;
}
};
// 删除文档
const deleteDoc = async (record: any) => {
try {
// 执行删除操作
await deleteKnowledgeBaseDocument(currentKbId.value, record.id);
// 立即本地删除(核心修改)
const index = docList.value.findIndex(item => item.id === record.id);
if (index > -1) {
docList.value.splice(index, 1);
total.value -= 1;
}
message.success('删除成功');
// 阿里云异步删除,需等待异步删除完成再重新查询
// await loadDocuments();
} catch (error) {
message.error('删除失败');
console.error(error);
}
};
// 打开导入弹窗
const openImport = () => {
showImport.value = true;
};
/* 删除单个 */
const remove = (row: PwlProjectLibrary) => {
const hide = message.loading('请求中..', 0);