This commit is contained in:
hailin 2024-10-28 15:10:52 +08:00
parent 1307f63225
commit c5fad0da54
2 changed files with 39 additions and 3 deletions

24
app.py
View File

@ -88,6 +88,7 @@ def index():
# 默认展示第一个客户
return redirect(url_for('view_customer', index=0))
@app.route('/customer/<int:index>')
def view_customer(index):
# 判断是否有数据
@ -102,20 +103,35 @@ def view_customer(index):
# 为每个 email addresses 列表中的项添加唯一的索引
for domain, info in customer.items():
print(f"..........domain={domain}")
print(f"..........info={info}")
if 'email addresses' in info and isinstance(info['email addresses'], list):
for email_idx, email in enumerate(info['email addresses']):
email['idx'] = email_idx # 给每个 email 项添加唯一的索引
# 添加统计逻辑
total_emails = 0
cold_lead_count = 0
# 遍历所有客户数据
for customer in customer_data:
for domain, info in customer.items():
if 'email addresses' in info and isinstance(info['email addresses'], list):
for email in info['email addresses']:
total_emails += 1
# 检查邮件是否属于 "cold lead"
if email.get('category', '').lower() == "cold lead":
cold_lead_count += 1
is_first = index == 0
is_last = index == len(customer_data) - 1
# 将统计信息传递到模板
return render_template('edit_customers.html',
customer=customer,
index=index,
is_first=is_first,
is_last=is_last)
is_last=is_last,
total_emails=total_emails,
cold_lead_count=cold_lead_count)
# @app.route('/customer/<int:index>')
# def view_customer(index):
@ -146,6 +162,8 @@ def view_customer(index):
# is_first=is_first,
# is_last=is_last)
@app.route('/update/<int:index>', methods=['POST'])
def update_customers(index):
updated_data = request.form.to_dict(flat=False)

View File

@ -4,6 +4,19 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Edit Customer Data</title>
<style>
/* 固定底部状态栏样式 */
.status-bar {
position: fixed;
bottom: 0;
width: 100%;
background-color: #f1f1f1;
border-top: 1px solid #ccc;
padding: 10px;
text-align: center;
font-size: 14px;
}
</style>
</head>
<body>
<h2>Edit Customer Data</h2>
@ -67,6 +80,11 @@
</button>
</div>
<!-- 固定状态栏 -->
<div class="status-bar">
<p>Total Emails: {{ total_emails }} | Cold Leads: {{ cold_lead_count }}</p>
</div>
<!-- JavaScript 脚本 -->
<script>
// 跳转到数据库的第一条记录