axum-sqlx/templates/index.html

94 lines
3.3 KiB
HTML

{% extends "./base.html" %} {%block title%}列表{%endblock%} {%block content%}
{%match msg%} {%when Some with (msg)%}
<div class="alert alert-success" role="alert">{{msg}}</div>
{%when None%} {%endmatch%}
<div class="my-3">
<table class="table table-striped">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">名称</th>
<th scope="col">余额</th>
<th scope="col">类型</th>
<th scope="col">时间</th>
<th scope="col">已删除</th>
<th scope="col">操作</th>
</tr>
</thead>
<tbody>
{%for m in p.data%}
<tr>
<th scope="row">{{ m.id }}</th>
<td>{{ m.name }}</td>
<td>{{ m.balance }}</td>
<td>{{ m.types }}</td>
<td>{{ m.dateline }}</td>
<td>
{% if m.is_del %}
<span class="badge text-bg-danger"></span> {%else%}
<span class="badge text-bg-success"></span> {%endif%}
</td>
<td>
<a class="btn btn-secondary btn-sm" href="/detail/{{m.id}}">详情</a>
<a class="btn btn-primary btn-sm" href="/edit/{{m.id}}">修改</a>
<div class="btn-group btn-group-sm" role="group">
<button
type="button"
class="btn btn-danger dropdown-toggle"
data-bs-toggle="dropdown"
aria-expanded="false"
>
删除
</button>
<ul class="dropdown-menu">
<li>
<a
class="dropdown-item"
href="/del/{{m.id}}"
onclick="if(!confirm('确定删除?')){return false;}"
>逻辑删除</a
>
</li>
<li>
<a
class="dropdown-item"
href="/real_del/{{m.id}}"
onclick="if(!confirm('确定删除?')){return false;}"
>物理删除</a
>
</li>
</ul>
</div>
</td>
</tr>
{%endfor%}
</tbody>
</table>
</div>
{% if p.total_page > 0 %}
<nav>
<ul class="pagination">
<li class="page-item">
{%if p.has_prev()%}
<a class="page-link" href="?page={{p.page-1}}">上一页</a>
{%else%}
<a class="page-link" href="?page=0">上一页</a>
{%endif%}
</li>
{%for i in 0..p.total_page%}
<li class="page-item{%if p.page==i%} active{%endif%}">
<a class="page-link" href="?page={{i}}">{{i+1}}</a>
</li>
{%endfor%}
<li class="page-item">
{%if p.has_next()%}
<a class="page-link" href="?page={{p.page+1}}">下一页</a>
{%else%}
<a class="page-link" href="?page={{p.last_page()}}">下一页</a>
{%endif%}
</li>
</ul>
</nav>
{%endif%} {%endblock%}