admin_new P0+P1 全批次合并 (84 commits) #2
@ -118,9 +118,9 @@ async function load() {
|
||||
raw: it
|
||||
}))
|
||||
total.value = Number(resp.total || 0)
|
||||
// 统计 (在当前搜索结果中)
|
||||
enabledStats.normal = list.value.filter(u => u.enabled === 1).length
|
||||
enabledStats.disabled = list.value.filter(u => u.enabled === 0).length
|
||||
// 统计 (后端 enabled 语义: 0=正常 1=禁用)
|
||||
enabledStats.normal = list.value.filter(u => u.enabled === 0).length
|
||||
enabledStats.disabled = list.value.filter(u => u.enabled === 1).length
|
||||
} else {
|
||||
list.value = []
|
||||
total.value = 0
|
||||
@ -141,9 +141,10 @@ const tabItems = computed(() => [
|
||||
])
|
||||
|
||||
function onTabChange(key: string) {
|
||||
// 后端 enabled 语义: 0=正常 1=禁用
|
||||
if (key === 'all') query.enabled = ''
|
||||
else if (key === 'normal') query.enabled = '1'
|
||||
else if (key === 'disabled') query.enabled = '0'
|
||||
else if (key === 'normal') query.enabled = '0'
|
||||
else if (key === 'disabled') query.enabled = '1'
|
||||
query.page = 1
|
||||
load()
|
||||
}
|
||||
@ -164,8 +165,9 @@ function onEdit(row: FrontUser) {
|
||||
}
|
||||
|
||||
async function toggleEnabled(row: FrontUser) {
|
||||
const next = row.enabled === 1 ? 0 : 1
|
||||
const action = next === 1 ? '启用' : '禁用'
|
||||
// 当前 enabled: 0=正常 1=禁用; 要切换到对端
|
||||
const next = row.enabled === 0 ? 1 : 0
|
||||
const action = next === 1 ? '禁用' : '启用'
|
||||
try {
|
||||
await ElMessageBox.confirm(`确认${action}用户「${row.nickName}」?`, `${action}确认`, { type: 'warning' })
|
||||
} catch { return }
|
||||
@ -236,15 +238,15 @@ onMounted(load)
|
||||
@limit-change="onLimitChange"
|
||||
>
|
||||
<template #enabled="{ row }">
|
||||
<el-tag v-if="row.enabled === 1" type="success" size="small" effect="light" round>正常</el-tag>
|
||||
<el-tag v-if="row.enabled === 0" type="success" size="small" effect="light" round>正常</el-tag>
|
||||
<el-tag v-else type="danger" size="small" effect="light" round>禁用</el-tag>
|
||||
</template>
|
||||
<template #action="{ row }">
|
||||
<span class="rr-actions">
|
||||
<el-link type="primary" :underline="false" @click="onEdit(row)">修改</el-link>
|
||||
<span class="rr-actions__sep">|</span>
|
||||
<el-link :type="row.enabled === 1 ? 'warning' : 'success'" :underline="false" @click="toggleEnabled(row)">
|
||||
{{ row.enabled === 1 ? '禁用' : '启用' }}
|
||||
<el-link :type="row.enabled === 0 ? 'warning' : 'success'" :underline="false" @click="toggleEnabled(row)">
|
||||
{{ row.enabled === 0 ? '禁用' : '启用' }}
|
||||
</el-link>
|
||||
<span class="rr-actions__sep">|</span>
|
||||
<el-link type="danger" :underline="false" @click="deleteUser(row)">删除</el-link>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user