基于javaweb+jsp的医院住院管理系统

基于javaweb+jsp的医院住院管理系统

代码实现

<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
    <meta charset="UTF-8">
    <title>病房 管理</title>
    <link rel="stylesheet" href="css/bootstrap.css">
    <link rel="stylesheet" href="css/main.css">
    <script src="js/jquery-3.5.1.js"></script>
</head>

<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container-fluid">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                <span class="sr-only">医院住院管理系统</span> <span class="icon-bar"></span>
                <span class="icon-bar"></span> <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">医院住院管理系统</a>
        <div id="navbar" class="navbar-collapse collapse">
            <ul class="nav navbar-nav navbar-right">
                <li><a href="#">欢迎:<span style="color: yellow">${loginUser.username}</span></a></li>
                <li><a href="AuthServlet?action=logout">退出</a></li>
            </ul>
    </div>
</nav>

<div class="container-fluid">
    <div class="row">
            <!-- 侧边栏 -->
            <jsp:include page="menu.jsp">
                <jsp:param value="active" name="Bingfang_active"/>
            </jsp:include>
        </div>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <div class="row">
                <div class="col-sm-7">
                    <div class="input-group">
                        <input class="form-control" type="hidden" id="searchColumn" name="searchColumn" value="bingfang_name"/>
                    </div>
                </div>
                <div class="col-sm-5">
                    <button type="button" <c:if test="${loginUser.userType != '管理员'}">disabled="disabled" title="没有权限!!!"</c:if> class="btn btn-pill btn-line btn-success" data-toggle="modal" data-target="#modal-add">添加病房 
                    </button>
            </div>
            <br>
            <br>
            <div class="table-responsive">
                <table class="table table-striped table-hover">
                    <tr>
                            <th>病房号</th>
                            <th>科室</th>
                            <th>类型</th>
                            <th>容量</th>
                        <th style="text-align: center;">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach items="${list}" var="vo">
                <td>${vo.bingfangNo}</td>
                <td>${vo.bingfangName}</td>
                <td>${vo.bingfangType}</td>
                <td>${vo.bingfangCount}</td>
                <td>${vo.bingfangPrice}</td>
                                <button class="btn btn-pill btn-line btn-info btn-sm" data-id="${vo.id}"
                                        data-toggle="modal" data-target="#modal-info">详情
                                </button>
                                <button class="btn btn-pill btn-line btn-primary btn-sm"
                                                <c:if test="${loginUser.userType != '管理员'}">disabled="disabled" title="没有权限!!!"</c:if>
                                        data-toggle="modal" data-target="#modal-edit">编辑
                                </button>
                                <button class="btn btn-pill btn-line btn-info btn-sm" <c:if test="${loginUser.userType != '管理员'}">disabled="disabled" title="没有权限!!!"</c:if> data-id="${vo.id}"
                                        data-toggle="modal" data-target="#modal-delete">删除
                                </button>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

<!-- add -->
     aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <form action="BingfangServlet" onsubmit="return addCheck()">
                <div class="modal-header">
                            aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title" id="myModalLabel">增加病房 </h4>
                </div>
                    <div class="form-group hidden">
                        <label class="control-label">(hidden)</label>
                        <input type="text" class="form-control" name="action" value="add">
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control" name="bingfangNo" id="add-bingfangNo">
                    </div>
                    <div class="form-group">
                        <label for="add-bingfangName" class="control-label">科室:</label>
                        <input type="text" class="form-control" name="bingfangName" id="add-bingfangName">
                    <div class="form-group">
                        <label class="control-label">类型:</label>
                        <input name="bingfangType" id="add-bingfangType_普通" type="radio" value="普通" checked="checked"/>普通
                        <input name="bingfangType" id="add-bingfangType_重症" type="radio" value="重症"/>重症
                    </div>
                        <label for="add-bingfangCount" class="control-label">容量:</label>
                        <input type="text" class="form-control" name="bingfangCount" id="add-bingfangCount">
                    </div>
                    <div class="form-group">
                        <label for="add-bingfangPrice" class="control-label">价格:</label>
                    </div>
                    <div class="form-group">
                        <label for="add-bingfangText" class="control-label">详情:</label>
                        <textarea style="height: 100px;" class="form-control" name="bingfangText" id="add-bingfangText"></textarea>
                    </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-pill btn-line btn-success" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-pill btn-line btn-success">提交</button>
                </div>
            </form>
    </div>
</div>

<!-- info -->
<div class="modal fade" id="modal-info" tabindex="-1" role="dialog"
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <form>
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    </button>
                    <h4 class="modal-title">病房 </h4>
                </div>
                <div class="modal-body">
                    <table class="table table-striped table-hover" style="font-size: 15px;">
                            <td style="width: 15%;">病房号:</td>
                            <td><b id="info-bingfangNo"></b></td>
                        </tr>
                        <tr>
                            <td style="width: 15%;">科室:</td>
                        </tr>
                        <tr>
                            <td style="width: 15%;">类型:</td>
                            <td><b id="info-bingfangType"></b></td>
                        </tr>
                            <td style="width: 15%;">容量:</td>
                            <td><b id="info-bingfangCount"></b></td>
                        </tr>
                        <tr>
                            <td style="width: 15%;">价格:</td>
                        </tr>
                        <tr>
                            <td style="width: 15%;">详情:</td>
                            <td><b id="info-bingfangText"></b></td>
                        </tr>
                    <br>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-pill btn-line btn-success" data-dismiss="modal">关闭</button>
                </div>
        </div>
    </div>
</div>

