Authored by liuyue

网销

... ... @@ -36,10 +36,13 @@ var grid = function(options) {
grid.prototype = {
constructor: grid,
init: function(url) {
init: function(url, second) {
var g = this,
p = this.options;
p.url = url;
p.second = second;
g.grid = $(p.el);
g.grid.html(p.innerHtml);
g.table = $("table", g.grid);
... ... @@ -76,7 +79,7 @@ grid.prototype = {
if (typeof p.url == "string") {
g.ajax(_p);
} else {
g.__bodyClomun(p.url);
g.__bodyClomun(p.url, p.second);
}
}
... ... @@ -206,8 +209,7 @@ grid.prototype = {
total: data.totalPage,
page: data.page
});
g.__bodyClomun(data.list);
// setpage(res);
g.__bodyClomun(data.list, p.second);
},
complete: function(res) {
console.log("complete~~");
... ... @@ -222,7 +224,7 @@ grid.prototype = {
};
$.ajax(ajaxOptions);
},
__bodyClomun: function(rows) {
__bodyClomun: function(rows, second) {
var g = this,
p = this.options;
g.tbody.html("");
... ... @@ -236,31 +238,37 @@ grid.prototype = {
return (p.page - 1) * parseInt(p.rp);
}
if (rows.length > 0) {
for (var row in rows) {
var item = rows[row],
_h = "";
var num = _r_num() + _count;
item._num = _count;
item.rowid = "wqt_" + num + "_" + _count;
if (!item) continue;
_h += ('<tr >');
g.records.push(_count);
item.__index = _count;
g.rows.push(item);
$(p.columns).each(function(i, column) {
if (!column.hidden) {
//console.log(item, column);
_h += ('<td>');
_h += (g.__bodyCell(item, column));
_h += ('</td>');
}
})
_h += ('</tr>');
if (item[second] && item[second].length > 0) {
_h += g.__bodySecondClomun(item, item[second])
} else {
_h += ('<tr >');
$(p.columns).each(function(i, column) {
if (!column.hidden) {
_h += ('<td>');
_h += (g.__bodyCell(item, column));
_h += ('</td>');
}
})
_h += ('</tr>');
_count++;
}
_r.push(_h);
_count++;
g.tbody.html(_r.join(''));
}
} else {
... ... @@ -274,13 +282,40 @@ grid.prototype = {
g.tbody.html(_r.join(''));
}
},
__bodySecondClomun: function(row, second) {
var g = this,
p = this.options,
index = this.options.secondIndex;
var _r = '',
count = 0;
$.each(second, function(i, value) {
_r += '<tr>';
$(p.columns).each(function(i, column) {
if (!column.hidden && count < index) {
_r += ('<td rowspan="' + second.length + '">');
_r += (g.__bodyCell(row, column));
_r += ('</td>');
count++;
} else {
if (i >= index) {
_r += ('<td>');
_r += (g.__bodyCell(value, column));
_r += ('</td>');
}
}
});
_r += '</tr>';
});
return _r;
},
__bodyCell: function(row, col) {
var g = this,
p = this.options;
if (!row || !col) return "";
var value = col.name ? row[col.name] : null;
var content = "";
if (col.type) {
content = "<input type='" + col.type + "' name='" + col.name + "' class='wqt_checkbox' data-index='" + row.__index + "'>";
... ...
... ... @@ -290,6 +290,7 @@ $('#basicTable').on('click', '.shelve-btn', function() {
var shelveTable = new common.grid({
el: "#shelve-table",
secondIndex: 2,
columns: [{
display: 'SKC(商品信息)',
render: function(item) {
... ... @@ -301,57 +302,65 @@ $('#basicTable').on('click', '.shelve-btn', function() {
display: 'SKC上架操作(状态)',
render: function(item) {
if (item.status == 0) {
return '<a class="btn btn-success" href="javascript:;">点击上架</a>';
return '<a class="btn btn-success" data-type="1" data-skc="' + item.productSkc + '" href="javascript:;">点击上架</a>';
} else {
return '<a class="btn btn-danger" href="javascript:;">点击下架</a>';
return '<a class="btn btn-danger" data-type="0" data-skc="' + item.productSkc + '" href="javascript:;">点击下架</a>';
}
}
}, {
display: 'SKU',
render: function(item) {
//console.log(item.goodsSizeList);
var html = '';
$.each(item.goodsSizeList, function(i, value) {
html += value.productSku + '<br>';
});
return html;
}
name: 'productSku'
}, {
display: '尺码',
render: function(item) {
var html = '';
$.each(item.goodsSizeList, function(i, value) {
html += value.sizeName + '<br>';
});
return html;
}
name: 'sizeName'
}, {
display: '库存',
render: function(item) {
var html = '';
$.each(item.goodsSizeList, function(i, value) {
html += value.stock + '<br>';
});
return html;
}
name: 'stock'
}, {
display: 'SKU上架操作',
render: function(item) {
var html = '';
/*$.each(item.goodsSizeList, function(i, value) {
html += value.sizeName + '<br>';
});*/
return html;
if (item.status == 0) {
return '下架';
} else {
return '上架';
}
}
}, {
display: 'SKU上架状态',
name: 'vip_discount_type',
display: 'SKU上架操作',
render: function(item) {
//return ENUM.ageLevel[item.ageLevel] + '/' + ENUM.gender[item.gender];
if (item.status == 0) {
return '<a class="btn btn-success" data-type="1" data-sku="' + item.productSku + '" href="javascript:;">上架</a>';
} else {
return '<a class="btn btn-danger" data-type="0" data-sku="' + item.productSku + '" href="javascript:;">下架</a>';
}
}
}]
});
shelveTable.init(res.data.goodsList);
shelveTable.init(res.data.goodsList, 'goodsSizeList');
$('#shelve-table').on('click', '.btn', function() {
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');
console.log(param);
common.util.__ajax({
url: reqUrl,
data: param
}, function(res) {
console.log(res);
if (res.data.code == 200) {
shelveModal.close();
}
})
})
}, true);
});
\ No newline at end of file
... ...
exports.domain = require('../config/common.js').domain;
//exports.domain = 'http://172.16.6.227:8083/yohobuy-platform-web'; //变价
//exports.domain = require('../config/common.js').domain;
exports.domain = 'http://172.16.6.227:8083/yohobuy-platform-web'; //变价
//exports.domain = 'http://172.16.6.162:8088/platform'; //品牌合作
//商品管理路由配置
... ... @@ -151,6 +151,30 @@ exports.res = [
type: 'string'
}]
}, {
//网销信息 -> skc上下架
route: '/goods/product/updateGoodsStatus',
method: 'POST',
url: '/product/updateGoodsStatus',
params: [{
name: 'productSkc',
type: 'number'
}, {
name: 'targetStatus',
type: 'number'
}]
}, {
//网销信息 -> sku上下架
route: '/goods/product/updateProductSkuStatus',
method: 'POST',
url: '/product/updateProductSkuStatus',
params: [{
name: 'productSku',
type: 'number'
}, {
name: 'targetStatus',
type: 'number'
}]
}, {
//网销信息 -> 批量页面渲染
route: '/goods/netsale/batch',
method: 'GET',
... ...
... ... @@ -212,8 +212,8 @@
<script type="text/template" id="template">
<p>SKN{productSkn} 品牌:{brandName}</p>
<p>商品名称:{productName}</p>
<p style="color: red;">SKN{productSkn} 品牌:{brandName}</p>
<p style="color: red;">商品名称:{productName}</p>
<div id="shelve-table" class="dataTables_wrapper no-footer"></div>
</script>
\ No newline at end of file
... ...
<div class="panel panel-default">
<form action="" class="form-horizontal form-bordered">
<div class="panel-heading">
<div class="panel-btns" style="display: none;">
<a href="" class="panel-minimize tooltips" data-toggle="tooltip" title=""><i class="fa fa-minus"></i></a>
</div>
<h2 class="panel-title">模特</h2>
</div>
<div class="panel-body nopadding">
</div>
</form>
</div>
\ No newline at end of file
... ...