|
@@ -6,10 +6,12 @@ defineOptions({
|
|
|
import { Plus } from '@element-plus/icons-vue'
|
|
import { Plus } from '@element-plus/icons-vue'
|
|
|
import { ElButton, ElDialog, ElEmpty, ElInput, ElOption, ElPagination, ElSelect, ElTable, ElTableColumn, ElTag } from 'element-plus'
|
|
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 type { TSearchParams } from './components/SearchForm.vue'
|
|
|
|
|
+import EditForm from './components/EditForm.vue'
|
|
|
import AudioFileUploader from '@/components/Uploader/AudioFileUploader.vue'
|
|
import AudioFileUploader from '@/components/Uploader/AudioFileUploader.vue'
|
|
|
import type { TVoice } from '@/types/voice'
|
|
import type { TVoice } from '@/types/voice'
|
|
|
import { toast } from 'vue-sonner'
|
|
import { toast } from 'vue-sonner'
|
|
|
-import { voiceList, cloneVoice } from '@/api/modules/anycallService'
|
|
|
|
|
|
|
+import { voiceList, cloneVoice } from '@/api/modules/voice'
|
|
|
import { formatDateGeneral } from '@/utils'
|
|
import { formatDateGeneral } from '@/utils'
|
|
|
|
|
|
|
|
const tableRef = ref()
|
|
const tableRef = ref()
|
|
@@ -19,11 +21,20 @@ const router = useRouter()
|
|
|
const route = useRoute()
|
|
const route = useRoute()
|
|
|
|
|
|
|
|
// 搜索参数
|
|
// 搜索参数
|
|
|
-const searchParams = ref<{name: string, type: number}>({
|
|
|
|
|
|
|
+const searchParams = ref<TSearchParams>({
|
|
|
name: '',
|
|
name: '',
|
|
|
- type: 1
|
|
|
|
|
|
|
+ type: 1,
|
|
|
|
|
+ gender: null
|
|
|
})
|
|
})
|
|
|
const dataList = ref<TVoice[]>([]);
|
|
const dataList = ref<TVoice[]>([]);
|
|
|
|
|
+const editFormVisible = ref(false)
|
|
|
|
|
+const editMode = ref<'create' | 'edit'>('create')
|
|
|
|
|
+const currentData = ref<{
|
|
|
|
|
+ "id": string|undefined,
|
|
|
|
|
+ "name": string,
|
|
|
|
|
+ "photoUrl": string,
|
|
|
|
|
+ "feature": string
|
|
|
|
|
+}|null>(null)
|
|
|
|
|
|
|
|
const currentAudio = ref<{
|
|
const currentAudio = ref<{
|
|
|
src: string;
|
|
src: string;
|
|
@@ -60,17 +71,14 @@ const updateUrlParams = (page: number, size: number) => {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-const handleRecommend = (id: string) => {
|
|
|
|
|
-
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
async function fetchData() {
|
|
async function fetchData() {
|
|
|
loading.value = true
|
|
loading.value = true
|
|
|
|
|
+ const gender = searchParams.value.gender === -1 ? null : searchParams.value.gender
|
|
|
const res = await voiceList({
|
|
const res = await voiceList({
|
|
|
- gender: 1,
|
|
|
|
|
|
|
+ gender,
|
|
|
system: searchParams.value.type === 1 ? true : false,
|
|
system: searchParams.value.type === 1 ? true : false,
|
|
|
name: searchParams.value.name,
|
|
name: searchParams.value.name,
|
|
|
|
|
+ type: searchParams.value.type,
|
|
|
page: pagination.value.page,
|
|
page: pagination.value.page,
|
|
|
size: pagination.value.size,
|
|
size: pagination.value.size,
|
|
|
})
|
|
})
|
|
@@ -104,6 +112,7 @@ function handleReset () {
|
|
|
searchParams.value = {
|
|
searchParams.value = {
|
|
|
name: '',
|
|
name: '',
|
|
|
type: 1,
|
|
type: 1,
|
|
|
|
|
+ gender: null,
|
|
|
}
|
|
}
|
|
|
pagination.value.page = 1 // 重置时重置到第一页
|
|
pagination.value.page = 1 // 重置时重置到第一页
|
|
|
updateUrlParams(1, pagination.value.size)
|
|
updateUrlParams(1, pagination.value.size)
|
|
@@ -152,6 +161,18 @@ const handleClone = async (res: { src: string, srcName: string, duration: numbe
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+const handleEdit = (data: TVoice) => {
|
|
|
|
|
+ editMode.value = 'edit'
|
|
|
|
|
+ currentData.value = {
|
|
|
|
|
+ id: data.id,
|
|
|
|
|
+ name: data.name ?? '',
|
|
|
|
|
+ photoUrl: data.photoUrl ?? '',
|
|
|
|
|
+ feature: data.feature ?? ''
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ editFormVisible.value = true
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
onMounted(async () => {
|
|
onMounted(async () => {
|
|
|
await fetchData()
|
|
await fetchData()
|
|
|
})
|
|
})
|
|
@@ -178,6 +199,11 @@ onMounted(async () => {
|
|
|
>
|
|
>
|
|
|
<ElTableColumn label="ID" prop="id" width="280" />
|
|
<ElTableColumn label="ID" prop="id" width="280" />
|
|
|
<ElTableColumn label="Name" prop="name" min-width="200"/>
|
|
<ElTableColumn label="Name" prop="name" min-width="200"/>
|
|
|
|
|
+ <ElTableColumn label="Avatar" prop="photoUrl">
|
|
|
|
|
+ <template #default="{row}">
|
|
|
|
|
+ <ElImage :src="row.photoUrl" fit="cover" class="w-12 h-12 rounded" />
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </ElTableColumn>
|
|
|
<ElTableColumn label="Gender" prop="gender">
|
|
<ElTableColumn label="Gender" prop="gender">
|
|
|
<template #default="{row}">
|
|
<template #default="{row}">
|
|
|
{{ row.gender === 1 ? '男':"女" }}
|
|
{{ row.gender === 1 ? '男':"女" }}
|
|
@@ -193,6 +219,11 @@ onMounted(async () => {
|
|
|
{{ formatDateGeneral(row.ctime) }}
|
|
{{ formatDateGeneral(row.ctime) }}
|
|
|
</template>
|
|
</template>
|
|
|
</ElTableColumn>
|
|
</ElTableColumn>
|
|
|
|
|
+ <ElTableColumn fixed="right" label="操作" min-width="240">
|
|
|
|
|
+ <template #default="{row}">
|
|
|
|
|
+ <ElButton link type="primary" size="small" @click="handleEdit(row)">编辑</ElButton>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </ElTableColumn>
|
|
|
</ElTable>
|
|
</ElTable>
|
|
|
<div class="p-4">
|
|
<div class="p-4">
|
|
|
<ElPagination
|
|
<ElPagination
|
|
@@ -206,6 +237,7 @@ onMounted(async () => {
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
</FaPageMain>
|
|
</FaPageMain>
|
|
|
|
|
+ <EditForm v-model="currentData" v-model:visible="editFormVisible" :mode="editMode" @refresh="fetchData"></EditForm>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
<style scoped>
|
|
<style scoped>
|