提交 | 用户 | 时间
|
820397
|
1 |
<template> |
H |
2 |
<ContentWrap> |
|
3 |
<!-- 搜索工作栏 --> |
|
4 |
<el-form |
|
5 |
class="-mb-15px" |
|
6 |
:model="queryParams" |
|
7 |
ref="queryFormRef" |
|
8 |
:inline="true" |
|
9 |
label-width="68px" |
|
10 |
> |
|
11 |
<el-form-item label="用户编号" prop="userId"> |
|
12 |
<el-select |
|
13 |
v-model="queryParams.userId" |
|
14 |
clearable |
|
15 |
placeholder="请输入用户编号" |
|
16 |
class="!w-240px" |
|
17 |
> |
|
18 |
<el-option |
|
19 |
v-for="item in userList" |
|
20 |
:key="item.id" |
|
21 |
:label="item.nickname" |
|
22 |
:value="item.id" |
|
23 |
/> |
|
24 |
</el-select> |
|
25 |
</el-form-item> |
|
26 |
<el-form-item label="聊天编号" prop="title"> |
|
27 |
<el-input |
|
28 |
v-model="queryParams.title" |
|
29 |
placeholder="请输入聊天编号" |
|
30 |
clearable |
|
31 |
@keyup.enter="handleQuery" |
|
32 |
class="!w-240px" |
|
33 |
/> |
|
34 |
</el-form-item> |
|
35 |
<el-form-item label="创建时间" prop="createTime"> |
|
36 |
<el-date-picker |
|
37 |
v-model="queryParams.createTime" |
|
38 |
value-format="YYYY-MM-DD HH:mm:ss" |
|
39 |
type="daterange" |
|
40 |
start-placeholder="开始日期" |
|
41 |
end-placeholder="结束日期" |
|
42 |
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" |
|
43 |
class="!w-240px" |
|
44 |
/> |
|
45 |
</el-form-item> |
|
46 |
<el-form-item> |
|
47 |
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> |
|
48 |
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> |
|
49 |
</el-form-item> |
|
50 |
</el-form> |
|
51 |
</ContentWrap> |
|
52 |
|
|
53 |
<!-- 列表 --> |
|
54 |
<ContentWrap> |
|
55 |
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true"> |
|
56 |
<el-table-column label="对话编号" align="center" prop="id" width="180" fixed="left" /> |
|
57 |
<el-table-column label="对话标题" align="center" prop="title" width="180" fixed="left" /> |
|
58 |
<el-table-column label="用户" align="center" prop="userId" width="180"> |
|
59 |
<template #default="scope"> |
|
60 |
<span>{{ userList.find((item) => item.id === scope.row.userId)?.nickname }}</span> |
|
61 |
</template> |
|
62 |
</el-table-column> |
|
63 |
<el-table-column label="角色" align="center" prop="roleName" width="180" /> |
|
64 |
<el-table-column label="模型标识" align="center" prop="model" width="180" /> |
|
65 |
<el-table-column label="消息数" align="center" prop="messageCount" /> |
|
66 |
<el-table-column |
|
67 |
label="创建时间" |
|
68 |
align="center" |
|
69 |
prop="createTime" |
|
70 |
:formatter="dateFormatter" |
|
71 |
width="180px" |
|
72 |
/> |
|
73 |
<el-table-column label="温度参数" align="center" prop="temperature" /> |
|
74 |
<el-table-column label="回复 Token 数" align="center" prop="maxTokens" width="120" /> |
|
75 |
<el-table-column label="上下文数量" align="center" prop="maxContexts" width="120" /> |
|
76 |
<el-table-column label="操作" align="center" width="180" fixed="right"> |
|
77 |
<template #default="scope"> |
|
78 |
<el-button |
|
79 |
link |
|
80 |
type="danger" |
|
81 |
@click="handleDelete(scope.row.id)" |
|
82 |
v-hasPermi="['ai:chat-conversation:delete']" |
|
83 |
> |
|
84 |
删除 |
|
85 |
</el-button> |
|
86 |
</template> |
|
87 |
</el-table-column> |
|
88 |
</el-table> |
|
89 |
<!-- 分页 --> |
|
90 |
<Pagination |
|
91 |
:total="total" |
|
92 |
v-model:page="queryParams.pageNo" |
|
93 |
v-model:limit="queryParams.pageSize" |
|
94 |
@pagination="getList" |
|
95 |
/> |
|
96 |
</ContentWrap> |
|
97 |
</template> |
|
98 |
|
|
99 |
<script setup lang="ts"> |
|
100 |
import { dateFormatter } from '@/utils/formatTime' |
|
101 |
import { ChatConversationApi, ChatConversationVO } from '@/api/ai/chat/conversation' |
|
102 |
import * as UserApi from '@/api/system/user' |
|
103 |
|
|
104 |
const message = useMessage() // 消息弹窗 |
|
105 |
const { t } = useI18n() // 国际化 |
|
106 |
|
|
107 |
const loading = ref(true) // 列表的加载中 |
|
108 |
const list = ref<ChatConversationVO[]>([]) // 列表的数据 |
|
109 |
const total = ref(0) // 列表的总页数 |
|
110 |
const queryParams = reactive({ |
|
111 |
pageNo: 1, |
|
112 |
pageSize: 10, |
|
113 |
userId: undefined, |
|
114 |
title: undefined, |
|
115 |
createTime: [] |
|
116 |
}) |
|
117 |
const queryFormRef = ref() // 搜索的表单 |
|
118 |
const userList = ref<UserApi.UserVO[]>([]) // 用户列表 |
|
119 |
|
|
120 |
/** 查询列表 */ |
|
121 |
const getList = async () => { |
|
122 |
loading.value = true |
|
123 |
try { |
|
124 |
const data = await ChatConversationApi.getChatConversationPage(queryParams) |
|
125 |
list.value = data.list |
|
126 |
total.value = data.total |
|
127 |
} finally { |
|
128 |
loading.value = false |
|
129 |
} |
|
130 |
} |
|
131 |
|
|
132 |
/** 搜索按钮操作 */ |
|
133 |
const handleQuery = () => { |
|
134 |
queryParams.pageNo = 1 |
|
135 |
getList() |
|
136 |
} |
|
137 |
|
|
138 |
/** 重置按钮操作 */ |
|
139 |
const resetQuery = () => { |
|
140 |
queryFormRef.value.resetFields() |
|
141 |
handleQuery() |
|
142 |
} |
|
143 |
|
|
144 |
/** 删除按钮操作 */ |
|
145 |
const handleDelete = async (id: number) => { |
|
146 |
try { |
|
147 |
// 删除的二次确认 |
|
148 |
await message.delConfirm() |
|
149 |
// 发起删除 |
|
150 |
await ChatConversationApi.deleteChatConversationByAdmin(id) |
|
151 |
message.success(t('common.delSuccess')) |
|
152 |
// 刷新列表 |
|
153 |
await getList() |
|
154 |
} catch {} |
|
155 |
} |
|
156 |
|
|
157 |
/** 初始化 **/ |
|
158 |
onMounted(async () => { |
|
159 |
getList() |
|
160 |
// 获得用户列表 |
|
161 |
userList.value = await UserApi.getSimpleUserList() |
|
162 |
}) |
|
163 |
</script> |