17 lines
796 B
HTML
17 lines
796 B
HTML
|
|
{# 可排序表头:点击升序,再点降序 #}
|
||
|
|
{% macro sort_th(endpoint, field, label, sort='', order='asc', params={}, class='text-end', title='') %}
|
||
|
|
{% set next_order = 'desc' if sort == field and order == 'asc' else 'asc' %}
|
||
|
|
{% set link_params = params.copy() %}
|
||
|
|
{% set _ = link_params.update({'sort': field, 'order': next_order}) %}
|
||
|
|
<a href="{{ url_for(endpoint, **link_params) }}"
|
||
|
|
class="th-sort {{ class }} {% if sort == field %}active{% endif %}"
|
||
|
|
{% if title %}title="{{ title }}"{% else %}title="点击排序,再点反向"{% endif %}>
|
||
|
|
{{ label }}
|
||
|
|
{% if sort == field %}
|
||
|
|
<i class="bi bi-caret-{{ 'up' if order == 'asc' else 'down' }}-fill"></i>
|
||
|
|
{% else %}
|
||
|
|
<i class="bi bi-arrow-down-up opacity-50"></i>
|
||
|
|
{% endif %}
|
||
|
|
</a>
|
||
|
|
{% endmacro %}
|