members.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. {% extends "layout.html" %}
  2. {% block title %}成员列表 - 家谱管理系统{% endblock %}
  3. {% block extra_css %}
  4. <style>
  5. .lineage-badge {
  6. display: inline-flex;
  7. align-items: center;
  8. gap: 5px;
  9. padding: 4px 14px 4px 10px;
  10. border: 1.5px solid #b8c9e8;
  11. border-radius: 20px;
  12. background: #f0f4fb;
  13. color: #3b5998;
  14. font-size: 13px;
  15. font-weight: 500;
  16. white-space: nowrap;
  17. line-height: 1.6;
  18. }
  19. .lineage-icon {
  20. width: 16px;
  21. height: 16px;
  22. opacity: 0.6;
  23. flex-shrink: 0;
  24. }
  25. /* 兄弟 hover 弹窗 */
  26. .siblings-wrapper {
  27. position: relative;
  28. display: inline-block;
  29. }
  30. .siblings-popup {
  31. display: none;
  32. position: absolute;
  33. top: 100%;
  34. left: 0;
  35. z-index: 999;
  36. background: #fff;
  37. border: 1px solid #d0d7e6;
  38. border-radius: 8px;
  39. box-shadow: 0 4px 18px rgba(0,0,0,0.13);
  40. padding: 8px 4px;
  41. min-width: 140px;
  42. max-width: 220px;
  43. max-height: 260px;
  44. overflow-y: auto;
  45. white-space: nowrap;
  46. }
  47. .siblings-wrapper:hover .siblings-popup {
  48. display: block;
  49. }
  50. .siblings-popup a {
  51. display: block;
  52. padding: 3px 12px;
  53. font-size: 12px;
  54. color: #3b5998;
  55. text-decoration: none;
  56. border-radius: 4px;
  57. transition: background 0.12s;
  58. }
  59. .siblings-popup a:hover {
  60. background: #f0f4fb;
  61. color: #1a3a80;
  62. }
  63. .sibling-summary {
  64. font-size: 11.5px;
  65. color: #666;
  66. margin-top: 2px;
  67. cursor: default;
  68. }
  69. .sibling-count-badge {
  70. display: inline-block;
  71. background: #e8eef7;
  72. color: #4a69bd;
  73. border-radius: 10px;
  74. padding: 0 6px;
  75. font-size: 11px;
  76. vertical-align: middle;
  77. margin-left: 2px;
  78. }
  79. </style>
  80. {% endblock %}
  81. {% block content %}
  82. <div class="d-flex justify-content-between align-items-center mb-4">
  83. <h2><i class="bi bi-people"></i> 家谱成员管理</h2>
  84. <div class="d-flex gap-2">
  85. <form class="d-flex" action="{{ url_for('members') }}" method="GET">
  86. <div class="input-group">
  87. <select name="search_type" class="form-select" style="max-width:100px; border-right:0; border-radius:6px 0 0 6px;">
  88. <option value="name" {% if search_type != 'name_word' %}selected{% endif %}>姓名</option>
  89. <option value="name_word" {% if search_type == 'name_word' %}selected{% endif %}>字辈</option>
  90. </select>
  91. <input type="text" name="name" class="form-control"
  92. placeholder="{{ '输入字辈精确搜索...' if search_type == 'name_word' else '输入姓名搜索...' }}"
  93. value="{{ search_name or '' }}">
  94. <button class="btn btn-outline-primary" type="submit"><i class="bi bi-search"></i></button>
  95. {% if search_name %}
  96. <a href="{{ url_for('members') }}" class="btn btn-outline-secondary">重置</a>
  97. {% endif %}
  98. </div>
  99. </form>
  100. <a href="{{ url_for('add_member') }}" class="btn btn-primary text-nowrap"><i class="bi bi-plus-lg"></i> 录入新成员</a>
  101. <a href="{{ url_for('suspected_errors') }}" class="btn btn-warning text-nowrap"><i class="bi bi-exclamation-triangle"></i> 疑似汇总</a>
  102. <a href="{{ url_for('generation_check_page') }}" class="btn btn-outline-info text-nowrap"><i class="bi bi-clipboard2-check"></i> 代数核查</a>
  103. </div>
  104. </div>
  105. <div class="card shadow-sm border-0">
  106. <div class="card-body p-0">
  107. <div class="table-responsive">
  108. <table class="table table-hover align-middle mb-0">
  109. <thead class="table-light">
  110. <tr>
  111. <th class="px-4">序号</th>
  112. <th>基本信息</th>
  113. <th>世系世代</th>
  114. <th>父亲</th>
  115. <th>职业背景</th>
  116. <th>堂内排行</th>
  117. <th>分房 / 堂号</th>
  118. <th>居住地</th>
  119. <th>状态</th>
  120. <th class="text-center">操作</th>
  121. </tr>
  122. </thead>
  123. <tbody>
  124. {% for member in members %}
  125. <tr>
  126. <td class="px-4 text-muted small">{{ loop.index + (page - 1) * 20 }}</td>
  127. <td>
  128. <div class="fw-bold">
  129. {{ member.name }}{% if member.simplified_name %}({{ member.simplified_name }}){% endif %}
  130. </div>
  131. <div class="small text-muted">
  132. {{ '男' if member.sex == 1 else '女' }} | {{ member.birthday_str or '未知' }}
  133. </div>
  134. {% if member.name_word %}
  135. <div class="mt-1">
  136. <span style="display:inline-flex;align-items:center;gap:3px;padding:1px 7px;border-radius:10px;background:#f0f4ff;color:#3b5bdb;font-size:11px;font-weight:500;border:1px solid #d0d9ff;">
  137. <svg width="10" height="10" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg>
  138. 字辈:{{ member.name_word }}
  139. </span>
  140. </div>
  141. {% endif %}
  142. </td>
  143. <td>
  144. {% if member.name_word_generation %}
  145. <div class="d-flex flex-column gap-1">
  146. {% for gen in member.name_word_generation.split(';') %}
  147. {% if gen.strip() %}
  148. <span class="lineage-badge">
  149. <svg class="lineage-icon" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z"/></svg>
  150. {{ gen.strip() }}
  151. </span>
  152. {% endif %}
  153. {% endfor %}
  154. </div>
  155. {% else %}
  156. <span class="text-muted small">-</span>
  157. {% endif %}
  158. </td>
  159. <td>
  160. {% if member.father_id %}
  161. {% set co_labels = {1: '长子', 2: '次子', 3: '三子', 4: '四子', 5: '五子', 6: '六子', 7: '七子', 8: '八子', 9: '九子', 10: '十子'} %}
  162. <a href="{{ url_for('member_detail', member_id=member.father_id) }}"
  163. target="_blank" class="text-decoration-none small fw-medium">
  164. {{ member.father_name }}{% if member.father_simplified_name %}({{ member.father_simplified_name }}){% endif %}
  165. {% if member.child_order_to_father %}
  166. <span class="text-muted">{{ co_labels.get(member.child_order_to_father, '第' ~ member.child_order_to_father ~ '子') }}</span>
  167. {% endif %}
  168. </a>
  169. {% else %}
  170. <span class="text-muted small">-</span>
  171. {% endif %}
  172. {# 兄弟信息 #}
  173. {% if member.siblings %}
  174. {% set sibs = member.siblings %}
  175. {% set first = sibs[0] %}
  176. {% set rest_count = sibs|length - 1 %}
  177. <div class="sibling-summary siblings-wrapper" style="display:block; margin-top:3px;">
  178. 兄弟:<a href="{{ url_for('member_detail', member_id=first.id) }}"
  179. target="_blank"
  180. style="font-size:11.5px; color:#3b5998; text-decoration:none;"
  181. onclick="event.stopPropagation()">{{ first.simplified_name or first.name }}</a>{% if rest_count > 0 %}<span class="sibling-count-badge">+{{ rest_count }}个兄弟</span>{% endif %}
  182. {% if sibs|length > 1 %}
  183. <div class="siblings-popup">
  184. {% for sib in sibs %}
  185. <a href="{{ url_for('member_detail', member_id=sib.id) }}" target="_blank">
  186. {{ sib.simplified_name or sib.name }}
  187. </a>
  188. {% endfor %}
  189. </div>
  190. {% endif %}
  191. </div>
  192. {% endif %}
  193. </td>
  194. <td>
  195. {% if member.occupation %}
  196. <div class="small" style="max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" title="{{ member.occupation }}">
  197. {{ member.occupation[:10] }}{% if member.occupation|length > 10 %}...{% endif %}
  198. </div>
  199. {% else %}
  200. <span class="text-muted small">-</span>
  201. {% endif %}
  202. </td>
  203. <td>
  204. <div class="small">
  205. {{ member.family_rank or '-' }}
  206. </div>
  207. </td>
  208. <td>
  209. <div class="small">
  210. {{ member.branch_family_hall or '-' }}
  211. </div>
  212. </td>
  213. <td>
  214. <div class="small text-truncate" style="max-width: 150px;">
  215. {{ member.residential_address or '-' }}
  216. </div>
  217. </td>
  218. <td>
  219. {% if member.is_pass_away == 1 %}
  220. <span class="badge bg-secondary">已故</span>
  221. {% elif member.is_pass_away == 2 %}
  222. <span class="badge bg-warning">未知</span>
  223. {% else %}
  224. <span class="badge bg-success">健在</span>
  225. {% endif %}
  226. {% if member.modified_time_str %}
  227. <div class="text-muted" style="font-size: 0.75rem;">修改: {{ member.modified_time_str }}</div>
  228. {% else %}
  229. <div class="text-muted" style="font-size: 0.75rem;">录入: {{ member.create_time_str or '-' }}</div>
  230. {% endif %}
  231. </td>
  232. <td class="text-center">
  233. <div class="btn-group btn-group-sm">
  234. <a href="{{ url_for('member_detail', member_id=member.id) }}" class="btn btn-outline-info">
  235. <i class="bi bi-eye"></i> 详情
  236. </a>
  237. <a href="{{ url_for('edit_member', member_id=member.id) }}" class="btn btn-outline-primary">
  238. <i class="bi bi-pencil"></i> 编辑
  239. </a>
  240. <button type="button" class="btn btn-outline-danger" onclick="confirmDelete({{ member.id }}, '{{ member.name }}')">
  241. <i class="bi bi-trash"></i> 删除
  242. </button>
  243. </div>
  244. </td>
  245. </tr>
  246. {% endfor %}
  247. {% if not members %}
  248. <tr>
  249. <td colspan="9" class="text-center py-5 text-muted">
  250. <i class="bi bi-person-x fs-1 d-block mb-2"></i>
  251. 暂无成员数据
  252. </td>
  253. </tr>
  254. {% endif %}
  255. </tbody>
  256. </table>
  257. </div>
  258. </div>
  259. <!-- 分页控件 -->
  260. {% if total_pages > 1 %}
  261. <nav class="mt-4">
  262. <ul class="pagination justify-content-center">
  263. <li class="page-item {{ 'disabled' if page == 1 }}">
  264. <a class="page-link" href="{{ url_for('members', page=page-1, name=search_name, search_type=search_type) }}">上一页</a>
  265. </li>
  266. {% for p in range(1, total_pages + 1) %}
  267. {% if p == page %}
  268. <li class="page-item active"><span class="page-link">{{ p }}</span></li>
  269. {% else %}
  270. {# Show first, last, and around current page #}
  271. {% if p == 1 or p == total_pages or (p >= page - 2 and p <= page + 2) %}
  272. <li class="page-item"><a class="page-link" href="{{ url_for('members', page=p, name=search_name, search_type=search_type) }}">{{ p }}</a></li>
  273. {% elif p == page - 3 or p == page + 3 %}
  274. <li class="page-item disabled"><span class="page-link">...</span></li>
  275. {% endif %}
  276. {% endif %}
  277. {% endfor %}
  278. <li class="page-item {{ 'disabled' if page == total_pages }}">
  279. <a class="page-link" href="{{ url_for('members', page=page+1, name=search_name, search_type=search_type) }}">下一页</a>
  280. </li>
  281. </ul>
  282. <div class="text-center text-muted small mt-2">
  283. 共 {{ total }} 条记录,当前第 {{ page }} / {{ total_pages }} 页
  284. </div>
  285. </nav>
  286. {% endif %}
  287. </div>
  288. {% endblock %}
  289. {% block extra_js %}
  290. <script>
  291. function confirmDelete(id, name) {
  292. if (confirm(`确定要删除成员 "${name}" 吗?此操作将同时删除与其相关的所有家谱关系,且不可恢复。`)) {
  293. const form = document.createElement('form');
  294. form.method = 'POST';
  295. form.action = `/manager/delete_member/${id}`;
  296. document.body.appendChild(form);
  297. form.submit();
  298. }
  299. }
  300. </script>
  301. {% endblock %}