|
|
@@ -648,33 +648,114 @@
|
|
|
breadcrumb.textContent = '首页 > 院区信息管理 > 病房管理';
|
|
|
mainContent.innerHTML = `
|
|
|
<div style="background: white; padding: 20px; box-shadow: 0 2px 10px rgba(0,0,0,0.1);">
|
|
|
- <table class="data-table">
|
|
|
+ <div style="display: flex; justify-content: space-between; margin-bottom: 15px; flex-wrap: wrap; gap: 10px;">
|
|
|
+ <div style="display: flex; flex-wrap: wrap; gap: 10px;">
|
|
|
+ <div>
|
|
|
+ <input type="text" id="roomCode" placeholder="病房代码" style="padding: 6px; border: 1px solid #ddd; border-radius: 4px; width: 120px;">
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <select id="roomDepartment" style="padding: 6px; border: 1px solid #ddd; border-radius: 4px; width: 120px;">
|
|
|
+ <option value="">请选择科室</option>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <select id="roomWard" style="padding: 6px; border: 1px solid #ddd; border-radius: 4px; width: 120px;">
|
|
|
+ <option value="">请选择病区</option>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <select id="roomEnabled" style="padding: 6px; border: 1px solid #ddd; border-radius: 4px; width: 100px;">
|
|
|
+ <option value="">是否启用</option>
|
|
|
+ <option value="true">是</option>
|
|
|
+ <option value="false">否</option>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <button class="btn btn-primary" onclick="searchRooms()" style="padding: 6px 12px;">查询</button>
|
|
|
+ <button class="btn btn-secondary" onclick="clearRoomSearch()" style="padding: 6px 12px;">重置</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <table class="data-table" id="roomTable">
|
|
|
<thead>
|
|
|
<tr>
|
|
|
- <th>病房编号</th>
|
|
|
+ <th>病房代码</th>
|
|
|
+ <th>病房外部代码</th>
|
|
|
<th>病房名称</th>
|
|
|
+ <th>额定床位</th>
|
|
|
+ <th>所属科室</th>
|
|
|
<th>所属病区</th>
|
|
|
- <th>床位数量</th>
|
|
|
- <th>状态</th>
|
|
|
+ <th>排序号</th>
|
|
|
+ <th>是否启用</th>
|
|
|
+ <th>备注</th>
|
|
|
<th>操作</th>
|
|
|
</tr>
|
|
|
</thead>
|
|
|
- <tbody>
|
|
|
- <tr>
|
|
|
- <td>R001</td>
|
|
|
- <td>101病房</td>
|
|
|
- <td>内科一病区</td>
|
|
|
- <td>4</td>
|
|
|
- <td>可用</td>
|
|
|
- <td>
|
|
|
- <button class="btn btn-primary">编辑</button>
|
|
|
- <button class="btn btn-danger">删除</button>
|
|
|
- </td>
|
|
|
- </tr>
|
|
|
+ <tbody id="roomTableBody">
|
|
|
+ <!-- 数据将通过JS动态加载 -->
|
|
|
</tbody>
|
|
|
</table>
|
|
|
</div>
|
|
|
+
|
|
|
+ <!-- 病房详情模态框 -->
|
|
|
+ <div id="roomModal" style="display:none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.4); overflow: auto; padding: 50px 0;">
|
|
|
+ <div style="background-color: #fff; margin: 0 auto; padding: 0; border: 1px solid #888; width: 80%; max-width: 600px; border-radius: 5px; max-height: 80%; display: flex; flex-direction: column;">
|
|
|
+ <div style="padding: 20px; border-bottom: 1px solid #eee;">
|
|
|
+ <h2 style="margin-top: 0;">病房详情</h2>
|
|
|
+ </div>
|
|
|
+ <div style="overflow-y: auto; flex: 1; padding: 15px;">
|
|
|
+ <div class="form-group">
|
|
|
+ <label>病房代码:</label>
|
|
|
+ <input type="text" id="modalCode" readonly style="width: 100%; padding: 6px;">
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label>病房外部代码:</label>
|
|
|
+ <input type="text" id="modalOutCode" readonly style="width: 100%; padding: 6px;">
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label>病房名称:</label>
|
|
|
+ <input type="text" id="modalName" readonly style="width: 100%; padding: 6px;">
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label>额定床位:</label>
|
|
|
+ <input type="text" id="modalBedCount" readonly style="width: 100%; padding: 6px;">
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label>所属科室:</label>
|
|
|
+ <input type="text" id="modalBelongDept" readonly style="width: 100%; padding: 6px;">
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label>所属病区:</label>
|
|
|
+ <input type="text" id="modalBelongWard" readonly style="width: 100%; padding: 6px;">
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label>排序号:</label>
|
|
|
+ <input type="text" id="modalSort" readonly style="width: 100%; padding: 6px;">
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label>是否启用:</label>
|
|
|
+ <input type="text" id="modalEnabled" readonly style="width: 100%; padding: 6px;">
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label>备注:</label>
|
|
|
+ <textarea id="modalRemark" readonly style="width: 100%; padding: 6px; height: 80px;"></textarea>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div style="padding: 20px; border-top: 1px solid #eee; text-align: right;">
|
|
|
+ <button class="btn btn-secondary" onclick="closeRoomModal()">关闭</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
`;
|
|
|
+ // 使用setTimeout确保DOM元素完全加载后再加载数据
|
|
|
+ setTimeout(function() {
|
|
|
+ // 加载科室下拉框数据
|
|
|
+ loadDepartmentOptions();
|
|
|
+ // 加载病区下拉框数据
|
|
|
+ loadWardOptions();
|
|
|
+ // 加载病房数据
|
|
|
+ loadRoomData();
|
|
|
+ }, 0);
|
|
|
break;
|
|
|
|
|
|
case 'bedManagement':
|
|
|
@@ -1257,71 +1338,6 @@
|
|
|
console.error('加载科室数据失败:', error);
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- // 显示新增科室表单
|
|
|
- function showAddDepartmentForm() {
|
|
|
- alert('显示新增科室表单');
|
|
|
- }
|
|
|
-
|
|
|
- // 查询科室
|
|
|
- function searchDepartments() {
|
|
|
- const name = document.getElementById('departmentName').value;
|
|
|
- const enabled = document.getElementById('enabled').value;
|
|
|
-
|
|
|
- // 构建查询参数
|
|
|
- let url = '/shixian/api/departments';
|
|
|
- const params = [];
|
|
|
-
|
|
|
- if (name) {
|
|
|
- params.push(`name=${encodeURIComponent(name)}`);
|
|
|
- }
|
|
|
-
|
|
|
- if (enabled !== '') {
|
|
|
- params.push(`enabled=${enabled}`);
|
|
|
- }
|
|
|
-
|
|
|
- if (params.length > 0) {
|
|
|
- url += '?' + params.join('&');
|
|
|
- }
|
|
|
-
|
|
|
- fetch(url)
|
|
|
- .then(response => response.json())
|
|
|
- .then(data => {
|
|
|
- const tbody = document.getElementById('departmentTableBody');
|
|
|
- tbody.innerHTML = '';
|
|
|
-
|
|
|
- data.forEach(dept => {
|
|
|
- const row = document.createElement('tr');
|
|
|
- row.innerHTML = `
|
|
|
- <td>${dept.code}</td>
|
|
|
- <td>${dept.outCode}</td>
|
|
|
- <td>${dept.name}</td>
|
|
|
- <td>${dept.address || ''}</td>
|
|
|
- <td>${dept.telephone || ''}</td>
|
|
|
- <td>${dept.introduction || ''}</td>
|
|
|
- <td>${dept.enabled ? '是' : '否'}</td>
|
|
|
- <td>${dept.remark || ''}</td>
|
|
|
- <td>
|
|
|
- <button class="btn btn-primary" onclick="viewDepartment('${dept.code}')">详情</button>
|
|
|
- </td>
|
|
|
- `;
|
|
|
- tbody.appendChild(row);
|
|
|
- });
|
|
|
- })
|
|
|
- .catch(error => {
|
|
|
- console.error('查询科室数据失败:', error);
|
|
|
- alert('查询失败,请稍后重试');
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- // 清空查询条件
|
|
|
- function clearSearch() {
|
|
|
- document.getElementById('departmentName').value = '';
|
|
|
- document.getElementById('enabled').value = '';
|
|
|
- // 重新加载所有数据
|
|
|
- loadDepartmentData();
|
|
|
- }
|
|
|
-
|
|
|
// 查看科室详情
|
|
|
function viewDepartment(code) {
|
|
|
// 获取科室数据
|
|
|
@@ -1362,11 +1378,14 @@
|
|
|
window.onclick = function(event) {
|
|
|
const departmentModal = document.getElementById('departmentModal');
|
|
|
const wardModal = document.getElementById('wardModal');
|
|
|
+ const roomModal = document.getElementById('roomModal');
|
|
|
|
|
|
if (event.target === departmentModal) {
|
|
|
departmentModal.style.display = 'none';
|
|
|
} else if (event.target === wardModal) {
|
|
|
wardModal.style.display = 'none';
|
|
|
+ } else if (event.target === roomModal) {
|
|
|
+ roomModal.style.display = 'none';
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -1676,12 +1695,18 @@
|
|
|
document.getElementById('wardModal').style.display = 'none';
|
|
|
}
|
|
|
|
|
|
+ // 关闭病房详情弹窗
|
|
|
+ function closeRoomModal() {
|
|
|
+ document.getElementById('roomModal').style.display = 'none';
|
|
|
+ }
|
|
|
+
|
|
|
// 点击弹窗关闭按钮或按ESC键关闭弹窗
|
|
|
document.addEventListener('keydown', function(event) {
|
|
|
if (event.key === 'Escape') {
|
|
|
const wardModal = document.getElementById('wardModal');
|
|
|
const wardCodeSettingModal = document.getElementById('wardCodeSettingModal');
|
|
|
const departmentModal = document.getElementById('departmentModal');
|
|
|
+ const roomModal = document.getElementById('roomModal');
|
|
|
|
|
|
if (wardModal && wardModal.style.display === 'block') {
|
|
|
wardModal.style.display = 'none';
|
|
|
@@ -1689,6 +1714,8 @@
|
|
|
wardCodeSettingModal.style.display = 'none';
|
|
|
} else if (departmentModal && departmentModal.style.display === 'block') {
|
|
|
departmentModal.style.display = 'none';
|
|
|
+ } else if (roomModal && roomModal.style.display === 'block') {
|
|
|
+ roomModal.style.display = 'none';
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
@@ -1700,6 +1727,182 @@
|
|
|
document.getElementById('wardEnabled').value = '';
|
|
|
loadWardData();
|
|
|
}
|
|
|
+
|
|
|
+ // 加载科室下拉选项
|
|
|
+ function loadDepartmentOptions() {
|
|
|
+ fetch('/shixian/api/departments')
|
|
|
+ .then(response => response.json())
|
|
|
+ .then(data => {
|
|
|
+ const departmentSelect = document.getElementById('roomDepartment');
|
|
|
+ // 清空现有选项
|
|
|
+ departmentSelect.innerHTML = '<option value="">请选择科室</option>';
|
|
|
+
|
|
|
+ // 添加科室选项
|
|
|
+ data.forEach(dept => {
|
|
|
+ const option = document.createElement('option');
|
|
|
+ option.value = dept.name;
|
|
|
+ option.textContent = dept.name;
|
|
|
+ departmentSelect.appendChild(option);
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.error('加载科室数据失败:', error);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 加载病区下拉选项
|
|
|
+ function loadWardOptions() {
|
|
|
+ fetch('/shixian/api/wards')
|
|
|
+ .then(response => response.json())
|
|
|
+ .then(data => {
|
|
|
+ const wardSelect = document.getElementById('roomWard');
|
|
|
+ // 清空现有选项
|
|
|
+ wardSelect.innerHTML = '<option value="">请选择病区</option>';
|
|
|
+
|
|
|
+ // 添加病区选项
|
|
|
+ data.forEach(ward => {
|
|
|
+ const option = document.createElement('option');
|
|
|
+ option.value = ward.name;
|
|
|
+ option.textContent = ward.name;
|
|
|
+ wardSelect.appendChild(option);
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.error('加载病区数据失败:', error);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 加载病房数据
|
|
|
+ function loadRoomData() {
|
|
|
+ // 获取查询条件
|
|
|
+ const code = document.getElementById('roomCode') ? document.getElementById('roomCode').value : '';
|
|
|
+ const department = document.getElementById('roomDepartment') ? document.getElementById('roomDepartment').value : '';
|
|
|
+ const ward = document.getElementById('roomWard') ? document.getElementById('roomWard').value : '';
|
|
|
+ const enabled = document.getElementById('roomEnabled') ? document.getElementById('roomEnabled').value : '';
|
|
|
+
|
|
|
+ // 构建查询参数
|
|
|
+ let url = '/shixian/api/rooms';
|
|
|
+ const params = [];
|
|
|
+ if (code) params.push(`code=${encodeURIComponent(code)}`);
|
|
|
+ if (department) params.push(`department=${encodeURIComponent(department)}`);
|
|
|
+ if (ward) params.push(`ward=${encodeURIComponent(ward)}`);
|
|
|
+ if (enabled !== '') params.push(`enabled=${enabled}`);
|
|
|
+ if (params.length > 0) url += '?' + params.join('&');
|
|
|
+
|
|
|
+ fetch(url)
|
|
|
+ .then(response => response.json())
|
|
|
+ .then(data => {
|
|
|
+ const tbody = document.getElementById('roomTableBody');
|
|
|
+ tbody.innerHTML = '';
|
|
|
+
|
|
|
+ // 注意:这里假设后端直接返回数组,如果不是,需要相应调整
|
|
|
+ // 如果后端返回 {success: true, data: [...]} 这样的结构,则需要解构
|
|
|
+ const rooms = Array.isArray(data) ? data : (data.data || []);
|
|
|
+
|
|
|
+ rooms.forEach(room => {
|
|
|
+ const row = document.createElement('tr');
|
|
|
+ const statusText = room.enabled ? '是' : '否';
|
|
|
+
|
|
|
+ row.innerHTML = `
|
|
|
+ <td>${room.code || ''}</td>
|
|
|
+ <td>${room.outCode || ''}</td>
|
|
|
+ <td>${room.name || ''}</td>
|
|
|
+ <td>${room.bedCount || 0}</td>
|
|
|
+ <td>${room.belongDept || ''}</td>
|
|
|
+ <td>${room.belongWard || ''}</td>
|
|
|
+ <td>${room.sort || ''}</td>
|
|
|
+ <td>${statusText}</td>
|
|
|
+ <td>${room.remark || ''}</td>
|
|
|
+ <td>
|
|
|
+ <button class="btn btn-primary" onclick="viewRoomDetail('${room.code}')">详情</button>
|
|
|
+ </td>
|
|
|
+ `;
|
|
|
+ tbody.appendChild(row);
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.error('加载病房数据失败:', error);
|
|
|
+ alert('加载病房数据失败');
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询病房
|
|
|
+ function searchRooms() {
|
|
|
+ loadRoomData();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 清空查询条件
|
|
|
+ function clearRoomSearch() {
|
|
|
+ document.getElementById('roomCode').value = '';
|
|
|
+ document.getElementById('roomDepartment').value = '';
|
|
|
+ document.getElementById('roomWard').value = '';
|
|
|
+ document.getElementById('roomEnabled').value = '';
|
|
|
+ loadRoomData();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查看病房详情
|
|
|
+ function viewRoomDetail(code) {
|
|
|
+ fetch(`/shixian/api/rooms/${code}`)
|
|
|
+ .then(response => response.json())
|
|
|
+ .then(data => {
|
|
|
+ if (data.success) {
|
|
|
+ const room = data.data;
|
|
|
+
|
|
|
+ // 填充弹窗内容
|
|
|
+ document.getElementById('modalCode').value = room.code || '';
|
|
|
+ document.getElementById('modalOutCode').value = room.outCode || '';
|
|
|
+ document.getElementById('modalName').value = room.name || '';
|
|
|
+ document.getElementById('modalBedCount').value = room.bedCount || '';
|
|
|
+ document.getElementById('modalBelongDept').value = room.belongDept || '';
|
|
|
+ document.getElementById('modalBelongWard').value = room.belongWard || '';
|
|
|
+ document.getElementById('modalSort').value = room.sort || '';
|
|
|
+ document.getElementById('modalEnabled').value = room.enabled ? '是' : '否';
|
|
|
+ document.getElementById('modalRemark').value = room.remark || '';
|
|
|
+
|
|
|
+ // 显示弹窗
|
|
|
+ document.getElementById('roomModal').style.display = 'block';
|
|
|
+ } else {
|
|
|
+ alert('获取病房信息失败: ' + data.message);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.error('获取病房信息失败:', error);
|
|
|
+ alert('获取病房信息失败,请稍后重试');
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 关闭病房详情弹窗
|
|
|
+ function closeRoomModal() {
|
|
|
+ document.getElementById('roomModal').style.display = 'none';
|
|
|
+ }
|
|
|
+
|
|
|
+ // 编辑病房
|
|
|
+ function editRoom(code) {
|
|
|
+ alert('编辑病房: ' + code);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 删除病房
|
|
|
+ function deleteRoom(code) {
|
|
|
+ if (confirm('确定要删除该病房吗?')) {
|
|
|
+ fetch(`/shixian/api/rooms/${code}`, {
|
|
|
+ method: 'DELETE'
|
|
|
+ })
|
|
|
+ .then(response => response.json())
|
|
|
+ .then(data => {
|
|
|
+ if (data.success) {
|
|
|
+ alert('删除成功');
|
|
|
+ // 重新加载数据
|
|
|
+ loadRoomData();
|
|
|
+ } else {
|
|
|
+ alert('删除失败: ' + data.message);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.error('删除病房失败:', error);
|
|
|
+ alert('删除失败,请稍后重试');
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
</script>
|
|
|
</body>
|
|
|
</html>
|