基于javaweb+jsp的甜品店奶茶店管理系统
代码实现
<!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="Dinggou_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="dinggou_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-danger" 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>支付方式</th>
<th>状态</th>
<th style="text-align: center;">操作</th>
</tr>
</thead>
<c:forEach items="${list}" var="vo">
<tr>
<td>${vo.dinggouName}</td>
<td>${vo.dinggouXiangqing}</td>
<td>${vo.dinggouShouhuo}</td>
<td>${vo.dinggouAdd}</td>
<td>${vo.dinggouZhifufangshi}</td>
<td>${vo.dinggouZhuangtai}</td>
<th style="text-align: center;">
<button class="btn btn-pill btn-primary btn-sm" data-id="${vo.id}"
</button>
<button class="btn btn-pill btn-primary btn-sm"
<c:if test="${loginUser.userType != '管理员'}">disabled="disabled" title="没有权限!!!"</c:if>
data-id="${vo.id}"
data-toggle="modal" data-target="#modal-edit">编辑
<button class="btn btn-pill btn-warning btn-sm" <c:if test="${loginUser.userType != '管理员'}">disabled="disabled" title="没有权限!!!"</c:if> data-id="${vo.id}"
data-toggle="modal" data-target="#modal-delete">删除
</button>
</th>
</tr>
</tbody>
</table>
</div>
<div style="float: right;padding-right: 10px;color: #515151;"><jsp:include page="split.jsp"/></div>
</div>
</div>
<!-- add -->
<div class="modal fade" id="modal-add" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel">
<div class="modal-content">
<form action="DinggouServlet" onsubmit="return addCheck()">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
</button>
<h4 class="modal-title" id="myModalLabel">增加订购 </h4>
</div>
<div class="modal-body">
<div class="form-group hidden">
<input type="text" class="form-control" name="action" value="add">
</div>
<div class="form-group">
<label for="add-dinggouName" class="control-label">商品:</label>
<input type="text" class="form-control" name="dinggouName" id="add-dinggouName">
<div class="form-group">
<label for="add-dinggouXiangqing" class="control-label">商品详情:</label>
<input type="text" class="form-control" name="dinggouXiangqing" id="add-dinggouXiangqing">
</div>
<div class="form-group">
<input type="text" class="form-control" name="dinggouShouhuo" id="add-dinggouShouhuo">
</div>
<div class="form-group">
<label for="add-dinggouTel" class="control-label">电话:</label>
<input type="text" class="form-control" name="dinggouTel" id="add-dinggouTel">
<div class="form-group">
<label for="add-dinggouAdd" class="control-label">地址:</label>
<input type="text" class="form-control" name="dinggouAdd" id="add-dinggouAdd">
</div>
<div class="form-group">
<input name="dinggouZhifufangshi" id="add-dinggouZhifufangshi_现金" type="radio" value="现金" checked="checked"/>现金
<input name="dinggouZhifufangshi" id="add-dinggouZhifufangshi_转帐" type="radio" value="转帐"/>转帐
</div>
<div class="form-group">
<label class="control-label">状态:</label>
<input name="dinggouZhuangtai" id="add-dinggouZhuangtai_配送中" type="radio" value="配送中"/>配送中
<input name="dinggouZhuangtai" id="add-dinggouZhuangtai_已完成" type="radio" value="已完成"/>已完成
</div>
<div class="form-group">
<label for="add-dinggouText" class="control-label">备注:</label>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-pill btn-info" data-dismiss="modal">取消</button>
<button type="submit" class="btn btn-pill btn-danger">提交</button>
</form>
</div>
</div>
</div>
<div class="modal fade" id="modal-info" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">订购 </h4>
</div>
<table class="table table-striped table-hover" style="font-size: 15px;">
<tr>
<td style="width: 15%;">商品:</td>
<td><b id="info-dinggouName"></b></td>
</tr>
<td style="width: 15%;">商品详情:</td>
<td><b id="info-dinggouXiangqing"></b></td>
</tr>
<tr>
<td style="width: 15%;">订购人:</td>
</tr>
<tr>
<td style="width: 15%;">电话:</td>
<td><b id="info-dinggouTel"></b></td>
</tr>
<td style="width: 15%;">地址:</td>
<td><b id="info-dinggouAdd"></b></td>
</tr>
<tr>
<td style="width: 15%;">支付方式:</td>
</tr>
<tr>
<td style="width: 15%;">状态:</td>
<td><b id="info-dinggouZhuangtai"></b></td>
</tr>
<td style="width: 15%;">备注:</td>
<td><b id="info-dinggouText"></b></td>
</tr>
</table>
<br>
<div class="modal-footer">
<button type="button" class="btn btn-pill btn-info" data-dismiss="modal">关闭</button>
</div>
</form>
</div>
</div>
<!-- edit -->
<div class="modal fade" id="modal-edit" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel">
<div class="modal-content">
<form action="DinggouServlet" onsubmit="return editCheck()">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
<h4 class="modal-title">更新订购 </h4>
</div>
<div class="modal-body">
<div class="form-group hidden">
<label class="control-label">(hidden)</label>
<input type="text" readonly class="form-control" name="id" id="edit-id">
</div>
<div class="form-group">
<label for="edit-dinggouName" class="control-label">商品:</label>
<input type="text" class="form-control" name="dinggouName" id="edit-dinggouName">
<div class="form-group">
<label for="edit-dinggouXiangqing" class="control-label">商品详情:</label>
<input type="text" class="form-control" name="dinggouXiangqing" id="edit-dinggouXiangqing">
</div>
<div class="form-group">
<input type="text" class="form-control" name="dinggouShouhuo" id="edit-dinggouShouhuo">
</div>
<div class="form-group">
<label for="edit-dinggouTel" class="control-label">电话:</label>
<input type="text" class="form-control" name="dinggouTel" id="edit-dinggouTel">
<div class="form-group">
<label for="edit-dinggouAdd" class="control-label">地址:</label>
<input type="text" class="form-control" name="dinggouAdd" id="edit-dinggouAdd">
</div>
<div class="form-group">
<input name="dinggouZhifufangshi" id="edit-dinggouZhifufangshi_现金" type="radio" value="现金"/>现金
<input name="dinggouZhifufangshi" id="edit-dinggouZhifufangshi_转帐" type="radio" value="转帐"/>转帐
</div>
<div class="form-group">
<label class="control-label">状态:</label>
<input name="dinggouZhuangtai" id="edit-dinggouZhuangtai_配送中" type="radio" value="配送中"/>配送中
<input name="dinggouZhuangtai" id="edit-dinggouZhuangtai_已完成" type="radio" value="已完成"/>已完成
</div>
<div class="form-group">
<label for="edit-dinggouText" class="control-label">备注:</label>
</div>
<div class="form-group hidden">
<label for="edit-createTime" class="control-label">创建时间:</label>
<input type="text" class="form-control" name="createTime" id="edit-createTime">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-pill btn-info" data-dismiss="modal">取消</button>
<button type="submit" class="btn btn-pill btn-danger">提交</button>
</div>
</form>
</div>
</div>
<!-- delete -->
<div class="modal fade" id="modal-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-content">
<form action="DinggouServlet">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
<h4 class="modal-title">删除订购 </h4>
</div>
<div class="modal-body">
确认要删除该订购 记录吗?
<div class="form-group hidden">
<input type="hidden" class="form-control" name="action" value="delete">
<input type="text" class="form-control" name="id" id="delete-id">
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-pill btn-warning">删除</button>
</div>
</form>
</div>
</div>
</body>
<script>
$('#modal-delete').on('show.bs.modal', function (event) {
let button = $(event.relatedTarget);
let modal = $(this);
modal.find('#delete-id').val(id);
})
$('#modal-edit').on('show.bs.modal', function (event) {
let id = button.data('id');
let modal = $(this);
$.ajax({
url: 'DinggouServlet?action=get&id=' + id,
type: "get",
let vo = eval('(' + voString + ')');
modal.find('#edit-id').val(vo.id);
modal.find('#edit-dinggouName').val(vo.dinggouName);
modal.find('#edit-dinggouXiangqing').val(vo.dinggouXiangqing);
modal.find('#edit-dinggouShouhuo').val(vo.dinggouShouhuo);
modal.find('#edit-dinggouAdd').val(vo.dinggouAdd);
for (let val of "现金/转帐".split('/')) {
if (val == vo.dinggouZhifufangshi) {
modal.find('#edit-dinggouZhifufangshi_' + vo.dinggouZhifufangshi).prop("checked", true);
} else {
}
};
for (let val of "待配送/配送中/已完成".split('/')) {
if (val == vo.dinggouZhuangtai) {
modal.find('#edit-dinggouZhuangtai_' + vo.dinggouZhuangtai).prop("checked", true);
modal.find('#edit-dinggouZhuangtai_' + vo.dinggouZhuangtai).removeAttr("checked");
}
};
modal.find('#edit-dinggouText').val(vo.dinggouText);
}
})
$('#modal-info').on('show.bs.modal', function (event) {
let button = $(event.relatedTarget);
let id = button.data('id');
let modal = $(this);
url: 'DinggouServlet?action=get&id=' + id,
type: "get",
success: function (voString) {
let vo = eval('(' + voString + ')');
modal.find('#info-dinggouName').text(vo.dinggouName);
modal.find('#info-dinggouShouhuo').text(vo.dinggouShouhuo);
modal.find('#info-dinggouTel').text(vo.dinggouTel);
modal.find('#info-dinggouAdd').text(vo.dinggouAdd);
modal.find('#info-dinggouZhifufangshi').text(vo.dinggouZhifufangshi);
modal.find('#info-dinggouZhuangtai').text(vo.dinggouZhuangtai);
}
})
})
function searchList() {
window.location.href = "DinggouServlet?action=list&searchColumn="+document.getElementById("searchColumn").value+"&keyword=" + document.getElementById("search_keyword").value;
//增加表单提交之前进行检查,如果return false,则不允许提交
function addCheck() {
//根据ID获取值
if (document.getElementById("add-dinggouName").value.trim().length == 0) {
alert("商品不能为空");
}
if (document.getElementById("add-dinggouXiangqing").value.trim().length == 0) {
alert("商品详情不能为空");
return false;
}
alert("订购人不能为空");
return false;
}
if (document.getElementById("add-dinggouTel").value.trim().length == 0) {
alert("电话不能为空");
}
if (document.getElementById("add-dinggouAdd").value.trim().length == 0) {
alert("地址不能为空");
return false;
}
}
//编辑表单提交之前进行检查,如果return false,则不允许提交
function editCheck() {
//根据ID获取值
if (document.getElementById("edit-dinggouName").value.trim().length == 0) {
return false;
}
if (document.getElementById("edit-dinggouXiangqing").value.trim().length == 0) {
alert("商品详情不能为空");
return false;
if (document.getElementById("edit-dinggouShouhuo").value.trim().length == 0) {
alert("订购人不能为空");
return false;
}
if (document.getElementById("edit-dinggouTel").value.trim().length == 0) {
return false;
}
if (document.getElementById("edit-dinggouAdd").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等
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
管理员、普通用户、登录、注册、退出、用户模块、公告模块、订购模块、商品模块的增删改查管理