feat(后台用户): 用户列表按班级看、「重置密码」常驻;批量建号粘进名单当场列出会建成的账号,重名和已有的先点出来,建好能下载名单、打印账号条
用户列表去掉 ID、真名、占位邮箱和四颗彩色按钮。下载的名单开头带 BOM,Excel 打开中文不再乱码。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ba823ecb7d
commit
5561e0bc3a
5 files changed
+607
-158
No files matched your search
@@ -1,7 +1,13 @@
|
||||
<script lang="ts" setup>
|
||||
import { Icon } from "@iconify/vue"
|
||||
import { editUser } from "admin/api"
|
||||
import type { AdminUserForm } from "utils/types"
|
||||
|
||||
/**
|
||||
* 用户列表一行的操作(设计稿「后台用户与批量建号」UsList):最常用的「重置密码」常驻
|
||||
* (学生忘了密码是后台进得最多的一件事),其余收进 ⋯。原来四颗彩色按钮并排,
|
||||
* 1366 的屏上把「上次登录」挤成了半截
|
||||
*/
|
||||
interface Props {
|
||||
user: AdminUserForm
|
||||
}
|
||||
@@ -13,33 +19,42 @@ const emit = defineEmits<{
|
||||
(e: "resetPassword", value: AdminUserForm): void
|
||||
}>()
|
||||
|
||||
const dialog = useDialog()
|
||||
|
||||
async function banUser() {
|
||||
props.user.isDisabled = !props.user.isDisabled
|
||||
await editUser(props.user)
|
||||
emit("userBanned", props.user)
|
||||
}
|
||||
|
||||
const menuOptions = computed<DropdownOption[]>(() => [
|
||||
{ label: "编辑", key: "edit" },
|
||||
{ label: props.user.isDisabled ? "解除禁用" : "禁用", key: "ban" },
|
||||
{ type: "divider", key: "divider" },
|
||||
{ label: "删除", key: "delete" },
|
||||
])
|
||||
|
||||
function onMenu(key: string) {
|
||||
if (key === "edit") emit("openEditModal", props.user)
|
||||
else if (key === "ban") banUser()
|
||||
else if (key === "delete") {
|
||||
dialog.warning({
|
||||
title: `删除 ${props.user.username}?`,
|
||||
content: "删掉就找不回来了。交过题的账号删不掉,那种请改为禁用。",
|
||||
positiveText: "删除",
|
||||
negativeText: "不删",
|
||||
onPositiveClick: () => emit("deleteUser", [props.user.id]),
|
||||
})
|
||||
}
|
||||
}
|
||||
</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 :size="4" justify="end" :wrap="false">
|
||||
<n-button size="small" @click="emit('resetPassword', props.user)">重置密码</n-button>
|
||||
<n-dropdown trigger="click" placement="bottom-end" :options="menuOptions" @select="onMenu">
|
||||
<n-button size="small" quaternary aria-label="更多">
|
||||
<template #icon><Icon icon="ph:dots-three-bold" /></template>
|
||||
</n-button>
|
||||
</n-dropdown>
|
||||
</n-flex>
|
||||
</template>
|
||||
Reference in new issue
Block a user