|
|
@ -18,6 +18,9 @@ |
|
|
|
border-radius: 10px; |
|
|
|
box-shadow:0 4px 30px 2px rgba(223, 225, 230, 0.5) !important; |
|
|
|
} |
|
|
|
input { |
|
|
|
width: 50%; |
|
|
|
} |
|
|
|
</style> |
|
|
|
|
|
|
|
<div> |
|
|
@ -25,118 +28,132 @@ |
|
|
|
<h5>未发货商品</h5> |
|
|
|
<table class="table unShipped-table"> |
|
|
|
<tr> |
|
|
|
<th>商品ID</th> |
|
|
|
<th>商品名称</th> |
|
|
|
<th>商品sku</th> |
|
|
|
<th>还需发货数量</th> |
|
|
|
<th>发货数量</th> |
|
|
|
</tr> |
|
|
|
|
|
|
|
<?php |
|
|
|
foreach ($deliveryGoods['unShipped'] as $value) { |
|
|
|
$lackNumber = isset($value['lack_number']) ? $value['lack_number'] : $value['goods_count']; |
|
|
|
echo '<tr>' . |
|
|
|
'<td>' . $value['goods_id'] . '</td>' . |
|
|
|
'<td>' . $value['goods_name'] . '</td>' . |
|
|
|
'<td>' . $value['sku_value'] . '</td>' . |
|
|
|
'<td>' . $lackNumber . '</td>' . |
|
|
|
"<td><input type='number' name='deliveryGoods[{$value['id']}]' max='{$lackNumber}' min='0' value={$lackNumber} /></td>" . |
|
|
|
'</tr>'; |
|
|
|
} |
|
|
|
?>
|
|
|
|
</table> |
|
|
|
</div> |
|
|
|
<div class="box shipped-box"> |
|
|
|
<h5>已发货商品</h5> |
|
|
|
</div> |
|
|
|
<input type="hidden" id="deliveryGoods" name="deliveryGoods"><!-- 用于保存商品json --> |
|
|
|
</div> |
|
|
|
|
|
|
|
<?php |
|
|
|
$js = <<<SCRIPT |
|
|
|
//初始化订单商品数据
|
|
|
|
var data = $deliveryGoods; |
|
|
|
console.log(data); |
|
|
|
var unShipped = {}; |
|
|
|
function init() { |
|
|
|
unShipped = data.unShipped; |
|
|
|
showUnShipped(unShipped); |
|
|
|
if(data.shipped){ |
|
|
|
var shipped = data.shipped; |
|
|
|
showShipped(shipped) |
|
|
|
} |
|
|
|
unShipped = JSON.stringify(unShipped); |
|
|
|
$('#deliveryGoods').val(unShipped) |
|
|
|
} |
|
|
|
init(); |
|
|
|
|
|
|
|
//编辑发货数量
|
|
|
|
function updateGoods(ref){ |
|
|
|
ref = $(ref)[0].target; |
|
|
|
$(ref).hide(); |
|
|
|
$(ref).next().show(); |
|
|
|
$(ref).parent().parent().find('.goods_count').removeAttr('disabled') |
|
|
|
} |
|
|
|
|
|
|
|
//保存编辑
|
|
|
|
function saveGoods(ref) { |
|
|
|
if(typeof unShipped =='string'){ |
|
|
|
unShipped = JSON.parse(unShipped) |
|
|
|
} |
|
|
|
ref = $(ref)[0].target; |
|
|
|
var tr = $(ref).parent().parent(); |
|
|
|
tr.find('.goods_count').attr('disabled','disabled'); |
|
|
|
var index = tr.attr('data-index'); |
|
|
|
var number = tr.find('.goods_count').val(); |
|
|
|
if (number < 0) { |
|
|
|
alert('发货数量不能低于0'); |
|
|
|
tr.find('.goods_count').val(0); |
|
|
|
return false; |
|
|
|
} |
|
|
|
unShipped[index].goods_count = number; |
|
|
|
unShipped = JSON.stringify(unShipped); |
|
|
|
$('#deliveryGoods').val(unShipped); |
|
|
|
$(ref).hide(); |
|
|
|
$(ref).prev().show(); |
|
|
|
} |
|
|
|
|
|
|
|
//显示未发货商品
|
|
|
|
function showUnShipped(unShipped) { |
|
|
|
unShipped.forEach(function (item,index) { |
|
|
|
var tr = "<tr data-index='" + index +"'>" + |
|
|
|
"<td class='goods_name'>" + item.goods_name + "</td>" + |
|
|
|
"<td class='goods_sku'>" + item.sku_value + "</td>" + |
|
|
|
"<td class='lack_number'>" + item.lack_number + "</td>" + |
|
|
|
"<td><input type='text' class='goods_count' value='"+item.lack_number+"' disabled/></td>" + |
|
|
|
"<td>" + |
|
|
|
"<input type='button' class='btn btn-primary btn-update' value='编辑'/>" + |
|
|
|
"<input type='button' class='btn btn-primary btn-save' value='保存' style='display: none' />" + |
|
|
|
"</td>" + |
|
|
|
"</tr>"; |
|
|
|
$('.unShipped-table').append(tr) |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
//显示已发货商品
|
|
|
|
function showShipped(shipped) { |
|
|
|
shipped.forEach(function(item,index){ |
|
|
|
var table = ' <table class="table shipped-table">' + |
|
|
|
'<tr>' + |
|
|
|
'<th>商品名称</th>' + |
|
|
|
'<th>商品sku</th>' + |
|
|
|
'<th>发货数量</th>' + |
|
|
|
'</tr>' + |
|
|
|
'</table>'; |
|
|
|
// var div = document.createElement('div');
|
|
|
|
// div.innerText = '运单号:' + item.logisticInfo.invoice_no + '快递公司:'+ item.logisticInfo.exp_name;
|
|
|
|
// $('.shipped-box').append(div);
|
|
|
|
$('.shipped-box').append(table); |
|
|
|
table = $('.shipped-table').eq(index); |
|
|
|
item.goodsInfo.forEach(function (item,index) { |
|
|
|
var tr = "<tr data-index='" + index +"'>" + |
|
|
|
"<td class='goods_name'>" + item.goods_name + "</td>" + |
|
|
|
"<td class='goods_sku'>" + item.sku_value + "</td>" + |
|
|
|
"<td class='goods_count'>" + item.delivery_number + "</td>" + |
|
|
|
"</tr>"; |
|
|
|
$(table).append(tr); |
|
|
|
}); |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
var btnUpdate = $('.btn-update'); |
|
|
|
var btnSave = $('.btn-save'); |
|
|
|
for (i = 0; i < btnUpdate.length; i++) { |
|
|
|
btnUpdate[i].addEventListener("click", updateGoods); |
|
|
|
btnSave[i].addEventListener("click", saveGoods); |
|
|
|
} |
|
|
|
SCRIPT; |
|
|
|
$this->registerJs($js); |
|
|
|
?>
|
|
|
|
//$js = <<<SCRIPT
|
|
|
|
////初始化订单商品数据
|
|
|
|
/* var data = "<?php echo json_encode($deliveryGoods) ?>";*/ |
|
|
|
// console.log(data);
|
|
|
|
// var unShipped = {};
|
|
|
|
// function init() {
|
|
|
|
//<!-- unShipped = data.unShipped;-->
|
|
|
|
//<!-- showUnShipped(unShipped);-->
|
|
|
|
//<!-- if(data.shipped){-->
|
|
|
|
//<!-- var shipped = data.shipped;-->
|
|
|
|
//<!-- showShipped(shipped)-->
|
|
|
|
//<!-- }-->
|
|
|
|
// unShipped = JSON.stringify(unShipped);
|
|
|
|
// $('#deliveryGoods').val(unShipped)
|
|
|
|
// }
|
|
|
|
// init();
|
|
|
|
//
|
|
|
|
// //编辑发货数量
|
|
|
|
// function updateGoods(ref){
|
|
|
|
// ref = $(ref)[0].target;
|
|
|
|
// $(ref).hide();
|
|
|
|
// $(ref).next().show();
|
|
|
|
// $(ref).parent().parent().find('.goods_count').removeAttr('disabled')
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// //保存编辑
|
|
|
|
// function saveGoods(ref) {
|
|
|
|
// if(typeof unShipped =='string'){
|
|
|
|
// unShipped = JSON.parse(unShipped)
|
|
|
|
// }
|
|
|
|
// ref = $(ref)[0].target;
|
|
|
|
// var tr = $(ref).parent().parent();
|
|
|
|
// tr.find('.goods_count').attr('disabled', 'disabled');
|
|
|
|
// var index = tr.attr('data-index');
|
|
|
|
// var number = tr.find('.goods_count').val();
|
|
|
|
// if (number < 0) {
|
|
|
|
// alert('发货数量不能低于0');
|
|
|
|
// tr.find('.goods_count').val(0);
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
// unShipped[index].goods_count = number;
|
|
|
|
// unShipped = JSON.stringify(unShipped);
|
|
|
|
// $('#deliveryGoods').val(unShipped);
|
|
|
|
// $(ref).hide();
|
|
|
|
// $(ref).prev().show();
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// //显示未发货商品
|
|
|
|
// function showUnShipped(unShipped) {
|
|
|
|
// unShipped.forEach(function (item,index) {
|
|
|
|
// var tr = "<tr data-index='" + index +"'>" +
|
|
|
|
// "<td class='goods_id' name='goodsId[]'>" + item.goods_id + "</td>" +
|
|
|
|
// "<td class='goods_name'>" + item.goods_name + "</td>" +
|
|
|
|
// "<td class='goods_sku'>" + item.sku_value + "</td>" +
|
|
|
|
// "<td class='lack_number'>" + item.lack_number + "</td>" +
|
|
|
|
// "<td><input type='text' class='goods_count' value='"+item.lack_number+"' name='deliveryGoods' disabled/></td>" +
|
|
|
|
// "<td>" +
|
|
|
|
// "<input type='button' class='btn btn-primary btn-update' value='编辑'/>" +
|
|
|
|
// "<input type='button' class='btn btn-primary btn-save' value='保存' style='display: none' />" +
|
|
|
|
// "</td>" +
|
|
|
|
// "</tr>";
|
|
|
|
// $('.unShipped-table').append(tr)
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// //显示已发货商品
|
|
|
|
// function showShipped(shipped) {
|
|
|
|
// shipped.forEach(function(item,index) {
|
|
|
|
// var table = ' <table class="table shipped-table">' +
|
|
|
|
// '<tr>' +
|
|
|
|
// '<th>商品名称</th>' +
|
|
|
|
// '<th>商品sku</th>' +
|
|
|
|
// '<th>发货数量</th>' +
|
|
|
|
// '</tr>' +
|
|
|
|
// '</table>';
|
|
|
|
// // var div = document.createElement('div');
|
|
|
|
// // div.innerText = '运单号:' + item.logisticInfo.invoice_no + '快递公司:'+ item.logisticInfo.exp_name;
|
|
|
|
// // $('.shipped-box').append(div);
|
|
|
|
// $('.shipped-box').append(table);
|
|
|
|
// table = $('.shipped-table').eq(index);
|
|
|
|
// item.goodsInfo.forEach(function (item,index) {
|
|
|
|
// var tr = "<tr data-index='" + index +"'>" +
|
|
|
|
// "<td class='goods_name'>" + item.goods_name + "</td>" +
|
|
|
|
// "<td class='goods_sku'>" + item.sku_value + "</td>" +
|
|
|
|
// "<td class='goods_count'>" + item.delivery_number + "</td>" +
|
|
|
|
// "</tr>";
|
|
|
|
// $(table).append(tr);
|
|
|
|
// });
|
|
|
|
// })
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// var btnUpdate = $('.btn-update');
|
|
|
|
// var btnSave = $('.btn-save');
|
|
|
|
// for (i = 0; i < btnUpdate.length; i++) {
|
|
|
|
// btnUpdate[i].addEventListener("click", updateGoods);
|
|
|
|
// btnSave[i].addEventListener("click", saveGoods);
|
|
|
|
// }
|
|
|
|
//SCRIPT;
|
|
|
|
//$this->registerJs($js);
|
|
|
|
//?>
|
|
|
|
|
|
|
|
|