提交 | 用户 | 时间
|
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="status"> |
|
36 |
<el-select |
|
37 |
v-model="queryParams.status" |
|
38 |
placeholder="请选择音乐状态" |
|
39 |
clearable |
|
40 |
class="!w-240px" |
|
41 |
> |
|
42 |
<el-option |
|
43 |
v-for="dict in getIntDictOptions(DICT_TYPE.AI_MUSIC_STATUS)" |
|
44 |
:key="dict.value" |
|
45 |
:label="dict.label" |
|
46 |
:value="dict.value" |
|
47 |
/> |
|
48 |
</el-select> |
|
49 |
</el-form-item> |
|
50 |
<el-form-item label="生成模式" prop="generateMode"> |
|
51 |
<el-select |
|
52 |
v-model="queryParams.generateMode" |
|
53 |
placeholder="请选择生成模式" |
|
54 |
clearable |
|
55 |
class="!w-240px" |
|
56 |
> |
|
57 |
<el-option |
|
58 |
v-for="dict in getIntDictOptions(DICT_TYPE.AI_GENERATE_MODE)" |
|
59 |
:key="dict.value" |
|
60 |
:label="dict.label" |
|
61 |
:value="dict.value" |
|
62 |
/> |
|
63 |
</el-select> |
|
64 |
</el-form-item> |
|
65 |
<el-form-item label="创建时间" prop="createTime"> |
|
66 |
<el-date-picker |
|
67 |
v-model="queryParams.createTime" |
|
68 |
value-format="YYYY-MM-DD HH:mm:ss" |
|
69 |
type="daterange" |
|
70 |
start-placeholder="开始日期" |
|
71 |
end-placeholder="结束日期" |
|
72 |
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" |
|
73 |
class="!w-220px" |
|
74 |
/> |
|
75 |
</el-form-item> |
|
76 |
<el-form-item label="是否发布" prop="publicStatus"> |
|
77 |
<el-select |
|
78 |
v-model="queryParams.publicStatus" |
|
79 |
placeholder="请选择是否发布" |
|
80 |
clearable |
|
81 |
class="!w-240px" |
|
82 |
> |
|
83 |
<el-option |
|
84 |
v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)" |
|
85 |
:key="dict.value" |
|
86 |
:label="dict.label" |
|
87 |
:value="dict.value" |
|
88 |
/> |
|
89 |
</el-select> |
|
90 |
</el-form-item> |
|
91 |
<el-form-item> |
|
92 |
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> |
|
93 |
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> |
|
94 |
</el-form-item> |
|
95 |
</el-form> |
|
96 |
</ContentWrap> |
|
97 |
|
|
98 |
<!-- 列表 --> |
|
99 |
<ContentWrap> |
|
100 |
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true"> |
|
101 |
<el-table-column label="编号" align="center" prop="id" width="180" fixed="left" /> |
|
102 |
<el-table-column label="音乐名称" align="center" prop="title" width="180px" fixed="left" /> |
|
103 |
<el-table-column label="用户" align="center" prop="userId" width="180"> |
|
104 |
<template #default="scope"> |
|
105 |
<span>{{ userList.find((item) => item.id === scope.row.userId)?.nickname }}</span> |
|
106 |
</template> |
|
107 |
</el-table-column> |
|
108 |
<el-table-column label="音乐状态" align="center" prop="status" width="100"> |
|
109 |
<template #default="scope"> |
|
110 |
<dict-tag :type="DICT_TYPE.AI_MUSIC_STATUS" :value="scope.row.status" /> |
|
111 |
</template> |
|
112 |
</el-table-column> |
|
113 |
<el-table-column label="模型" align="center" prop="model" width="180" /> |
|
114 |
<el-table-column label="内容" align="center" width="180"> |
|
115 |
<template #default="{ row }"> |
|
116 |
<el-link |
|
117 |
v-if="row.audioUrl?.length > 0" |
|
118 |
type="primary" |
|
119 |
:href="row.audioUrl" |
|
120 |
target="_blank" |
|
121 |
> |
|
122 |
音乐 |
|
123 |
</el-link> |
|
124 |
<el-link |
|
125 |
v-if="row.videoUrl?.length > 0" |
|
126 |
type="primary" |
|
127 |
:href="row.videoUrl" |
|
128 |
target="_blank" |
|
129 |
class="!pl-5px" |
|
130 |
> |
|
131 |
视频 |
|
132 |
</el-link> |
|
133 |
<el-link |
|
134 |
v-if="row.imageUrl?.length > 0" |
|
135 |
type="primary" |
|
136 |
:href="row.imageUrl" |
|
137 |
target="_blank" |
|
138 |
class="!pl-5px" |
|
139 |
> |
|
140 |
封面 |
|
141 |
</el-link> |
|
142 |
</template> |
|
143 |
</el-table-column> |
|
144 |
<el-table-column label="时长(秒)" align="center" prop="duration" width="100" /> |
|
145 |
<el-table-column label="提示词" align="center" prop="prompt" width="180" /> |
|
146 |
<el-table-column label="歌词" align="center" prop="lyric" width="180" /> |
|
147 |
<el-table-column label="描述" align="center" prop="gptDescriptionPrompt" width="180" /> |
|
148 |
<el-table-column label="生成模式" align="center" prop="generateMode" width="100"> |
|
149 |
<template #default="scope"> |
|
150 |
<dict-tag :type="DICT_TYPE.AI_GENERATE_MODE" :value="scope.row.generateMode" /> |
|
151 |
</template> |
|
152 |
</el-table-column> |
|
153 |
<el-table-column label="风格标签" align="center" prop="tags" width="180"> |
|
154 |
<template #default="scope"> |
|
155 |
<el-tag v-for="tag in scope.row.tags" :key="tag" round class="ml-2px"> |
|
156 |
{{ tag }} |
|
157 |
</el-tag> |
|
158 |
</template> |
|
159 |
</el-table-column> |
|
160 |
<el-table-column label="是否发布" align="center" prop="publicStatus"> |
|
161 |
<template #default="scope"> |
|
162 |
<el-switch |
|
163 |
v-model="scope.row.publicStatus" |
|
164 |
:active-value="true" |
|
165 |
:inactive-value="false" |
|
166 |
@change="handleUpdatePublicStatusChange(scope.row)" |
|
167 |
:disabled="scope.row.status !== AiMusicStatusEnum.SUCCESS" |
|
168 |
/> |
|
169 |
</template> |
|
170 |
</el-table-column> |
|
171 |
<el-table-column label="任务编号" align="center" prop="taskId" width="180" /> |
|
172 |
<el-table-column label="错误信息" align="center" prop="errorMessage" /> |
|
173 |
<el-table-column |
|
174 |
label="创建时间" |
|
175 |
align="center" |
|
176 |
prop="createTime" |
|
177 |
:formatter="dateFormatter" |
|
178 |
width="180px" |
|
179 |
/> |
|
180 |
<el-table-column label="操作" align="center" width="100" fixed="right"> |
|
181 |
<template #default="scope"> |
|
182 |
<el-button |
|
183 |
link |
|
184 |
type="danger" |
|
185 |
@click="handleDelete(scope.row.id)" |
|
186 |
v-hasPermi="['ai:music:delete']" |
|
187 |
> |
|
188 |
删除 |
|
189 |
</el-button> |
|
190 |
</template> |
|
191 |
</el-table-column> |
|
192 |
</el-table> |
|
193 |
<!-- 分页 --> |
|
194 |
<Pagination |
|
195 |
:total="total" |
|
196 |
v-model:page="queryParams.pageNo" |
|
197 |
v-model:limit="queryParams.pageSize" |
|
198 |
@pagination="getList" |
|
199 |
/> |
|
200 |
</ContentWrap> |
|
201 |
</template> |
|
202 |
|
|
203 |
<script setup lang="ts"> |
|
204 |
import { getIntDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict' |
|
205 |
import { dateFormatter } from '@/utils/formatTime' |
|
206 |
import { MusicApi, MusicVO } from '@/api/ai/music' |
|
207 |
import * as UserApi from '@/api/system/user' |
|
208 |
import { AiMusicStatusEnum } from '@/views/ai/utils/constants' |
|
209 |
|
|
210 |
/** AI 音乐 列表 */ |
|
211 |
defineOptions({ name: 'AiMusicManager' }) |
|
212 |
|
|
213 |
const message = useMessage() // 消息弹窗 |
|
214 |
const { t } = useI18n() // 国际化 |
|
215 |
|
|
216 |
const loading = ref(true) // 列表的加载中 |
|
217 |
const list = ref<MusicVO[]>([]) // 列表的数据 |
|
218 |
const total = ref(0) // 列表的总页数 |
|
219 |
const queryParams = reactive({ |
|
220 |
pageNo: 1, |
|
221 |
pageSize: 10, |
|
222 |
userId: undefined, |
|
223 |
title: undefined, |
|
224 |
status: undefined, |
|
225 |
generateMode: undefined, |
|
226 |
createTime: [], |
|
227 |
publicStatus: undefined |
|
228 |
}) |
|
229 |
const queryFormRef = ref() // 搜索的表单 |
|
230 |
const userList = ref<UserApi.UserVO[]>([]) // 用户列表 |
|
231 |
|
|
232 |
/** 查询列表 */ |
|
233 |
const getList = async () => { |
|
234 |
loading.value = true |
|
235 |
try { |
|
236 |
const data = await MusicApi.getMusicPage(queryParams) |
|
237 |
list.value = data.list |
|
238 |
total.value = data.total |
|
239 |
} finally { |
|
240 |
loading.value = false |
|
241 |
} |
|
242 |
} |
|
243 |
|
|
244 |
/** 搜索按钮操作 */ |
|
245 |
const handleQuery = () => { |
|
246 |
queryParams.pageNo = 1 |
|
247 |
getList() |
|
248 |
} |
|
249 |
|
|
250 |
/** 重置按钮操作 */ |
|
251 |
const resetQuery = () => { |
|
252 |
queryFormRef.value.resetFields() |
|
253 |
handleQuery() |
|
254 |
} |
|
255 |
|
|
256 |
/** 删除按钮操作 */ |
|
257 |
const handleDelete = async (id: number) => { |
|
258 |
try { |
|
259 |
// 删除的二次确认 |
|
260 |
await message.delConfirm() |
|
261 |
// 发起删除 |
|
262 |
await MusicApi.deleteMusic(id) |
|
263 |
message.success(t('common.delSuccess')) |
|
264 |
// 刷新列表 |
|
265 |
await getList() |
|
266 |
} catch {} |
|
267 |
} |
|
268 |
|
|
269 |
/** 修改是否发布 */ |
|
270 |
const handleUpdatePublicStatusChange = async (row: MusicVO) => { |
|
271 |
try { |
|
272 |
// 修改状态的二次确认 |
|
273 |
const text = row.publicStatus ? '公开' : '私有' |
|
274 |
await message.confirm('确认要"' + text + '"该音乐吗?') |
|
275 |
// 发起修改状态 |
|
276 |
await MusicApi.updateMusic({ |
|
277 |
id: row.id, |
|
278 |
publicStatus: row.publicStatus |
|
279 |
}) |
|
280 |
await getList() |
|
281 |
} catch { |
|
282 |
row.publicStatus = !row.publicStatus |
|
283 |
} |
|
284 |
} |
|
285 |
|
|
286 |
/** 初始化 **/ |
|
287 |
onMounted(async () => { |
|
288 |
getList() |
|
289 |
// 获得用户列表 |
|
290 |
userList.value = await UserApi.getSimpleUserList() |
|
291 |
}) |
|
292 |
</script> |