更新了年份显示和统计周期的显示
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -15,7 +15,9 @@
|
||||
<header class="bg-gray-50 dark:bg-gray-800 dark:border-gray-700 p-4 text-center text-xl font-bold">
|
||||
分支机构活动管理
|
||||
<br>
|
||||
2025年
|
||||
{{ ''|get_current_year }}年
|
||||
<br>
|
||||
统计周期:{{ ''|get_statistic_period }}
|
||||
</header>
|
||||
|
||||
<!-- 主体内容:左右两侧栏布局 -->
|
||||
|
||||
Binary file not shown.
@@ -28,3 +28,39 @@ def format_chinese_full_date(value):
|
||||
weekdays = ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"]
|
||||
weekday = weekdays[date_obj.weekday()]
|
||||
return f"{date_obj.year}年{date_obj.month}月{date_obj.day}日 {weekday}"
|
||||
|
||||
|
||||
@register.filter
|
||||
def get_current_year(value=None):
|
||||
"""
|
||||
获取当前年份
|
||||
"""
|
||||
now = datetime.now() if value is None else value
|
||||
return now.year
|
||||
|
||||
|
||||
@register.filter
|
||||
def get_statistic_period(value=None):
|
||||
"""
|
||||
计算统计周期
|
||||
规则:
|
||||
- 在2026年1月,实际统计的是2025年11月至2026年1月
|
||||
- 在2026年2月,实际统计的是2025年12月至2026年2月
|
||||
- 以此类推
|
||||
"""
|
||||
now = datetime.now() if value is None else value
|
||||
current_year = now.year
|
||||
current_month = now.month
|
||||
|
||||
# 计算统计周期的开始月份和年份
|
||||
if current_month <= 2:
|
||||
start_year = current_year - 1
|
||||
start_month = 11 + current_month
|
||||
else:
|
||||
start_year = current_year
|
||||
start_month = current_month - 2
|
||||
|
||||
# 构建统计周期字符串
|
||||
period = f"{start_year}年{start_month}月至{current_year}年{current_month}月"
|
||||
|
||||
return period
|
||||
|
||||
Reference in New Issue
Block a user