diff --git a/fzjgact/db.sqlite3 b/fzjgact/db.sqlite3
index 2175f82..2eb1374 100644
Binary files a/fzjgact/db.sqlite3 and b/fzjgact/db.sqlite3 differ
diff --git a/fzjgact/huodong/__pycache__/views.cpython-311.pyc b/fzjgact/huodong/__pycache__/views.cpython-311.pyc
index f20300a..1247d81 100644
Binary files a/fzjgact/huodong/__pycache__/views.cpython-311.pyc and b/fzjgact/huodong/__pycache__/views.cpython-311.pyc differ
diff --git a/fzjgact/huodong/templates/contact_list.html b/fzjgact/huodong/templates/contact_list.html
index e882b53..0faa093 100644
--- a/fzjgact/huodong/templates/contact_list.html
+++ b/fzjgact/huodong/templates/contact_list.html
@@ -1,336 +1,345 @@
-{% extends "base.html" %}
-
-{% block content %}
-
-
联系人信息
-
-
-
-
-
-
-
- | 分支机构 |
- 分类 |
- 姓名 |
- 电话 |
- 邮箱 |
-
-
-
- {% for contact in contacts %}
-
- | {{ contact.branch.name }} |
- {{ contact.category|default:"" }} |
- {{ contact.name|default:"" }} |
- {{ contact.phone|default:"" }} |
- {{ contact.email|default:"" }} |
-
- {% empty %}
-
- | 没有找到匹配的联系人 |
-
- {% endfor %}
-
-
-
-
-
+{% extends "base.html" %}
+
+{% block content %}
+
+
联系人信息
+
+
+
+
+
+
+
+ | 分支机构 |
+ 分类 |
+ 姓名 |
+ 电话 |
+ 邮箱 |
+
+
+
+ {% for contact in contacts %}
+
+ | {{ contact.branch.name }} |
+ {{ contact.category|default:"" }} |
+ {{ contact.name|default:"" }} |
+ {{ contact.phone|default:"" }} |
+ {{ contact.email|default:"" }} |
+
+ {% empty %}
+
+ | 没有找到匹配的联系人 |
+
+ {% endfor %}
+
+
+
+
+
+
+
{% endblock %}
\ No newline at end of file
diff --git a/fzjgact/huodong/templatetags/__pycache__/custom_filters.cpython-311.pyc b/fzjgact/huodong/templatetags/__pycache__/custom_filters.cpython-311.pyc
index b384739..496100f 100644
Binary files a/fzjgact/huodong/templatetags/__pycache__/custom_filters.cpython-311.pyc and b/fzjgact/huodong/templatetags/__pycache__/custom_filters.cpython-311.pyc differ
diff --git a/fzjgact/huodong/urls.py b/fzjgact/huodong/urls.py
index 9cdced3..827353f 100644
--- a/fzjgact/huodong/urls.py
+++ b/fzjgact/huodong/urls.py
@@ -15,6 +15,7 @@ urlpatterns = [
path('branch/info/', views.Branchinfo, name='branchinfo'),
path('statistics/', views.Statistics, name='statistics'),
path('contact/', views.contact_list, name='contact-list'),
+ path('contact/export/pdf/', views.export_contacts_pdf, name='export-contacts-pdf'),
path('equipment-images/', views.equipment_images, name='equipment-images'),
path('public-screens/', views.public_screens, name='public-screens'),
path('video-terminals/', views.video_terminal_list, name='video-terminals'),
diff --git a/fzjgact/huodong/views.py b/fzjgact/huodong/views.py
index 93d831e..90b11b7 100644
--- a/fzjgact/huodong/views.py
+++ b/fzjgact/huodong/views.py
@@ -466,6 +466,109 @@ def contact_list(request):
return render(request, 'contact_list.html', context)
+def export_contacts_pdf(request):
+ # 创建响应对象
+ response = HttpResponse(content_type='application/pdf')
+ response['Content-Disposition'] = 'attachment; filename="contacts_info.pdf"'
+
+ # 注册中文字体
+ from reportlab.pdfbase import pdfmetrics
+ from reportlab.pdfbase.ttfonts import TTFont
+
+ # 尝试注册系统中文字体,这里使用Windows系统自带的中文字体
+ try:
+ # 尝试注册微软雅黑字体
+ pdfmetrics.registerFont(TTFont('MSYaHei', 'C:/Windows/Fonts/msyh.ttc'))
+ chinese_font = 'MSYaHei'
+ except:
+ try:
+ # 如果微软雅黑不存在,尝试注册宋体
+ pdfmetrics.registerFont(TTFont('SimSun', 'C:/Windows/Fonts/simsun.ttc'))
+ chinese_font = 'SimSun'
+ except:
+ # 如果都找不到,使用默认字体(可能仍会有乱码)
+ chinese_font = 'Helvetica'
+
+ # 创建PDF文档
+ doc = SimpleDocTemplate(response, pagesize=letter)
+ elements = []
+
+ # 添加标题
+ styles = getSampleStyleSheet()
+ # 复制Title样式并修改字体
+ title_style = ParagraphStyle(
+ 'ChineseTitle',
+ parent=styles['Title'],
+ fontName=chinese_font,
+ fontSize=18,
+ spaceAfter=30,
+ alignment=1 # 1表示居中
+ )
+ title = Paragraph("联系人信息", title_style)
+ elements.append(title)
+
+ # 获取筛选参数
+ branches_param = request.GET.get('branches')
+ category = request.GET.get('category')
+ contact_name = request.GET.get('contact_name')
+
+ # 构建查询条件
+ filters = Q()
+
+ # 分支机构筛选(支持多选)
+ if branches_param:
+ branch_ids = [bid.strip() for bid in branches_param.split(',') if bid.strip().isdigit()]
+ if branch_ids:
+ filters &= Q(branch_id__in=branch_ids)
+
+ # 联系人类别筛选
+ if category:
+ filters &= Q(category__contains=category)
+
+ # 联系人姓名筛选
+ if contact_name:
+ filters &= Q(name__icontains=contact_name)
+
+ # 获取筛选后的联系人
+ contacts = Contact.objects.filter(filters)
+
+ # 准备表格数据
+ data = [['分支机构', '分类', '姓名', '电话', '邮箱']] # 表头
+ for contact in contacts:
+ data.append([
+ contact.branch.name if contact.branch else '',
+ contact.category or '',
+ contact.name or '',
+ contact.phone or '',
+ contact.email or ''
+ ])
+
+ # 创建表格
+ table = Table(data)
+
+ # 设置表格样式
+ style = TableStyle([
+ ('BACKGROUND', (0, 0), (-1, 0), colors.grey),
+ ('TEXTCOLOR', (0, 0), (-1, 0), colors.whitesmoke),
+ ('ALIGN', (0, 0), (-1, -1), 'CENTER'),
+ ('FONTNAME', (0, 0), (-1, 0), chinese_font), # 使用中文字体
+ ('FONTSIZE', (0, 0), (-1, 0), 14),
+ ('BOTTOMPADDING', (0, 0), (-1, 0), 12),
+ ('BACKGROUND', (0, 1), (-1, -1), colors.beige),
+ ('FONTNAME', (0, 1), (-1, -1), chinese_font), # 使用中文字体
+ ('GRID', (0, 0), (-1, -1), 1, colors.black)
+ ])
+ table.setStyle(style)
+
+ # 添加表格到文档
+ elements.append(table)
+
+ # 构建PDF
+ doc.build(elements)
+
+ return response
+
+
def video_terminal_list(request):
# 获取筛选参数
selected_branch = request.GET.get('branch', '')