可信代码库-AI大模型批量管理功能对接
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
<GLink class="g-toolbar-left-logo" @click="gotoAIHome" />
|
||||
<GLink class="g-toolbar-left-title" @click="gotoAIHome">AI助手</GLink>
|
||||
<div class="jyh-split"></div>
|
||||
<d-button class="jyh-button" variant="solid" @click="handleLogin('login')">
|
||||
<d-button class="jyh-button" variant="solid">
|
||||
<div class="flex flex-center">
|
||||
<img style="height: 15px;margin-right: 8px" width="16" :src="icon_dh" />
|
||||
<span>AI对话</span>
|
||||
@@ -28,12 +28,12 @@
|
||||
<img style="height: 15px;" width="16" :src="zh" />
|
||||
<span class="ml-xs">返回平台搜索</span>
|
||||
</a>
|
||||
<d-button class="jyh-button1" variant="solid" @click="handleLogin('login')">
|
||||
<div class="flex flex-center">
|
||||
<img style="height: 15px;margin-right: 8px" width="16" :src="icon_sj" />
|
||||
<span>升级产品</span>
|
||||
</div>
|
||||
</d-button>
|
||||
<!-- <d-button class="jyh-button1" variant="solid" @click="handleLogin('login')">-->
|
||||
<!-- <div class="flex flex-center">-->
|
||||
<!-- <img style="height: 15px;margin-right: 8px" width="16" :src="icon_sj" />-->
|
||||
<!-- <span>升级产品</span>-->
|
||||
<!-- </div>-->
|
||||
<!-- </d-button>-->
|
||||
<!-- <d-button class="jyh-button1" variant="solid" @click="handleLogin('login')">-->
|
||||
<!-- <div class="flex flex-center">-->
|
||||
<!-- <img style="height: 15px;margin-right: 8px" width="16" :src="icon_api" />-->
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
style="width: 100%"
|
||||
placeholder="请输入搜索内容"
|
||||
v-model="searchText"
|
||||
@change="handleSearch"
|
||||
@change="handleSearch('dhls')"
|
||||
></d-search>
|
||||
<div class="mt-3 px-20">
|
||||
<d-table
|
||||
v-if="currentDhlsData.length>0"
|
||||
v-if="dhlsList.length>0"
|
||||
class="jyh-table"
|
||||
:data="currentDhlsData"
|
||||
:data="dhlsList"
|
||||
row-key="id"
|
||||
@check-change="handleCheckChange('dhls')"
|
||||
:pagination="false"
|
||||
@@ -21,7 +21,6 @@
|
||||
>
|
||||
<d-column type="checkable" width="40" :checkable="checkable" reserve-check></d-column>
|
||||
<d-column field="title" header="对话内容" show-overflow-tooltip></d-column>
|
||||
<!-- <d-column field="agent" header="智能体" show-overflow-tooltip></d-column>-->
|
||||
<d-column field="createTime" header="发起对话时间" show-overflow-tooltip></d-column>
|
||||
<d-column width="80" field="operation" header="操作">
|
||||
<template #default="scope">
|
||||
@@ -38,12 +37,12 @@
|
||||
<div class="mt-20 mb-20 flex justify-end">
|
||||
<d-pagination
|
||||
size="md"
|
||||
:page-size="pageSize"
|
||||
:total="dhlsList.length"
|
||||
v-model:current-page="currentPage"
|
||||
:page-size="dhlsPagination.size"
|
||||
:total="dhlsPagination.total"
|
||||
v-model:current-page="dhlsPagination.page"
|
||||
:page-size-options="[10, 20, 50]"
|
||||
@page-size-change="handlePageSizeChange"
|
||||
@current-page-change="handlePageChange"
|
||||
@page-size-change="(num)=>handlePageSizeChange('scdh', num)"
|
||||
@current-page-change="(num)=>handlePageChange('scdh', num)"
|
||||
total-item-text="总计"
|
||||
/>
|
||||
</div>
|
||||
@@ -54,13 +53,13 @@
|
||||
style="width: 100%"
|
||||
placeholder="请输入搜索内容"
|
||||
v-model="searchText"
|
||||
@change="handleSearch"
|
||||
@change="handleSearch('scdh')"
|
||||
></d-search>
|
||||
<div class="mt-3 px-20">
|
||||
<d-table
|
||||
v-if="currentCollectionData.length>0"
|
||||
v-if="collectionList.length>0"
|
||||
class="jyh-table"
|
||||
:data="currentCollectionData"
|
||||
:data="collectionList"
|
||||
row-key="id"
|
||||
@check-change="handleCheckChange('scdh')"
|
||||
:pagination="false"
|
||||
@@ -84,12 +83,12 @@
|
||||
<div class="mt-20 mb-20 flex justify-end">
|
||||
<d-pagination
|
||||
size="md"
|
||||
:page-size="pageSize"
|
||||
:total="collectionList.length"
|
||||
v-model:current-page="currentPage"
|
||||
v-model:pageSize="collectionPagination.size"
|
||||
:total="collectionPagination.total"
|
||||
v-model:pageIndex="collectionPagination.page"
|
||||
:page-size-options="[10, 20, 50]"
|
||||
@page-size-change="handlePageSizeChange"
|
||||
@current-page-change="handlePageChange"
|
||||
@page-index-change="handlePageChange"
|
||||
total-item-text="总计"
|
||||
/>
|
||||
</div>
|
||||
@@ -130,26 +129,22 @@ const checkable = ref(true);
|
||||
const dhlsList = ref([]); // 对话历史数据
|
||||
const collectionList = ref([]); // 收藏对话数据
|
||||
|
||||
// 分页状态
|
||||
const pageSize = ref(10); // 每页显示条数
|
||||
const currentPage = ref(1); // 当前页码
|
||||
|
||||
// 计算当前页数据(对话历史)
|
||||
const currentDhlsData = computed(() => {
|
||||
const filteredData = dhlsList.value.filter(row =>
|
||||
row.title.includes(searchText.value)
|
||||
);
|
||||
const start = (currentPage.value - 1) * pageSize.value;
|
||||
return filteredData.slice(start, start + pageSize.value);
|
||||
// 分页状态(每个标签页独立)
|
||||
const dhlsPagination = ref({
|
||||
page: 1,
|
||||
size: 10,
|
||||
total: 0
|
||||
});
|
||||
|
||||
// 计算当前页数据(收藏对话)
|
||||
const currentCollectionData = computed(() => {
|
||||
const filteredData = collectionList.value.filter(row =>
|
||||
row.title.includes(searchText.value)
|
||||
);
|
||||
const start = (currentPage.value - 1) * pageSize.value;
|
||||
return filteredData.slice(start, start + pageSize.value);
|
||||
const collectionPagination = ref({
|
||||
page: 1,
|
||||
size: 10,
|
||||
total: 0
|
||||
});
|
||||
|
||||
// 当前激活的分页对象
|
||||
const activePagination = computed(() => {
|
||||
return selectTab.value === 'dhls' ? dhlsPagination.value : collectionPagination.value;
|
||||
});
|
||||
|
||||
// 接口调用 - 对话历史
|
||||
@@ -159,16 +154,18 @@ const getQuestionHistory = async () => {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const {data} = await axios.post(VITE_AI_API_HOST + '/api/conversationList', {
|
||||
const { data } = await axios.post(import.meta.env.VITE_AI_API_HOST + '/api/conversationList', {
|
||||
"userId": props.username,
|
||||
"list_type": "history",
|
||||
"is_manage": true,
|
||||
"page": currentPage.value,
|
||||
"size": pageSize.value,
|
||||
"page": dhlsPagination.value.page,
|
||||
"size": dhlsPagination.value.size,
|
||||
"search": searchText.value
|
||||
});
|
||||
if (data.conversationList) {
|
||||
dhlsList.value = data.conversationList
|
||||
debugger
|
||||
if (data.data.conversationList) {
|
||||
dhlsList.value = data.data.conversationList;
|
||||
dhlsPagination.value.total = data.data.pagination.total || 0;
|
||||
}
|
||||
} catch (error) {
|
||||
Message.error('获取对话历史失败');
|
||||
@@ -182,16 +179,17 @@ const getQuestionCollection = async () => {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const {data} = await axios.post(VITE_AI_API_HOST + '/api/conversationList', {
|
||||
const { data } = await axios.post(import.meta.env.VITE_AI_API_HOST + '/api/conversationList', {
|
||||
"userId": props.username,
|
||||
"list_type": "collection",
|
||||
"is_manage": true,
|
||||
"page": currentPage.value,
|
||||
"size": pageSize.value,
|
||||
"page": collectionPagination.value.page,
|
||||
"size": collectionPagination.value.size,
|
||||
"search": searchText.value
|
||||
});
|
||||
if (data.conversationList) {
|
||||
collectionList.value = data.conversationList
|
||||
if (data.data.conversationList) {
|
||||
collectionList.value = data.data.conversationList;
|
||||
collectionPagination.value.total = data.data.pagination.total || 0;
|
||||
}
|
||||
} catch (error) {
|
||||
Message.error('获取收藏对话失败');
|
||||
@@ -201,76 +199,65 @@ const getQuestionCollection = async () => {
|
||||
// 打开模态框时加载数据
|
||||
const openModal = async () => {
|
||||
visible.value = true;
|
||||
await fetchData(); // 调用接口
|
||||
currentPage.value = 1; // 重置页码
|
||||
// 重置分页状态
|
||||
dhlsPagination.value = { page: 1, size: 10, total: 0 };
|
||||
collectionPagination.value = { page: 1, size: 10, total: 0 };
|
||||
// 加载当前标签页数据
|
||||
initData()
|
||||
};
|
||||
|
||||
// 搜索时触发数据加载
|
||||
const handleSearch = async () => {
|
||||
currentPage.value = 1; // 搜索后重置到第一页
|
||||
await fetchData(); // 调用接口
|
||||
// 搜索处理
|
||||
const handleSearch = async (tabType) => {
|
||||
// 重置当前标签页的分页到第一页
|
||||
if (tabType === 'dhls') {
|
||||
dhlsPagination.value.page = 1;
|
||||
await getQuestionHistory();
|
||||
} else {
|
||||
collectionPagination.value.page = 1;
|
||||
await getQuestionCollection();
|
||||
}
|
||||
};
|
||||
|
||||
// 分页大小变化时触发数据加载
|
||||
// 分页大小变化
|
||||
const handlePageSizeChange = async (size) => {
|
||||
pageSize.value = size;
|
||||
currentPage.value = 1; // 切换页大小后重置到第一页
|
||||
await fetchData(); // 调用接口
|
||||
let tabType = selectTab.value
|
||||
debugger
|
||||
if (tabType === 'dhls') {
|
||||
dhlsPagination.value.size = size;
|
||||
dhlsPagination.value.page = 1; // 重置到第一页
|
||||
await getQuestionHistory();
|
||||
} else {
|
||||
collectionPagination.value.size = size;
|
||||
collectionPagination.value.page = 1; // 重置到第一页
|
||||
await getQuestionCollection();
|
||||
}
|
||||
};
|
||||
|
||||
// 页码变化时触发数据加载
|
||||
// 页码变化
|
||||
const handlePageChange = async (page) => {
|
||||
currentPage.value = page;
|
||||
await fetchData(); // 调用接口
|
||||
};
|
||||
|
||||
// 统一数据获取方法
|
||||
const fetchData = async () => {
|
||||
if (!props.username) {
|
||||
Message.error('请先登录');
|
||||
return;
|
||||
}
|
||||
|
||||
// 构建公共参数
|
||||
const commonParams = {
|
||||
userId: props.username,
|
||||
is_manage: true,
|
||||
page: currentPage.value,
|
||||
size: pageSize.value,
|
||||
search: searchText.value,
|
||||
};
|
||||
|
||||
// 获取对话历史
|
||||
const historyData = await axios.post(
|
||||
`${import.meta.env.VITE_AI_API_HOST}/api/conversationList`,
|
||||
{ ...commonParams, list_type: 'history' }
|
||||
);
|
||||
if (historyData.data.conversationList) {
|
||||
dhlsList.value = historyData.data.conversationList;
|
||||
}
|
||||
|
||||
// 获取收藏对话
|
||||
const collectionData = await axios.post(
|
||||
`${import.meta.env.VITE_AI_API_HOST}/api/conversationList`,
|
||||
{ ...commonParams, list_type: 'collection' }
|
||||
);
|
||||
if (collectionData.data.conversationList) {
|
||||
collectionList.value = collectionData.data.conversationList;
|
||||
debugger
|
||||
let tabType = selectTab.value
|
||||
if (tabType === 'dhls') {
|
||||
dhlsPagination.value.page = page;
|
||||
await getQuestionHistory();
|
||||
} else {
|
||||
collectionPagination.value.page = page;
|
||||
await getQuestionCollection();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 选中的行ID
|
||||
const selectedRowKeys = ref([]);
|
||||
// 复选框选中状态变化
|
||||
const handleCheckChange = (tabType, checkedKeys) => {
|
||||
if (tabType === 'dhls') {
|
||||
selectedRowKeys.value = checkedKeys;
|
||||
} else {
|
||||
selectedRowKeys.value = checkedKeys;
|
||||
}
|
||||
selectedRowKeys.value = checkedKeys;
|
||||
};
|
||||
|
||||
const initData = async () => {
|
||||
await getQuestionCollection();
|
||||
await getQuestionHistory();
|
||||
}
|
||||
|
||||
// 删除对话
|
||||
const handleDelete = async (conversationIds, tabType) => {
|
||||
if (!props.username) {
|
||||
@@ -288,7 +275,8 @@ const handleDelete = async (conversationIds, tabType) => {
|
||||
);
|
||||
if (res.data.code === 20000) {
|
||||
Message.success(res.data.message || '删除成功');
|
||||
await fetchData(); // 删除后重新加载数据
|
||||
// 刷新当前标签页的数据
|
||||
initData()
|
||||
selectedRowKeys.value = []; // 清空选中项
|
||||
} else {
|
||||
Message.error(res.data.message || '删除失败');
|
||||
@@ -310,8 +298,8 @@ const handleBatchDelete = () => {
|
||||
Message.confirm({
|
||||
title: '确认删除',
|
||||
content: `确定要删除选中的 ${selectedRowKeys.value.length} 条对话吗?`,
|
||||
onConfirm: () => {
|
||||
handleDelete(selectedRowKeys.value, selectTab.value);
|
||||
onConfirm: async () => {
|
||||
await handleDelete(selectedRowKeys.value, selectTab.value === 'dhls' ? 'history' : 'collection');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -339,7 +339,7 @@ const toggleCollect = async (item) => {
|
||||
try {
|
||||
const res = await axios.post(`${VITE_AI_API_HOST}/api/toggleConversationCollect`, {
|
||||
userId: props.username,
|
||||
conversationId: item.conversationId
|
||||
conversationIdList: [item.conversationId]
|
||||
});
|
||||
|
||||
if (res.data.code === 20000) {
|
||||
|
||||
@@ -277,8 +277,8 @@ const getAIAnswer = async (content) => {
|
||||
let arr = JSON.parse(response.data[type]);
|
||||
if(arr&&arr.length===1) {
|
||||
messages.value[messages.value.length - 1].type = 'critical_software_info';
|
||||
messages.value[messages.value.length - 1].id = arr[0]?.id;
|
||||
messages.value[messages.value.length - 1].software_name = arr[0]?.software_name;
|
||||
messages.value[messages.value.length - 1].id = arr[0]?.id || arr[0]?.ID;
|
||||
messages.value[messages.value.length - 1].software_name = arr[0]?.software_name || arr[0]['软件名称'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -399,7 +399,7 @@ const getConversationDetail = async (convId: string) => {
|
||||
conversationId: convId,
|
||||
},
|
||||
});
|
||||
const detail = response.data;
|
||||
const detail = response.data.messages;
|
||||
// 处理详情数据(如回显消息列表)
|
||||
handleDetailResponse(detail);
|
||||
} catch (error) {
|
||||
@@ -410,8 +410,36 @@ const getConversationDetail = async (convId: string) => {
|
||||
|
||||
// 处理详情数据(示例:更新消息列表)
|
||||
const handleDetailResponse = (detail: any) => {
|
||||
debugger
|
||||
// 假设接口返回消息列表为 messagesList
|
||||
messages.value = detail.messages || [];
|
||||
messages.value = detail.map(i=>{
|
||||
let messages = i;
|
||||
if(i.role=== 'user') {
|
||||
return messages
|
||||
} else {
|
||||
let type = i.type;
|
||||
let table_name = i.table_name;
|
||||
if(type==='text') {
|
||||
messages.content = i.text;
|
||||
messages.loading = false;
|
||||
messages.type = 'text';
|
||||
} else if(type==='df') {
|
||||
messages.content = i.content;
|
||||
messages.loading = false;
|
||||
messages.type = 'df';
|
||||
// 判断是否软件详情
|
||||
if(table_name[0]==='critical_software_info'&&table_name.length===1) {
|
||||
let arr = JSON.parse(i.content);
|
||||
if(arr&&arr.length===1) {
|
||||
messages.type = 'critical_software_info';
|
||||
messages.id = arr[0]?.id || arr[0]?.ID;
|
||||
messages.software_name = arr[0]?.software_name || arr[0]['软件名称'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return messages
|
||||
}
|
||||
})
|
||||
startChat.value = true; // 显示聊天界面
|
||||
nextTick(() => {
|
||||
conversationRef.value?.scrollTo({
|
||||
|
||||
Reference in New Issue
Block a user