Commit ddd495fb authored by erio's avatar erio
Browse files

feat(ui): 渠道列表状态列改为 Toggle 开关,支持直接启用/禁用

parent 58f20446
...@@ -57,17 +57,11 @@ ...@@ -57,17 +57,11 @@
<span class="text-sm text-gray-600 dark:text-gray-400">{{ value || '-' }}</span> <span class="text-sm text-gray-600 dark:text-gray-400">{{ value || '-' }}</span>
</template> </template>
<template #cell-status="{ value }"> <template #cell-status="{ row }">
<span <Toggle
:class="[ :modelValue="row.status === 'active'"
'inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium', @update:modelValue="toggleChannelStatus(row)"
value === 'active' />
? 'bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400'
: 'bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400'
]"
>
{{ value === 'active' ? t('admin.channels.statusActive', 'Active') : t('admin.channels.statusDisabled', 'Disabled') }}
</span>
</template> </template>
<template #cell-group_count="{ row }"> <template #cell-group_count="{ row }">
...@@ -434,6 +428,7 @@ import EmptyState from '@/components/common/EmptyState.vue' ...@@ -434,6 +428,7 @@ import EmptyState from '@/components/common/EmptyState.vue'
import Select from '@/components/common/Select.vue' import Select from '@/components/common/Select.vue'
import Icon from '@/components/icons/Icon.vue' import Icon from '@/components/icons/Icon.vue'
import PlatformIcon from '@/components/common/PlatformIcon.vue' import PlatformIcon from '@/components/common/PlatformIcon.vue'
import Toggle from '@/components/common/Toggle.vue'
import PricingEntryCard from '@/components/admin/channel/PricingEntryCard.vue' import PricingEntryCard from '@/components/admin/channel/PricingEntryCard.vue'
import { getPersistedPageSize } from '@/composables/usePersistedPageSize' import { getPersistedPageSize } from '@/composables/usePersistedPageSize'
...@@ -950,6 +945,18 @@ async function handleSubmit() { ...@@ -950,6 +945,18 @@ async function handleSubmit() {
} }
} }
// ── Toggle status ──
async function toggleChannelStatus(channel: Channel) {
const newStatus = channel.status === 'active' ? 'disabled' : 'active'
try {
await adminAPI.channels.update(channel.id, { status: newStatus })
channel.status = newStatus
} catch (error) {
appStore.showError(t('admin.channels.updateError', 'Failed to update channel'))
console.error('Error toggling channel status:', error)
}
}
// ── Delete ── // ── Delete ──
function handleDelete(channel: Channel) { function handleDelete(channel: Channel) {
deletingChannel.value = channel deletingChannel.value = channel
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment