diff --git a/src/views/Jyh/AI/Home/components/ViewHistoryAside/BatchManageModal.vue b/src/views/Jyh/AI/Home/components/ViewHistoryAside/BatchManageModal.vue index fb3f671..5227dc9 100644 --- a/src/views/Jyh/AI/Home/components/ViewHistoryAside/BatchManageModal.vue +++ b/src/views/Jyh/AI/Home/components/ViewHistoryAside/BatchManageModal.vue @@ -11,6 +11,7 @@ >
+
+
{ return; } try { - const { data } = await axios.get( - `${import.meta.env.VITE_AI_API_HOST}/api/conversationList?userId=${props.username}&list_type=history` - ); + const {data} = await axios.post(VITE_AI_API_HOST + '/api/conversationList', { + "userId": props.username, + "list_type": "history", + "is_manage": true, + "page": currentPage.value, + "size": pageSize.value, + "search": searchText.value + }); if (data.conversationList) { dhlsList.value = data.conversationList } @@ -172,9 +182,14 @@ const getQuestionCollection = async () => { return; } try { - const { data } = await axios.get( - `${import.meta.env.VITE_AI_API_HOST}/api/conversationList?userId=${props.username}&list_type=collection` - ); + const {data} = await axios.post(VITE_AI_API_HOST + '/api/conversationList', { + "userId": props.username, + "list_type": "collection", + "is_manage": true, + "page": currentPage.value, + "size": pageSize.value, + "search": searchText.value + }); if (data.conversationList) { collectionList.value = data.conversationList } @@ -186,27 +201,65 @@ const getQuestionCollection = async () => { // 打开模态框时加载数据 const openModal = async () => { visible.value = true; - await getQuestionHistory(); - await getQuestionCollection(); + await fetchData(); // 调用接口 currentPage.value = 1; // 重置页码 }; -// 搜索处理 -const handleSearch = () => { +// 搜索时触发数据加载 +const handleSearch = async () => { currentPage.value = 1; // 搜索后重置到第一页 + await fetchData(); // 调用接口 }; -// 分页大小变化 -const handlePageSizeChange = (size) => { +// 分页大小变化时触发数据加载 +const handlePageSizeChange = async (size) => { pageSize.value = size; - currentPage.value = 1; + currentPage.value = 1; // 切换页大小后重置到第一页 + await fetchData(); // 调用接口 }; -// 页码变化 -const handlePageChange = (page) => { +// 页码变化时触发数据加载 +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; + } +}; + + // 选中的行ID const selectedRowKeys = ref([]); // 复选框选中状态变化 @@ -235,8 +288,7 @@ const handleDelete = async (conversationIds, tabType) => { ); if (res.data.code === 20000) { Message.success(res.data.message || '删除成功'); - getQuestionHistory() - getQuestionCollection() + await fetchData(); // 删除后重新加载数据 selectedRowKeys.value = []; // 清空选中项 } else { Message.error(res.data.message || '删除失败'); diff --git a/src/views/Jyh/AI/Home/components/ViewHistoryAside/ViewHistoryAside.vue b/src/views/Jyh/AI/Home/components/ViewHistoryAside/ViewHistoryAside.vue index 574de4e..2e4fe0f 100644 --- a/src/views/Jyh/AI/Home/components/ViewHistoryAside/ViewHistoryAside.vue +++ b/src/views/Jyh/AI/Home/components/ViewHistoryAside/ViewHistoryAside.vue @@ -2,7 +2,7 @@ - +
@@ -101,11 +101,12 @@ style="width: 60px" size="sm" class="jyh-select" + @value-change="handleHistoryLimitChange" > 10 20 30 - 0 + 不限
@@ -120,7 +121,7 @@
- +
@@ -222,15 +223,15 @@ 0
- - - - - - - - - +
+ + + 批量管理 + + +
@@ -260,6 +261,20 @@ const BatchManageModalRef = ref(null); const { formatTime } = useTimeFormat(); +// 监听historyLimit变化,更新page.size并重置页码 +const handleHistoryLimitChange = (val) => { + debugger + page.value.size = Number(val) || Infinity; // 0转换为Infinity表示不限 + page.value.pageNum = 1; // 重置为第一页 + loadData(); // 重新加载数据 +}; + + +// 统一数据加载方法 +const loadData = async () => { + await getQuestionHistory(); + await getQuestionCollection(); +}; const handleSelect = (item) => { // 触发父组件事件,传递选中的 convId @@ -377,11 +392,23 @@ const cardList = ref([ ]); const dhlsList = ref([]); const collectionList = ref([]); +const page = ref({ + pageNum: 1, + size: 10 +}); const VITE_AI_API_HOST = import.meta.env.VITE_AI_API_HOST; const getQuestionHistory = async () => { if(props.username) { - const {data} = await axios.get(VITE_AI_API_HOST + '/api/conversationList?userId='+props.username + '&list_type=history'); + const {data} = await axios.post(VITE_AI_API_HOST + '/api/conversationList', { + "userId": props.username, + "list_type": "history", + "is_manage": true, + "page": page.value.pageNum, + "size": page.value.size, + "search": searchText.value + }); + if(data.conversationList) { dhlsList.value = data.conversationList } else { @@ -393,7 +420,14 @@ const getQuestionHistory = async () => { }; const getQuestionCollection = async () => { if(props.username) { - const {data} = await axios.get(VITE_AI_API_HOST + '/api/conversationList?userId='+props.username + '&list_type=collection'); + const {data} = await axios.post(VITE_AI_API_HOST + '/api/conversationList', { + "userId": props.username, + "list_type": "collection", + "is_manage": true, + "page": page.value.pageNum, + "size": page.value.size, + "search": searchText.value + }); if(data.conversationList) { collectionList.value = data.conversationList } else { @@ -421,8 +455,7 @@ const handleDelete = async (conversationIds, tabType) => { ); if (res.data.code === 20000) { Message.success(res.data.message || '删除成功'); - getQuestionHistory() - getQuestionCollection() + loadData() } else { Message.error(res.data.message || '删除失败'); } @@ -434,8 +467,7 @@ const handleDelete = async (conversationIds, tabType) => { onMounted(() => { - getQuestionHistory() - getQuestionCollection() + loadData() }); defineExpose({