fix: 站点/审核编辑改回单文本框多行输入,后端保留数组支持
This commit is contained in:
@@ -33,11 +33,15 @@
|
||||
</el-card>
|
||||
|
||||
<!-- 审核编辑弹窗 -->
|
||||
<el-dialog v-model="approveVisible" title="审核通过 - 编辑站点信息" width="520px" :close-on-click-modal="false">
|
||||
<el-form :model="approveForm" label-width="80px">
|
||||
<el-dialog v-model="approveVisible" title="审核通过 - 编辑站点信息" width="500px" :close-on-click-modal="false">
|
||||
<el-form label-width="80px">
|
||||
<el-form-item label="站点ID"><el-input v-model="approveForm.siteId" disabled /></el-form-item>
|
||||
<el-form-item label="名称"><el-input v-model="approveForm.name" type="textarea" :rows="3" /></el-form-item>
|
||||
<el-form-item label="地址"><el-input v-model="approveForm.baseUrl" type="textarea" :rows="3" /></el-form-item>
|
||||
<el-form-item label="名称">
|
||||
<el-input v-model="approveForm.namesText" type="textarea" :rows="3" placeholder="站点名称(一行一个)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="地址">
|
||||
<el-input v-model="approveForm.urlsText" type="textarea" :rows="3" placeholder="站点地址(一行一个)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="类型">
|
||||
<el-select v-model="approveForm.siteType" style="width:100%">
|
||||
<el-option v-for="t in siteTypes" :key="t.value" :label="t.label" :value="t.value" />
|
||||
@@ -74,7 +78,7 @@ import api from '../api'
|
||||
|
||||
const submissions = ref([])
|
||||
const approveVisible = ref(false), saving = ref(false)
|
||||
const approveForm = reactive({ id: null, siteId: '', name: '', baseUrl: '', siteType: '', status: 'active', notes: '' })
|
||||
const approveForm = reactive({ id: null, siteId: '', namesText: '', urlsText: '', siteType: '', status: 'active', notes: '' })
|
||||
const siteTypes = [
|
||||
{ value: 'nexusphp', label: 'NexusPHP' }, { value: 'mtorrent', label: 'MTorrent' },
|
||||
{ value: 'mteam', label: 'M-Team API' }, { value: 'pttime', label: 'PTTime' },
|
||||
@@ -92,8 +96,8 @@ const fetch = async () => {
|
||||
const handleApprove = (row) => {
|
||||
approveForm.id = row.id
|
||||
approveForm.siteId = row.siteId
|
||||
approveForm.name = (row.names || []).join('\n')
|
||||
approveForm.baseUrl = (row.urls || []).join('\n')
|
||||
approveForm.namesText = (row.names || []).join('\n')
|
||||
approveForm.urlsText = (row.urls || []).join('\n')
|
||||
approveForm.siteType = row.siteType || 'unknown'
|
||||
approveForm.status = row.siteStatus === '关停' ? 'deprecated' : 'active'
|
||||
approveForm.notes = row.notes || ''
|
||||
@@ -101,12 +105,13 @@ const handleApprove = (row) => {
|
||||
}
|
||||
|
||||
const confirmApprove = async () => {
|
||||
if (!approveForm.name.trim() || !approveForm.baseUrl.trim()) { ElMessage.warning('名称和地址不能为空'); return }
|
||||
const name = approveForm.namesText.split('\n').map(s => s.trim()).filter(Boolean)[0] || ''
|
||||
const baseUrl = approveForm.urlsText.split('\n').map(s => s.trim()).filter(Boolean)[0] || ''
|
||||
if (!name || !baseUrl) { ElMessage.warning('名称和地址不能为空'); return }
|
||||
saving.value = true
|
||||
try {
|
||||
await api.sites.approveChange(approveForm.id, {
|
||||
name: approveForm.name.trim().split('\n').filter(Boolean)[0] || '',
|
||||
baseUrl: approveForm.baseUrl.trim().split('\n').filter(Boolean)[0] || '',
|
||||
name, baseUrl,
|
||||
siteType: approveForm.siteType || 'unknown',
|
||||
status: approveForm.status,
|
||||
notes: approveForm.notes || null,
|
||||
|
||||
@@ -33,24 +33,16 @@
|
||||
</el-card>
|
||||
|
||||
<!-- 编辑对话框 -->
|
||||
<el-dialog v-model="editVisible" title="编辑站点" width="560px" :close-on-click-modal="false">
|
||||
<el-dialog v-model="editVisible" title="编辑站点" width="500px" :close-on-click-modal="false">
|
||||
<el-form label-width="80px">
|
||||
<el-form-item label="站点ID">
|
||||
<el-input v-model="editForm.siteId" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="名称">
|
||||
<div v-for="(n, i) in editForm.names" :key="i" style="display:flex;gap:6px;margin-bottom:4px">
|
||||
<el-input v-model="editForm.names[i]" placeholder="站点名称" />
|
||||
<el-button @click="editForm.names.splice(i,1)" :disabled="editForm.names.length===1" size="small">删</el-button>
|
||||
</div>
|
||||
<el-button size="small" @click="editForm.names.push('')" style="margin-top:4px">+ 添加名称</el-button>
|
||||
<el-input v-model="editForm.namesText" type="textarea" :rows="3" placeholder="站点名称(一行一个)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="地址">
|
||||
<div v-for="(u, i) in editForm.urls" :key="i" style="display:flex;gap:6px;margin-bottom:4px">
|
||||
<el-input v-model="editForm.urls[i]" placeholder="站点地址" />
|
||||
<el-button @click="editForm.urls.splice(i,1)" :disabled="editForm.urls.length===1" size="small">删</el-button>
|
||||
</div>
|
||||
<el-button size="small" @click="editForm.urls.push('')" style="margin-top:4px">+ 添加地址</el-button>
|
||||
<el-input v-model="editForm.urlsText" type="textarea" :rows="3" placeholder="站点地址(一行一个)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="类型">
|
||||
<el-select v-model="editForm.siteType" placeholder="选择类型" style="width:100%">
|
||||
@@ -130,7 +122,7 @@ import api from '../api'
|
||||
const sites = ref([])
|
||||
const loading = ref(false)
|
||||
const editVisible = ref(false), saving = ref(false)
|
||||
const editForm = reactive({ id: null, siteId: '', names: [''], urls: [''], siteType: '', status: '', description: '' })
|
||||
const editForm = reactive({ id: null, siteId: '', namesText: '', urlsText: '', siteType: '', status: '', description: '' })
|
||||
const siteTypes = [
|
||||
{ value: 'nexusphp', label: 'NexusPHP' }, { value: 'mtorrent', label: 'MTorrent' },
|
||||
{ value: 'mteam', label: 'M-Team API' }, { value: 'pttime', label: 'PTTime' },
|
||||
@@ -156,8 +148,8 @@ const fetchAll = async () => {
|
||||
const handleEdit = (row) => {
|
||||
editForm.id = row.id
|
||||
editForm.siteId = row.siteId
|
||||
editForm.names = (row.names && row.names.length) ? [...row.names] : ['']
|
||||
editForm.urls = (row.urls && row.urls.length) ? [...row.urls] : ['']
|
||||
editForm.namesText = (row.names || []).join('\n')
|
||||
editForm.urlsText = (row.urls || []).join('\n')
|
||||
editForm.siteType = row.siteType || ''
|
||||
editForm.status = row.status || 'active'
|
||||
editForm.description = row.description || ''
|
||||
@@ -165,8 +157,8 @@ const handleEdit = (row) => {
|
||||
}
|
||||
|
||||
const handleSave = async () => {
|
||||
const names = editForm.names.filter(n => n.trim())
|
||||
const urls = editForm.urls.filter(u => u.trim())
|
||||
const names = editForm.namesText.split('\n').map(s => s.trim()).filter(Boolean)
|
||||
const urls = editForm.urlsText.split('\n').map(s => s.trim()).filter(Boolean)
|
||||
if (names.length === 0 || urls.length === 0) { ElMessage.warning('名称和地址不能为空'); return }
|
||||
saving.value = true
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user