基于javaweb+jsp的医院住院管理系统(JavaWeb JSP MySQL Servlet SSM SpringBoot Layui Ajax)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
技术框架
JavaWeb JavaBean JSP MVC MySQL Tomcat JavaScript Layui Ajax
基础JSP+Servlet或JSP+SSM(Spring、SpringMVC、MyBatis)框架或JSP+SSM+Maven(pom.xml)框架或SpringBoot…均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
登录、注册、退出、用户模块、公告模块、病房模块、费用模块、住院模块的增删改查管理
<script src="js/layui/layui.js"/>
<script>
//JavaScript代码区域
layui.use('element', function () {
let element = layui.element;
});
</script>
<script type="text/html" id="myToolbar">
<div class="layui-btn-container">
<c:if test="${loginUser.userType == '管理员'}"><button class='layui-btn layui-btn-sm' lay-event='add'>添加</button></c:if>
</div>
</script>
<script>
function arrayBufferToBase64(buffer) {
let binary = '';
let bytes = new Uint8Array(buffer);
let len = bytes.byteLength;
for (let i = 0; i < len; i++) {
binary += String.fromCharCode(bytes[i]);
}
return window.btoa(binary);
}
layui.use('table', function () {
</resultMap>
<sql id="Base_Column_List">
`id`,`username`,`password`,`real_name`,`user_sex`,`user_phone`,`user_text`,`user_type`
</sql>
<!--新增-->
<insert id="doCreate" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="com.demo.vo.User">
INSERT INTO `t_user`
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test ='id != null'>`id`,</if>
<if test ='username != null'>`username`,</if>
<if test ='password != null'>`password`,</if>
<if test ='realName != null'>`real_name`,</if>
<if test ='userSex != null'>`user_sex`,</if>
<if test ='userPhone != null'>`user_phone`,</if>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.demo.dao.BingfangMapper">
<resultMap id="BaseResultMap" type="com.demo.vo.Bingfang" >
<result column="id" property="id" />
<result column="bingfang_no" property="bingfangNo" />
<result column="bingfang_name" property="bingfangName" />
<result column="bingfang_type" property="bingfangType" />
<result column="bingfang_count" property="bingfangCount" />
<result column="bingfang_price" property="bingfangPrice" />
<result column="bingfang_text" property="bingfangText" />
</resultMap>
<sql id="Base_Column_List">
`id`,`bingfang_no`,`bingfang_name`,`bingfang_type`,`bingfang_count`,`bingfang_price`,`bingfang_text`
</sql>
<!--新增-->
<insert id="doCreate" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="com.demo.vo.Bingfang">
INSERT INTO `t_bingfang`
<trim prefix="(" suffix=")" suffixOverrides=",">
},
page: { //支持传入 laypage 组件的所有参数(某些参数除外,如:jump/elem) - 详见文档
layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'], //自定义分页布局
groups: 1, //只显示 1 个连续页码
first: false, //不显示首页
last: false, //不显示尾页
},
toolbar: '#myToolbar', //开启头部工具栏,并为其绑定左侧模板
defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可
title: '提示',
layEvent: 'LAYTABLE_TIPS',
icon: 'layui-icon-tips'
}],
title: '用户列表',
cols: [
[
{
field: 'username',
title: '用户名',
},
{
field: 'realName',
title: '姓名',
templet: vo => (vo = vo.realName) ? '<a href="#" style="color: #009688;">' + vo + '</a>' : '',
event: 'info',
},
{
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("zhuyuanAdd")
public void add(HttpServletResponse response, HttpServletRequest request) throws IOException {
Zhuyuan vo = new Zhuyuan();
//取出页面传进来的参数
vo.setZhuyuanName(Util.decode(request, "zhuyuanName"));
vo.setZhuyuanHao(Util.decode(request, "zhuyuanHao"));
vo.setZhuyuanSex(Util.decode(request, "zhuyuanSex"));
vo.setZhuyuanKeshi(Util.decode(request, "zhuyuanKeshi"));
vo.setZhuyuanBingfanghao(Util.decode(request, "zhuyuanBingfanghao"));
vo.setZhuyuanTime(Util.decode(request, "zhuyuanTime"));
vo.setZhuyuanYishi(Util.decode(request, "zhuyuanYishi"));
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.Serializable;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping
public class FeiyongController {
@Autowired
private FeiyongService feiyongService;
public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = Util.decode(request, "id");//取出主键id
Bingfang vo = bingfangService.get(id);
request.getSession().setAttribute("vo", vo);
String to = request.getRequestURI().toLowerCase().contains("get") ? "info" : "edit";//判断是去详情显示页面还是编辑页面
response.sendRedirect("bingfang_" + to + ".jsp");
}
/**
* 根据条件查询病房的列表并跳转回页面
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("bingfangList")
field: 'noticeText',
title: '内容',
},
{
field: 'noticeType',
title: '类型',
},
{
field: 'createDate',
title: '创建时间',
},
{
align: 'center',
fixed: 'right',
title: '操作',
width: 130,
templet: vo => {
let flag = ${loginUser.userType == '管理员'};
return flag ? '<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>' : '';
}
1=1
</where>
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.demo.dao.NoticeMapper">
<resultMap id="BaseResultMap" type="com.demo.vo.Notice" >
<result column="id" property="id" />
<result column="notice_name" property="noticeName" />
<result column="notice_text" property="noticeText" />
content: 'feiyongEditPre?id=' + data.id
});
obj.update({});//同步更新缓存对应的值
} else if (layEvent === 'info') { //详情
layer.open({
type: 2,
area: ['800px', '650px'],
fixed: false, //不固定
maxmin: true,
content: 'feiyongGet?id=' + data.id
});
obj.update({});//同步更新缓存对应的值
} else if (layEvent === 'LAYTABLE_TIPS') {
layer.alert('Hi,头部工具栏扩展的右侧图标。');
str = new String(str.getBytes("GB2312"), "GBK");
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(parameterName + "==" + str.trim());
return str.trim();
}
}
package com.demo.vo;
import java.io.Serializable;
/**
* 住院(t_zhuyuan表对应的Java实体类)
*/
public class Zhuyuan implements Serializable {
vo.setCreateDate(Util.decode(request, "createDate"));
//调用Service层的增加(insert)方法
noticeService.insert(vo);
this.redirectList(request, response);
}
/**
* 删除公告
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("noticeDelete")
public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = Util.decode(request, "id");
noticeService.delete(Arrays.asList(id));
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>医院住院管理系统</title>
<link rel="stylesheet" href="js/layui/css/layui.css">
<script src="js/jquery.js"></script>
<script src="js/layer.js"></script>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
<div class="layui-header">
<div class="layui-logo" style="font-weight: bold;font-size: 19px">医院住院管理系统</div>
<ul class="layui-nav layui-layout-left"></ul>
<c:if test="${loginUser==null}">
<ul class="layui-nav layui-layout-right">
<li class="layui-nav-item"><a href="login.jsp">请登录</a></li>
</ul>
</c:if>
<c:if test="${loginUser!=null}">
<ul class="layui-nav layui-layout-right">
<li class="layui-nav-item"><a>${loginUser.username}</a></li>
<li class="layui-nav-item"><a href="authLogout">退出登录</a></li>
</ul>
</c:if>
</div>
<div class="layui-side layui-bg-black">
<div class="layui-side-scroll">
<resultMap id="BaseResultMap" type="com.demo.vo.Zhuyuan" >
<result column="id" property="id" />
<result column="zhuyuan_name" property="zhuyuanName" />
<result column="zhuyuan_hao" property="zhuyuanHao" />
<result column="zhuyuan_sex" property="zhuyuanSex" />
<result column="zhuyuan_keshi" property="zhuyuanKeshi" />
<result column="zhuyuan_bingfanghao" property="zhuyuanBingfanghao" />
<result column="zhuyuan_time" property="zhuyuanTime" />
<result column="zhuyuan_yishi" property="zhuyuanYishi" />
<result column="zhuyuan_text" property="zhuyuanText" />
</resultMap>
<sql id="Base_Column_List">
`id`,`zhuyuan_name`,`zhuyuan_hao`,`zhuyuan_sex`,`zhuyuan_keshi`,`zhuyuan_bingfanghao`,`zhuyuan_time`,`zhuyuan_yishi`,`zhuyuan_text`
</sql>
let bytes = new Uint8Array(buffer);
let len = bytes.byteLength;
for (let i = 0; i < len; i++) {
binary += String.fromCharCode(bytes[i]);
}
return window.btoa(binary);
}
layui.use('table', function () {
let table = layui.table;
table.render({
elem: '#myData',
id: 'myTable',
url: 'userList',
parseData: function (res) { //res:即为原始返回的数据
let data = obj.data; //获得当前行数据
let layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值)
if (layEvent === 'del') { //删除
// layer.confirm('删除' + data.feiyongName + "?", function (index) {
$.ajax({
type: "GET",
dataType: "text",
url: "feiyongDelete?id=" + data.id,
success: function () {
console.log("已删除!");
}
});
obj.del(); //删除对应行(tr)的DOM结构,并更新缓存
//parent.location.reload();//刷新父级页面
// layer.close(index);
//parent.location.reload();//刷新父级页面
});
obj.update({});//同步更新缓存对应的值
} else if (layEvent === 'info') { //详情
layer.open({
type: 2,
area: ['800px', '650px'],
fixed: false, //不固定
maxmin: true,
content: 'zhuyuanGet?id=' + data.id
});
obj.update({});//同步更新缓存对应的值
} else if (layEvent === 'LAYTABLE_TIPS') {
layer.alert('Hi,头部工具栏扩展的右侧图标。');
}
});
//头工具栏事件
table.on('toolbar(myTable)', function (obj) {
if ('add' == obj.event) {