<input type="button" value="订单管理" οnclick="ddgl()" style="width: 400px;height: 160px;margin-bottom: 20px;"><br/>
οnclick="ddgl() onclick点击的事件
function ddgl() { var input=document.getElementById("hidd"); var i=input.value; switch (i) { case "2": //经理,只能查看所有订单,修改订单,删除订单,不能添加订单 location.href="GetBills.do"; break; case "3": //普通员工,添加订单和查询自己的订单 location.href="GetBillsByUserId.do"; break; default: //管理员身份不允许操作该功能 alert("当前登录的员工不具备该功能的操作权限"); break; } }
GetBills.do"用于删除修改
<%@page import="com.github.pagehelper.PageInfo"%> <%@page import="java.util.Map"%> <%@page import="java.util.List"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>超市订单管理系统--订单列表</title> <style type="text/css"> tr { height: 40px; } *{ background-color: white; } </style> </head> <body> <% //PageInfo pi=(PageInfo)request.getAttribute("bills"); %> <div style="width: 1800px;height: 1000px;margin: auto;"> <div style="width: 100%;height: 160px;"> <div style="width: 100%;height: 20px;"> <div align="left" style="width: 20%;height: 100%;float: left;" > <a href="home.do" style="text-decoration: none;">返回首页</a> </div> <div align="right" style="width: 80%;height: 100%;float: right;"> <a>欢迎,<span style="color: red;">${user.userName}</span></a> <a href="index.do" style="text-decoration: none;">注销</a> </div> </div> <div align="center" style="width: 100%;height: 140px;line-height: 140px;"><h1>超市订单管理系统</h1></div> </div> <% //List<Map<String,Object>> list=pi.getList(); %> <% List<Map<String,Object>> list= (List<Map<String, Object>>) request.getAttribute("bills");%> <div align="center" style="width: 100%;height: 840px;overflow: scroll;"> <!-- 当前普通员工是否有谈下过订单信息,如果没有,显示暂无信息,如果有,展示该员工的所有订单 --> <% if(list==null||list.size()==0){ %> <div style="width: 98%;text-align: center;height: 800px;"> 当前暂无订单信息 </div> <%}else { %> <table border="1" style="width: 98%;text-align: center;border-collapse: collapse;"> <tr> <td>主键Id</td> <td>账单编码</td> <td>商品名称</td> <td>商品描述</td> <td>商品数量</td> <td>商品单位</td> <td>商品总额</td> <td>是否支付</td> <td>员工姓名</td> <td>供应商名称</td> <td>创建时间</td> <td>修改时间</td> <td>操作</td> </tr> <% for(int i=0;i<list.size();i++){ %> <tr> <td ><%=list.get(i).get("id") %></td> <td><%=list.get(i).get("billCode") %></td> <td><%=list.get(i).get("productName") %></td> <td><%=list.get(i).get("productDesc") %></td> <td><%=list.get(i).get("productCount") %></td> <td><%=list.get(i).get("productUnit") %></td> <td><%=list.get(i).get("totalPrice")%>元</td> <% int type=(int)list.get(i).get("isPayment"); %> <% if(type==1){ %> <td style="color:red;">未支付</td> <%}else if(type==2){ %> <td style="color:green;">已支付</td> <%} %> <td><%=list.get(i).get("userName") %></td> <td><%=list.get(i).get("proName")%></td> <td><%=list.get(i).get("creationDate")%></td> <% String time=""; if(list.get(i).get("modifyDate")==null){ time="暂未修改"; }else if("null".equals(list.get(i).get("modifyDate"))){ time="暂未修改"; }else{ time=list.get(i).get("modifyDate").toString(); } %> <td><%=time %></td> <td> <a href="GetBillByIndex.do?index=<%=i%>"><input type="button" value="修改" style="border: 2px;border-radius: 12px;color: black;color: black;background-color: #ece8e8"></a> <a href="DeleteBill.do?id=<%=list.get(i).get("id") %>"><input type="button" value="删除" style="border: 2px;border-radius: 12px;color: black;background-color: #ece8e8"></a> </td> </tr> <%} %> </table> <!-- 分页页码导航栏 --> <%--<br> <div align="center"> <!-- 判断当前页是否存在上一页,不存在则不显示上一页的按钮 --> <%if(pi.getPrePage()>0){ %> <a href="GetBills.do?ym=<%=pi.getPrePage()%>"><input type="button" value="上一页"/></a> <%} %> <% for(int i:pi.getNavigatepageNums()){ %> <a href="GetBills.do?ym=<%=i%>"><%=i %></a> <%} %> <!-- 判断当前页是否存在下一页,不存在则不显示下一页的按钮 --> <% if(pi.getPageNum()<pi.getLastPage()){ %> <a href="GetBills.do?ym=<%=pi.getNextPage()%>"><input type="button" value="下一页"/></a> <%} %> </div>--%> <%} %> </div> </div> </body> </html>
上面是billList2的页面:
package com.smbms.controller; import com.smbms.service.IBillService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.servlet.ModelAndView; /** * 控制层用于控制和判断 * */ @Controller public interface IBillController { //将service层对象自动写入 public ModelAndView GetBills(); } package com.smbms.controller; import com.smbms.service.IBillService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import java.util.List; import java.util.Map; /** * */ @Controller public class BillControllerImp implements IBillController { @Autowired IBillService billService; @RequestMapping("/GetBills.do") public ModelAndView GetBills(){ ModelAndView mav=new ModelAndView(); List<Map<String, Object>> billls=billService.getBills(); mav.addObject("bills",billls); mav.setViewName("billList2"); return mav; } }
package com.smbms.service; import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; public interface IBillService { //获得所有订单信息 List<Map<String,Object>> getBills(); }
package com.smbms.service; import com.smbms.dao.IBillDao; import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; import java.util.Map; @Service(value = "bService") public class BillServiceImp implements IBillService{ @Autowired IBillDao dao; @Override public List<Map<String, Object>> getBills() { return dao.getBills(); } }
package com.smbms.dao; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import java.util.List; import java.util.Map; public interface IBillDao { //查询所有订单,并显示用户的姓名和供应商的名称 //完成该数据的查询需要做三张表的多表联查 @Select("select smbms_bill.id,billCode,productName," + "productDesc,productCount,productUnit,totalPrice,isPayment,smbms_user.userName," + "smbms_provider.proName,smbms_bill.creationDate,smbms_bill.modifyDate " + "from smbms_user,smbms_bill,smbms_provider " + "where smbms_user.id=smbms_bill.createdBy " + "and smbms_bill.providerId=smbms_provider.id") List<Map<String,Object>> getBills(); }
效果图
今天到项目的内容后续更新