Files
drl_2/xuexiao/templates/macros/sortable.html
user9994793890 ee860ce0ae Initial commit
2026-05-29 10:28:07 +08:00

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 %}