Commit bcfb747d by 朱继来

供应商附加费随价格或数量改变

parent f55bd7a9
......@@ -1015,13 +1015,30 @@
$('.order-change-table input').on('blur', function(){
var table = $('.order-change-table');
var goods_total = 0;
var supplier = [];
$(table).find('tbody tr').each(function(){
var num = parseInt($(this).find('.num').val()) || 0;
var price = parseFloat($(this).find('.price').val()) || 0;
goods_total += parseFloat(num * price);
var sup = $(this).data('sup');
if (supplier.hasOwnProperty(sup)) { // 判断当前key是否存在于数组中
supplier[sup] += parseFloat(num * price);
} else {
supplier[sup] = parseFloat(num * price);
}
});
// 附加费商品金额设置
$('.extend-fee-table').find('tbody tr').each(function(){
var sup = $(this).data('sup');
$(this).find('.sup_amount').val(supplier[sup]);
$(this).find('.sup_amount_val').text(supplier[sup]);
})
var fee = parseFloat($('input[name="extra_fee"]').val());
var total = parseFloat(goods_total + fee).toFixed(2);
......
......@@ -89,7 +89,7 @@
<tbody>
@foreach ($order_items_info as $v)
<tr>
<tr data-sup="{{$v['supplier_name']}}">
<td>
<p>{{$v['supplier_name']}}</p>
</td>
......@@ -122,7 +122,7 @@
<?php $extend_fee_items = json_decode($order_temp_info['extend_fee_items'], true); ?>
@foreach ($extend_fee_items as $k => $v)
<tr>
<tr data-sup="{{$v['supplier_name']}}">
<td>
@if (strpos($k, '.') !== false)
<p>
......@@ -137,8 +137,8 @@
<input type="hidden" name="change_extend_fee[{{$k}}][supplier_name]" value="{{$v['supplier_name']}}">
</td>
<td>
<input type="hidden" name="change_extend_fee[{{$k}}][amount]" value="{{$v['amount']}}">
<p>{{$v['amount']}}</p>
<input type="hidden" name="change_extend_fee[{{$k}}][amount]" class="sup_amount" value="{{$v['amount']}}">
<p class="sup_amount_val">{{$v['amount']}}</p>
</td>
<td>
<input class="adjust_extend_fee only_number" name="change_extend_fee[{{$k}}][extend_fee]" value="{{$v['extend_fee']}}">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment