feat(历史记录): 重构历史记录页面并添加AI咨询功能
This commit is contained in:
parent
8be8799e3d
commit
df1649e7c5
|
|
@ -46,12 +46,16 @@
|
|||
<view class="history-list">
|
||||
<view
|
||||
class="date-group"
|
||||
v-for="group in groupedHistoryList"
|
||||
:key="group.header"
|
||||
v-for="(group, groupIndex) in currentHistoryList"
|
||||
:key="groupIndex"
|
||||
>
|
||||
<view class="date-header">{{ group.header }}</view>
|
||||
<view class="date-header">{{ group.id }}</view>
|
||||
|
||||
<view class="history-item" v-for="item in group.items" :key="item.id">
|
||||
<view
|
||||
class="history-item"
|
||||
v-for="item in group.conversation"
|
||||
:key="item.id"
|
||||
>
|
||||
<!-- 批量删除模式下的选择框 -->
|
||||
<view
|
||||
class="item-checkbox"
|
||||
|
|
@ -72,11 +76,14 @@
|
|||
<view class="item-content">
|
||||
<view class="item-header">
|
||||
<view class="item-icon">
|
||||
<text class="icon-text">B</text>
|
||||
<image
|
||||
class="icon-image"
|
||||
src="/static/common/images/icon_chat2.png"
|
||||
/>
|
||||
</view>
|
||||
<view class="item-title">{{ item.title }}</view>
|
||||
</view>
|
||||
<view class="item-description">{{ item.content }}</view>
|
||||
<!-- <view class="item-description">{{ item.content }}</view> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -178,9 +185,20 @@ export default {
|
|||
type: "human",
|
||||
},
|
||||
],
|
||||
chatHistoryAI: [], // ai咨询历史记录
|
||||
chatHistoryTeacher: [], // 人工咨询历史记录
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
// 当前tab的历史记录
|
||||
currentHistoryList() {
|
||||
if (this.activeTab === "1") {
|
||||
return this.chatHistoryAI;
|
||||
} else {
|
||||
return this.chatHistoryTeacher;
|
||||
}
|
||||
},
|
||||
|
||||
// 根据当前tab过滤历史记录
|
||||
filteredHistoryList() {
|
||||
return this.historyList.filter((item) => {
|
||||
|
|
@ -220,7 +238,58 @@ export default {
|
|||
return groups;
|
||||
},
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.getChatHistoryList();
|
||||
// this.GetDialogueList_User();
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 获取ai历史记录
|
||||
async getChatHistoryList() {
|
||||
this.$u.api.GetConversationPage().then((res) => {
|
||||
this.chatHistoryAI = res.data;
|
||||
// if (this.chatHistoryAI.length > 0) {
|
||||
// this.chatHistoryAI = res.data.map((group) => {
|
||||
// // 对每个组的conversation数组进行倒序排序
|
||||
// return {
|
||||
// ...group,
|
||||
// conversation: group.conversation.sort((a, b) => {
|
||||
// // 将日期字符串转换为时间戳并比较(倒序)
|
||||
// return (
|
||||
// new Date(b.startTime).getTime() -
|
||||
// new Date(a.startTime).getTime()
|
||||
// );
|
||||
// }),
|
||||
// };
|
||||
// });
|
||||
// }
|
||||
console.log("this.chatHistoryAI", this.chatHistoryAI);
|
||||
});
|
||||
},
|
||||
|
||||
// 获取人工咨询数据
|
||||
async GetDialogueList_User() {
|
||||
this.$u.api.GetDialogueList_UserApi().then((res) => {
|
||||
this.chatHistoryTeacher = res.data;
|
||||
// if (this.chatHistoryTeacher.length > 0) {
|
||||
// this.chatHistoryTeacher = res.data.map((group) => {
|
||||
// // 对每个组的conversation数组进行倒序排序
|
||||
// return {
|
||||
// ...group,
|
||||
// conversation: group.conversation.sort((a, b) => {
|
||||
// // 将日期字符串转换为时间戳并比较(倒序)
|
||||
// return (
|
||||
// new Date(b.startTime).getTime() -
|
||||
// new Date(a.startTime).getTime()
|
||||
// );
|
||||
// }),
|
||||
// };
|
||||
// });
|
||||
// }
|
||||
});
|
||||
},
|
||||
|
||||
// 格式化时间显示
|
||||
formatTime(timestamp) {
|
||||
const now = new Date();
|
||||
|
|
@ -277,6 +346,12 @@ export default {
|
|||
|
||||
switchTab(tab) {
|
||||
this.activeTab = tab;
|
||||
// 切换tab时,刷新当前tab的历史记录
|
||||
if (tab === "1") {
|
||||
this.getChatHistoryList();
|
||||
} else {
|
||||
this.GetDialogueList_User();
|
||||
}
|
||||
},
|
||||
|
||||
// 显示/隐藏右上角更多菜单
|
||||
|
|
@ -348,6 +423,10 @@ export default {
|
|||
(item) => !this.selectedItems.includes(item.id)
|
||||
);
|
||||
|
||||
console.log('删除后的历史记录:',this.historyList);
|
||||
|
||||
return
|
||||
|
||||
// 重置状态
|
||||
this.selectedItems = [];
|
||||
this.selectAll = false;
|
||||
|
|
@ -358,18 +437,6 @@ export default {
|
|||
type: "success",
|
||||
});
|
||||
},
|
||||
|
||||
handleDelete(item, callback) {
|
||||
console.log("handleDelete", item);
|
||||
|
||||
setTimeout(() => {
|
||||
this.$refs.uToast.show({
|
||||
title: "撤回成功",
|
||||
type: "success",
|
||||
});
|
||||
callback(true);
|
||||
}, 1500);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
@ -543,22 +610,21 @@ export default {
|
|||
.item-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 24rpx;
|
||||
margin-bottom: 30rpx;
|
||||
|
||||
.item-icon {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
background-color: #4f6aff;
|
||||
width: 50rpx;
|
||||
height: 50rpx;
|
||||
background-color: rgba(79, 106, 255, 0.1);
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 16rpx;
|
||||
|
||||
.icon-text {
|
||||
color: #ffffff;
|
||||
font-size: 24rpx;
|
||||
font-weight: bold;
|
||||
.icon-image {
|
||||
width: 26rpx;
|
||||
height: 26rpx;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in New Issue