feat(历史记录): 重构历史记录页面并添加AI咨询功能
This commit is contained in:
parent
8be8799e3d
commit
df1649e7c5
|
|
@ -46,12 +46,16 @@
|
||||||
<view class="history-list">
|
<view class="history-list">
|
||||||
<view
|
<view
|
||||||
class="date-group"
|
class="date-group"
|
||||||
v-for="group in groupedHistoryList"
|
v-for="(group, groupIndex) in currentHistoryList"
|
||||||
:key="group.header"
|
: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
|
<view
|
||||||
class="item-checkbox"
|
class="item-checkbox"
|
||||||
|
|
@ -72,11 +76,14 @@
|
||||||
<view class="item-content">
|
<view class="item-content">
|
||||||
<view class="item-header">
|
<view class="item-header">
|
||||||
<view class="item-icon">
|
<view class="item-icon">
|
||||||
<text class="icon-text">B</text>
|
<image
|
||||||
|
class="icon-image"
|
||||||
|
src="/static/common/images/icon_chat2.png"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
<view class="item-title">{{ item.title }}</view>
|
<view class="item-title">{{ item.title }}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="item-description">{{ item.content }}</view>
|
<!-- <view class="item-description">{{ item.content }}</view> -->
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -178,9 +185,20 @@ export default {
|
||||||
type: "human",
|
type: "human",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
chatHistoryAI: [], // ai咨询历史记录
|
||||||
|
chatHistoryTeacher: [], // 人工咨询历史记录
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
// 当前tab的历史记录
|
||||||
|
currentHistoryList() {
|
||||||
|
if (this.activeTab === "1") {
|
||||||
|
return this.chatHistoryAI;
|
||||||
|
} else {
|
||||||
|
return this.chatHistoryTeacher;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// 根据当前tab过滤历史记录
|
// 根据当前tab过滤历史记录
|
||||||
filteredHistoryList() {
|
filteredHistoryList() {
|
||||||
return this.historyList.filter((item) => {
|
return this.historyList.filter((item) => {
|
||||||
|
|
@ -220,7 +238,58 @@ export default {
|
||||||
return groups;
|
return groups;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onLoad() {
|
||||||
|
this.getChatHistoryList();
|
||||||
|
// this.GetDialogueList_User();
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
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) {
|
formatTime(timestamp) {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
|
@ -277,6 +346,12 @@ export default {
|
||||||
|
|
||||||
switchTab(tab) {
|
switchTab(tab) {
|
||||||
this.activeTab = 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)
|
(item) => !this.selectedItems.includes(item.id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log('删除后的历史记录:',this.historyList);
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
// 重置状态
|
// 重置状态
|
||||||
this.selectedItems = [];
|
this.selectedItems = [];
|
||||||
this.selectAll = false;
|
this.selectAll = false;
|
||||||
|
|
@ -358,18 +437,6 @@ export default {
|
||||||
type: "success",
|
type: "success",
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
handleDelete(item, callback) {
|
|
||||||
console.log("handleDelete", item);
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
this.$refs.uToast.show({
|
|
||||||
title: "撤回成功",
|
|
||||||
type: "success",
|
|
||||||
});
|
|
||||||
callback(true);
|
|
||||||
}, 1500);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -543,22 +610,21 @@ export default {
|
||||||
.item-header {
|
.item-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 24rpx;
|
margin-bottom: 30rpx;
|
||||||
|
|
||||||
.item-icon {
|
.item-icon {
|
||||||
width: 48rpx;
|
width: 50rpx;
|
||||||
height: 48rpx;
|
height: 50rpx;
|
||||||
background-color: #4f6aff;
|
background-color: rgba(79, 106, 255, 0.1);
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
margin-right: 16rpx;
|
margin-right: 16rpx;
|
||||||
|
|
||||||
.icon-text {
|
.icon-image {
|
||||||
color: #ffffff;
|
width: 26rpx;
|
||||||
font-size: 24rpx;
|
height: 26rpx;
|
||||||
font-weight: bold;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
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