在营业部信息系统类型里增加一行统计信息

This commit is contained in:
2025-12-04 17:33:23 +08:00
parent acf4ef12ec
commit a92fcb50b5
4 changed files with 79 additions and 62 deletions

View File

@@ -51,7 +51,7 @@
{% if budgets %}
{% for budget in budgets %}
<div class="mb-6">
<h3 class="text-lg font-semibold mb-3">{{ budget.activity.name }} - 总预算: ¥{{ budget.total_budget }}</h3>
<h3 class="text-lg font-semibold mb-3">{{ budget.name }} - 总预算: ¥{{ budget.total_budget }}</h3>
<!-- 设备预算部分 -->
<div class="mb-4">

View File

@@ -1,59 +1,67 @@
{% extends 'base.html' %}
{% block content %}
<table class="items-center bg-transparent w-full border-collapse ">
<thead>
<tr class="bg-gray-100">
<th class="px-6 bg-blueGray-50 text-blueGray-500 align-middle border border-solid border-blueGray-100 py-3 text-base uppercase border-l-0 border-r-0 whitespace-nowrap font-semibold text-left">
分支机构名称
<br>
基础信息
</th>
<th class="px-6 bg-blueGray-50 text-blueGray-500 align-middle border border-solid border-blueGray-100 py-3 text-base uppercase border-l-0 border-r-0 whitespace-nowrap font-semibold text-left">
信息系统类别
</th>
</tr>
</thead>
<tbody>
{% for item in branches %}
<!-- 这里是其他行的处理逻辑 -->
<tr class="{% if forloop.counter|divisibleby:2 %}bg-gray-100{% else %}bg-white{% endif %}">
<td class="px-6 py-4 whitespace-no-wrap text-left border-b border-gray-200">
<a href="{% url 'branch-detail' item.pk %}"
class="bg-transparent hover:bg-blue-900 hover:text-white p-2 rounded-md">
{{ item.name }}
</a>
</td>
<td class="px-6 py-4 whitespace-no-wrap text-left border-b border-gray-200">
{{ item.category }}
</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr class="bg-gray-50">
<td colspan="2" class="px-6 py-4 text-right border-b border-gray-200">
<div class="flex justify-end space-x-3">
<a href="{% url 'export-branches-xls' %}" class="inline-flex items-center px-4 py-2 bg-blue-600 hover:bg-blue-700 text-black font-medium rounded-lg shadow-md transition duration-150 ease-in-out transform hover:scale-105">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm3.293-7.707a1 1 0 011.414 0L9 10.586V3a1 1 0 112 0v7.586l1.293-1.293a1 1 0 111.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z" clip-rule="evenodd" />
</svg>
导出为XLS
</a>
<a href="{% url 'export-branches-pdf' %}" class="inline-flex items-center px-4 py-2 bg-purple-600 hover:bg-purple-800 text-black font-medium rounded-lg shadow-md transition duration-300 ease-in-out transform hover:scale-105 hover:shadow-lg">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm3.293-7.707a1 1 0 011.414 0L9 10.586V3a1 1 0 112 0v7.586l1.293-1.293a1 1 0 111.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z" clip-rule="evenodd" />
</svg>
导出为PDF
</a>
</div>
</td>
</tr>
</tfoot>
</table>
<hr class="h-px my-8 bg-red-500 border-1 dark:bg-red-700">
{% extends 'base.html' %}
{% block content %}
<table class="items-center bg-transparent w-full border-collapse ">
<thead>
<tr class="bg-gray-100">
<th class="px-6 bg-blueGray-50 text-blueGray-500 align-middle border border-solid border-blueGray-100 py-3 text-base uppercase border-l-0 border-r-0 whitespace-nowrap font-semibold text-left">
分支机构名称
<br>
基础信息
</th>
<th class="px-6 bg-blueGray-50 text-blueGray-500 align-middle border border-solid border-blueGray-100 py-3 text-base uppercase border-l-0 border-r-0 whitespace-nowrap font-semibold text-left">
信息系统类别
</th>
</tr>
</thead>
<tbody>
{% for item in branches %}
<!-- 这里是其他行的处理逻辑 -->
<tr class="{% if forloop.counter|divisibleby:2 %}bg-gray-100{% else %}bg-white{% endif %}">
<td class="px-6 py-4 whitespace-no-wrap text-left border-b border-gray-200">
<a href="{% url 'branch-detail' item.pk %}"
class="bg-transparent hover:bg-blue-900 hover:text-white p-2 rounded-md">
{{ item.name }}
</a>
</td>
<td class="px-6 py-4 whitespace-no-wrap text-left border-b border-gray-200">
{{ item.category }}
</td>
</tr>
{% endfor %}
</tbody>
<tr class="bg-gray-200 font-bold">
<td class="px-6 py-4 whitespace-no-wrap text-left border-b border-gray-200">
分支机构类别统计
</td>
<td class="px-6 py-4 whitespace-no-wrap text-left border-b border-gray-200">
A型: {{ type_a_count }}家 | B型: {{ type_b_count }}家 | C型: {{ type_c_count }}家
</td>
</tr>
<tfoot>
<tr class="bg-gray-50">
<td colspan="2" class="px-6 py-4 text-right border-b border-gray-200">
<div class="flex justify-end space-x-3">
<a href="{% url 'export-branches-xls' %}" class="inline-flex items-center px-4 py-2 bg-blue-600 hover:bg-blue-700 text-black font-medium rounded-lg shadow-md transition duration-150 ease-in-out transform hover:scale-105">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm3.293-7.707a1 1 0 011.414 0L9 10.586V3a1 1 0 112 0v7.586l1.293-1.293a1 1 0 111.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z" clip-rule="evenodd" />
</svg>
导出为XLS
</a>
<a href="{% url 'export-branches-pdf' %}" class="inline-flex items-center px-4 py-2 bg-purple-600 hover:bg-purple-800 text-black font-medium rounded-lg shadow-md transition duration-300 ease-in-out transform hover:scale-105 hover:shadow-lg">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm3.293-7.707a1 1 0 011.414 0L9 10.586V3a1 1 0 112 0v7.586l1.293-1.293a1 1 0 111.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z" clip-rule="evenodd" />
</svg>
导出为PDF
</a>
</div>
</td>
</tr>
</tfoot>
</table>
<hr class="h-px my-8 bg-red-500 border-1 dark:bg-red-700">
{% endblock %}

View File

@@ -56,7 +56,7 @@ def branch_detail(request, branch_id):
public_screens = branch.public_screens.all()
# 获取预算数据
budgets = Budget.objects.filter(branch=branch).select_related('activity').prefetch_related('equipment_budgets', 'infrastructure_budgets').order_by('-created_at')
budgets = Budget.objects.filter(branch=branch).prefetch_related('equipment_budgets', 'infrastructure_budgets').order_by('-created_at')
# 获取预算模板
budget_templates = BudgetTemplate.objects.all()
@@ -228,8 +228,17 @@ def BranchAll(request):
# 生成branchinfo的视图
def Branchinfo(request):
branches = Branch.objects.all
context = {'branches': branches, }
branches = Branch.objects.all()
# 统计A型、B型、C型分支机构的数量
type_a_count = branches.filter(category='A型').count()
type_b_count = branches.filter(category='B型').count()
type_c_count = branches.filter(category='C型').count()
context = {
'branches': branches,
'type_a_count': type_a_count,
'type_b_count': type_b_count,
'type_c_count': type_c_count,
}
return render(request, 'branch_info.html', context)