"""验证看板HTML的成本字段是否都被保护"""
import re

with open(r'C:\Users\Administrator\.openclaw\workspace\letaro\data_model\wang_dashboard.html', 'r', encoding='utf-8') as f:
    html = f.read()

# 查找所有出现'成本'的位置
lines = html.split('\n')
unprotected = []
for i, line in enumerate(lines, 1):
    if '成本' in line or 'cost' in line.lower():
        has_protection = 'canViewCost' in line or 'viewCost' in line
        if not has_protection:
            unprotected.append((i, line.strip()[:120]))

print(f"=== 未受保护的'成本'字段 ===")
if unprotected:
    for i, line in unprotected:
        print(f"  行{i}: {line}")
else:
    print("  ✅ 全部受保护，没有遗漏！")

total_cost = html.count('成本')
cannot_view = len(re.findall(r'canViewCost\(\)', html))
print(f"\n总计出现'成本'次数: {total_cost}")
print(f"canViewCost调用次数: {cannot_view}")
print(f"未保护字段数: {len(unprotected)}")
