页面订单多选框批量操作
程序员文章站
2022-07-13 23:02:33
...
订单多选框添加
<button class="btn btn-info payall" type="button">支付</button>
<table class="table table-striped table-hover table-bordered">
<thead>
<tr>
<th><input name="btSelectAll" type="checkbox"></th>
<th>商品信息</th>
<th>商品金额</th
<th>操作</th>
</tr>
</thead>
<tbody id="search-order-tbody">
<tr>
<td colspan="12">
订单数据加载中...
</td>
</tr>
</tbody>
</table>
<tr>
<td><input name="member_id_checkbox" value="${order.orderId }" totalPrice="${order.totalPrice}" type="checkbox">
</td>
</tr>
js代码获取勾选的单子id和金额,传后台验证
$('[name="btSelectAll"]').die().live('click',function(){
var checked = $(this).prop('checked');
$('[name="member_id_checkbox"]').attr('checked',checked);
})
//支付按钮
$('.payall').die().live('click',function(){
Payall();
})
//支付
function Payall() {
if($('[name="member_id_checkbox"]:checked').length==0){
BootstrapDialog.show({
type : BootstrapDialog.TYPE_WARNING,
title: '消息',
message: '请选择订单',
buttons: [{
label: '确定',
action: function(dialogItself){
dialogItself.close();
}
}]
});
return;
}
//订单数量,订单id拼接字符串,订单总金额
var idnum=$('[name="member_id_checkbox"]:checked').length);
var ids='';
$('[name="member_id_checkbox"]:checked').each(function(){
ids+=","+$(this).val();
})
var prices=0;
$('[name="member_id_checkbox"]:checked').each(function(){ prices=parseInt(prices)+parseInt($(this).attr('totalPrice')*100);
})
//这里不知道用parsefloat会自动保存小数点后十位数,所以我直接转为整数操作
$.ajax({
url : "/ennOrder/payall?ids="+ids+"&price="+price,
type: "get",
success: function(msg){}
});
}
java
String [] memberidArry=ids.split(","); //字符串转数组根据,
for(int i=1;i<memberidArry.length;i++){
//i=0时候为空即为0,从下表1开始获取
Order order=ennOrderService.findOrder(memberidArry[i]);
}
上一篇: Electron # 自定义标题栏(缩小、放大、关闭)
下一篇: QT实现拖动没有标题栏的窗口