标签:
0 cell-data-list.jsp
<form action="cell-data-list.jhtml?functionId=1093" theme="simple" method="post" target="_self" name="searchform" id="searchform"> <div class="s_top_opt"> <ul class="clear"> <li class="ck">cat</li> <li><input type="text" class="w_t100" name="cat" value="<s:property value="cat"/>"/> <li><label class="b_cform_btn" style="display:inline-block; padding:0;"><input type="submit" class="input_btn" value="submit" /></label></li> <s:if test="items.size()>0"> <li><label class="b_cform_btn" style="display:inline-block; padding:0;"> <input type="button" class="input_btn" value="Download <s:property value="cat"/>" onclick="window.open(‘cell-data-export.jhtml?functionId=1093&cat=<s:property value="cat"/>‘,‘_blank‘)" /> </label></li> </s:if> </ul> </div> <s:if test="error!=null && error.length()>0"> <div style="color:red"> ERROR: <s:property value="error"/> </div> </s:if> </form
1. form表单:1. 提交表单的时候先执行check()方法,为真时才去提交表单,付款时间用了wdatepicker插件
<div class="back_cform"> <s:form action="savePrepaymentItem" onsubmit="return check()"> <input type="hidden" name="prepayment.id" value="<s:property value="prepayment.id"/>"/> <input type="hidden" name="item.id" value="<s:property value="item.id"/>"/> <input type="hidden" name="item.orderId" value="<s:property value="item.orderId"/>" id="orderId"/> <input type="hidden" name="item.orderPrice" value="<s:property value="item.orderPrice"/>" id="orderPrice"/> <input type="hidden" name="item.orderUnitAl" value="<s:property value="item.orderUnitAl"/>" id="orderUnitAl"/> <table id="table"> <tr> <th colspan="2" class="back_title"><h3>新增预付款订单 >></h3></th> </tr> <tr> <th>预付款公司</th> <td><s:property value="prepayment.company"/></td> </tr> <tr> <th>预付款金额</th> <td><s:property value="prepayment.unitAl"/> <s:property value="prepayment.advanceAmount"/></td> </tr> <tr> <th>预付款剩余金额</th> <td><s:property value="prepayment.unitAl"/> <s:property value="prepayment.remainAmount"/></td> </tr> <tr> <th>订单号</th> <td><input type="text" name="item.orderNo" class="w_t300" value="<s:property value="item.orderNo"/>" id="orderNo"></td> </tr> <tr> <th>订单金额</th> <td><span id="orderPriceText"><s:property value="item.orderUnitAl"/> <s:property value="item.orderPrice"/></span></td> </tr> <tr> <th>实际支付金额</th> <td><input type="text" name="item.paidPrice" class="w_t300" value="<s:property value="item.paidPrice"/>"></td> </tr> <tr> <th>付款时间</th> <td><input type="text" class="w_t300" id="payDate" name="item.payDate" value="<s:date name="item.payDate" format="yyyy-MM-dd"/>" onfocus="WdatePicker({el:‘payDate‘,dateFmt:‘yyyy-MM-dd‘,lang:‘en‘})"></td> </tr> <tr> <th>操作人</th> <td><s:property value="item.operator"/></td> </tr> <tr> <td align="right" colspan="2"> <div class="b_cform_btn" > <input type="button" value="Delete" class="input_btn" id="delete" style="background:darkred"> <input type="submit" value="Submit" class="input_btn" id="save"> </div> </td> </tr> </table> </s:form> </div> <script type="text/javascript"> function check() { var orderId = $(‘#orderId‘).val(); if ( ! orderId) { alert(‘未找到订单‘); return false; } return true; } </script>
1.2 public String prepaymentOrderInfo() { Map<String, Object> json = new HashMap<>(); Optional<OrderDTO> orderDTO = prepaymentService.findOrderInfoByOrderNo(orderNo); if (orderDTO.isPresent()) { OrderDTO order = orderDTO.get(); json.put("id", order.getId()); json.put("no", order.getNo()); json.put("unitAl", order.getUnitAL()); if (order.calcUnitPriceFirst()) { json.put("price", order.getLocalPrice()); } else { double price = order.getRealPrice() - Math.floor(order.getRealPrice() * 0.1 * (10 - order.getDiscount())) + order.getShippingFee() - order.getDiscounts(); json.put("price", price); } } else { json.put("id", null); } writeJSON(json); return null; }
1.3 @Override public Optional<OrderDTO> findOrderInfoByOrderNo(String orderNo) { String sql = "select id, no, unitAL, calcType, localPrice, realprice, discount, shippingFee, discounts" + "\n from selleck_order" + "\n where no=:no"; Map<String, Object> params = new HashMap<>(); params.put("no", orderNo); List<Map<String, Object>> list = dao.findRawBySql(sql, params); if (list.isEmpty()) { return Optional.empty(); } else { Map<String, Object> map = list.get(0); OrderDTO order = new OrderDTO(); order.setId(((Number) map.get("id")).intValue()); order.setNo((String) map.get("no")); order.setUnitAL((String) map.get("unitAL")); order.setCalcType((String) map.get("calcType")); if (map.get("localPrice") != null) { order.setLocalPrice(((Number) map.get("localPrice")).doubleValue()); } order.setRealPrice(((Number) map.get("realprice")).doubleValue()); order.setDiscount(((Number) map.get("discount")).doubleValue()); order.setShippingFee(((Number) map.get("shippingFee")).doubleValue()); order.setDiscounts(((Number) map.get("discounts")).doubleValue()); return Optional.of(order); } }
//1.4 protected void writeJSON(Object obj) { try { String json = mapper.writeValueAsString(obj); HttpServletResponse response = ServletActionContext.getResponse(); response.setContentLength(json.getBytes(utf8).length); response.setContentType("application/json;charset=UTF-8"); response.getWriter().write(json); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } }
注意:js上面还有单独的
<s:url action="deletePrepaymentItem" var="deleteAction" escapeAmp="false"> <s:param name="prepayment.id" value="prepayment.id"/> <s:param name="item.id" value="item.id"/> </s:url>
//1.0 window.location = url; <script type="text/javascript"> $(‘#orderNo‘).on(‘change‘, function() { $(‘#save‘).hide(); $.getJSON(‘<s:url action="prepaymentOrderInfo"/>‘, {orderNo: $(this).val()}) .done(function(json) { $(‘#orderId‘).val(json.id); $(‘#orderUnitAl‘).val(json.unitAl); $(‘#orderPrice‘).val(json.price); $(‘#orderPriceText‘).text(json.unitAl + ‘ ‘ + json.price); }) .always(function() { $(‘#save‘).show(); }) }); $(‘#delete‘).on(‘click‘, function () { if (confirm(‘由预付款中删除此订单?‘)) { window.location = ‘<s:url action="deletePrepaymentItem"/>‘ + ‘?prepayment.id=‘ + ‘<s:property value="prepayment.id"/>‘ + ‘&item.id=‘ + ‘<s:property value="item.id"/>‘; } }); </script>
window.open(url);
<script language="javascript"> function exportExcel() { var company = $("#precompany").val(); var salesman = $("#presalesman").val(); var remainAmountType = $("#preselect").val(); var url = ‘arshare/exportExcel.jhtml?company=‘ + (encodeURI(company)) + ‘&remainAmountType=‘ + (encodeURI(remainAmountType)) + ‘&salesman=‘ + (encodeURI(salesman)); window.open(url) } </script>
3. 通过a标签
<s:iterator var="item" value="#prepayment.items"> <tr> <td class="w80"><label><s:property value="#item.orderNo"/></label></td> <td class="w100"><label><s:property value="#item.orderUnitAl"/> <s:property value="#item.orderPrice"/></label></td> <td class="w100"><label><s:property value="#prepayment.unitAl"/> <s:property value="#item.paidPrice"/></label></td> <td class="w120"><label><s:date name="#item.payDate" format="yyyy-MM-dd"/></label></td> <td class="w100"><label><s:property value="#item.operator"/></label></td> <td class="w30"> <label> <a href="<s:url action="editPrepaymentItem"/>?prepayment.id=<s:property value="#prepayment.id"/>&item.id=<s:property value="#item.id"/>">Edit</a> </label> </td> </tr> </s:iterator> </table>
标签:
原文地址:http://www.cnblogs.com/bravolove/p/5895501.html