|
|
@@ -5,23 +5,32 @@ defineOptions({
|
|
|
})
|
|
|
import { Plus } from '@element-plus/icons-vue'
|
|
|
import { ElButton, ElDialog, ElEmpty, ElInput, ElOption, ElPagination, ElSelect, ElTable, ElTableColumn, ElTag } from 'element-plus'
|
|
|
-// import SearchForm from './components/SearchForm.vue'
|
|
|
-
|
|
|
+import SearchForm from './components/SearchForm.vue'
|
|
|
+import AudioFileUploader from '@/components/Uploader/AudioFileUploader.vue'
|
|
|
import type { TVoice } from '@/types/voice'
|
|
|
-import { voiceList } from '@/api/modules/anycallService'
|
|
|
+import { toast } from 'vue-sonner'
|
|
|
+import { voiceList, cloneVoice } from '@/api/modules/anycallService'
|
|
|
import { formatDateGeneral } from '@/utils'
|
|
|
|
|
|
const tableRef = ref()
|
|
|
const loading = ref(false)
|
|
|
+const cloneLoading = ref(false)
|
|
|
const router = useRouter()
|
|
|
const route = useRoute()
|
|
|
|
|
|
// 搜索参数
|
|
|
-const searchParams = ref({
|
|
|
+const searchParams = ref<{name: string, type: number}>({
|
|
|
name: '',
|
|
|
+ type: 1
|
|
|
})
|
|
|
const dataList = ref<TVoice[]>([]);
|
|
|
|
|
|
+const currentAudio = ref<{
|
|
|
+ src: string;
|
|
|
+ srcName: string;
|
|
|
+ duration: number;
|
|
|
+}|undefined>()
|
|
|
+
|
|
|
// 从URL获取初始分页参数
|
|
|
const getInitialPagination = () => {
|
|
|
const page = Number(route.query.page) || 1
|
|
|
@@ -60,7 +69,7 @@ async function fetchData() {
|
|
|
loading.value = true
|
|
|
const res = await voiceList({
|
|
|
gender: 1,
|
|
|
- system: true,
|
|
|
+ system: searchParams.value.type === 1 ? true : false,
|
|
|
name: searchParams.value.name,
|
|
|
page: pagination.value.page,
|
|
|
size: pagination.value.size,
|
|
|
@@ -94,6 +103,7 @@ function handleSearch () {
|
|
|
function handleReset () {
|
|
|
searchParams.value = {
|
|
|
name: '',
|
|
|
+ type: 1,
|
|
|
}
|
|
|
pagination.value.page = 1 // 重置时重置到第一页
|
|
|
updateUrlParams(1, pagination.value.size)
|
|
|
@@ -118,6 +128,30 @@ watch(
|
|
|
{ deep: true }
|
|
|
)
|
|
|
|
|
|
+const handleUploadSuccess = (res: { code: number, data: { src: string, srcName: string, duration: number } }, file: any) => {
|
|
|
+ console.log(res, file)
|
|
|
+ if (res.code === 0) {
|
|
|
+
|
|
|
+ currentAudio.value = res.data
|
|
|
+ handleClone(res.data)
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const handleClone = async (res: { src: string, srcName: string, duration: number }) => {
|
|
|
+ cloneLoading.value = true
|
|
|
+ const {code, data} = await cloneVoice({
|
|
|
+ name: res.srcName,
|
|
|
+ audioUrl: res.src,
|
|
|
+ gender: 1
|
|
|
+ })
|
|
|
+ cloneLoading.value = false
|
|
|
+ console.log(code, data)
|
|
|
+ if(code === 0){
|
|
|
+ toast.success('克隆成功')
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
onMounted(async () => {
|
|
|
await fetchData()
|
|
|
})
|
|
|
@@ -127,8 +161,18 @@ onMounted(async () => {
|
|
|
|
|
|
<template>
|
|
|
<div class="absolute-container">
|
|
|
- <FaPageHeader title="Voice Management" />
|
|
|
+ <FaPageMain class="mb-0">
|
|
|
+ <ElCard shadow="never">
|
|
|
+ <SearchForm v-model="searchParams" @search="handleSearch" @reset="handleReset"></SearchForm>
|
|
|
+ </ElCard>
|
|
|
+ </FaPageMain>
|
|
|
<FaPageMain class="flex-1 overflow-auto" main-class="flex-1 flex flex-col overflow-auto">
|
|
|
+ <div class="pb-4">
|
|
|
+ <ElSpace>
|
|
|
+ <AudioFileUploader :disabled="cloneLoading" @on-success="handleUploadSuccess"><ElButton type="primary" :icon="Plus">克隆声音</ElButton></AudioFileUploader>
|
|
|
+ <!-- <ElButton type="primary" :icon="Plus" @click="handleClone">克隆声音</ElButton> -->
|
|
|
+ </ElSpace>
|
|
|
+ </div>
|
|
|
<ElTable
|
|
|
ref="tableRef" :data="dataList" stripe highlight-current-row border height="100%"
|
|
|
>
|