You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OneAuth/ui/page/app/user.html

144 lines
3.4 KiB
HTML

7 months ago
<!doctype html>
<html>
<head>
<title>用户管理</title>
</head>
<style>
body {
padding: 20px;
}
.header {
font-size: 24px;
line-height: 1.5;
margin-bottom: 20px;
font-weight: 600;
}
.dialog {
height: 60vh;
width: 60vw;
background-color: #fff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
padding: 2rem;
border-radius: 0.5rem;
}
</style>
<body>
<c-app-menu slot="menu"></c-app-menu>
<div class="header">应用用户管理</div>
7 months ago
<v-table :data="rows" :keys="keys" :api='user_api'>
7 months ago
<v-btn slot='_addon' size='sm' @click='show_user(row)' color='#2c9'>权限表</v-btn>
</v-table>
<v-dialog v:show='show'>
<div class="dialog">
<div class="text-2xl">{{selected.username}} 角色表</div>
<v-table :onerr="onerr" :keys="au_keys" :data="user_role_data"></v-table>
</div>
</v-dialog>
</body>
<script setup>
show = false
const params = new URLSearchParams(window.location.search)
id = params.get('id')
auOpts = {
0: ['正常', 'positive'],
1: ['拒绝', 'warning'],
2: ['申请中', 'primary'],
3: ['禁用', 'warning'],
}
7 months ago
user_api = ($env.root || '') + '/api/user'
7 months ago
keys = [
{
name: 'id',
label: 'ID',
style: '',
},
{
name: 'username',
label: '用户名',
style: 'text-align: left',
sortable: true
},
{
name: 'nickname',
label: '昵称',
style: 'text-align: left',
7 months ago
editable: true,
7 months ago
sortable: true
},
{name: 'created_at', label: '创建时间', field: (r) => new Date(r.created_at).toLocaleString()},
{name: 'updated_at', label: '更新时间', field: (r) => new Date(r.updated_at).toLocaleString()},
{name: 'status', label: '账号状态', sortable: true},
]
au_keys = [
{name: 'id', label: 'ID', no_create: true},
{name: 'username', required: true, label: '用户名'},
{name: 'created_at', label: '创建时间', no_create: true, field: (r) => new Date(r.created_at).toLocaleString()},
{name: 'updated_at', label: '更新时间', no_create: true, field: (r) => new Date(r.updated_at).toLocaleString()},
{name: 'status', label: '账号状态', sortable: true},
]
rows = []
user_role_data = []
selected = {}
show_user = async (row) => {
selected = row
console.log(row)
7 months ago
user_role_url = ($env.root || '') + `/api/user/${Guser.uid}/user_role`
7 months ago
// accessData = await access_api.next(0, 10)
user_role_data = await user_role_api.next(0, 10)
show = true
}
user_role_api = {
next: async (page, size) => {
return await $api.Get(user_role_url, {query: {page, size}})
7 months ago
}
}
reset = (id) => {
$q.dialog({
title: '是否重置密码',
message: '请谨慎操作',
cancel: true,
persistent: true
}).onOk(() => {
$api.user.reset(id).then(() => {
7 months ago
msg.Info('重置成功 ')
}).catch((e) => {
msg.Warn('失败 ' + e)
})
})
}
app = {}
sync = () => {
const params = new URLSearchParams(window.location.search)
id = params.get('id')
if (!id) {
history.back()
return
}
$api.Get(`/api/app/${id}`)
7 months ago
.then((data) => {
Object.assign(app, data)
document.title = `${app.name} - 项目主页`
$api.Get(`/api/user/`).then((e) => {
7 months ago
rows = e
console.log(e)
})
})
.catch((e) => {
console.log(e)
history.back()
})
}
sync()
</script>
</html>