Files
OJ2/apps/web/src/admin/user/components/Actions.vue
T
xuyue d25b5dbe6d
Deploy / deploy (push) Canceled after 0s
update
2026-09-27 19:36:28 +08:00

46 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 type { AdminUserForm } from "utils/types"
interface Props {
user: AdminUserForm
}
const props = defineProps<Props>()
const emit = defineEmits<{
(e: "deleteUser", value: number[]): void
(e: "userBanned", value: AdminUserForm): void
(e: "openEditModal", value: AdminUserForm): void
(e: "resetPassword", value: AdminUserForm): void
}>()
async function banUser() {
props.user.isDisabled = !props.user.isDisabled
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.isDisabled ? 'info' : 'error'"
@click="banUser"
>
{{ props.user.isDisabled ? "解封" : "封号" }}
</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>