声明还是写在前面,这里的代码都是直接复制过来的,再我第二遍写这个项目的时候会把每个功能模块的代码细细拆分,说明每一步的步骤。
7.后台登陆与管理首页面
引入EasyUi所需文件
登陆界面admin_login.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<title>电子商务平台——后台登录页</title>
<!-- 引入EasyUI的相关css和js文件 -->
<link href="EasyUI/themes/default/easyui.css" rel="stylesheet"
type="text/css" />
<link href="EasyUI/themes/icon.css" rel="stylesheet" type="text/css" />
<link href="EasyUI/demo.css" rel="stylesheet" type="text/css" />
<script src="EasyUI/jquery.min.js" type="text/javascript"></script>
<script src="EasyUI/jquery.easyui.min.js" type="text/javascript"></script>
<script src="EasyUI/easyui-lang-zh_CN.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
function clearForm() {
$('#adminLoginForm').form('clear');
}
function checkAdminLogin() {
$("#adminLoginForm").form("submit", {
// 向控制器类AdminInfoController中login方法发送请求
url : 'admininfo/login',
success : function(result) {
var result = eval('(' + result + ')');
if (result.success == 'true') {
window.location.href = 'admin.jsp';
$("#adminLoginDlg").dialog("close");
} else {
$.messager.show({
title : "提示信息",
msg : result.message
});
}
}
});
}
</script>
<div id="adminLoginDlg" class="easyui-dialog"
style="left: 550px; top: 200px;width: 300;height: 200"
data-options="title:'后台登录',buttons:'#bb',modal:true">
<form id="adminLoginForm" method="post">
<table style="margin:20px;font-size: 13;">
<tr>
<th >用户名</th>
<td><input class="easyui-textbox" type="text" id="name"
name="name" data-options="required:true" value="admin"></input></td>
</tr>
<tr>
<th>密码</th>
<td><input class="easyui-textbox" type="text" id="pwd"
name="pwd" data-options="required:true" value="123456"></input></td>
</tr>
</table>
</form>
</div>
<div id="bb">
<a href="javascript:void(0)" class="easyui-linkbutton"
onclick="checkAdminLogin()">登录</a> <a href="javascript:void(0)"
class="easyui-linkbutton" onclick="clearForm();">重置</a>
</div>
</body>
</html>
里面用到的控制器类AdminInfoController ,这会只写了login,一会还有其他功能,后续会添加。
@SessionAttributes(value = { "admin" })
@Controller
@RequestMapping("/admininfo")
public class AdminInfoController {
@Autowired
private AdminInfoService adminInfoService;
@RequestMapping(value = "/login", produces = "text/html;charset=UTF-8")
@ResponseBody
public String login(AdminInfo ai, ModelMap model) {
// 后台登录验证
AdminInfo admininfo = adminInfoService.login(ai);
if (admininfo != null && admininfo.getName() != null) {
// 验证通过后,再判断是否已为该管理员分配功能权限
if (adminInfoService.getAdminInfoAndFunctions(admininfo.getId()).getFs().size() > 0) {
// 验证通过且已分配功能权限,则将admininfo对象存入model中
model.put("admin", admininfo);
// 以JSON格式向页面发送成功信息
return "{\"success\":\"true\",\"message\":\"登录成功\"}";
} else {
return "{\"success\":\"false\",\"message\":\"您没有权限,请联系超级管理员设置权限!\"}";
}
} else
return "{\"success\":\"false\",\"message\":\"登录失败\"}";
}
登陆成功后进入后台管理首页admin.jsp
先大概给个预览图,方便对比观察代码
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%
if (session.getAttribute("admin") == null)
response.sendRedirect("/ecpbm/admin_login.jsp");
%>
<html>
<head>
<title>后台管理首页面</title>
<link href="EasyUI/themes/default/easyui.css" rel="stylesheet"
type="text/css" />
<link href="EasyUI/themes/icon.css" rel="stylesheet" type="text/css" />
<link href="EasyUI/demo.css" rel="stylesheet" type="text/css" />
<script src="EasyUI/jquery.min.js" type="text/javascript"></script>
<script src="EasyUI/jquery.easyui.min.js" type="text/javascript"></script>
<script src="EasyUI/easyui-lang-zh_CN.js" type="text/javascript"></script>
</head>
<body class="easyui-layout">
<div data-options="region:'north',border:false"
style="height: 60px; background: #B3DFDA; padding: 10px">
<div align="left">
<div style="font-family: Microsoft YaHei; font-size: 16px;">电商平台后台管理系统</div>
</div>
<div align="right">
欢迎您,<font color="Red">${sessionScope.admin.name}</font>
</div>
</div>
<div data-options="region:'west',split:true,title:'功能菜单'"
style="width: 180px">
<ul id="tt"></ul>
</div>
<div data-options="region:'south',border:false"
style="height: 50px; background: #A9FACD; padding: 10px; text-align: center">powered
by fzj</div>
<div data-options="region:'center'">
<div id="tabs" data-options="fit:true" class="easyui-tabs"
style="width: 500px; height: 250px;"></div>
</div>
<script type="text/javascript">
// 为tree指定数据
$('#tt').tree({
url : 'admininfo/getTree?adminid=${sessionScope.admin.id}'
});
$('#tt').tree({
onClick : function(node) {
if ("商品列表" == node.text) {
if ($('#tabs').tabs('exists', '商品列表')) {
$('#tabs').tabs('select', '商品列表');
} else {
$('#tabs').tabs('add', {
title : node.text,
href : 'productlist.jsp',
closable : true
});
}
} else if ("商品类型列表" == node.text) {
if ($('#tabs').tabs('exists', '商品类型列表')) {
$('#tabs').tabs('select', '商品类型列表');
} else {
$('#tabs').tabs('add', {
title : node.text,
href : 'typelist.jsp',
closable : true
});
}
} else if ("查询订单" == node.text) {
if ($('#tabs').tabs('exists', '查询订单')) {
$('#tabs').tabs('select', '查询订单');
} else {
$('#tabs').tabs('add', {
title : node.text,
href : 'searchorder.jsp',
closable : true
});
}
} else if ("创建订单" == node.text) {
if ($('#tabs').tabs('exists', '创建订单')) {
$('#tabs').tabs('select', '创建订单');
} else {
$('#tabs').tabs('add', {
title : node.text,
href : 'createorder.jsp',
closable : true
});
}
} else if ("客户列表" == node.text) {
if ($('#tabs').tabs('exists', '客户列表')) {
$('#tabs').tabs('select', '客户列表');
} else {
$('#tabs').tabs('add', {
title : node.text,
href : 'userlist.jsp',
closable : true
});
}
} else if ("退出系统" == node.text) {
$.ajax({
url : 'admininfo/logout',
success : function(data) {
window.location.href = "admin_login.jsp";
}
})
}
}
});
</script>
</body>
</html>
可以看到左侧有一个树控件,所以我们要把functions转换成json格式展示到前端
退出登录的功能顺便也写这了。
//进行json格式转换,并发送到前端页面
@RequestMapping("getTree")
@ResponseBody
public List<TreeNode> getTree(@RequestParam(value = "adminid") String adminid) {
// 根据管理员编号,获取AdminInfo对象
AdminInfo admininfo = adminInfoService.getAdminInfoAndFunctions(Integer.parseInt(adminid));
List<TreeNode> nodes = new ArrayList<TreeNode>();
// 获取关联的Functions对象集合
List<Functions> functionsList = admininfo.getFs();
// 对List<Functions>类型的Functions对象集合排序
Collections.sort(functionsList);
// 将排序后的Functions对象集合转换到List<TreeNode>类型的列表nodes
for (Functions functions : functionsList) {
TreeNode treeNode = new TreeNode();
treeNode.setId(functions.getId());
treeNode.setFid(functions.getParentid());
treeNode.setText(functions.getName());
nodes.add(treeNode);
}
// 调用自定义的工具类JsonFactory的buildtree方法,为nodes列表中的各个TreeNode元素中的
// children属性赋值(该节点包含的子节点)
List<TreeNode> treeNodes = JsonFactory.buildtree(nodes, 0);
return treeNodes;
}
// 退出
@RequestMapping(value = "/logout", method = RequestMethod.GET)
@ResponseBody
public String logout(SessionStatus status) {
// @SessionAttributes清除
status.setComplete();
return "{\"success\":\"true\",\"message\":\"注销成功\"}";
}
实现代码中提到的JsonFactory
package com.ecpbm.util;
import java.util.ArrayList;
import java.util.List;
import com.ecpbm.pojo.TreeNode;
public class JsonFactory {
public static List<TreeNode> buildtree(List<TreeNode> nodes, int id) {
List<TreeNode> treeNodes = new ArrayList<TreeNode>();
for (TreeNode treeNode : nodes) {
TreeNode node = new TreeNode();
node.setId(treeNode.getId());
node.setText(treeNode.getText());
if (id == treeNode.getFid()) {
// 递给调用buildtree方法给TreeNode中的children属性赋值
node.setChildren(buildtree(nodes, node.getId()));
treeNodes.add(node);
}
}
return treeNodes;
}
}
此时可以运行测试一下,结果图片我放在上面了。
8.商品管理
商品列表页productlist.jsp
<%@ page language="java" import="java.util.*"
contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>商品列表页</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<body>
<!-- 定义table, 用于创建easy ui的datagrid控件 -->
<table id="dg_productinfo" class="easyui-datagrid"></table>
<!-- 创建datagrid控件的工具栏 -->
<div id="tb_productinfo" style="padding: 2px 5px;">
<a href="javascript:void(0)" class="easyui-linkbutton"
iconCls="icon-add" plain="true" onclick="addProduct();">添加</a> <a
href="javascript:void(0)" class="easyui-linkbutton"
iconCls="icon-edit" plain="true" onclick="editProduct();">修改</a> <a
href="javascript:void(0)" class="easyui-linkbutton"
iconCls="icon-remove" onclick="removeProduct();" plain="true">删除</a>
</div>
<!-- 创建查询工具栏 -->
<div id="searchtb_productinfo" style="padding: 2px 5px;">
<form id="searchForm_productinfo" method="post">
<div style="padding: 3px">
商品编号 <input class="easyui-textbox"
name="productinfo_search_code" id="productinfo_search_code"
style="width: 110px" />
</div>
<div style="padding: 3px">
商品名称 <input class="easyui-textbox"
name="productinfo_search_name" id="productinfo_search_name"
style="width: 110px" /> 商品类型 <input
style="width: 110px;" id="productinfo_search_tid"
class="easyui-combobox" name="productinfo_search_tid"
data-options="valueField:'id',textField:'name',url:'type/getType/1'"
value="0"> 商品品牌 <input
class="easyui-textbox" name="productinfo_search_brand"
id="productinfo_search_brand" style="width: 110px" />
价格: <input class="easyui-numberbox"
name="productinfo_search_priceFrom"
id="productinfo_search_priceFrom" style="width: 80px;" /> ~ <input
class="easyui-numberbox" name="productinfo_search_priceTo"
id="productinfo_search_priceTo" style="width: 80px;" />
<a href="javascript:void(0)" class="easyui-linkbutton"
iconCls="icon-search" plain="true" onclick="searchProduct();">查找</a>
</div>
</form>
</div>
<!-- 添加商品信息对话框 -->
<div id="dlg_productinfo" class="easyui-dialog" title="添加商品"
closed="true" style="width: 500px;">
<div style="padding: 10px 60px 20px 60px">
<form id="ff_productinfo" method="POST" action=""
enctype="multipart/form-data">
<table cellpadding="5">
<tr>
<td>商品状态:</td>
<td><select id="status" class="easyui-combobox" name="status"
style="width: 150px;">
<option value="1">在售</option>
<option value="0">下架</option>
</select></td>
</tr>
<tr>
<td>商品类型:</td>
<td><input style="width: 150px;" id="type.id"
class="easyui-combobox" name="type.id"
data-options="valueField:'id',textField:'name',url:'type/getType/0'"></input>
</td>
</tr>
<tr>
<td>商品名称:</td>
<td><input class="easyui-textbox" type="text" id="name"
name="name" data-options="required:true"></input></td>
</tr>
<tr>
<td>商品编码:</td>
<td><input class="easyui-textbox" type="text" id="code"
name="code" data-options="required:true"></input></td>
</tr>
<tr>
<td>商品品牌:</td>
<td><input class="easyui-textbox" type="text" id="brand"
name="brand" data-options="required:true"></input></td>
</tr>
<tr>
<td>商品数量:</td>
<td><input class="easyui-textbox" type="text" id="num"
name="num" data-options="required:true"></input></td>
</tr>
<tr>
<td>商品价格:</td>
<td><input class="easyui-textbox" type="text" id="price"
name="price" data-options="required:true"></input></td>
</tr>
<tr>
<td>商品描述:</td>
<td><input class="easyui-textbox" name="intro" id="intro"
data-options="multiline:true" style="height: 60px"></input></td>
</tr>
<tr>
<td>商品图片:</td>
<td><input class="easyui-filebox" id="file" name="file"
style="width: 200px" value="选择图片"></input></td>
</tr>
</table>
</form>
<div style="text-align: center; padding: 5px">
<a href="javascript:void(0)" class="easyui-linkbutton"
onclick="saveProduct();">保存</a> <a href="javascript:void(0)"
class="easyui-linkbutton" onclick="clearForm();">清空</a>
</div>
</div>
</div>
<script type="text/javascript">
$(function() {
$('#dg_productinfo').datagrid({
singleSelect : false, //设置datagrid为支持多选
url : 'productinfo/list', //为datagrid设置数据源
pagination : true, //启用分页
pageSize : 10, //设置初始每页记录数(页大小)
pageList : [ 10, 15, 20 ], //设置可供选择的页大小
rownumbers : true, //显示行号
fit : true, //设置自适应
toolbar : '#tb_productinfo', //为datagrid添加工具栏
header : '#searchtb_productinfo', //为datagrid标头添加搜索栏
columns : [ [ { //编辑datagrid的列
title : '序号',
field : 'id',
align : 'center',
checkbox : true
}, {
field : 'name',
title : '商品名称',
width : 200
}, {
field : 'type',
title : '商品类型',
formatter : function(value, row, index) {
if (row.type) {
return row.type.name;
} else {
return value;
}
},
width : 60
}, {
field : 'status',
title : '商品状态',
formatter : function(value, row, index) {
if (row.status == 1) {
return "在售";
} else {
return "下架";
}
},
width : 60
}, {
field : 'code',
title : '商品编码',
width : 100
}, {
field : 'brand',
title : '品牌',
width : 120
}, {
field : 'price',
title : '价格',
width : 50
}, {
field : 'num',
title : '库存',
width : 50
}, {
field : 'intro',
title : '商品描述',
width : 450
} ] ]
});
});
var urls;
var data;
// 删除商品(商品下架)
function removeProduct() {
var rows = $("#dg_productinfo").datagrid('getSelections');
if (rows.length > 0) {
$.messager.confirm('Confirm', '确认要删除么?', function(r) {
if (r) {
var ids = "";
for (var i = 0; i < rows.length; i++) {
ids += rows[i].id + ",";
}
$.post('productinfo/deleteProduct', {
id : ids,
flag : 0
}, function(result) {
if (result.success == 'true') {
$("#dg_productinfo").datagrid('reload');
$.messager.show({
title : '提示信息',
msg : result.message
});
} else {
$.messager.show({
title : '提示信息',
msg : result.message
});
}
}, 'json');
}
});
} else {
$.messager.alert('提示', '请选择要删除的行', 'info');
}
}
// 打开新增商品对话框
function addProduct() {
$('#dlg_productinfo').dialog('open').dialog('setTitle', '新增商品');
$('#dlg_productinfo').form('clear');
urls = 'productinfo/addProduct';
}
// 保存商品信息
function saveProduct() {
$("#ff_productinfo").form("submit", {
url : urls, //使用参数
success : function(result) {
var result = eval('(' + result + ')');
if (result.success == 'true') {
$("#dg_productinfo").datagrid("reload");
$("#dlg_productinfo").dialog("close");
}
$.messager.show({
title : "提示信息",
msg : result.message
});
}
});
}
function clearForm() {
$('#ff_productinfo').form('clear');
}
// 打开修改商品对话框(与新增商品对话框共用)
function editProduct() {
var rows = $("#dg_productinfo").datagrid('getSelections');
if (rows.length > 0) {
var row = $("#dg_productinfo").datagrid("getSelected");
if (row) {
$("#dlg_productinfo").dialog("open").dialog('setTitle',
'修改商品信息');
$("#ff_productinfo").form("load", {
"type.id" : row.type.id,
"name" : row.name,
"code" : row.code,
"brand" : row.brand,
"num" : row.num,
"price" : row.price,
"intro" : row.intro,
"status" : row.status,
});
urls = "productinfo/updateProduct?id=" + row.id;
}
} else {
$.messager.alert('提示', '请选择要修改的行', 'info');
}
}
// 查询商品
function searchProduct() {
var productinfo_search_code = $('#productinfo_search_code')
.textbox("getValue");
var productinfo_search_name = $('#productinfo_search_name')
.textbox("getValue");
var productinfo_search_tid = $('#productinfo_search_tid').combobox(
"getValue");
var productinfo_search_brand = $('#productinfo_search_brand')
.textbox("getValue");
var productinfo_search_priceFrom;
if ($("#productinfo_search_priceFrom").val() != null
&& $("#productinfo_search_priceFrom").val() != "") {
productinfo_search_priceFrom = $(
'#productinfo_search_priceFrom').textbox("getValue");
} else {
productinfo_search_priceFrom = "0";
}
var productinfo_search_priceTo;
if ($("#productinfo_search_priceTo").val() != null
&& $("#productinfo_search_priceTo").val() != "") {
productinfo_search_priceTo = $('#productinfo_search_priceTo')
.textbox("getValue");
} else {
productinfo_search_priceTo = "0";
}
$("#dg_productinfo").datagrid('load', {
"code" : productinfo_search_code,
"name" : productinfo_search_name,
"type.id" : productinfo_search_tid,
"brand" : productinfo_search_brand,
"priceFrom" : productinfo_search_priceFrom,
"priceTo" : productinfo_search_priceTo
});
}
</script>
</body>
</html>
对应控制器ProductInfoController
package com.ecpbm.controller;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.ecpbm.pojo.Pager;
import com.ecpbm.pojo.ProductInfo;
import com.ecpbm.service.ProductInfoService;
@Controller
@RequestMapping("/productinfo")
public class ProductInfoController {
@Autowired
ProductInfoService productInfoService;
// 后台商品列表分页显示
@RequestMapping(value = "/list")
@ResponseBody
public Map<String, Object> list(Integer page, Integer rows, ProductInfo productInfo) {
// 初始化分页类对象pager
Pager pager = new Pager();
pager.setCurPage(page);
pager.setPerPageRows(rows);
// 创建params对象,封装查询条件
Map<String, Object> params = new HashMap<String, Object>();
params.put("productInfo", productInfo);
// 获取满足条件的商品总数
int totalCount = productInfoService.count(params);
// 获取满足条件的商品列表
List<ProductInfo> productinfos = productInfoService.findProductInfo(productInfo, pager);
// 创建result对象,保存查询结果数据
Map<String, Object> result = new HashMap<String, Object>(2);
result.put("total", totalCount);
result.put("rows", productinfos);
// 将结果以JSON格式发送到前端控制器
return result;
}
// 添加商品
@RequestMapping(value = "/addProduct", produces = "text/html;charset=UTF-8")
@ResponseBody
public String addProduct(ProductInfo pi, @RequestParam(value = "file", required = false) MultipartFile file,
HttpServletRequest request, ModelMap model) {
// 服务器端upload文件夹物理路径
String path = request.getSession().getServletContext().getRealPath("product_images");
// 获取文件名
String fileName = file.getOriginalFilename();
// 实例化一个File对象,表示目标文件(含物理路径)
File targetFile = new File(path, fileName);
if (!targetFile.exists()) {
targetFile.mkdirs();
}
try {
// 将上传文件写到服务器上指定的文件
file.transferTo(targetFile);
pi.setPic(fileName);
productInfoService.addProductInfo(pi);
return "{\"success\":\"true\",\"message\":\"商品添加成功\"}";
} catch (Exception e) {
return "{\"success\":\"false\",\"message\":\"商品添加失败\"}";
}
}
// 修改商品
@RequestMapping(value = "/updateProduct", produces = "text/html;charset=UTF-8")
@ResponseBody
public String updateProduct(ProductInfo pi, @RequestParam(value = "file", required = false) MultipartFile file,
HttpServletRequest request, ModelMap model) {
// 服务器端upload文件夹物理路径
String path = request.getSession().getServletContext().getRealPath("product_images");
// 获取文件名
String fileName = file.getOriginalFilename();
// 实例化一个File对象,表示目标文件(含物理路径)
File targetFile = new File(path, fileName);
if (!targetFile.exists()) {
targetFile.mkdirs();
}
try {
// 将上传文件写到服务器上指定的文件
file.transferTo(targetFile);
pi.setPic(fileName);
productInfoService.modifyProductInfo(pi);
return "{\"success\":\"true\",\"message\":\"商品修改成功\"}";
} catch (Exception e) {
return "{\"success\":\"false\",\"message\":\"商品修改失败\"}";
}
}
// 商品下架(删除商品)
@RequestMapping(value = "/deleteProduct", produces = "text/html;charset=UTF-8")
@ResponseBody
public String deleteProduct(@RequestParam(value = "id") String id, @RequestParam(value = "flag") String flag) {
String str = "";
try {
productInfoService.modifyStatus(id.substring(0, id.length() - 1), Integer.parseInt(flag));
str = "{\"success\":\"true\",\"message\":\"删除成功\"}";
} catch (Exception e) {
str = "{\"success\":\"false\",\"message\":\"删除失败\"}";
}
return str;
}
// 获取在售商品列表
@ResponseBody
@RequestMapping("/getOnSaleProduct")
public List<ProductInfo> getOnSaleProduct() {
List<ProductInfo> piList = productInfoService.getOnSaleProduct();
return piList;
}
// 根据商品id获取商品对象
@ResponseBody
@RequestMapping("/getPriceById")
public String getPriceById(@RequestParam(value = "pid") String pid) {
if (pid != null && !"".equals(pid)) {
ProductInfo pi = productInfoService.getProductInfoById(Integer.parseInt(pid));
return pi.getPrice() + "";
}else{
return "";
}
}
}
添加控制器类TypeController
package com.ecpbm.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ecpbm.pojo.Type;
import com.ecpbm.service.TypeService;
@Controller
@RequestMapping("/type")
public class TypeController {
@Autowired
private TypeService typeService;
@RequestMapping("/getType/{flag}")
@ResponseBody
public List<Type> getType(@PathVariable("flag") Integer flag) {
List<Type> typeList = typeService.getAll();
if (flag == 1) {
Type t = new Type();
t.setId(0);
t.setName("请选择...");
typeList.add(0, t);
}
return typeList;
}
@RequestMapping(value = "/addType", produces = "text/html;charset=UTF-8")
@ResponseBody
public String addType(Type type) {
try {
typeService.addType(type);
return "{\"success\":\"true\",\"message\":\"添加成功\"}";
} catch (Exception e) {
return "{\"success\":\"false\",\"message\":\"添加失败\"}";
}
}
@RequestMapping(value = "/updateType", produces = "text/html;charset=UTF-8")
@ResponseBody
public String updateType(Type type) {
try {
typeService.updateType(type);
return "{\"success\":\"true\",\"message\":\"修改成功\"}";
} catch (Exception e) {
return "{\"success\":\"false\",\"message\":\"修改失败\"}";
}
}
}
9.订单管理
creatorder.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'createorder.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<!-- 定义table,用于创建easy ui的datagrid控件 -->
<table id="odbox"></table>
<!-- 创建datagrid控件的工具栏 -->
<div id="ordertb" style="padding: 2px 5px;">
<a href="javascript:void(0)" class="easyui-linkbutton"
iconCls="icon-add" plain="true" onclick="addOrderDetail();">添加订单明细</a><a
href="javascript:void(0)" class="easyui-linkbutton"
iconCls="icon-save" plain="true" onclick="saveorder();">保存订单</a><a
href="javascript:void(0)" class="easyui-linkbutton"
iconCls="icon-remove" plain="true" onclick="removeOrderDetail();">删除订单明细</a>
</div>
<!-- 创建订单主表录入布局 -->
<div id="divOrderInfo">
<div style="padding: 3px">
客户名称 <input style="width: 115px;" id="create_uid"
class="easyui-combobox" name="create_uid" value="0"
data-options="valueField:'id',textField:'userName',url:'userinfo/getValidUser'">
订单金额 <input type="text" name="create_orderprice"
id="create_orderprice" class="easyui-textbox" readonly="readonly"
style="width: 115px" />
</div>
<div style="padding: 3px">
订单日期 <input type="text" name="create_ordertime"
id="create_ordertime" class="easyui-datebox" style="width: 115px"
value="<%=new Date().toLocaleString()%>" />
订单状态 <select id="create_status" class="easyui-combobox"
name="create_status" style="width: 115px;">
<option value="未付款" selected>未付款</option>
<option value="已付款">已付款</option>
<option value="待发货">待发货</option>
<option value="已发货">已发货</option>
<option value="已完成">已完成</option>
</select>
</div>
</div>
<script type="text/javascript">
var $odbox = $('#odbox');
$(function() {
$odbox.datagrid({
rownumbers : true,
singleSelect : false,
fit : true,
toolbar : '#ordertb',
header : '#divOrderInfo',
columns : [ [ {
title : '序号',
field : '',
align : 'center',
checkbox : true
}, {
field : 'pid',
title : '商品名称',
width : 300,
editor : {
type : 'combobox',
options : {
valueField : 'id',
textField : 'name',
url : 'productinfo/getOnSaleProduct',
onChange: function (newValue, oldValue) {
var rows = $odbox.datagrid('getRows');
var orderprice=0;
for (var i = 0; i < rows.length; i++) {
var pidEd = $('#odbox').datagrid('getEditor', {
index: i,
field: 'pid'
});
var priceEd = $('#odbox').datagrid('getEditor', {
index: i,
field: 'price'
});
var totalpriceEd = $('#odbox').datagrid('getEditor', {
index: i,
field: 'totalprice'
});
var numEd = $('#odbox').datagrid('getEditor', {
index: i,
field: 'num'
});
if (pidEd != null){
var pid=$(pidEd.target).combobox('getValue');
$.ajax({
type: 'POST',
url: 'productinfo/getPriceById',
data: {pid : pid},
success: function(result) {
$(priceEd.target).numberbox('setValue',result);
$(totalpriceEd.target).numberbox('setValue',result * $(numEd.target).numberbox('getValue'));
orderprice=Number(orderprice)+Number($(totalpriceEd.target).numberbox('getValue'));
},
dataType: 'json',
async : false
});
}
}
$("#create_orderprice").textbox("setValue",orderprice);
}
}
}
}, {
field : 'price',
title : '单价',
width : 80,
editor: {
type : "numberbox",
options: {
editable : false
}
}
} , {
field : 'num',
title : '数量',
width : 50,
editor : {
type : 'numberbox',
options :{
onChange: function (newValue, oldValue) {
var rows = $odbox.datagrid('getRows');
var orderprice=0;
for (var i = 0; i < rows.length; i++) {
var priceEd = $('#odbox').datagrid('getEditor', {
index: i,
field: 'price'
});
var totalpriceEd = $('#odbox').datagrid('getEditor', {
index: i,
field: 'totalprice'
});
var numEd = $('#odbox').datagrid('getEditor', {
index: i,
field: 'num'
});
$(totalpriceEd.target).numberbox('setValue',$(priceEd.target).numberbox('getValue') * $(numEd.target).numberbox('getValue'));
orderprice=Number(orderprice)+Number($(totalpriceEd.target).numberbox('getValue'));
}
$("#create_orderprice").textbox("setValue",orderprice);
}
}
}
}, {
field : 'totalprice',
title : '小计',
width : 100,
editor: {
type : "numberbox",
options: {
editable : false
}
}
} ] ]
});
});
// datagrid中添加记录行
function addOrderDetail() {
$odbox.datagrid('appendRow', {
num : '1',
price : '0',
totalprice : '0'
});
var rows = $odbox.datagrid('getRows');
// 让添加的行处于可编辑状态
$odbox.datagrid('beginEdit', rows.length - 1);
}
// datagrid中删除记录行
function removeOrderDetail() {
// 获取所选择的行记录
var rows = $odbox.datagrid('getSelections');
if (rows.length > 0) {
// 获取“订单金额”文本域的值
var create_orderprice = $("#create_orderprice").textbox("getValue");
// 遍历选中的行记录,以更新订单金额
for (var i = 0; i < rows.length; i++) {
var index = $odbox.datagrid('getRowIndex', rows[i]);
var totalpriceEd = $('#odbox').datagrid('getEditor', {
index: index,
field: 'totalprice'
});
create_orderprice = create_orderprice - Number($(totalpriceEd.target).numberbox('getValue'));
$odbox.datagrid('deleteRow', index);
}
$("#create_orderprice").textbox("setValue",create_orderprice);
} else {
$.messager.alert('提示', '请选择要删除的行', 'info');
}
}
// 保存订单
function saveorder() {
// 获取订单客户
var uid = $("#create_uid").combobox("getValue");
if(uid==0){
$.messager.alert('提示', '请选择客户名称', 'info');
} else {
// 取消datagrid控件的行编辑状态
create_endEdit();
// 定义orderinfo存放订单主表数据
var orderinfo = [];
// 获取订单时间
var ordertime = $("#create_ordertime").datebox("getValue");
// 获取订单状态
var status = $("#create_status").combobox("getValue");
// 获取订单金额
var orderprice = $("#create_orderprice").textbox("getValue");
orderinfo.push({
ordertime : ordertime,
uid : uid,
status : status,
orderprice : orderprice
});
// 获取订单明细(即datagrid控件中的记录)
if ($odbox.datagrid('getChanges').length) {
// 获取datagrid控件中插入的记录行
var inserted = $odbox.datagrid('getChanges', "inserted");
// 获取datagrid控件中删除的记录行
var deleted = $odbox.datagrid('getChanges', "deleted");
// 获取datagrid控件中更新的记录行
var updated = $odbox.datagrid('getChanges', "updated");
// 定义effectRow,保存inserted和orderinfo
var effectRow = new Object();
if (inserted.length) {
effectRow["inserted"] = JSON.stringify(inserted);
}
effectRow["orderinfo"] = JSON.stringify(orderinfo);
// 提交请求
$.post(
"orderinfo/commitOrder",
effectRow,
function(data) {
if (data == 'success') {
$.messager.alert("提示", "创建成功!");
$odbox.datagrid('acceptChanges');
if ($('#tabs').tabs('exists', '创建订单')) {
$('#tabs').tabs('close', '创建订单');
}
$("#orderDg").datagrid('reload');
} else {
$.messager.alert("提示", "创建失败!");
}
});
}
}
}
// 取消datagrid控件的行编辑状态
function create_endEdit() {
var rows = $odbox.datagrid('getRows');
for (var i = 0; i < rows.length; i++) {
$odbox.datagrid('endEdit', i);
}
}
</script>
</body>
</html>
searchorder.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'newslist.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<!-- 定义table, 用于创建Easy UI的datagrid控件 -->
<table id="orderDg" class="easyui-datagrid"></table>
<!-- 工具栏 -->
<div id="orderTb" style="padding:2px 5px;">
<a href="javascript:void(0)" class="easyui-linkbutton"
iconCls="icon-edit" plain="true" onclick="editOrder();">查看明细</a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove"
onclick="removeOrder();" plain="true">删除订单</a>
</div>
<!-- 查询表单 -->
<div id="searchOrderTb" style="padding:2px 5px;">
<form id="searchOrderForm">
<div style="padding:3px">
订单编号 <input class="easyui-textbox" name="search_oid"
id="search_oid" style="width:110px" />
</div>
<div style="padding:3px">
客户名称 <input style="width:115px;" id="search_uid"
class="easyui-combobox" value="0" name="search_uid"
data-options="valueField:'id',textField:'userName',url:'userinfo/getValidUser'">
订单状态 <select id="search_status" class="easyui-combobox" name="search_status" style="width:115px;">
<option value="请选择" selected>请选择</option>
<option value="未付款">未付款</option>
<option value="已付款">已付款</option>
<option value="待发货">待发货</option>
<option value="已发货">已发货</option>
<option value="已完成">已完成</option>
</select> 订单时间 <input class="easyui-datebox"
name="orderTimeFrom" id="orderTimeFrom" style="width:115px;" /> ~
<input class="easyui-datebox" name="orderTimeTo" id="orderTimeTo"
style="width:115px;" /> <a href="javascript:void(0)"
class="easyui-linkbutton" iconCls="icon-search" plain="true"
onclick="searchOrderInfo();">查找</a>
</div>
</form>
</div>
<script type="text/javascript">
$(function() {
$('#orderDg').datagrid({
singleSelect : false,
url : 'orderinfo/list', //为datagrid设置数据源
queryParams : {}, //查询条件
pagination : true, //启用分页
pageSize : 5, //设置初始每页记录数(页大小)
pageList : [ 5, 10, 15 ], //设置可供选择的页大小
rownumbers : true, //显示行号
fit : true, //设置自适应
toolbar : '#orderTb', //为datagrid添加工具栏
header : '#searchOrderTb', //为datagrid标头添加搜索栏
columns : [ [ { //编辑datagrid的列
title : '序号',
field : 'id',
align : 'center',
checkbox : true
}, {
field : 'ui',
title : '订单客户',
formatter : function(value, row, index) {
if (row.ui) {
return row.ui.userName;
} else {
return value;
}
},
width : 100
}, {
field : 'status',
title : '订单状态',
width : 80
}, {
field : 'ordertime',
title : '订单时间',
width : 100
}, {
field : 'orderprice',
title : '订单金额',
width : 100
} ] ]
});
});
var urls;
var data;
// 删除订单
function removeOrder() {
// 获取选中的订单记录行
var rows = $("#orderDg").datagrid('getSelections');
if (rows.length > 0) {
$.messager.confirm('Confirm', '确认要删除么?', function(r) {
if (r) {
var ids = "";
// 获取选中订单记录的订单id, 保存到ids中
for (var i = 0; i < rows.length; i++) {
ids += rows[i].id + ",";
}
// 发送请求
$.post('orderinfo/deleteOrder', {
oids : ids
}, function(result) {
if (result.success == 'true') {
$("#orderDg").datagrid('reload');
$.messager.show({
title : '提示信息',
msg : result.message
});
} else {
$.messager.show({
title : '提示信息',
msg : result.message
});
}
}, 'json');
}
});
} else {
$.messager.alert('提示', '请选择要删除的行', 'info');
}
}
// 查看明细
function editOrder() {
var rows = $("#orderDg").datagrid('getSelections');
if (rows.length > 0) {
var row = $("#orderDg").datagrid("getSelected");
if ($('#tabs').tabs('exists', '订单明细')) {
$('#tabs').tabs('close', '订单明细');
}
$('#tabs').tabs('add', {
title : "订单明细",
href : 'orderinfo/getOrderInfo?oid=' + row.id,
closable : true
});
}else {
$.messager.alert('提示', '请选择要修改的订单', 'info');
}
}
// 查询订单
function searchOrderInfo() {
var oid = $('#search_oid').val();
var status = $('#search_status').combobox("getValue");
var uid = $('#search_uid').combobox("getValue");
var orderTimeFrom = $("#orderTimeFrom").datebox("getValue");
var orderTimeTo = $("#orderTimeTo").datebox("getValue");
$('#orderDg').datagrid('load', {
id : oid,
status : status,
uid : uid,
orderTimeFrom : orderTimeFrom,
orderTimeTo : orderTimeTo
});
}
</script>
</body>
</html>
UserInfoController
package com.ecpbm.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ecpbm.pojo.Pager;
import com.ecpbm.pojo.UserInfo;
import com.ecpbm.service.UserInfoService;
@Controller
@RequestMapping("/userinfo")
public class UserInfoController {
@Autowired
UserInfoService userInfoService;
@RequestMapping("/getValidUser")
@ResponseBody
public List<UserInfo> getValidUser() {
List<UserInfo> uiList = userInfoService.getValidUser();
UserInfo ui = new UserInfo();
ui.setId(0);
ui.setUserName("请选择...");
uiList.add(0, ui);
return uiList;
}
@RequestMapping("/list")
@ResponseBody
public Map<String, Object> userlist(Integer page, Integer rows, UserInfo userInfo) {
// 创建分页类对象
Pager pager = new Pager();
pager.setCurPage(page);
pager.setPerPageRows(rows);
// 创建对象params,封装查询条件
Map<String, Object> params = new HashMap<String, Object>();
params.put("userInfo", userInfo);
// 根据查询条件,获取客户记录数
int totalCount = userInfoService.count(params);
// 根据查询条件,分页获取客户列表
List<UserInfo> userinfos = userInfoService.findUserInfo(userInfo, pager);
// 创建对象result,保存查询结果数据
Map<String, Object> result = new HashMap<String, Object>(2);
result.put("total", totalCount);
result.put("rows", userinfos);
return result;
}
// 更新客户状态
@RequestMapping(value = "/setIsEnableUser", produces = "text/html;charset=UTF-8")
@ResponseBody
public String setIsEnableUser(@RequestParam(value = "uids") String uids,
@RequestParam(value = "flag") String flag) {
try {
userInfoService.modifyStatus(uids.substring(0, uids.length() - 1), Integer.parseInt(flag));
return "{\"success\":\"true\",\"message\":\"更改成功\"}";
} catch (Exception e) {
return "{\"success\":\"false\",\"message\":\"更改失败\"}";
}
}
}
OrderInfoController
package com.ecpbm.controller;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ecpbm.pojo.OrderDetail;
import com.ecpbm.pojo.OrderInfo;
import com.ecpbm.pojo.Pager;
import com.ecpbm.service.OrderInfoService;
import com.ecpbm.service.ProductInfoService;
import com.ecpbm.service.UserInfoService;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.google.gson.JsonParseException;
@Controller
@RequestMapping("/orderinfo")
public class OrderInfoController {
@Autowired
OrderInfoService orderInfoService;
@Autowired
UserInfoService userInfoService;
@Autowired
ProductInfoService productInfoService;
// 分页显示
@RequestMapping(value = "/list")
@ResponseBody
public Map<String, Object> list(Integer page, Integer rows, OrderInfo orderInfo) {
// 初始化一个分页类对象pager
Pager pager = new Pager();
pager.setCurPage(page);
pager.setPerPageRows(rows);
// 创建对象params,用于封装查询条件
Map<String, Object> params = new HashMap<String, Object>();
params.put("orderInfo", orderInfo);
// 获取满足条件的订单总数
int totalCount = orderInfoService.count(params);
// 获取满足条件的订单列表
List<OrderInfo> orderinfos = orderInfoService.findOrderInfo(orderInfo, pager);
// 创建result对象,保存查询结果数据
Map<String, Object> result = new HashMap<String, Object>(2);
result.put("total", totalCount);
result.put("rows", orderinfos);
return result;
}
// 保存订单
@ResponseBody
@RequestMapping(value = "/commitOrder")
public String commitOrder(String inserted, String orderinfo)
throws JsonParseException, JsonMappingException, IOException {
try {
// 创建ObjectMapper对象,实现JavaBean和JSON的转换
ObjectMapper mapper = new ObjectMapper();
// 设置输入时忽略在JSON字符串中存在但Java对象实际没有的属性
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
// 将json字符串orderinfo转换成JavaBean对象(订单信息)
OrderInfo oi = mapper.readValue(orderinfo, OrderInfo[].class)[0];
// 保存订单信息
orderInfoService.addOrderInfo(oi);
// 将json字符串转换成List<OrderDetail>集合(订单明细信息)
List<OrderDetail> odList = mapper.readValue(inserted, new TypeReference<ArrayList<OrderDetail>>() {
});
// 给订单明细对象的其他属性赋值
for (OrderDetail od : odList) {
od.setOid(oi.getId());
// 保存订单明细
orderInfoService.addOrderDetail(od);
}
return "success";
} catch (Exception e) {
return "failure";
}
}
// 根据订单id号获取要查看的订单对象, 再返回订单明细页
@RequestMapping("/getOrderInfo")
public String getOrderInfo(String oid, Model model) {
OrderInfo oi = orderInfoService.getOrderInfoById(Integer.parseInt(oid));
model.addAttribute("oi", oi);
return "orderdetail";
}
// 根据订单id号获取订单明细列表
@RequestMapping("/getOrderDetails")
@ResponseBody
public List<OrderDetail> getOrderDetails(String oid) {
List<OrderDetail> ods = orderInfoService.getOrderDetailByOid(Integer.parseInt(oid));
for (OrderDetail od : ods) {
// od.setPid(od.getPi().getId());
od.setPrice(od.getPi().getPrice());
od.setTotalprice(od.getPi().getPrice() * od.getNum());
}
return ods;
}
// 删除订单
@ResponseBody
@RequestMapping(value = "/deleteOrder", produces = "text/html;charset=UTF-8")
public String deleteOrder(String oids) {
String str = "";
try {
oids = oids.substring(0, oids.length() - 1);
String[] ids = oids.split(",");
for (String id : ids) {
orderInfoService.deleteOrder(Integer.parseInt(id));
}
str = "{\"success\":\"true\",\"message\":\"删除成功!\"}";
} catch (Exception e) {
str = "{\"success\":\"false\",\"message\":\"删除失败!\"}";
}
return str;
}
}
10.客户管理
userlist.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<%
if(session.getAttribute("admin")==null)
response.sendRedirect("/digital-um/admin_login.jsp");
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'newslist.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<!-- 创建一个table -->
<table id="userListDg" class="easyui-datagrid"></table>
<!-- 创建工具栏 -->
<div id="userListTb" style="padding:2px 5px;"><a href="javascript:void(0)"
class="easyui-linkbutton" iconCls="icon-edit" plain="true"
onclick="SetIsEnableUser(1);">启用客户</a> <a href="javascript:void(0)"
class="easyui-linkbutton" iconCls="icon-remove"
onclick="SetIsEnableUser(0);" plain="true">禁用客户</a>
</div>
<!-- 创建搜索栏 -->
<div id="searchUserListTb" style="padding:4px 3px;">
<form id="searchUserListForm">
<div style="padding:3px ">
客户名称 <input class="easyui-textbox" name="search_userName"
id="search_userName" style="width:110px" /><a href="javascript:void(0)"
class="easyui-linkbutton" iconCls="icon-search" plain="true"
onclick="searchUserInfo();">查找</a>
</div>
</form>
</div>
<script type="text/javascript">
$(function() {
$('#userListDg').datagrid({
singleSelect : false,
url : 'userinfo/list',
queryParams : {}, //查询条件
pagination : true, //启用分页
pageSize : 5, //设置初始每页记录数(页大小)
pageList : [ 5, 10, 15 ], //设置可供选择的页大小
rownumbers : true, //显示行号
fit : true, //设置自适应
toolbar : '#userListTb', //为datagrid添加工具栏
header : '#searchUserListTb', //为datagrid标头添加搜索栏
columns : [ [ { //编辑datagrid的列
title : '序号',
field : 'id',
align : 'center',
checkbox : true
}, {
field : 'userName',
title : '登录名',
width : 100
}, {
field : 'realName',
title : '真实姓名',
width : 80
}, {
field : 'sex',
title : '性别',
width : 100
}, {
field : 'address',
title : '住址',
width : 200
} , {
field : 'email',
title : '邮箱',
width : 150
} , {
field : 'regDate',
title : '注册日期',
width : 100
} , {
field : 'status',
title : '客户状态',
width : 100,
formatter : function(value, row, index) {
if (row.status==1) {
return "启用";
} else {
return "禁用";
}
}
} ] ]
});
});
var urls;
var data;
function searchUserInfo() {
var userName = $('#search_userName').textbox("getValue");
$('#userListDg').datagrid('load', {
userName : userName
});
}
// 设置启用或禁用客户
function SetIsEnableUser(flag) {
var rows = $("#userListDg").datagrid('getSelections');
if (rows.length > 0) {
$.messager.confirm('Confirm', '确认要设置么?', function(r) {
if (r) {
var uids = "";
for (var i = 0; i < rows.length; i++) {
uids += rows[i].id + ",";
}
$.post('userinfo/setIsEnableUser', {
uids : uids,
flag : flag
}, function(result) {
if (result.success == 'true') {
$("#userListDg").datagrid('reload');
$.messager.show({
title : '提示信息',
msg : result.message
});
} else {
$.messager.show({
title : '提示信息',
msg : result.message
});
}
}, 'json');
}
});
} else {
$.messager.alert('提示', '请选择要启用或禁用的客户', 'info');
}
}
</script>
</body>
</html>
这两张只是简单的把代码先贴上来,运行下看看流程,然后下一章开始会细细拆分每个功能。
用到的工具
ProcessOn:画图
SQLyog:图形化管理MYSQL数据库的工具
eclipse
Spring,Spring MVC MyBatis
EasyUi