edit user.

This commit is contained in:
2023-03-20 13:53:18 +08:00
parent 0fa885d892
commit efbc21ba18
9 changed files with 181 additions and 20 deletions

View File

@@ -1,15 +1,46 @@
<script lang="ts" setup>
import { editUser } from "~/admin/api"
import { User } from "~/utils/types"
interface Props {
user: User
}
const props = defineProps<Props>()
const emit = defineEmits<{
(e: "deleteUser", value: number[]): void
(e: "userBanned", value: User): void
(e: "openEditModal", value: User): void
}>()
async function banUser() {
props.user.is_disabled = !props.user.is_disabled
await editUser(props.user)
emit("userBanned", props.user)
}
</script>
<template>
<n-space align="center">
<n-button size="small" secondary type="primary">编辑</n-button>
<n-button size="small" secondary type="error">封号</n-button>
<n-button size="small" secondary type="default">删除</n-button>
<n-button
size="small"
type="primary"
secondary
@click="$emit('openEditModal', props.user)"
>
编辑
</n-button>
<n-button
size="small"
secondary
:type="props.user.is_disabled ? 'info' : 'error'"
@click="banUser"
>
{{ props.user.is_disabled ? "解封" : "封号" }}
</n-button>
<n-popconfirm @positive-click="$emit('deleteUser', [props.user.id])">
<template #trigger>
<n-button size="small" secondary type="warning">删除</n-button>
</template>
确定删除这个用户吗删除后无法恢复
</n-popconfirm>
</n-space>
</template>