|
@@ -59,6 +59,7 @@
|
|
|
v-for="item in filteredHistory"
|
|
|
:key="item.id"
|
|
|
class="favorite-item"
|
|
|
+ :class="{'file-download': item.relatedType === 'file.download'}"
|
|
|
>
|
|
|
<div class="item-content" @click="handleItemClick(item)">
|
|
|
<el-checkbox
|
|
@@ -157,6 +158,7 @@
|
|
|
import { Search, ArrowLeft } from '@element-plus/icons-vue'
|
|
|
import { get, post, del ,put} from '../utils/request'
|
|
|
import { useRouter } from 'vue-router'
|
|
|
+ import { downloadFile } from '../utils'
|
|
|
|
|
|
// 将状态变量的声明移到最前面
|
|
|
const searchText = ref('')
|
|
@@ -226,9 +228,9 @@
|
|
|
pageSize: pageSize.value
|
|
|
}
|
|
|
const response = await get('admin/userHistoryLog/pageList', params)
|
|
|
- console.log('response.rows', response.data.rows);
|
|
|
+ // console.log('response.rows', response.data.rows);
|
|
|
history.value = response.data.rows || []
|
|
|
- console.log('history.value', history.value);
|
|
|
+ // console.log('history.value', history.value);
|
|
|
total.value = Number(response.data.total) || 0
|
|
|
} catch (error) {
|
|
|
ElMessage.error('获取列表失败')
|
|
@@ -368,18 +370,22 @@
|
|
|
// 工具函数
|
|
|
const getTagType = (type) => {
|
|
|
const types = {
|
|
|
- chat: '',
|
|
|
- solution: 'success',
|
|
|
- doc: 'warning'
|
|
|
+ 'ai.answer': 'success',
|
|
|
+ scheme: 'success',
|
|
|
+ doc: 'warning',
|
|
|
+ 'file.download': 'success',
|
|
|
+ 'file.search': 'warning'
|
|
|
}
|
|
|
return types[type] || 'info'
|
|
|
}
|
|
|
|
|
|
const getTypeLabel = (type) => {
|
|
|
const labels = {
|
|
|
- chat: '对话',
|
|
|
- solution: '方案',
|
|
|
- doc: '文档'
|
|
|
+ 'ai.answer': 'AI对话',
|
|
|
+ scheme: '方案生成',
|
|
|
+ doc: '文档',
|
|
|
+ 'file.download': '下载文件',
|
|
|
+ 'file.search': '文件检索'
|
|
|
}
|
|
|
return labels[type] || '未知'
|
|
|
}
|
|
@@ -389,6 +395,7 @@
|
|
|
}
|
|
|
|
|
|
const getEmptyText = () => {
|
|
|
+ // console.log('currentType.value', currentType.value);
|
|
|
if (searchText.value) {
|
|
|
return '未找到匹配的历史'
|
|
|
}
|
|
@@ -441,7 +448,7 @@
|
|
|
// 类型选择相关
|
|
|
const typeOptions = [
|
|
|
{ label: '全部', value: 'all' },
|
|
|
- { label: 'AI问答', value: 'ai.answer' },
|
|
|
+ { label: 'AI对话', value: 'ai.answer' },
|
|
|
{ label: '方案生成', value: 'scheme' },
|
|
|
{ label: '下载文件', value: 'file.download' }
|
|
|
]
|
|
@@ -464,16 +471,17 @@
|
|
|
router.push(`/solution?historyId=${item.id}`);
|
|
|
break;
|
|
|
case 'file.download':
|
|
|
- try {
|
|
|
- window.open(item.fileUrl, '_blank')
|
|
|
- // 添加文件下载记录
|
|
|
- await post('/admin/userHistoryLog/saveFileDownloadLog', {
|
|
|
- relatedId: item.id
|
|
|
- })
|
|
|
- } catch (error) {
|
|
|
- console.log('error', error);
|
|
|
- ElMessage.error('下载失败,请重试文件地址:'+item.fileUrl)
|
|
|
- }
|
|
|
+ try {
|
|
|
+ // console.log('item.fileName',item.fileName);
|
|
|
+ await downloadFile(item.fileUrl, item.fileName)
|
|
|
+ // 添加文件下载记录
|
|
|
+ await post('/admin/userHistoryLog/saveFileDownloadLog', {
|
|
|
+ relatedId: item.relatedId
|
|
|
+ })
|
|
|
+ } catch (error) {
|
|
|
+ console.log('error', error)
|
|
|
+ ElMessage.error('下载失败,请重试文件地址:'+item.fileUrl)
|
|
|
+ }
|
|
|
// try {
|
|
|
// // 调用下载接口
|
|
|
// const response = await get(`admin/file/download/${item.id}`, {}, {
|
|
@@ -494,6 +502,18 @@
|
|
|
// ElMessage.error('文件下载失败');
|
|
|
// }
|
|
|
break;
|
|
|
+ case 'file.search':
|
|
|
+ try {
|
|
|
+ await downloadFile(item.fileUrl, item.fileName)
|
|
|
+ // 添加文件下载记录
|
|
|
+ await post('/admin/userHistoryLog/saveFileDownloadLog', {
|
|
|
+ relatedId: item.relatedId
|
|
|
+ })
|
|
|
+ } catch (error) {
|
|
|
+ console.log('error', error)
|
|
|
+ ElMessage.error('下载失败,请重试文件地址:'+item.fileUrl)
|
|
|
+ }
|
|
|
+ break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|