Authored by 马力

Merge branch 'dev-店铺商品排序' into gray

... ... @@ -125,4 +125,7 @@ module.exports=function(app) {
app.post("/product/saveProductParam","netsale_saveProductParam");
app.post("/goods/product/addproductModelCard","netsale_addproductModelCard");
/*保存店铺商品搜索顺序*/
app.post("/netSale/saveShopsSearchSort","netsale_saveShopsSearchSort");
}
\ No newline at end of file
... ...
... ... @@ -358,6 +358,13 @@ module.exports={
modelCardId:{type:Number},
size:{type:String}
}
},
saveShopsSearchSort:{
title:'保存店铺搜索顺序',
url: '/product/saveShopsSearchSort',
params: [
{name: 'searchSortList', type: 'string'}
]
}
}
}
... ...
... ... @@ -23,6 +23,10 @@
<input type="text" class="form-control" id="sort2" value="0" required />
</div>
-->
<label class="col-sm-1 control-label" for="sort3">店铺</label>
<div class="col-sm-2">
<input type="text" class="form-control" id="sort3" value="0" required modelId="1" projectId="5"/>
</div>
</div>
<div class="col-sm-12" style="color: red;"><div class="col-sm-1"></div>提示:商品在品牌商品列表中的排序,数字越大越靠前</div>
</div>
... ...
... ... @@ -306,6 +306,7 @@ var g = new common.grid({
render: function (item) {
var HtmArr = [];
var intValue ;
var intVal_shopsSearchSort;
if (item.status == 4 || item.status == 1 || item.status == 5 || item.status == 6) {
HtmArr.push('<a target="_blank" 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-index="' + item.__index + '">下架</a>');
... ... @@ -323,6 +324,15 @@ var g = new common.grid({
}
HtmArr.push('<br><br><input type="text" style="width:100px" name="brandSort" class="brandSortText" data-index="' + item.__index + '" value='+intValue+'>');
HtmArr.push('<a href="javascript:;" class="btn btn-success btn-xs brandSort-btn" data-index="' + item.__index + '" >品牌排序</a>');
if(typeof(item.shopsSearchSort) == "undefined"){
intVal_shopsSearchSort = 0;
}else{
intVal_shopsSearchSort = item.shopsSearchSort.intValue;
}
HtmArr.push('<br><br><input type="text" style="width:100px" name="shopsSort" class="brandSortText" data-index="' + item.__index + '" value='+ intVal_shopsSearchSort+'>');
HtmArr.push('<a href="javascript:;" class="btn btn-success btn-xs shopsSort-btn" data-index="' + item.__index + '" >店铺排序</a>');
return HtmArr.join('');
}
}]
... ... @@ -668,6 +678,28 @@ $(document).on("click", ".brandSort-btn", function () {
}
);
});
/**
*店铺商品排序
*/
$(document).on("click", ".shopsSort-btn", function () {
var item = g.rows[$(this).data("index")];
var num = $("input:text[name='shopsSort']").eq($(this).data("index")).val();
var searchSortList = [];
searchSortList.push({
productSkn: item.productSkn,
modelId: 1,
projectId: 5,
intValue: num
});
common.util.__ajax({
url: '/netSale/saveShopsSearchSort',
data: {
searchSortList: JSON.stringify(searchSortList)
}
}
);
});
//当点击“无需测量”,该列输入框不可编辑
common.sizeInfo.check();
... ...
... ... @@ -131,25 +131,30 @@ if (window.NETSALEDATA) {
}
for (var i = 0; i < searchSortList.length; i++) {
if (searchSortList[i].modelId == 1)
if (searchSortList[i].modelId == 1 && searchSortList[i].projectId == 1 ){
$("#sort0").val(searchSortList[i].intValue);
else if (searchSortList[i].modelId == 2)
$("#sort1").val(searchSortList[i].intValue);
else if (searchSortList[i].modelId == 3)
$("#sort2").val(searchSortList[i].intValue);
}
if (searchSortList[i].modelId == 1 && searchSortList[i].projectId == 5 ){
$("#sort3").val(searchSortList[i].intValue);
}
}
var item = [];
for (var i = 0; i < 3; i++) {
item[i] = {
productSkn: window.NETSALEDATA.baseProductInfo.baseProduct.productSkn,
modelId: i + 1,
projectId: 1,
intValue: parseInt($("#sort" + i).val())
};
}
for (var i = 0; i < 3; i++) {
var item_brand = {
productSkn: window.NETSALEDATA.baseProductInfo.baseProduct.productSkn,
modelId: 1,
projectId: 1,
intValue: parseInt($("#sort0").val())
};
item.push(item_brand);
var item_shops = {
productSkn: window.NETSALEDATA.baseProductInfo.baseProduct.productSkn,
modelId: 5,
projectId: 1,
intValue: parseInt($("#sort3").val())
};
item.push(item_shops);
for (var i = 0; i < item.length; i++) {
for (var j = 0; j < searchSortList.length; j++) {
if (searchSortList[j].modelId == item[i].modelId) {
item[i].id = searchSortList[j].id;
... ... @@ -159,13 +164,12 @@ if (window.NETSALEDATA) {
}
searchSortList = item;
var sortList = [];
sortList.push(searchSortList[0])
$('#sort-save').on('click', function () {
common.util.__ajax({
url: '/product/saveSearchSort',
data: {
searchSortList: JSON.stringify(sortList)
searchSortList: JSON.stringify(searchSortList)
}
});
return false;
... ... @@ -175,21 +179,14 @@ if (window.NETSALEDATA) {
searchSortList[0].intValue = parseInt($("#sort0").val());
});
$("#sort1").on('change', function () {
searchSortList[1].intValue = parseInt($("#sort1").val());
});
$("#sort2").on('change', function () {
searchSortList[2].intValue = parseInt($("#sort2").val());
$("#sort3").on('change', function () {
searchSortList[1].intValue = parseInt($("#sort3").val());
});
$("#sort0").keyup(function () {
$(this).val($(this).val().replace(/\D/g, ""));
});
$("#sort1").keyup(function () {
$(this).val($(this).val().replace(/\D/g, ""));
});
$("#sort2").keyup(function () {
$("#sort3").keyup(function () {
$(this).val($(this).val().replace(/\D/g, ""));
});
... ...