Authored by weiqingting

提交

... ... @@ -277,10 +277,10 @@ var g = new common.grid({
if (item.status == 4 || item.status == 1 || item.status == 5 || item.status == 6) {
HtmArr.push('<a href="/goods/netsale/edit/' + item.productSkn + editPostion + '" class="btn btn-info btn-xs edit-btn">编辑</a>');
HtmArr.push('<a href="javascript:;" class="btn btn-danger btn-xs shelve-btn" data-skn="' + item.productSkn + '">下架</a>');
HtmArr.push('<a href="javascript:;" class="btn btn-danger btn-xs shelve-btn" data-index="' + item.__index + '">下架</a>');
} else if (item.status == 3 || item.status == 8 || item.status == 2 || item.status == 0) {
HtmArr.push('<a href="/goods/netsale/edit/' + item.productSkn + editPostion + '" class="btn btn-info btn-xs edit-btn">编辑</a>');
HtmArr.push('<a href="javascript:;" class="btn btn-success btn-xs shelve-btn" data-skn="' + item.productSkn + '">上架</a>');
HtmArr.push('<a href="javascript:;" class="btn btn-success btn-xs shelve-btn" data-index="' + item.__index + '">上架</a>');
}
HtmArr.push('<a href="/goods/netsale/info/' + item.productSkn + editPostion + '" class="btn btn-info btn-xs info-btn">查看</a>');
return HtmArr.join('');
... ... @@ -398,72 +398,110 @@ var shelveTable = new common.grid({
display: 'SKC上架操作(状态)',
render: function(item) {
if (item.status == 0) {
return '<a class="btn btn-success" data-type="1" data-index="'+item.__index+'" data-skc="' + item.productSkc + '" 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" data-type="0" data-index="'+item.__index+'" data-skc="' + item.productSkc + '" 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){
console.log(item);
return "<div class='subhhead'><i>xxx</i><i>尺码</i><i>库存</i><i>SKU上架操作</i><i>SKU上架操作</i></div>";
return common.util.__template2($("#template2").html(),item)
}
}]
});
/*代码优惠*/
var goodsList={},shelveLayer=null;
//单个sku,skc上下架
$('#basicTable').on('click', '.shelve-btn', function() {
var that = this,
skn = $(this).data('skn'),
shelveModalHtml = '',
shelveLayer = null;
var item=g.rows[$(this).data("index")];
var that = this;
$(that).addClass('disabled');
common.util.__ajax({
url: '/goods/netsale/getdata',
data: {
param: skn
}
}, function(res) {
shelveModalHtml = common.util.__template($('#template').html(), res.data.baseProductInfo.baseProduct);
getdata(item.productSkn,function(res){
shelveLayer = common.dialog.open({
title: '上/下架',
width: 900,
content: shelveModalHtml
content: common.util.__template($('#template').html(), res.data.baseProductInfo.baseProduct)
});
$(that).removeClass('disabled');
goodsList=res.data.goodsList;
shelveTable.init(goodsList);
});
shelveTable.init(res.data.goodsList);
$('#shelve-table').on('click', '.btn', function() {
var item=res.data.goodsList[$(this).data("index")];
var param = {},
reqUrl = '';
if ($(this).data('skc')) {
param.productSkc = $(this).data('skc');
reqUrl = '/goods/product/updateGoodsStatus';
} else if ($(this).data('sku')) {
param.productSku = $(this).data('sku');
reqUrl = '/goods/product/updateProductSkuStatus';
}
});
param.targetStatus = $(this).data('type');
common.util.__ajax({
url: reqUrl,
data: param
}, function(res) {
if (res.code == 200) {
// console.log("res.data.goodsList",res.data.goodsList);
// console.log(res.data);
item.status=(item.status)?0:1;
shelveTable.reload();
//shelveLayer.close();
}
})
})
}, true);
function getdata(Skn,callback){
common.util.__ajax({
url: '/goods/netsale/getdata',
data: {
param: Skn
}
}, function(res) {
callback&&callback(res);
},true);
}
});
\ No newline at end of file
$(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}
}, function(res) {
if (res.code == 200) {
getdata(item.productSkc,function(res){
goodsList=res.data.goodsList;
shelveTable.reload();
});
}
})
});
$(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}
}, function(res) {
if (res.code == 200) {
getdata(item.productSkc,function(res){
goodsList=res.data.goodsList;
console.log(goodsList);
shelveTable.reload();
});
}
})
});
$(document).on("change",".wqt_checkbox,.wqt_all",function(){
var _count1=0,_count2=0;
$.each(g.selected,function(index,item){
console.log(item.status);
/*添加兼容逻辑*/
if(item.status){
_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").addClass("btn-info").removeClass("btn-default").prop("disabled",false);
}else{
$("#onshelve").addClass("btn-default").removeClass("btn-info").prop("disabled",true);
}
})
\ No newline at end of file
... ...
... ... @@ -239,7 +239,7 @@ input[type=date], input[type=time], input[type=datetime-local], input[type=month
.subhhead{
span{
width: 80px;
width: 100px;
display: inline-block;
height: 100%;
text-align: center;
... ...
... ... @@ -142,9 +142,9 @@
</div>
<div class="row" style="margin: 0 0 0 -5px;">
<a id="onshelve" href="javascript:;" class="btn btn-default">上架</a>
<a id="onshelve" href="javascript:;" class="btn btn-default" >上架</a>
<a id="offshelve" href="javascript:;" class="btn btn-default">下架</a>
<a id="export-btn" href="javascript:;" class="btn btn-default">导出</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>
</div>
... ... @@ -220,11 +220,17 @@
<script type="text/template" id="template2">
[[each goodsSizeList as item index]]
<div class="subhhead">
<span>[[item.SKU]]</span>
<span>[[item.productSku]]</span>
<span>[[item.sizeName]]</span>
<span>[[item.stock]]</span>
<span>SKU上架操作</span>
<span>SKU上架操作</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]]
<a class="btn btn-danger btnsku" data-subindex='[[index]]' data-index=[[__index]] href="javascript:;">下架</a>
[[/if]]
</span>
</div>
[[/each]]
</script>
\ No newline at end of file
... ...