diff --git a/web-admin/health-checkup/archive-personal.html b/web-admin/health-checkup/archive-personal.html
index b99cab2..1367090 100644
--- a/web-admin/health-checkup/archive-personal.html
+++ b/web-admin/health-checkup/archive-personal.html
@@ -117,11 +117,17 @@
-
+
+
+
+
+
@@ -130,12 +136,6 @@
-
-
-
-
@@ -378,7 +379,7 @@ function switchType(type){
document.getElementById('pane-' + type).classList.add('active');
}
-/* ===== 新增医院抽屉 ===== */
+/* ===== 新增/编辑医院抽屉 ===== */
var hospitalData = {
'h1': { name: '西安市中心医院', address: '西安市新城区西五路161号', intro: '西安市中心医院体检中心' },
'h2': { name: '陕西省人民医院', address: '西安市碑林区友谊西路256号', intro: '陕西省人民医院健康管理中心' },
@@ -387,13 +388,26 @@ var hospitalData = {
'h5': { name: '宝鸡市人民医院', address: '宝鸡市渭滨区经二路185号', intro: '宝鸡市人民医院体检科' }
};
-function openDrawer(){
- var isNormal = currentType === 'normal';
- document.getElementById('drawer-title').textContent = isNormal ? '新增常规体检医院' : '新增胃肠镜体检医院';
- document.getElementById('normal-fields').style.display = isNormal ? '' : 'none';
- document.getElementById('gastro-fields').style.display = isNormal ? 'none' : '';
- document.getElementById('hospital-drawer').classList.add('open');
- document.getElementById('drawer-overlay').classList.add('open');
+/* 当前正在编辑的行(null 表示新增) */
+var editingRow = null;
+
+/* 抽屉内是否锁定医院选择(编辑时医院不可更换) */
+function setHospitalLocked(locked, name, address){
+ var input = document.getElementById('search-input');
+ if(locked){
+ input.value = name || '';
+ input.readOnly = true;
+ input.placeholder = '';
+ var info = document.getElementById('hospital-info');
+ document.getElementById('hospital-address').textContent = address || '';
+ if(address) info.classList.add('show');
+ } else {
+ input.readOnly = false;
+ input.placeholder = '请输入医院名称搜索';
+ }
+}
+
+function resetDrawerFields(){
document.getElementById('search-input').value = '';
document.getElementById('search-value').value = '';
document.getElementById('hospital-info').classList.remove('show');
@@ -407,6 +421,53 @@ function openDrawer(){
document.getElementById('form-card-reg').value = '';
}
+function openDrawer(){
+ editingRow = null;
+ var isNormal = currentType === 'normal';
+ document.getElementById('drawer-title').textContent = isNormal ? '新增常规体检医院' : '新增胃肠镜体检医院';
+ document.getElementById('normal-fields').style.display = isNormal ? '' : 'none';
+ document.getElementById('gastro-fields').style.display = isNormal ? 'none' : '';
+ resetDrawerFields();
+ setHospitalLocked(false);
+ document.getElementById('hospital-drawer').classList.add('open');
+ document.getElementById('drawer-overlay').classList.add('open');
+}
+
+/* 读取单元格文本 */
+function readTd(tr, i){
+ var td = tr.children[i];
+ return td ? td.textContent.trim() : '';
+}
+
+/* 打开编辑抽屉:按行数据回填,医院锁定不可改 */
+function openEditDrawer(btn){
+ editingRow = btn.closest('tr');
+ var isNormal = currentType === 'normal';
+ resetDrawerFields();
+ if(isNormal){
+ document.getElementById('drawer-title').textContent = '编辑常规体检医院';
+ document.getElementById('normal-fields').style.display = '';
+ document.getElementById('gastro-fields').style.display = 'none';
+ setHospitalLocked(true, readTd(editingRow, 1), readTd(editingRow, 3));
+ document.querySelectorAll('input[name="hos-type"]').forEach(function(r){ r.checked = (r.value === readTd(editingRow, 2)); });
+ document.getElementById('switch-oc').classList.toggle('on', readTd(editingRow, 6) === '是');
+ document.getElementById('form-sort-normal').value = readTd(editingRow, 7);
+ } else {
+ document.getElementById('drawer-title').textContent = '编辑胃肠镜体检医院';
+ document.getElementById('normal-fields').style.display = 'none';
+ document.getElementById('gastro-fields').style.display = '';
+ setHospitalLocked(true, readTd(editingRow, 1), readTd(editingRow, 2));
+ var needCard = readTd(editingRow, 5) === '是';
+ document.getElementById('switch-card').classList.toggle('on', needCard);
+ document.getElementById('card-reg-item').style.display = needCard ? '' : 'none';
+ document.getElementById('form-sort-gastro').value = readTd(editingRow, 6);
+ document.getElementById('form-gastro-notice').value = editingRow.dataset.notice || '';
+ document.getElementById('form-card-reg').value = editingRow.dataset.cardreg || '';
+ }
+ document.getElementById('hospital-drawer').classList.add('open');
+ document.getElementById('drawer-overlay').classList.add('open');
+}
+
function closeDrawer(){
document.getElementById('hospital-drawer').classList.remove('open');
document.getElementById('drawer-overlay').classList.remove('open');
@@ -466,6 +527,7 @@ function onHospitalChange(){
}
input.addEventListener('focus', function(){
+ if(this.readOnly) return;
renderOptions(this.value);
dropdown.classList.add('show');
});
@@ -482,49 +544,98 @@ function onHospitalChange(){
});
})();
-/* 保存新增医院 */
+/* 单元格操作链接(新增与编辑行共用) */
+var ROW_ACTIONS = '编辑 删除 | ';
+var HOSPITAL_IMG = (document.querySelector('.hospital-img') || {}).getAttribute ? document.querySelector('.hospital-img').getAttribute('src') : '';
+
+/* 刷新某个表格的序号列 */
+function refreshSeq(tbody){
+ tbody.querySelectorAll('tr').forEach(function(tr, i){ tr.children[0].textContent = i + 1; });
+}
+
+/* 生成常规体检行 HTML */
+function buildNormalRow(data, hosType, oc, sort){
+ return ' | '
+ + '' + data.name + ' | '
+ + '' + hosType + ' | '
+ + '' + data.address + ' | '
+ + ' | '
+ + '' + data.intro + ' | '
+ + '' + (oc ? '是' : '否') + ' | '
+ + '' + sort + ' | '
+ + ROW_ACTIONS;
+}
+
+/* 生成胃肠镜体检行 HTML */
+function buildGastroRow(data, needCard, sort){
+ return ' | '
+ + '' + data.name + ' | '
+ + '' + data.address + ' | '
+ + ' | '
+ + '' + data.intro + ' | '
+ + '' + (needCard ? '是' : '否') + ' | '
+ + '' + sort + ' | '
+ + ROW_ACTIONS;
+}
+
+/* 保存(新增或编辑) */
function saveHospital(){
+ var isNormal = currentType === 'normal';
+ var tbody = document.getElementById(isNormal ? 'normal-tbody' : 'gastro-tbody');
+
+ if(editingRow){
+ /* 编辑:医院不变,更新可变列 */
+ if(isNormal){
+ var hosTypeEl = document.querySelector('input[name="hos-type"]:checked');
+ if(!hosTypeEl){ alert('请选择医院类型'); return; }
+ var sort = document.getElementById('form-sort-normal').value.trim() || editingRow.children[7].textContent.trim();
+ var oc = document.getElementById('switch-oc').classList.contains('on');
+ editingRow.children[2].textContent = hosTypeEl.value;
+ editingRow.children[6].textContent = oc ? '是' : '否';
+ editingRow.children[7].textContent = sort;
+ } else {
+ var needCard = document.getElementById('switch-card').classList.contains('on');
+ var sortG = document.getElementById('form-sort-gastro').value.trim() || editingRow.children[6].textContent.trim();
+ editingRow.children[5].textContent = needCard ? '是' : '否';
+ editingRow.children[6].textContent = sortG;
+ editingRow.dataset.notice = document.getElementById('form-gastro-notice').value;
+ editingRow.dataset.cardreg = document.getElementById('form-card-reg').value;
+ }
+ closeDrawer();
+ return;
+ }
+
+ /* 新增:需从医院库选择 */
var value = document.getElementById('search-value').value;
if(!value || !hospitalData[value]){ alert('请选择医院'); return; }
var data = hospitalData[value];
- var isNormal = currentType === 'normal';
- var tbody = document.getElementById(isNormal ? 'normal-tbody' : 'gastro-tbody');
var seq = tbody.querySelectorAll('tr').length + 1;
- var imgSrc = (document.querySelector('.hospital-img') || {}).getAttribute ? document.querySelector('.hospital-img').getAttribute('src') : '';
-
+ var tr = document.createElement('tr');
if(isNormal){
var hosTypeEl = document.querySelector('input[name="hos-type"]:checked');
if(!hosTypeEl){ alert('请选择医院类型'); return; }
- var hosType = hosTypeEl.value;
var sort = document.getElementById('form-sort-normal').value.trim() || String(seq);
- var oc = document.getElementById('switch-oc').classList.contains('on');
- var tr = document.createElement('tr');
- tr.innerHTML = '' + seq + ' | '
- + '' + data.name + ' | '
- + '' + hosType + ' | '
- + '' + data.address + ' | '
- + ' | '
- + '' + data.intro + ' | '
- + '' + (oc ? '是' : '否') + ' | '
- + '' + sort + ' | '
- + '编辑 删除 | ';
- tbody.appendChild(tr);
+ tr.innerHTML = buildNormalRow(data, hosTypeEl.value, document.getElementById('switch-oc').classList.contains('on'), sort);
} else {
var needCard = document.getElementById('switch-card').classList.contains('on');
var sortG = document.getElementById('form-sort-gastro').value.trim() || String(seq);
- var tr2 = document.createElement('tr');
- tr2.innerHTML = '' + seq + ' | '
- + '' + data.name + ' | '
- + '' + data.address + ' | '
- + ' | '
- + '' + data.intro + ' | '
- + '' + (needCard ? '是' : '否') + ' | '
- + '' + sortG + ' | '
- + '编辑 删除 | ';
- tbody.appendChild(tr2);
+ tr.innerHTML = buildGastroRow(data, needCard, sortG);
+ tr.dataset.notice = document.getElementById('form-gastro-notice').value;
+ tr.dataset.cardreg = document.getElementById('form-card-reg').value;
}
+ tbody.appendChild(tr);
+ tr.children[0].textContent = seq;
closeDrawer();
}
+
+/* 删除行 */
+function deleteRow(btn){
+ if(!confirm('确认删除该医院?')) return;
+ var tr = btn.closest('tr');
+ var tbody = tr.parentElement;
+ tr.remove();
+ refreshSeq(tbody);
+}