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