members.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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. <input type="text" name="name" class="form-control" placeholder="输入姓名搜索..." value="{{ search_name or '' }}">
  88. <button class="btn btn-outline-primary" type="submit"><i class="bi bi-search"></i></button>
  89. {% if search_name %}
  90. <a href="{{ url_for('members') }}" class="btn btn-outline-secondary">重置</a>
  91. {% endif %}
  92. </div>
  93. </form>
  94. <a href="{{ url_for('add_member') }}" class="btn btn-primary text-nowrap"><i class="bi bi-plus-lg"></i> 录入新成员</a>
  95. <a href="{{ url_for('suspected_errors') }}" class="btn btn-warning text-nowrap"><i class="bi bi-exclamation-triangle"></i> 疑似汇总</a>
  96. </div>
  97. </div>
  98. <div class="card shadow-sm border-0">
  99. <div class="card-body p-0">
  100. <div class="table-responsive">
  101. <table class="table table-hover align-middle mb-0">
  102. <thead class="table-light">
  103. <tr>
  104. <th class="px-4">序号</th>
  105. <th>基本信息</th>
  106. <th>世系世代</th>
  107. <th>父亲</th>
  108. <th>职业背景</th>
  109. <th>堂内排行</th>
  110. <th>分房 / 堂号</th>
  111. <th>居住地</th>
  112. <th>状态</th>
  113. <th class="text-center">操作</th>
  114. </tr>
  115. </thead>
  116. <tbody>
  117. {% for member in members %}
  118. <tr>
  119. <td class="px-4 text-muted small">{{ loop.index + (page - 1) * 20 }}</td>
  120. <td>
  121. <div class="fw-bold">
  122. {{ member.name }}{% if member.simplified_name %}({{ member.simplified_name }}){% endif %}
  123. </div>
  124. <div class="small text-muted">
  125. {{ '男' if member.sex == 1 else '女' }} | {{ member.birthday_str or '未知' }}
  126. </div>
  127. </td>
  128. <td>
  129. {% if member.name_word_generation %}
  130. <div class="d-flex flex-column gap-1">
  131. {% for gen in member.name_word_generation.split(';') %}
  132. {% if gen.strip() %}
  133. <span class="lineage-badge">
  134. <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>
  135. {{ gen.strip() }}
  136. </span>
  137. {% endif %}
  138. {% endfor %}
  139. </div>
  140. {% else %}
  141. <span class="text-muted small">-</span>
  142. {% endif %}
  143. </td>
  144. <td>
  145. {% if member.father_id %}
  146. {% set co_labels = {1: '长子', 2: '次子', 3: '三子', 4: '四子', 5: '五子', 6: '六子', 7: '七子', 8: '八子', 9: '九子', 10: '十子'} %}
  147. <a href="{{ url_for('member_detail', member_id=member.father_id) }}"
  148. target="_blank" class="text-decoration-none small fw-medium">
  149. {{ member.father_name }}{% if member.father_simplified_name %}({{ member.father_simplified_name }}){% endif %}
  150. {% if member.child_order_to_father %}
  151. <span class="text-muted">{{ co_labels.get(member.child_order_to_father, '第' ~ member.child_order_to_father ~ '子') }}</span>
  152. {% endif %}
  153. </a>
  154. {% else %}
  155. <span class="text-muted small">-</span>
  156. {% endif %}
  157. {# 兄弟信息 #}
  158. {% if member.siblings %}
  159. {% set sibs = member.siblings %}
  160. {% set first = sibs[0] %}
  161. {% set rest_count = sibs|length - 1 %}
  162. <div class="sibling-summary siblings-wrapper" style="display:block; margin-top:3px;">
  163. 兄弟:<a href="{{ url_for('member_detail', member_id=first.id) }}"
  164. target="_blank"
  165. style="font-size:11.5px; color:#3b5998; text-decoration:none;"
  166. onclick="event.stopPropagation()">{{ first.simplified_name or first.name }}</a>{% if rest_count > 0 %}<span class="sibling-count-badge">+{{ rest_count }}个兄弟</span>{% endif %}
  167. {% if sibs|length > 1 %}
  168. <div class="siblings-popup">
  169. {% for sib in sibs %}
  170. <a href="{{ url_for('member_detail', member_id=sib.id) }}" target="_blank">
  171. {{ sib.simplified_name or sib.name }}
  172. </a>
  173. {% endfor %}
  174. </div>
  175. {% endif %}
  176. </div>
  177. {% endif %}
  178. </td>
  179. <td>
  180. {% if member.occupation %}
  181. <div class="small" style="max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" title="{{ member.occupation }}">
  182. {{ member.occupation[:10] }}{% if member.occupation|length > 10 %}...{% endif %}
  183. </div>
  184. {% else %}
  185. <span class="text-muted small">-</span>
  186. {% endif %}
  187. </td>
  188. <td>
  189. <div class="small">
  190. {{ member.family_rank or '-' }}
  191. </div>
  192. </td>
  193. <td>
  194. <div class="small">
  195. {{ member.branch_family_hall or '-' }}
  196. </div>
  197. </td>
  198. <td>
  199. <div class="small text-truncate" style="max-width: 150px;">
  200. {{ member.residential_address or '-' }}
  201. </div>
  202. </td>
  203. <td>
  204. {% if member.is_pass_away == 1 %}
  205. <span class="badge bg-secondary">已故</span>
  206. {% elif member.is_pass_away == 2 %}
  207. <span class="badge bg-warning">未知</span>
  208. {% else %}
  209. <span class="badge bg-success">健在</span>
  210. {% endif %}
  211. {% if member.modified_time_str %}
  212. <div class="text-muted" style="font-size: 0.75rem;">修改: {{ member.modified_time_str }}</div>
  213. {% else %}
  214. <div class="text-muted" style="font-size: 0.75rem;">录入: {{ member.create_time_str or '-' }}</div>
  215. {% endif %}
  216. </td>
  217. <td class="text-center">
  218. <div class="btn-group btn-group-sm">
  219. <a href="{{ url_for('member_detail', member_id=member.id) }}" class="btn btn-outline-info">
  220. <i class="bi bi-eye"></i> 详情
  221. </a>
  222. <a href="{{ url_for('edit_member', member_id=member.id) }}" class="btn btn-outline-primary">
  223. <i class="bi bi-pencil"></i> 编辑
  224. </a>
  225. <button type="button" class="btn btn-outline-danger" onclick="confirmDelete({{ member.id }}, '{{ member.name }}')">
  226. <i class="bi bi-trash"></i> 删除
  227. </button>
  228. </div>
  229. </td>
  230. </tr>
  231. {% endfor %}
  232. {% if not members %}
  233. <tr>
  234. <td colspan="9" class="text-center py-5 text-muted">
  235. <i class="bi bi-person-x fs-1 d-block mb-2"></i>
  236. 暂无成员数据
  237. </td>
  238. </tr>
  239. {% endif %}
  240. </tbody>
  241. </table>
  242. </div>
  243. </div>
  244. <!-- 分页控件 -->
  245. {% if total_pages > 1 %}
  246. <nav class="mt-4">
  247. <ul class="pagination justify-content-center">
  248. <li class="page-item {{ 'disabled' if page == 1 }}">
  249. <a class="page-link" href="{{ url_for('members', page=page-1, name=search_name) }}">上一页</a>
  250. </li>
  251. {% for p in range(1, total_pages + 1) %}
  252. {% if p == page %}
  253. <li class="page-item active"><span class="page-link">{{ p }}</span></li>
  254. {% else %}
  255. {# Show first, last, and around current page #}
  256. {% if p == 1 or p == total_pages or (p >= page - 2 and p <= page + 2) %}
  257. <li class="page-item"><a class="page-link" href="{{ url_for('members', page=p, name=search_name) }}">{{ p }}</a></li>
  258. {% elif p == page - 3 or p == page + 3 %}
  259. <li class="page-item disabled"><span class="page-link">...</span></li>
  260. {% endif %}
  261. {% endif %}
  262. {% endfor %}
  263. <li class="page-item {{ 'disabled' if page == total_pages }}">
  264. <a class="page-link" href="{{ url_for('members', page=page+1, name=search_name) }}">下一页</a>
  265. </li>
  266. </ul>
  267. <div class="text-center text-muted small mt-2">
  268. 共 {{ total }} 条记录,当前第 {{ page }} / {{ total_pages }} 页
  269. </div>
  270. </nav>
  271. {% endif %}
  272. </div>
  273. {% endblock %}
  274. {% block extra_js %}
  275. <script>
  276. function confirmDelete(id, name) {
  277. if (confirm(`确定要删除成员 "${name}" 吗?此操作将同时删除与其相关的所有家谱关系,且不可恢复。`)) {
  278. const form = document.createElement('form');
  279. form.method = 'POST';
  280. form.action = `/manager/delete_member/${id}`;
  281. document.body.appendChild(form);
  282. form.submit();
  283. }
  284. }
  285. </script>
  286. {% endblock %}