feat: 新增 site_submissions 审核表, 提交先进审核再写入sites

This commit is contained in:
mediabot-pt
2026-06-30 08:57:10 +08:00
parent aa1e3e9b28
commit 657e0c1a78
10 changed files with 292 additions and 91 deletions

View File

@@ -1,8 +1,48 @@
<template>
<div>
<h2>站点管理</h2>
<!-- 审核中的提交 -->
<el-card style="margin-top: 20px" v-if="submissions.length > 0">
<template #header><span style="font-weight:bold">待审核</span></template>
<el-table :data="submissions" stripe size="small">
<el-table-column prop="siteId" label="站点ID" width="120" />
<el-table-column label="名称" width="180">
<template #default="scope">
<div v-for="(n, i) in scope.row.names" :key="i" class="text-xs">{{ n }}</div>
</template>
</el-table-column>
<el-table-column label="地址" min-width="200">
<template #default="scope">
<div v-for="(u, i) in scope.row.urls" :key="i" class="text-xs">{{ u }}</div>
</template>
</el-table-column>
<el-table-column label="站点状态" width="90">
<template #default="scope">
<el-tag size="small" :type="scope.row.siteStatus === '正常' ? 'success' : scope.row.siteStatus === '关停' ? 'danger' : 'warning'">
{{ scope.row.siteStatus }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="备注" min-width="120">
<template #default="scope">
<span class="text-xs text-muted">{{ scope.row.notes || '-' }}</span>
</template>
</el-table-column>
<el-table-column prop="createdAt" label="提交时间" width="160" />
<el-table-column label="操作" width="150">
<template #default="scope">
<el-button size="small" type="success" @click="handleApprove(scope.row)">通过</el-button>
<el-button size="small" type="danger" @click="handleReject(scope.row)">拒绝</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
<!-- 已审核站点 -->
<el-card style="margin-top: 20px">
<el-table :data="sites" v-loading="loading" stripe>
<template #header><span style="font-weight:bold">已审核站点</span></template>
<el-table :data="sites" v-loading="loading" stripe size="small">
<el-table-column prop="siteId" label="站点ID" width="120" />
<el-table-column label="名称" width="180">
<template #default="scope">
@@ -17,20 +57,15 @@
<el-table-column prop="siteType" label="类型" width="100" />
<el-table-column prop="status" label="状态" width="100">
<template #default="scope">
<el-tag :type="statusType(scope.row.status)">
<el-tag size="small" :type="scope.row.status === 'active' ? 'success' : 'info'">
{{ scope.row.status }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="schemaVersion" label="Schema版本" width="120" />
<el-table-column label="操作" width="280">
<el-table-column label="操作" width="150">
<template #default="scope">
<el-button size="small" @click="handleEdit(scope.row)">编辑</el-button>
<el-button size="small" @click="handleViewConfig(scope.row)">配置</el-button>
<template v-if="scope.row.status === 'pending'">
<el-button size="small" type="success" @click="handleApprove(scope.row)">通过</el-button>
<el-button size="small" type="danger" @click="handleReject(scope.row)">拒绝</el-button>
</template>
</template>
</el-table-column>
</el-table>
@@ -80,6 +115,7 @@
import api from '../api'
const sites = ref([])
const submissions = ref([])
const loading = ref(false)
const editVisible = ref(false)
const saving = ref(false)
@@ -157,19 +193,17 @@ const escapeHtml = (str) => {
return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
}
const statusType = (s) => {
if (s === 'active') return 'success'
if (s === 'pending') return 'warning'
return 'info'
}
const fetchSites = async () => {
const fetchAll = async () => {
loading.value = true
try {
const res = await api.sites.adminList()
sites.value = res.data || []
const [siteRes, subRes] = await Promise.all([
api.sites.adminList(),
api.sites.pendingSubmissions(),
])
sites.value = siteRes.data || []
submissions.value = subRes.data || []
} catch (e) {
ElMessage.error('获取站点列表失败')
ElMessage.error('获取数据失败')
} finally {
loading.value = false
}
@@ -177,9 +211,9 @@ const fetchSites = async () => {
const handleApprove = async (row) => {
try {
await api.sites.approve(row.id)
await api.sites.approveSubmission(row.id)
ElMessage.success('已通过')
fetchSites()
fetchAll()
} catch (e) {
ElMessage.error(e.response?.data?.message || '操作失败')
}
@@ -187,10 +221,11 @@ const handleApprove = async (row) => {
const handleReject = async (row) => {
try {
await ElMessageBox.confirm(`确认拒绝站点 "${row.name}"?此操作将删除该站点。`, '警告', { type: 'warning' })
await api.sites.reject(row.id)
const name = (row.names || [])[0] || row.siteId
await ElMessageBox.confirm(`确认拒绝 "${name}" 的提交?`, '警告', { type: 'warning' })
await api.sites.rejectSubmission(row.id)
ElMessage.success('已拒绝')
fetchSites()
fetchAll()
} catch (e) {
if (e !== 'cancel') ElMessage.error(e.response?.data?.message || '操作失败')
}
@@ -223,7 +258,7 @@ const handleSave = async () => {
})
ElMessage.success('保存成功')
editVisible.value = false
fetchSites()
fetchAll()
} catch (e) {
ElMessage.error(e.response?.data?.message || '保存失败')
} finally {
@@ -231,7 +266,7 @@ const handleSave = async () => {
}
}
onMounted(fetchSites)
onMounted(fetchAll)
</script>
<style scoped>