Files
drl_2/xuexiao/templates/role_list.html

77 lines
3.7 KiB
HTML
Raw Permalink Normal View History

2026-05-29 10:28:07 +08:00
{% extends "base.html" %}
{% block title %}角色管理 - 学生课程管理系统{% endblock %}
{% block content %}
<div class="container-fluid py-4">
<div class="d-flex justify-content-between align-items-center mb-3">
<h4 class="mb-0">角色管理</h4>
{% if current_user.has_permission('role_add') %}
<a href="{{ url_for('role_add') }}" class="btn btn-primary">
<i class="bi bi-plus-circle"></i> 添加角色
</a>
{% endif %}
</div>
<div class="card shadow">
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="table-light">
<tr>
<th>ID</th>
<th>角色名称</th>
<th>权限</th>
<th>备注</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{% for role in roles %}
<tr>
<td>{{ role.id }}</td>
<td>{{ role.name }}</td>
<td>
{% if role.name == '超级管理员' %}
<span class="badge bg-primary">全部权限</span>
{% elif role.permissions %}
{% set perms = role.permissions.split(',') %}
{% for p in perms %}
{% if p.endswith('_view') %}
<span class="badge bg-info">{{ p.replace('_view','').replace('_',' ') }} 查看</span>
{% elif p.endswith('_export') %}
<span class="badge bg-success">{{ p.replace('_export','').replace('_',' ') }} 导出</span>
{% else %}
<span class="badge bg-secondary">{{ p }}</span>
{% endif %}
{% endfor %}
{% else %}
<span class="text-muted">无权限</span>
{% endif %}
</td>
<td>{{ role.remark or '' }}</td>
<td>
{% if current_user.has_permission('role_edit') and role.name != '超级管理员' %}
<a href="{{ url_for('role_edit', role_id=role.id) }}" class="btn btn-sm btn-outline-primary">
<i class="bi bi-pencil"></i> 编辑
</a>
{% endif %}
{% if current_user.has_permission('role_delete') and role.name != '超级管理员' %}
<form method="POST" action="{{ url_for('role_delete', role_id=role.id) }}"
class="d-inline" onsubmit="return confirm('确定删除此角色?')">
<button class="btn btn-sm btn-outline-danger">
<i class="bi bi-trash"></i> 删除
</button>
</form>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
{% endblock %}