文件还在测试中
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/** @var array $user @var string $sys @var string $sysName @var array $pages @var bool $edit */
|
||||
$labelMap = [];
|
||||
foreach (\subsys_nav($sys) as $it) { $labelMap[$it['k']] = $it['label']; }
|
||||
$raw = $user[$sys . '_perms'] ?? '';
|
||||
$dec = is_string($raw) && $raw !== '' ? @json_decode($raw, true) : [];
|
||||
$cur = is_array($dec) ? array_keys(array_filter($dec)) : [];
|
||||
$roleKey = $sys . '_role';
|
||||
$role = $user[$roleKey] ?? 'user';
|
||||
$upper = strtoupper($sys);
|
||||
?>
|
||||
<div class="page-head">
|
||||
<h1><?php echo $edit ? '编辑用户' : '新增用户'; ?></h1>
|
||||
<p class="sub"><?php echo e($sysName); ?></p>
|
||||
</div>
|
||||
|
||||
<?php echo flash_html(); ?>
|
||||
|
||||
<div class="panel form-card">
|
||||
<form method="post" action="<?php echo site_url($upper . '/users/' . ($edit ? 'update/' . $user['id'] : 'store')); ?>">
|
||||
<?php echo csrf_field(); ?>
|
||||
<div class="form-row">
|
||||
<label>用户名 <span class="req">*</span></label>
|
||||
<input type="text" name="username" value="<?php echo e($user['username'] ?? ''); ?>" <?php echo $edit ? 'readonly' : ''; ?> required>
|
||||
<?php if ($edit): ?><small class="muted">用户名不可修改</small><?php endif; ?>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>姓名</label>
|
||||
<input type="text" name="name" value="<?php echo e($user['name'] ?? ''); ?>">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>角色</label>
|
||||
<div class="radio-row">
|
||||
<label class="radio"><input type="radio" name="<?php echo e($roleKey); ?>" value="user" <?php echo $role !== 'admin' ? 'checked' : ''; ?>> 普通用户</label>
|
||||
<label class="radio"><input type="radio" name="<?php echo e($roleKey); ?>" value="admin" <?php echo $role === 'admin' ? 'checked' : ''; ?>> 管理员(可管理本系统用户与权限)</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>页面权限</label>
|
||||
<div class="perm-grid">
|
||||
<?php foreach ($pages as $p): ?>
|
||||
<?php if ($p === 'dashboard') continue; ?>
|
||||
<label class="check"><input type="checkbox" name="perm_<?php echo e($p); ?>" value="1" <?php echo in_array($p, $cur, true) ? 'checked' : ''; ?>> <?php echo e($labelMap[$p] ?? $p); ?></label>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<small class="muted">仪表盘对所有用户默认可见;未勾选的页面该用户不可访问(侧栏隐藏且不可直访)。</small>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>密码 <?php if (!$edit): ?><span class="req">*</span><?php endif; ?></label>
|
||||
<input type="password" name="password" autocomplete="new-password" <?php echo $edit ? '' : 'required'; ?>>
|
||||
<small class="muted"><?php echo $edit ? '留空则保持原密码' : '请设置登录密码(至少 6 位)'; ?></small>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>状态</label>
|
||||
<div class="radio-row">
|
||||
<label class="radio"><input type="radio" name="status" value="1" <?php echo (!empty($user['status'])) ? 'checked' : ''; ?>> 启用</label>
|
||||
<label class="radio"><input type="radio" name="status" value="0" <?php echo (empty($user['status'])) ? 'checked' : ''; ?>> 停用</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn"><?php echo $edit ? '保存修改' : '创建用户'; ?></button>
|
||||
<a class="btn-soft" href="<?php echo site_url($upper . '/users'); ?>">取消</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/** @var array $user @var string $sys @var string $sysName */
|
||||
$upper = strtoupper($sys);
|
||||
?>
|
||||
<div class="page-head">
|
||||
<h1>重置密码</h1>
|
||||
<p class="sub"><?php echo e($sysName); ?> · 为用户 <b><?php echo e($user['username']); ?></b> 设置新密码</p>
|
||||
</div>
|
||||
|
||||
<?php echo flash_html(); ?>
|
||||
|
||||
<div class="panel form-card">
|
||||
<form method="post" action="<?php echo site_url($upper . '/users/reset/' . $user['id']); ?>">
|
||||
<?php echo csrf_field(); ?>
|
||||
<div class="form-row">
|
||||
<label>新密码 <span class="req">*</span></label>
|
||||
<input type="password" name="password" autocomplete="new-password" required>
|
||||
<small class="muted">至少 6 位</small>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn">确认重置</button>
|
||||
<a class="btn-soft" href="<?php echo site_url($upper . '/users'); ?>">取消</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/** @var array $users @var string $sys @var string $sysName @var array $pages */
|
||||
$labelMap = [];
|
||||
foreach (\subsys_nav($sys) as $it) { $labelMap[$it['k']] = $it['label']; }
|
||||
$roleLabels = ['super_admin' => '超级管理员', 'admin' => '管理员', 'user' => '普通用户', 'none' => '无'];
|
||||
$upper = strtoupper($sys);
|
||||
?>
|
||||
<div class="page-head">
|
||||
<h1>用户管理</h1>
|
||||
<p class="sub"><?php echo e($sysName); ?> · 管理系统内的用户账号及其页面访问权限</p>
|
||||
</div>
|
||||
|
||||
<?php echo flash_html(); ?>
|
||||
|
||||
<div class="panel">
|
||||
<div class="panel-bar">
|
||||
<h3>账号列表</h3>
|
||||
<a class="btn" href="<?php echo site_url($upper . '/users/create'); ?>"><?php echo admin_icon('user-plus', 16); ?> 新增用户</a>
|
||||
</div>
|
||||
<div class="table-wrap">
|
||||
<table class="tbl">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>用户名</th>
|
||||
<th>姓名</th>
|
||||
<th>角色</th>
|
||||
<th>页面权限</th>
|
||||
<th>状态</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($users as $u): ?>
|
||||
<?php
|
||||
$raw = $u[$sys . '_perms'] ?? '';
|
||||
$dec = is_string($raw) && $raw !== '' ? @json_decode($raw, true) : [];
|
||||
$perms = is_array($dec) ? array_keys(array_filter($dec)) : [];
|
||||
$role = $u[$sys . '_role'] ?? 'user';
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo (int)$u['id']; ?></td>
|
||||
<td><?php echo e($u['username']); ?></td>
|
||||
<td><?php echo e($u['name'] ?? ''); ?></td>
|
||||
<td><span class="role-badge role-<?php echo e($role); ?>"><?php echo e($roleLabels[$role] ?? $role); ?></span></td>
|
||||
<td class="perm-cell">
|
||||
<?php if (empty($perms)): ?>
|
||||
<span class="muted">仅仪表盘</span>
|
||||
<?php else: foreach ($perms as $p): ?>
|
||||
<span class="perm-chip"><?php echo e($labelMap[$p] ?? $p); ?></span>
|
||||
<?php endforeach; endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if (!empty($u['status'])): ?><span class="st st-on">启用</span><?php else: ?><span class="st st-off">停用</span><?php endif; ?>
|
||||
</td>
|
||||
<td class="row-actions">
|
||||
<a href="<?php echo site_url($upper . '/users/edit/' . $u['id']); ?>">编辑</a>
|
||||
<a href="<?php echo site_url($upper . '/users/reset/' . $u['id']); ?>">重置密码</a>
|
||||
<form method="post" class="inline-form" action="<?php echo site_url($upper . '/users/destroy/' . $u['id']); ?>" data-confirm="确认删除该用户?">
|
||||
<?php echo csrf_field(); ?>
|
||||
<button type="submit" class="link-danger">删除</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php if (empty($users)): ?>
|
||||
<tr><td colspan="7" class="muted" style="text-align:center;padding:24px">暂无用户</td></tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user