<!-- edit -->
     aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <form action="BingfangServlet" onsubmit="return editCheck()">
                <div class="modal-header">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title">更新病房 </h4>
                </div>
                <div class="modal-body">
                        <label class="control-label">(hidden)</label>
                        <input type="text" class="form-control" name="action" value="edit">
                        <input type="text" readonly class="form-control" name="id" id="edit-id">
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control" name="bingfangNo" id="edit-bingfangNo">
                    </div>
                    <div class="form-group">
                        <label for="edit-bingfangName" class="control-label">科室:</label>
                        <input type="text" class="form-control" name="bingfangName" id="edit-bingfangName">
                    <div class="form-group">
                        <label class="control-label">类型:</label>
                               <input name="bingfangType" id="edit-bingfangType_普通" type="radio" value="普通"/>普通
                               <input name="bingfangType" id="edit-bingfangType_重症" type="radio" value="重症"/>重症
                    </div>
                        <label for="edit-bingfangCount" class="control-label">容量:</label>
                        <input type="text" class="form-control" name="bingfangCount" id="edit-bingfangCount">
                    </div>
                    <div class="form-group">
                        <label for="edit-bingfangPrice" class="control-label">价格:</label>
                    </div>
                    <div class="form-group">
                        <label for="edit-bingfangText" class="control-label">详情:</label>
                        <textarea style="height: 100px;" class="form-control" name="bingfangText" id="edit-bingfangText"></textarea>
                    </div>
                        <label for="edit-createTime" class="control-label">创建时间:</label>
                        <input type="text" class="form-control" name="createTime" id="edit-createTime">
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-pill btn-line btn-success">提交</button>
                </div>
            </form>
        </div>
    </div>

<!-- delete -->
<div class="modal fade" id="modal-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title">删除病房 </h4>
                <div class="modal-body">
                    确认要删除该病房 记录吗?
                    <div class="form-group hidden">
                        <label class="control-label">(hidden)</label>
                        <input type="hidden" class="form-control" name="action" value="delete">
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-pill btn-line btn-success" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-pill btn-line btn-info">删除</button>
            </form>
        </div>
    </div>
</div>

<script>
    $('#modal-delete').on('show.bs.modal', function (event) {
        let button = $(event.relatedTarget);
        let id = button.data('id');
        let modal = $(this);
    })

    $('#modal-edit').on('show.bs.modal', function (event) {
        let button = $(event.relatedTarget);
        let id = button.data('id');
        $.ajax({
            url: 'BingfangServlet?action=get&id=' + id,
            type: "get",
            success: function (voString) {
                let vo = eval('(' + voString + ')');
                        modal.find('#edit-bingfangNo').val(vo.bingfangNo);
                        modal.find('#edit-bingfangName').val(vo.bingfangName);
                        for (let val of "普通/重症".split('/')) {
                            if (val == vo.bingfangType) {
                                modal.find('#edit-bingfangType_' + vo.bingfangType).prop("checked", true);
                                modal.find('#edit-bingfangType_' + vo.bingfangType).removeAttr("checked");
                            }
                        };
                        modal.find('#edit-bingfangCount').val(vo.bingfangCount);
                        modal.find('#edit-bingfangPrice').val(vo.bingfangPrice);
            }
        })
    })
    $('#modal-info').on('show.bs.modal', function (event) {
        let button = $(event.relatedTarget);
        let modal = $(this);
        $.ajax({
            url: 'BingfangServlet?action=get&id=' + id,
            type: "get",
            success: function (voString) {
                modal.find('#info-bingfangNo').text(vo.bingfangNo);
                modal.find('#info-bingfangName').text(vo.bingfangName);
                modal.find('#info-bingfangType').text(vo.bingfangType);
                modal.find('#info-bingfangCount').text(vo.bingfangCount);
                modal.find('#info-bingfangPrice').text(vo.bingfangPrice);
            }
        })
    })
    function searchList() {
        window.location.href = "BingfangServlet?action=list&searchColumn="+document.getElementById("searchColumn").value+"&keyword=" + document.getElementById("search_keyword").value;
    //增加表单提交之前进行检查,如果return false,则不允许提交
    function addCheck() {
        //根据ID获取值
        if (document.getElementById("add-bingfangNo").value.trim().length == 0) {
            alert("病房号不能为空");
        }
        if (document.getElementById("add-bingfangName").value.trim().length == 0) {
            alert("科室不能为空");
            return false;
        }
            alert("容量不能为空");
            return false;
        }
        if (document.getElementById("add-bingfangPrice").value.trim().length == 0) {
            alert("价格不能为空");
        }
        return true;
    }
    //编辑表单提交之前进行检查,如果return false,则不允许提交
    function editCheck() {
        if (document.getElementById("edit-bingfangNo").value.trim().length == 0) {
            alert("病房号不能为空");
            return false;
        }
        if (document.getElementById("edit-bingfangName").value.trim().length == 0) {
            return false;
        }
        if (document.getElementById("edit-bingfangCount").value.trim().length == 0) {
            alert("容量不能为空");
            return false;
        if (document.getElementById("edit-bingfangPrice").value.trim().length == 0) {
            alert("价格不能为空");
            return false;
        }
        return true;
</script>
</html>

运行环境

Java≥6、Tomcat≥7.0、MySQL≥5.5

开发工具

idea/eclipse/MyEclipse

技术框架

JSP JavaBean MVC MySQL JavaScript idea eclipse myEclipse Servlet或SSM等

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

管理员、普通用户、登录、注册、退出、用户模块、公告模块、病房模块、费用模块、住院模块的增删改查管理

基于javaweb+jsp的医院住院管理系统

基于javaweb+jsp的医院住院管理系统

基于javaweb+jsp的医院住院管理系统

基于javaweb+jsp的医院住院管理系统

基于javaweb+jsp的医院住院管理系统

上一篇:Redis HyperLogLog使用


下一篇:RHEL8系统学习打卡#day11#