|
|
@@ -210,51 +210,53 @@
|
|
|
<div class="section-title">关系录入 (选择关联成员及关系)</div>
|
|
|
<div id="relations-container">
|
|
|
<!-- Existing relations will be added here dynamically -->
|
|
|
- {% if current_relation %}
|
|
|
- <div class="row g-3 mb-1 relation-row" data-index="0">
|
|
|
- <div class="col-md-4">
|
|
|
- <label class="form-label">关联成员</label>
|
|
|
- <div class="input-group">
|
|
|
- <input type="text" class="form-control related-member-display" placeholder="点击选择关联成员" readonly value="{{ selected_member_name }}">
|
|
|
- <input type="hidden" name="relations[0][parent_mid]" class="related_mid" value="{{ current_relation.parent_mid }}">
|
|
|
- <button type="button" class="btn btn-outline-primary select-member-btn" data-index="0" data-bs-toggle="modal" data-bs-target="#memberSelectModal">
|
|
|
- <i class="bi bi-search"></i>
|
|
|
+ {% if relations and relations|length > 0 %}
|
|
|
+ {% for rel in relations %}
|
|
|
+ <div class="row g-3 mb-1 relation-row" data-index="{{ loop.index0 }}">
|
|
|
+ <div class="col-md-4">
|
|
|
+ <label class="form-label">关联成员</label>
|
|
|
+ <div class="input-group">
|
|
|
+ <input type="text" class="form-control related-member-display" placeholder="点击选择关联成员" readonly value="{{ selected_member_names[loop.index0] if selected_member_names and selected_member_names[loop.index0] else '' }}">
|
|
|
+ <input type="hidden" name="relations[{{ loop.index0 }}][parent_mid]" class="related_mid" value="{{ rel.parent_mid }}">
|
|
|
+ <button type="button" class="btn btn-outline-primary select-member-btn" data-index="{{ loop.index0 }}" data-bs-toggle="modal" data-bs-target="#memberSelectModal">
|
|
|
+ <i class="bi bi-search"></i>
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="col-md-3">
|
|
|
+ <label class="form-label">关系类型</label>
|
|
|
+ <select name="relations[{{ loop.index0 }}][relation_type]" class="form-select relation-type">
|
|
|
+ <option value="">-- 请选择 --</option>
|
|
|
+ <option value="1" {{ 'selected' if rel.relation_type == 1 else '' }}>父子 (关联人为父)</option>
|
|
|
+ <option value="2" {{ 'selected' if rel.relation_type == 2 else '' }}>母子 (关联人为母)</option>
|
|
|
+ <option value="10" {{ 'selected' if rel.relation_type == 10 else '' }}>夫妻</option>
|
|
|
+ <option value="11" {{ 'selected' if rel.relation_type == 11 else '' }}>兄弟</option>
|
|
|
+ <option value="12" {{ 'selected' if rel.relation_type == 12 else '' }}>姐妹</option>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ <div class="col-md-3">
|
|
|
+ <label class="form-label">子类型</label>
|
|
|
+ <select name="relations[{{ loop.index0 }}][sub_relation_type]" class="form-select sub-relation-type">
|
|
|
+ <option value="0" {{ 'selected' if rel.sub_relation_type == 0 else '' }}>亲生/正妻</option>
|
|
|
+ <option value="1" {{ 'selected' if rel.sub_relation_type == 1 else '' }}>养父</option>
|
|
|
+ <option value="2" {{ 'selected' if rel.sub_relation_type == 2 else '' }}>出继(亲生父母)</option>
|
|
|
+ <option value="3" {{ 'selected' if rel.sub_relation_type == 3 else '' }}>入继(养父母)</option>
|
|
|
+ <option value="10" {{ 'selected' if rel.sub_relation_type == 10 else '' }}>妾</option>
|
|
|
+ <option value="11" {{ 'selected' if rel.sub_relation_type == 11 else '' }}>外室</option>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ <div class="col-md-2 d-flex align-items-end">
|
|
|
+ <button type="button" class="btn btn-danger w-100 remove-relation-btn" {% if relations|length <= 1 %}style="display: none;"{% endif %}>
|
|
|
+ <i class="bi bi-trash"></i>
|
|
|
</button>
|
|
|
</div>
|
|
|
+ <div class="col-md-2 child-order-wrapper" style="display: {{ 'block' if rel.relation_type in [1,2] else 'none' }};">
|
|
|
+ <label class="form-label">第几子</label>
|
|
|
+ <input type="number" name="relations[{{ loop.index0 }}][child_order]" class="form-control child-order-input"
|
|
|
+ min="1" placeholder="排行(选填)" value="{{ rel.child_order if rel.child_order else '' }}">
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- <div class="col-md-3">
|
|
|
- <label class="form-label">关系类型</label>
|
|
|
- <select name="relations[0][relation_type]" class="form-select relation-type">
|
|
|
- <option value="">-- 请选择 --</option>
|
|
|
- <option value="1" {{ 'selected' if current_relation.relation_type == 1 else '' }}>父子 (关联人为父)</option>
|
|
|
- <option value="2" {{ 'selected' if current_relation.relation_type == 2 else '' }}>母子 (关联人为母)</option>
|
|
|
- <option value="10" {{ 'selected' if current_relation.relation_type == 10 else '' }}>夫妻</option>
|
|
|
- <option value="11" {{ 'selected' if current_relation.relation_type == 11 else '' }}>兄弟</option>
|
|
|
- <option value="12" {{ 'selected' if current_relation.relation_type == 12 else '' }}>姐妹</option>
|
|
|
- </select>
|
|
|
- </div>
|
|
|
- <div class="col-md-3">
|
|
|
- <label class="form-label">子类型</label>
|
|
|
- <select name="relations[0][sub_relation_type]" class="form-select sub-relation-type">
|
|
|
- <option value="0" {{ 'selected' if current_relation.sub_relation_type == 0 else '' }}>亲生/正妻</option>
|
|
|
- <option value="1" {{ 'selected' if current_relation.sub_relation_type == 1 else '' }}>养父</option>
|
|
|
- <option value="2" {{ 'selected' if current_relation.sub_relation_type == 2 else '' }}>出继(亲生父母)</option>
|
|
|
- <option value="3" {{ 'selected' if current_relation.sub_relation_type == 3 else '' }}>入继(养父母)</option>
|
|
|
- <option value="10" {{ 'selected' if current_relation.sub_relation_type == 10 else '' }}>妾</option>
|
|
|
- <option value="11" {{ 'selected' if current_relation.sub_relation_type == 11 else '' }}>外室</option>
|
|
|
- </select>
|
|
|
- </div>
|
|
|
- <div class="col-md-2 d-flex align-items-end">
|
|
|
- <button type="button" class="btn btn-danger w-100 remove-relation-btn" style="display: none;">
|
|
|
- <i class="bi bi-trash"></i>
|
|
|
- </button>
|
|
|
- </div>
|
|
|
- <div class="col-md-2 child-order-wrapper" style="display: {{ 'block' if current_relation.relation_type in [1,2] else 'none' }};">
|
|
|
- <label class="form-label">第几子</label>
|
|
|
- <input type="number" name="relations[0][child_order]" class="form-control child-order-input"
|
|
|
- min="1" placeholder="排行(选填)" value="{{ current_relation.child_order if current_relation.child_order else '' }}">
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ {% endfor %}
|
|
|
{% else %}
|
|
|
<div class="row g-3 mb-1 relation-row" data-index="0">
|
|
|
<div class="col-md-4">
|
|
|
@@ -1143,6 +1145,9 @@
|
|
|
const container = document.getElementById('relations-container');
|
|
|
const newIndex = currentRelationIndex++;
|
|
|
|
|
|
+ // Automatically set currentRelationIndex to the new row
|
|
|
+ window.currentRelationIndex = newIndex;
|
|
|
+
|
|
|
const newRow = document.createElement('div');
|
|
|
newRow.className = 'row g-3 mb-3 relation-row';
|
|
|
newRow.dataset.index = newIndex;
|