1 function deleteBill(obj){ 2 $.ajax({ 3 type:"GET", 4 url:path+"/BillServlet", 5 data:{method:"delbill",billid:obj.attr("billid")}, 6 dataType:"json", 7 success:function(data){ 8 if(data.delResult == "true"){//删除成功:移除删除行 9 cancleBtn(); 10 obj.parents("tr").remove(); 11 }else if(data.delResult == "false"){//删除失败 12 //alert("对不起,删除订单【"+obj.attr("billcc")+"】失败"); 13 changeDLGContent("对不起,删除订单【"+obj.attr("billcc")+"】失败"); 14 }else if(data.delResult == "notexist"){ 15 //alert("对不起,订单【"+obj.attr("billcc")+"】不存在"); 16 changeDLGContent("对不起,订单【"+obj.attr("billcc")+"】不存在"); 17 } 18 }, 19 error:function(data){ 20 alert("对不起,删除失败"); 21 } 22 }); 23 }
1 private void delBill(HttpServletRequest req, PrintWriter out, 2 BillBiz billBiz) { 3 int billid = Integer.parseInt(req.getParameter("billid")); 4 if (billBiz.delBill(billid)) { 5 out.print("{"delResult":"true"}"); 6 } else { 7 out.print("{"delResult":"false"}"); 8 } 9 }
1 $("#search").submit(function() { 2 $(".addBillList").remove(); 3 $.get("BillServlet", $.param($("#search").serializeArray()), function(data) { 4 $($.parseJSON(data)).each(function() { 5 var str = "<tr class="addBillList"><td><span>"+this.billCode+"</span></td>"+ 6 " <td>"+ 7 " <span>"+this.productName+"</span>"+ 8 " </td>"+ 9 " <td>"+ 10 " <span>"+this.providerName+"</span>"+ 11 " </td>"+ 12 " <td>"+ 13 " <span>"+this.totalPrice+"</span>"+ 14 " </td>"+ 15 " <td>"+ 16 " <span>"+(this.isPayment == 1?"未付款":"已付款")+ 17 " </span>"+ 18 " </td>"+ 19 " <td>"+ 20 " <span>"+ 21 " <fmt:formatDate value=""+this.creationDate+"" pattern="yyyy-MM-dd"/>"+ 22 " </span>"+ 23 " </td>"+ 24 " <td>"+ 25 " <span><a class="viewBill" href="BillServlet?method=view&billid="+this.id+"" billcc="+this.billCode+"><img src="images/read.png" alt="查看" title="查看"/></a></span>"+ 26 " <span><a class="modifyBill" href="BillServlet?method=modify&billid="+this.id+"" billcc="+this.billCode+"><img src="images/xiugai.png" alt="修改" title="修改"/></a></span>"+ 27 " <span><a class="deleteBill" href="javascript:;" billid="+this.id+" billcc="+this.billCode+"><img src="images/schu.png" alt="删除" title="删除"/></a></span>"+ 28 " </td>"+ 29 "</tr>"; 30 $(".providerTable").append(str); 31 $(".deleteBill").on("click",delBill); 32 }); 33 }); 34 return false; 35 });
1 private void getBills(HttpServletRequest req, PrintWriter out, 2 BillBiz billBiz) { 3 String queryProductName = req.getParameter("queryProductName"); //商品名称 4 int queryProviderId = Integer.parseInt(req.getParameter("queryProviderId")); //供应商id 5 int queryIsPayment = Integer.parseInt(req.getParameter("queryIsPayment")); //是否支付 6 List<Bill> billList = billBiz.getBills(queryProductName, queryProviderId, queryIsPayment); 7 String result = JSON.toJSONString(billList); 8 out.print(result); 9 }