|
@ -41,7 +41,7 @@ |
|
|
<?php |
|
|
<?php |
|
|
$js = <<<SCRIPT |
|
|
$js = <<<SCRIPT |
|
|
//初始化订单商品数据
|
|
|
//初始化订单商品数据
|
|
|
var data = $deliveryGoods ; |
|
|
|
|
|
|
|
|
var data = $deliveryGoods; |
|
|
console.log(data); |
|
|
console.log(data); |
|
|
var unShipped = {}; |
|
|
var unShipped = {}; |
|
|
function init() { |
|
|
function init() { |
|
@ -54,9 +54,38 @@ $js = <<<SCRIPT |
|
|
unShipped = JSON.stringify(unShipped); |
|
|
unShipped = JSON.stringify(unShipped); |
|
|
$('#deliveryGoods').val(unShipped) |
|
|
$('#deliveryGoods').val(unShipped) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
init(); |
|
|
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) { |
|
|
function showUnShipped(unShipped) { |
|
|
unShipped.forEach(function (item,index) { |
|
|
unShipped.forEach(function (item,index) { |
|
@ -66,8 +95,8 @@ $js = <<<SCRIPT |
|
|
"<td class='lack_number'>" + item.lack_number + "</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='text' class='goods_count' value='"+item.lack_number+"' disabled/></td>" + |
|
|
"<td>" + |
|
|
"<td>" + |
|
|
"<input type='button' class='btn btn-primary' value='编辑' onclick='updateGoods(this)'/>" + |
|
|
|
|
|
"<input type='button' class='btn btn-primary' value='保存' onclick='saveGoods(this)' style='display: none' />" + |
|
|
|
|
|
|
|
|
"<input type='button' class='btn btn-primary btn-update' value='编辑'/>" + |
|
|
|
|
|
"<input type='button' class='btn btn-primary btn-save' value='保存' style='display: none' />" + |
|
|
"</td>" + |
|
|
"</td>" + |
|
|
"</tr>"; |
|
|
"</tr>"; |
|
|
$('.unShipped-table').append(tr) |
|
|
$('.unShipped-table').append(tr) |
|
@ -100,35 +129,13 @@ $js = <<<SCRIPT |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//编辑发货数量
|
|
|
|
|
|
function updateGoods(ref){ |
|
|
|
|
|
$(ref).hide(); |
|
|
|
|
|
$(ref).next().show(); |
|
|
|
|
|
$(ref).parent().parent().find('.goods_count').removeAttr('disabled') |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//保存编辑
|
|
|
|
|
|
function saveGoods(ref) { |
|
|
|
|
|
if(typeof unShipped =='string'){ |
|
|
|
|
|
unShipped = JSON.parse(unShipped) |
|
|
|
|
|
} |
|
|
|
|
|
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(); |
|
|
|
|
|
|
|
|
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; |
|
|
SCRIPT; |
|
|
|
|
|
|
|
|
$this->registerJs($js); |
|
|
$this->registerJs($js); |
|
|
?>
|
|
|
?>
|
|
|
|
|
|
|
|
|