Files

40 lines
2.4 KiB
HTML

{% extends "base.html" %}
{% block body %}
<h1 class="page">用户与权限</h1>
<div class="card">
<h2>{{ '编辑用户' if target else '新增用户' }}</h2>
<form method="post" action="{{ url_for('users') }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
{% if target %}<input type="hidden" name="id" value="{{ target.id }}">{% endif %}
<div class="form-grid">
<div><label>登录名 *</label><input name="username" required maxlength="50" value="{{ target.username if target else '' }}"></div>
<div><label>姓名 *</label><input name="name" required maxlength="50" value="{{ target.name if target else '' }}"></div>
<div><label>角色</label><select name="role">
{% for k,v in roles.items() %}<option value="{{ k }}" {% if (target and target.role == k) or (not target and k == 'maker') %}selected{% endif %}>{{ v }}</option>{% endfor %}
</select></div>
<div><label>状态</label><select name="active">
<option value="1" {% if not target or target.active %}selected{% endif %}>启用</option>
<option value="0" {% if target and not target.active %}selected{% endif %}>停用</option>
</select></div>
<div><label>{{ '重置密码(留空则不修改)' if target else '初始密码 *' }}</label>
<input type="password" name="password" minlength="10" maxlength="128" autocomplete="new-password" {% if not target %}required{% endif %}>
</div>
</div>
<p class="hint">新增或重置密码后,用户首次登录须修改密码。编辑账号会使原有登录失效。</p>
<button class="btn primary">保存用户</button>
{% if target %}<a class="btn" href="{{ url_for('users') }}">取消编辑</a>{% endif %}
</form>
</div>
<div class="card">
<h2>用户列表</h2>
<table class="grid">
<tr><th>登录名</th><th>姓名</th><th>角色</th><th>状态</th><th>操作</th></tr>
{% for t in rows %}<tr>
<td>{{ t.username }}</td><td>{{ t.name }}</td><td>{{ roles.get(t.role,t.role) }}</td>
<td>{{ '启用' if t.active else '停用' }}</td><td><a class="btn sm" href="{{ url_for('users',edit=t.id) }}">编辑 / 重置密码</a></td>
</tr>{% endfor %}
</table>
<p class="hint">制单员仅访问自己的订单。审批员一次审批通过后即可生成正式文件;制单和审批须由不同账号完成,管理员也遵守此规则。</p>
</div>
{% endblock %}