Files
ojnext/src/admin/user/components/Actions.vue
2025-08-30 14:57:20 +08:00

56 lines
1.3 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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
(e: "resetPassword", 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-flex>
<n-button
size="small"
type="error"
secondary
@click="$emit('resetPassword', props.user)"
>
重置密码
</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-flex>
</template>