|
|
@@ -11,31 +11,14 @@
|
|
|
短剧资产列表
|
|
|
</h2>
|
|
|
<div class="flex items-center gap-3">
|
|
|
- <el-select
|
|
|
- v-model="orgAccountId"
|
|
|
- placeholder="选择组织账户"
|
|
|
- clearable
|
|
|
- filterable
|
|
|
- style="width: 250px"
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="auth in orgAccounts"
|
|
|
- :key="auth.accountId"
|
|
|
- :label="`${auth.accountId} (${auth.accountType || ''})`"
|
|
|
- :value="auth.accountId"
|
|
|
- />
|
|
|
+ <el-button type="primary" @click="showSyncAccountDialog">我的同步账号管理</el-button>
|
|
|
+ <el-select v-model="accountId" placeholder="选择同步账号" clearable filterable style="width: 250px">
|
|
|
+ <el-option v-for="conf in confList" :key="conf.id" :label="`${conf.accountId}`" :value="conf.accountId" />
|
|
|
</el-select>
|
|
|
- <el-input
|
|
|
- v-model="accountId"
|
|
|
- placeholder="推广账号ID"
|
|
|
- clearable
|
|
|
- style="width: 200px"
|
|
|
- />
|
|
|
<el-button
|
|
|
type="primary"
|
|
|
@click="handleSync"
|
|
|
:loading="syncing"
|
|
|
- :disabled="!orgAccountId || !accountId"
|
|
|
>
|
|
|
<el-icon><Refresh /></el-icon>
|
|
|
同步资产
|
|
|
@@ -44,6 +27,25 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
+ <!-- 查询条件 -->
|
|
|
+ <div class="flex flex-col gap-3 mb-6">
|
|
|
+ <div class="flex flex-wrap items-center gap-4">
|
|
|
+ <el-input
|
|
|
+ v-model="queryForm.dramaName"
|
|
|
+ placeholder="短剧名称筛选"
|
|
|
+ clearable
|
|
|
+ style="width: 220px"
|
|
|
+ @clear="handleSearch"
|
|
|
+ @keyup.enter="handleSearch"
|
|
|
+ />
|
|
|
+ <el-button type="primary" @click="handleSearch">
|
|
|
+ <el-icon><Search /></el-icon>
|
|
|
+ 查询
|
|
|
+ </el-button>
|
|
|
+ <el-button @click="handleReset">重置</el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
<!-- 数据统计 -->
|
|
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
|
|
|
<div class="bg-gradient-to-br from-indigo-50 to-indigo-100 rounded-lg p-4 border border-indigo-200">
|
|
|
@@ -139,6 +141,72 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
+ <!-- 同步账号管理对话框 -->
|
|
|
+ <el-dialog
|
|
|
+ v-model="syncAccountDialogVisible"
|
|
|
+ title="我的同步账号管理"
|
|
|
+ width="600px"
|
|
|
+ @close="resetConfForm"
|
|
|
+ >
|
|
|
+ <!-- 新增表单 -->
|
|
|
+ <div class="bg-gray-50 rounded-lg p-4 mb-5 border border-gray-200">
|
|
|
+ <p class="text-sm font-medium text-gray-700 mb-3">新增同步账号</p>
|
|
|
+ <el-form
|
|
|
+ :model="confForm"
|
|
|
+ :rules="confFormRules"
|
|
|
+ ref="confFormRef"
|
|
|
+ label-width="80px"
|
|
|
+ size="default"
|
|
|
+ >
|
|
|
+ <el-form-item label="账号ID" prop="accountId">
|
|
|
+ <el-input
|
|
|
+ v-model="confForm.accountId"
|
|
|
+ placeholder="请输入推广账号ID"
|
|
|
+ clearable
|
|
|
+ style="width: 100%"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item style="margin-bottom: 0">
|
|
|
+ <el-button type="primary" :loading="addingConf" @click="handleAddConf">确认新增</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- 账号列表 -->
|
|
|
+ <el-table
|
|
|
+ :data="confList"
|
|
|
+ v-loading="confListLoading"
|
|
|
+ stripe
|
|
|
+ border
|
|
|
+ style="width: 100%"
|
|
|
+ empty-text="暂无同步账号配置"
|
|
|
+ >
|
|
|
+ <el-table-column prop="accountId" label="账号ID" />
|
|
|
+ <el-table-column label="创建时间" width="170">
|
|
|
+ <template #default="{ row }">
|
|
|
+ {{ formatDate(row.createTime) }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" width="80" fixed="right">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <el-button
|
|
|
+ type="danger"
|
|
|
+ size="small"
|
|
|
+ link
|
|
|
+ @click="handleDelConf(row)"
|
|
|
+ >
|
|
|
+ <el-icon><Delete /></el-icon>
|
|
|
+ 删除
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="syncAccountDialogVisible = false">关闭</el-button>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
<!-- 短剧资产详情对话框 -->
|
|
|
<el-dialog
|
|
|
v-model="detailDialogVisible"
|
|
|
@@ -179,15 +247,16 @@
|
|
|
<script setup>
|
|
|
import { ref, computed, onMounted } from 'vue'
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
-import { getDramaList, syncDrama } from '@/api/drama'
|
|
|
-import { getAuthList } from '@/api/auth'
|
|
|
+import { getDramaList, syncDrama, myConfList, addConf, delConf } from '@/api/drama'
|
|
|
|
|
|
import {
|
|
|
Refresh,
|
|
|
VideoPlay,
|
|
|
Document,
|
|
|
Files,
|
|
|
- View
|
|
|
+ View,
|
|
|
+ Delete,
|
|
|
+ Search
|
|
|
} from '@element-plus/icons-vue'
|
|
|
|
|
|
// 数据
|
|
|
@@ -197,11 +266,25 @@ const dramaList = ref([])
|
|
|
const detailDialogVisible = ref(false)
|
|
|
const currentDrama = ref(null)
|
|
|
|
|
|
+// 同步账号管理 Dialog
|
|
|
+const syncAccountDialogVisible = ref(false)
|
|
|
+const confListLoading = ref(false)
|
|
|
+const addingConf = ref(false)
|
|
|
+const confFormRef = ref(null)
|
|
|
+const confForm = ref({ accountId: '' })
|
|
|
+const confFormRules = {
|
|
|
+ accountId: [
|
|
|
+ { required: true, message: '请输入账号ID', trigger: 'blur' },
|
|
|
+ { pattern: /^\d+$/, message: '账号ID必须为纯数字', trigger: 'blur' }
|
|
|
+ ]
|
|
|
+}
|
|
|
+
|
|
|
// 同步参数
|
|
|
-const orgAccountId = ref('')
|
|
|
const phone = ref('')
|
|
|
const accountId = ref('')
|
|
|
-const orgAccounts = ref([])
|
|
|
+const confList = ref([])
|
|
|
+
|
|
|
+const queryForm = ref({ dramaName: '' })
|
|
|
|
|
|
// 分页数据
|
|
|
const currentPage = ref(1)
|
|
|
@@ -213,11 +296,23 @@ const totalPages = computed(() => {
|
|
|
return Math.ceil(total.value / pageSize.value)
|
|
|
})
|
|
|
|
|
|
+const handleSearch = () => {
|
|
|
+ currentPage.value = 1
|
|
|
+ loadDramaList()
|
|
|
+}
|
|
|
+
|
|
|
+const handleReset = () => {
|
|
|
+ queryForm.value = { dramaName: '' }
|
|
|
+ currentPage.value = 1
|
|
|
+ loadDramaList()
|
|
|
+}
|
|
|
+
|
|
|
// 方法
|
|
|
const loadDramaList = async () => {
|
|
|
loading.value = true
|
|
|
try {
|
|
|
- const res = await getDramaList(currentPage.value, pageSize.value)
|
|
|
+ const { dramaName } = queryForm.value
|
|
|
+ const res = await getDramaList(currentPage.value, pageSize.value, dramaName)
|
|
|
if (res.success) {
|
|
|
dramaList.value = res.data || []
|
|
|
total.value = res.total || 0
|
|
|
@@ -245,7 +340,7 @@ const handleCurrentChange = async (newPage) => {
|
|
|
}
|
|
|
|
|
|
const handleSync = async () => {
|
|
|
- if (!orgAccountId.value || !accountId.value) {
|
|
|
+ if (!accountId.value) {
|
|
|
ElMessage.warning('请填写所有同步参数')
|
|
|
return
|
|
|
}
|
|
|
@@ -262,7 +357,7 @@ const handleSync = async () => {
|
|
|
)
|
|
|
|
|
|
syncing.value = true
|
|
|
- const res = await syncDrama(orgAccountId.value, accountId.value)
|
|
|
+ const res = await syncDrama(accountId.value)
|
|
|
|
|
|
if (res.success) {
|
|
|
ElMessage.success(res.message || '同步成功')
|
|
|
@@ -306,23 +401,83 @@ const formatJSON = (jsonStr) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-const loadAuthList = async () => {
|
|
|
+const loadConfList = async () => {
|
|
|
+ confListLoading.value = true
|
|
|
try {
|
|
|
- const response = await getAuthList()
|
|
|
+ const response = await myConfList()
|
|
|
if (response.success) {
|
|
|
- orgAccounts.value = response.data || []
|
|
|
+ confList.value = response.data || []
|
|
|
} else {
|
|
|
ElMessage.error(response.message || '加载授权列表失败')
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error('加载授权列表失败:', error)
|
|
|
ElMessage.error('加载授权列表失败')
|
|
|
+ } finally {
|
|
|
+ confListLoading.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const showSyncAccountDialog = () => {
|
|
|
+ syncAccountDialogVisible.value = true
|
|
|
+}
|
|
|
+
|
|
|
+const resetConfForm = () => {
|
|
|
+ confForm.value = { accountId: '' }
|
|
|
+ confFormRef.value?.clearValidate()
|
|
|
+}
|
|
|
+
|
|
|
+const handleAddConf = async () => {
|
|
|
+ await confFormRef.value?.validate(async (valid) => {
|
|
|
+ if (!valid) return
|
|
|
+ addingConf.value = true
|
|
|
+ try {
|
|
|
+ const res = await addConf({ accountId: confForm.value.accountId })
|
|
|
+ if (res.success) {
|
|
|
+ ElMessage.success('新增成功')
|
|
|
+ resetConfForm()
|
|
|
+ await loadConfList()
|
|
|
+ } else {
|
|
|
+ ElMessage.error(res.message || '新增失败')
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('新增同步账号失败:', error)
|
|
|
+ ElMessage.error('新增失败')
|
|
|
+ } finally {
|
|
|
+ addingConf.value = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const handleDelConf = async (row) => {
|
|
|
+ try {
|
|
|
+ await ElMessageBox.confirm(
|
|
|
+ `确定要删除账号 ${row.accountId} 的同步配置吗?`,
|
|
|
+ '确认删除',
|
|
|
+ {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }
|
|
|
+ )
|
|
|
+ const res = await delConf(row.id)
|
|
|
+ if (res.success) {
|
|
|
+ ElMessage.success('删除成功')
|
|
|
+ await loadConfList()
|
|
|
+ } else {
|
|
|
+ ElMessage.error(res.message || '删除失败')
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ if (error !== 'cancel') {
|
|
|
+ console.error('删除同步账号失败:', error)
|
|
|
+ ElMessage.error('删除失败')
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 生命周期
|
|
|
onMounted(async () => {
|
|
|
- await loadAuthList()
|
|
|
+ await loadConfList()
|
|
|
loadDramaList()
|
|
|
})
|
|
|
</script>
|