validate_contract.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import re
  2. path = r'd:\Users\chenjun\kyj-yanglao-web-new\src\views\elderly\apply\check-in\ContractForm.vue'
  3. with open(path, 'r', encoding='utf-8') as f:
  4. content = f.read()
  5. # 检查 <template> 标签匹配
  6. template_open = content.count('<template>') + content.count('<template ')
  7. template_close = content.count('</template>')
  8. print(f"<template> open: {template_open}, close: {template_close}")
  9. # 检查 <div> 标签匹配
  10. div_open = len(re.findall(r'<div\b', content))
  11. div_close = content.count('</div>')
  12. print(f"<div> open: {div_open}, close: {div_close}")
  13. # 检查 <el-drawer> 标签匹配
  14. drawer_open = len(re.findall(r'<el-drawer\b', content))
  15. drawer_close = content.count('</el-drawer>')
  16. print(f"<el-drawer> open: {drawer_open}, close: {drawer_close}")
  17. # 检查 <script> 标签
  18. script_open = content.count('<script')
  19. script_close = content.count('</script>')
  20. print(f"<script> open: {script_open}, close: {script_close}")
  21. # 检查 <style> 标签
  22. style_open = content.count('<style')
  23. style_close = content.count('</style>')
  24. print(f"<style> open: {style_open}, close: {style_close}")
  25. # 检查有没有剩余的 {{ contractForm.xxx || '' }} 模式(没有被isTextMode包裹的)
  26. # 应该只有在template条件下的,其他应该都被包裹
  27. remaining_raw = []
  28. for m in re.finditer(r'([^>])\{{2}\s*contractForm\.(\w+)\s*\|\|\s*', content):
  29. pos = m.start()
  30. line = content[:pos].count('\n') + 1
  31. remaining_raw.append((line, m.group(0)[:50]))
  32. print(f"\nRaw || patterns not wrapped (should be minimal): {len(remaining_raw)}")
  33. for line, snippet in remaining_raw[:10]:
  34. print(f" Line {line}: ...{snippet}...")
  35. # 检查附件是否还存在(关键词:附件1到附件9)
  36. attachments_found = []
  37. for m in re.finditer(r'附件[一二三四五六七八九十]', content):
  38. pos = m.start()
  39. line = content[:pos].count('\n') + 1
  40. snippet = content[max(0, pos-20):pos+30]
  41. attachments_found.append((line, snippet))
  42. print(f"\n附件 references found: {len(attachments_found)}")
  43. for line, snippet in attachments_found:
  44. print(f" Line {line}: {snippet.strip()}")
  45. print("\n=== Summary ===")
  46. print("File looks OK!" if (template_close > 0 and drawer_open == drawer_close and script_open == script_close and style_open == style_close) else "File has structural issues!")