Authored by liuyue

网销上架bug fix

... ... @@ -163,7 +163,8 @@ var g = new common.grid({
}
}, {
display: '商品信息',width:'30%',
display: '商品信息',
width: '30%',
render: function(item) {
var productName = item.productName ? item.productName : '',
brandName = item.brandName ? item.brandName : '',
... ... @@ -398,31 +399,32 @@ var shelveTable = new common.grid({
display: 'SKC上架操作(状态)',
render: function(item) {
if (item.status == 0) {
return '<a class="btn btn-success btnskc" data-type="1" data-index="'+item.__index+'" href="javascript:;">点击上架</a>';
return '<a class="btn btn-success btnskc" data-type="1" data-index="' + item.__index + '" href="javascript:;">点击上架</a>';
} else {
return '<a class="btn btn-danger btnskc" data-type="0" data-index="'+item.__index+'" href="javascript:;">点击下架</a>';
return '<a class="btn btn-danger btnskc" data-type="0" data-index="' + item.__index + '" href="javascript:;">点击下架</a>';
}
}
}, {
display: '<div class="subhhead"><span>SKU</span><span>尺码</span><span>库存</span><span>SKU上架操作</span><span>SKU上架操作</span></div>',
render: function(item){
render: function(item) {
console.log(item);
return common.util.__template2($("#template2").html(),item)
return common.util.__template2($("#template2").html(), item)
}
}]
});
/*代码优惠*/
var goodsList={},shelveLayer=null;
var goodsList = {},
shelveLayer = null;
//单个sku,skc上下架
$('#basicTable').on('click', '.shelve-btn', function() {
var item=g.rows[$(this).data("index")];
var item = g.rows[$(this).data("index")];
var that = this;
$(that).addClass('disabled');
getdata(item.productSkn,function(res){
getdata(item.productSkn, function(res) {
shelveLayer = common.dialog.open({
title: '上/下架',
width: 900,
... ... @@ -430,78 +432,86 @@ $('#basicTable').on('click', '.shelve-btn', function() {
});
$(that).removeClass('disabled');
goodsList=res.data.goodsList;
goodsList = res.data.goodsList;
shelveTable.init(goodsList);
});
});
function getdata(Skn,callback){
function getdata(Skn, callback) {
common.util.__ajax({
url: '/goods/netsale/getdata',
data: {
param: Skn
}
}, function(res) {
callback&&callback(res);
},true);
callback && callback(res);
}, true);
}
$(document).on("click",".btnskc",function(){
var item=goodsList[$(this).data("index")];
$(document).on("click", ".btnskc", function() {
var item = goodsList[$(this).data("index")];
console.log(item);
common.util.__ajax({
url: '/goods/product/updateGoodsStatus',
data: {productSkc:item.productSkc,targetStatus:item.status}
data: {
productSkc: item.productSkc,
targetStatus: item.status ? 0 : 1
}
}, function(res) {
if (res.code == 200) {
getdata(item.productSkc,function(res){
goodsList=res.data.goodsList;
shelveTable.reload();
getdata(item.productSkn, function(res) {
goodsList = res.data.goodsList;
shelveTable.init(res.data.goodsList);
});
}
})
});
$(document).on("click",".btnsku",function(){
var item=goodsList[$(this).data("index")]
var item1=item.goodsSizeList[$(this).data("subindex")];
$(document).on("click", ".btnsku", function() {
var item = goodsList[$(this).data("index")]
var item1 = item.goodsSizeList[$(this).data("subindex")];
common.util.__ajax({
url: '/goods/product/updateProductSkuStatus',
data: {productSkc:item1.productSku,targetStatus:item.status}
data: {
productSku: item1.productSku,
targetStatus: item1.status ? 0 : 1
}
}, function(res) {
if (res.code == 200) {
getdata(item.productSkc,function(res){
goodsList=res.data.goodsList;
getdata(item.productSkn, function(res) {
goodsList = res.data.goodsList;
console.log(goodsList);
shelveTable.reload();
shelveTable.init(res.data.goodsList);
});
}
})
});
$(document).on("change",".wqt_checkbox,.wqt_all",function(){
var _count1=0,_count2=0;
$.each(g.selected,function(index,item){
console.log(item.status);
$(document).on("change", ".wqt_checkbox,.wqt_all", function() {
var _count1 = 0,
_count2 = 0;
$.each(g.selected, function(index, item) {
/*添加兼容逻辑*/
if(item.status){
_count1++;//上
}else{
_count2++;//下
if (item.status == 8 || item.status == 3 || item.status == 2 || item.status == 0) {
_count1++; //上
} else {
_count2++; //下
}
});
if(_count2==g.selected.length){
$("#offshelve").addClass("btn-info").removeClass("btn-default").prop("disabled",false);
}else{
$("#offshelve").addClass("btn-default").removeClass("btn-info").prop("disabled",true);
if (_count1 == g.selected.length) {
$('#onshelve').removeClass('disabled');
} else {
$('#onshelve').addClass('disabled');
}
if(_count1==g.selected.length){
$("#onshelve").addClass("btn-info").removeClass("btn-default").prop("disabled",false);
}else{
$("#onshelve").addClass("btn-default").removeClass("btn-info").prop("disabled",true);
if (_count2 == g.selected.length) {
$('#offshelve').removeClass('disabled');
} else {
$('#offshelve').addClass('disabled');
}
})
\ No newline at end of file
});
\ No newline at end of file
... ...
... ... @@ -142,8 +142,8 @@
</div>
<div class="row" style="margin: 0 0 0 -5px;">
<a id="onshelve" href="javascript:;" class="btn btn-default" >上架</a>
<a id="offshelve" href="javascript:;" class="btn btn-default">下架</a>
<a id="onshelve" href="javascript:;" class="btn btn-info disabled" >上架</a>
<a id="offshelve" href="javascript:;" class="btn btn-info disabled">下架</a>
<a id="export-btn" href="javascript:;" class="btn btn-info">导出</a>
<a id="import-btn" href="/goods/netsale/batch" class="btn btn-info">批量(排序、款型系列)</a>
</div>
... ... @@ -225,10 +225,10 @@
<span>[[item.stock]]</span>
<span>[[ ["下架","上架"][item.status] ]]</span>
<span>
[[if item.state]]
<a class="btn btn-success btnsku" data-subindex='[[index]]' data-index=[[__index]] href="javascript:;">上架</a>
[[else]]
[[if item.status]]
<a class="btn btn-danger btnsku" data-subindex='[[index]]' data-index=[[__index]] href="javascript:;">下架</a>
[[else]]
<a class="btn btn-success btnsku" data-subindex='[[index]]' data-index=[[__index]] href="javascript:;">上架</a>
[[/if]]
</span>
</div>
... ...