PHP_WORKS/modules/departments/list.php
2025-05-30 11:10:29 +08:00

207 lines
14 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>科室管理 - 电子病历系统</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet">
<link href="../../css/material.css" rel="stylesheet">
</head>
<body>
<header class="header">
<h1>
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M12,11.5A2.5,2.5 0 0,1 9.5,9A2.5,2.5 0 0,1 12,6.5A2.5,2.5 0 0,1 14.5,9A2.5,2.5 0 0,1 12,11.5M12,2A7,7 0 0,0 5,9C5,14.25 12,22 12,22C12,22 19,14.25 19,9A7,7 0 0,0 12,2Z"/>
</svg>
科室管理
</h1>
</header>
<nav class="nav-menu">
<ul>
<li><a href="../../index.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M10,20V14H14V20H19V12H22L12,3L2,12H5V20H10Z"/>
</svg>
仪表板
</a></li>
<li><a href="../patients/list.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M12,4A4,4 0 0,1 16,8A4,4 0 0,1 12,12A4,4 0 0,1 8,8A4,4 0 0,1 12,4M12,14C16.42,14 20,15.79 20,18V20H4V18C4,15.79 7.58,14 12,14Z"/>
</svg>
患者管理
</a></li>
<li><a href="../doctors/list.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M14.84,2.5C16.2,2.5 17.5,3.2 18.28,4.38L18.5,4.75L19.25,4.38C19.92,4 20.75,4.2 21.13,4.87C21.5,5.54 21.33,6.42 20.66,6.79L20.04,7.12C20.04,7.12 20.04,7.12 20.04,7.12C20.47,7.88 20.47,8.78 20.04,9.54L20.5,9.78C21.17,10.15 21.33,11.04 20.97,11.71C20.6,12.38 19.72,12.54 19.05,12.17L18.5,11.88C17.71,13.07 16.39,13.77 15.04,13.77C13.68,13.77 12.36,13.07 11.57,11.88L11,12.17C10.33,12.54 9.45,12.38 9.08,11.71C8.71,11.04 8.88,10.15 9.55,9.78L10,9.54C9.58,8.78 9.58,7.88 10,7.12L9.38,6.79C8.71,6.42 8.55,5.54 8.92,4.87C9.29,4.2 10.17,4 10.84,4.38L11.57,4.75C12.35,3.56 13.67,2.86 15.04,2.86M15.04,4.64C14.18,4.64 13.4,5.09 12.96,5.78L12.5,6.5L11.78,6.06C11.58,5.94 11.32,6 11.19,6.21C11.07,6.42 11.13,6.68 11.34,6.81L12.06,7.25L11.78,7.94C11.58,8.38 11.58,8.87 11.78,9.31L12.06,10L11.34,10.44C11.13,10.57 11.07,10.83 11.19,11.04C11.32,11.25 11.58,11.31 11.78,11.19L12.5,10.75L12.96,11.47C13.4,12.16 14.18,12.61 15.04,12.61C15.9,12.61 16.68,12.16 17.12,11.47L17.58,10.75L18.3,11.19C18.5,11.31 18.76,11.25 18.89,11.04C19.01,10.83 18.95,10.57 18.74,10.44L18.02,10L18.3,9.31C18.5,8.87 18.5,8.38 18.3,7.94L18.02,7.25L18.74,6.81C18.95,6.68 19.01,6.42 18.89,6.21C18.76,6 18.5,5.94 18.3,6.06L17.58,6.5L17.12,5.78C16.68,5.09 15.9,4.64 15.04,4.64M11,15.5V17.5H3V15.5C3,14.39 6.69,13.5 9.5,13.5C10.4,13.5 11.5,13.65 12.5,13.91C11.84,14.8 11.5,15.88 11.5,17C11.34,16.83 11.17,16.66 11,15.5M9.5,12A2.5,2.5 0 0,1 7,9.5A2.5,2.5 0 0,1 9.5,7A2.5,2.5 0 0,1 12,9.5A2.5,2.5 0 0,1 9.5,12Z"/>
</svg>
医生管理
</a></li>
<li><a href="../medical_records/list.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20Z"/>
</svg>
病历管理
</a></li>
<li><a href="list.php" class="active">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M12,11.5A2.5,2.5 0 0,1 9.5,9A2.5,2.5 0 0,1 12,6.5A2.5,2.5 0 0,1 14.5,9A2.5,2.5 0 0,1 12,11.5M12,2A7,7 0 0,0 5,9C5,14.25 12,22 12,22C12,22 19,14.25 19,9A7,7 0 0,0 12,2Z"/>
</svg>
科室管理
</a></li>
<li><a href="../medications/list.php">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M17,3C18.1,3 19,3.9 19,5V8H21V10H19V19C19,20.1 18.1,21 17,21H7C5.9,21 5,20.1 5,19V10H3V8H5V5C5,3.9 5.9,3 7,3H17M7,5V8H17V5H7M7,10V19H17V10H7M9,12H15V14H9V12M9,15H13V17H9V15Z"/>
</svg>
药品管理
</a></li>
</ul>
</nav>
<div class="container">
<div class="grid grid-2">
<div class="card">
<div class="card-header">
<h2 class="card-title">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M12,11.5A2.5,2.5 0 0,1 9.5,9A2.5,2.5 0 0,1 12,6.5A2.5,2.5 0 0,1 14.5,9A2.5,2.5 0 0,1 12,11.5M12,2A7,7 0 0,0 5,9C5,14.25 12,22 12,22C12,22 19,14.25 19,9A7,7 0 0,0 12,2Z"/>
</svg>
科室列表
</h2>
</div>
<div class="card-content">
<?php
include "../../conn/conn.php";
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['action'])) {
if ($_POST['action'] == 'add') {
$name = mysqli_real_escape_string($connID, $_POST['name']);
$description = mysqli_real_escape_string($connID, $_POST['description']);
$phone = mysqli_real_escape_string($connID, $_POST['phone']);
$location = mysqli_real_escape_string($connID, $_POST['location']);
$sql = "INSERT INTO departments (name, description, phone, location) VALUES ('$name', '$description', '$phone', '$location')";
if (mysqli_query($connID, $sql)) {
echo '<div class="alert alert-success">科室添加成功!</div>';
} else {
echo '<div class="alert alert-error">添加失败:' . mysqli_error($connID) . '</div>';
}
}
}
$sql = "SELECT d.*, COUNT(doc.id) as doctor_count FROM departments d
LEFT JOIN doctors doc ON d.id = doc.department_id
GROUP BY d.id ORDER BY d.name";
$result = mysqli_query($connID, $sql);
?>
<div style="max-height: 600px; overflow-y: auto;">
<?php while($department = mysqli_fetch_assoc($result)): ?>
<div class="card" style="margin-bottom: 16px; border: 1px solid #e0e0e0;">
<div class="card-content" style="padding: 16px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
<h4 style="margin: 0; color: #1976d2;"><?php echo htmlspecialchars($department['name']); ?></h4>
<span class="status-badge status-processing"><?php echo $department['doctor_count']; ?> 名医生</span>
</div>
<?php if($department['description']): ?>
<p style="margin: 8px 0; color: #666; font-size: 14px;"><?php echo htmlspecialchars($department['description']); ?></p>
<?php endif; ?>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 14px; color: #666;">
<div>
<svg class="icon" style="width: 16px; height: 16px; margin-right: 4px;" viewBox="0 0 24 24" fill="currentColor">
<path d="M6.62,10.79C6.57,10.62 6.54,10.45 6.54,10.25C6.54,9.43 7.17,8.79 7.96,8.79C8.76,8.79 9.4,9.43 9.4,10.25C9.4,10.45 9.37,10.62 9.32,10.79L12,17.25L14.68,10.79C14.63,10.62 14.6,10.45 14.6,10.25C14.6,9.43 15.24,8.79 16.04,8.79C16.83,8.79 17.46,9.43 17.46,10.25C17.46,10.45 17.43,10.62 17.38,10.79L16.15,14.68L20.84,11.32C21.55,10.83 22.5,11.03 22.95,11.75C23.4,12.47 23.2,13.42 22.5,13.87L17.81,17.23L18.58,19.54C18.78,20.22 18.43,20.96 17.75,21.16C17.07,21.36 16.33,21 16.13,20.32L15.36,18.01L12,19.75L8.64,18.01L7.87,20.32C7.67,21 6.93,21.36 6.25,21.16C5.57,20.96 5.22,20.22 5.42,19.54L6.19,17.23L1.5,13.87C0.8,13.42 0.6,12.47 1.05,11.75C1.5,11.03 2.45,10.83 3.16,11.32L7.85,14.68L6.62,10.79Z"/>
</svg>
电话:<?php echo htmlspecialchars($department['phone'] ?: '未设置'); ?>
</div>
<div>
<svg class="icon" style="width: 16px; height: 16px; margin-right: 4px;" viewBox="0 0 24 24" fill="currentColor">
<path d="M12,2A7,7 0 0,1 19,9C19,14.25 12,22 12,22C12,22 5,14.25 5,9A7,7 0 0,1 12,2M12,4A5,5 0 0,0 7,9C7,10 7,12 12,18.71C17,12 17,10 17,9A5,5 0 0,0 12,4M12,7A2,2 0 0,1 14,9A2,2 0 0,1 12,11A2,2 0 0,1 10,9A2,2 0 0,1 12,7Z"/>
</svg>
位置:<?php echo htmlspecialchars($department['location'] ?: '未设置'); ?>
</div>
</div>
<div style="margin-top: 12px; display: flex; gap: 8px;">
<a href="../doctors/list.php?department=<?php echo $department['id']; ?>" class="btn btn-small btn-primary">查看医生</a>
<button onclick="editDepartment(<?php echo $department['id']; ?>, '<?php echo htmlspecialchars($department['name']); ?>', '<?php echo htmlspecialchars($department['description']); ?>', '<?php echo htmlspecialchars($department['phone']); ?>', '<?php echo htmlspecialchars($department['location']); ?>')" class="btn btn-small btn-warning">编辑</button>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<h2 class="card-title">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z"/>
</svg>
新增科室
</h2>
</div>
<div class="card-content">
<form method="POST" id="departmentForm">
<input type="hidden" name="action" value="add" id="formAction">
<input type="hidden" name="department_id" id="departmentId">
<div class="form-group">
<label class="form-label">科室名称 *</label>
<input type="text" name="name" id="departmentName" class="form-control" required>
</div>
<div class="form-group">
<label class="form-label">科室描述</label>
<textarea name="description" id="departmentDescription" class="form-control" rows="3" placeholder="科室的主要职能和专业范围"></textarea>
</div>
<div class="form-group">
<label class="form-label">联系电话</label>
<input type="tel" name="phone" id="departmentPhone" class="form-control">
</div>
<div class="form-group">
<label class="form-label">科室位置</label>
<input type="text" name="location" id="departmentLocation" class="form-control" placeholder="如1楼101室">
</div>
<div style="display: flex; gap: 16px; margin-top: 24px;">
<button type="submit" class="btn btn-primary" id="submitBtn">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/>
</svg>
<span id="submitText">保存科室</span>
</button>
<button type="button" onclick="resetForm()" class="btn" style="background: #f5f5f5; color: #666;">
<svg class="icon" viewBox="0 0 24 24" fill="currentColor">
<path d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"/>
</svg>
重置
</button>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
function editDepartment(id, name, description, phone, location) {
document.getElementById('formAction').value = 'edit';
document.getElementById('departmentId').value = id;
document.getElementById('departmentName').value = name;
document.getElementById('departmentDescription').value = description;
document.getElementById('departmentPhone').value = phone;
document.getElementById('departmentLocation').value = location;
document.getElementById('submitText').textContent = '更新科室';
}
function resetForm() {
document.getElementById('departmentForm').reset();
document.getElementById('formAction').value = 'add';
document.getElementById('departmentId').value = '';
document.getElementById('submitText').textContent = '保存科室';
}
</script>
</body>
</html>