Commit bcfb747d by 朱继来

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

parent f55bd7a9
...@@ -1015,13 +1015,30 @@ ...@@ -1015,13 +1015,30 @@
$('.order-change-table input').on('blur', function(){ $('.order-change-table input').on('blur', function(){
var table = $('.order-change-table'); var table = $('.order-change-table');
var goods_total = 0; var goods_total = 0;
var supplier = [];
$(table).find('tbody tr').each(function(){ $(table).find('tbody tr').each(function(){
var num = parseInt($(this).find('.num').val()) || 0; var num = parseInt($(this).find('.num').val()) || 0;
var price = parseFloat($(this).find('.price').val()) || 0; var price = parseFloat($(this).find('.price').val()) || 0;
goods_total += parseFloat(num * price); 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 fee = parseFloat($('input[name="extra_fee"]').val());
var total = parseFloat(goods_total + fee).toFixed(2); var total = parseFloat(goods_total + fee).toFixed(2);
......
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
<tbody> <tbody>
@foreach ($order_items_info as $v) @foreach ($order_items_info as $v)
<tr> <tr data-sup="{{$v['supplier_name']}}">
<td> <td>
<p>{{$v['supplier_name']}}</p> <p>{{$v['supplier_name']}}</p>
</td> </td>
...@@ -122,7 +122,7 @@ ...@@ -122,7 +122,7 @@
<?php $extend_fee_items = json_decode($order_temp_info['extend_fee_items'], true); ?> <?php $extend_fee_items = json_decode($order_temp_info['extend_fee_items'], true); ?>
@foreach ($extend_fee_items as $k => $v) @foreach ($extend_fee_items as $k => $v)
<tr> <tr data-sup="{{$v['supplier_name']}}">
<td> <td>
@if (strpos($k, '.') !== false) @if (strpos($k, '.') !== false)
<p> <p>
...@@ -137,15 +137,15 @@ ...@@ -137,15 +137,15 @@
<input type="hidden" name="change_extend_fee[{{$k}}][supplier_name]" value="{{$v['supplier_name']}}"> <input type="hidden" name="change_extend_fee[{{$k}}][supplier_name]" value="{{$v['supplier_name']}}">
</td> </td>
<td> <td>
<input type="hidden" name="change_extend_fee[{{$k}}][amount]" value="{{$v['amount']}}"> <input type="hidden" name="change_extend_fee[{{$k}}][amount]" class="sup_amount" value="{{$v['amount']}}">
<p>{{$v['amount']}}</p> <p class="sup_amount_val">{{$v['amount']}}</p>
</td> </td>
<td> <td>
<input class="adjust_extend_fee only_number" name="change_extend_fee[{{$k}}][extend_fee]" value="{{$v['extend_fee']}}"> <input class="adjust_extend_fee only_number" name="change_extend_fee[{{$k}}][extend_fee]" value="{{$v['extend_fee']}}">
</td> </td>
<input type="hidden" name="change_extend_fee[{{$k}}][count]" value="{{$v['count']}}"> <input type="hidden" name="change_extend_fee[{{$k}}][count]" value="{{$v['count']}}">
@if (isset($v['ladder_max'])) @if (isset($v['ladder_max']))
<input type="hidden" name="change_extend_fee[{{$k}}][ladder_max]" value="{{$v['ladder_max']}}"> <input type="hidden" name="change_extend_fee[{{$k}}][ladder_max]" value="{{$v['ladder_max']}}">
@endif @endif
......
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