Authored by liuyue

网销

var $=require('jquery'),
util=require('./util');
var $ = require('jquery'),
util = require('./util');
var tab=function(options) {
var defaults={
innerHtml:'<ul class="nav nav-pills"></ul>'
var tab = function(options) {
var defaults = {
innerHtml: '<ul class="nav nav-pills"></ul>'
};
this.options=$.extend({}, defaults, options);
this.options = $.extend({}, defaults, options);
$(options.el).html(this.options.innerHtml);
this.tab=$("ul",options.el);
this.active=undefined;//undefined==void(0)
return this;
this.tab = $("ul", options.el);
this.active = undefined; //undefined==void(0)
return this;
}
tab.prototype={
constructor:tab,
init:function(data){
var g = this, p = this.options;
tab.prototype = {
constructor: tab,
init: function(data) {
var g = this,
p = this.options;
$(this.tab).html("");
this.render(data);
this.bind(p.click);
return this;
},
bind:function(callback){
var g = this, p = this.options;
$(p.el).off("click","li");
$(p.el).on("click","li",function(){
bind: function(callback) {
var g = this,
p = this.options;
$(p.el).off("click", "li");
$(p.el).on("click", "li", function() {
$(this).addClass('active').siblings().removeClass('active');
g.active=$(this).find("a").attr("columnname");
g.active = $(this).find("a").attr("columnname");
g.key = $(this).find("a").attr("key");
g.value = $(this).find("a").attr("value");
callback&&callback();
callback && callback.call(this);
});
},
render:function(data){
var g = this, p = this.options;
var lis=[];
$(p.columns).each(function (i, column) {
var li = $("<li></li>");
var a = $("<a href='javascript:void(0);'></a>");
render: function(data) {
var g = this,
p = this.options;
if (column.name == 'all') {
li = $('<li class="active"></li>');
};
if (column.name) a.attr({ columnname: column.name });
if (column.key) a.attr({ key: column.key});
if (column.value) a.attr({ value: column.value});
var lis = [];
$(p.columns).each(function(i, column) {
var li = $("<li></li>");
var a = $("<a href='javascript:void(0);'></a>");
var h_t = column.display || "";
a.html(h_t);
if (column.name == 'all') {
li = $('<li class="active"></li>');
};
if (column.name) a.attr({
columnname: column.name
});
if (column.key) a.attr({
key: column.key
});
if (column.value) a.attr({
value: column.value
});
li.append(a);
g.tab.append(li);
});
var h_t = column.display || "";
a.html(h_t);
g.tab.html(util.__template(g.tab.html(),data||{}));
li.append(a);
g.tab.append(li);
});
g.tab.html(util.__template(g.tab.html(), data || {}));
},
load:function(data){
var g = this, p = this.options;
g.tab.html(util.__template(g.tab.html(),data||{}));
load: function(data) {
var g = this,
p = this.options;
g.tab.html(util.__template(g.tab.html(), data || {}));
}
}
module.exports=tab;
\ No newline at end of file
module.exports = tab;
\ No newline at end of file
... ...
... ... @@ -40,7 +40,14 @@ var ENUM = {
var t = new common.tab({
el: "#basicTab",
click: function() {
g.reload(1);
g.options.columns[11].hidden = true;
g.options.columns[8].hidden = true;
if ($(this).find('a').attr('columnname') == 3) {
g.options.columns[11].hidden = false;
} else if ($(this).find('a').attr('columnname') == 2) {
g.options.columns[8].hidden = false;
};
g.init($("#gridurl").val());
},
columns: [{
name: "0",
... ... @@ -132,6 +139,15 @@ var g = new common.grid({
return ENUM.attribute[item.attribute];
}
}, {
display: '搜索/标签',
hidden: true,
render: function(item) {
return '关键词:' + '<br>' +
'风格:' + item.style + '<br>' +
'纹理:' + item.style + '<br>' +
'工艺:' + item.style + '<br>';
}
}, {
display: '操作信息',
render: function(item) {
var html = '';
... ... @@ -156,16 +172,22 @@ var g = new common.grid({
return html;
}
}, {
display: '缺失信息',
hidden: true,
render: function(item) {
return '缺失信息';
}
}, {
display: '操作',
render: function(item) {
var HtmArr = [];
if (item.status == 1) {
HtmArr.push('<a href="/goods/netsale/edit/' + item.productSkn + '" class="btn btn-info btn-xs edit-btn">编辑</a>');
HtmArr.push('<a href="javascript:;" class="btn btn-danger btn-xs offshelve-btn">下架</a>');
HtmArr.push('<a href="javascript:;" class="btn btn-danger btn-xs shelve-btn" data-skn="' + item.productSkn + '">下架</a>');
} else if (item.status != 2 && item.status != 5) {
HtmArr.push('<a href="/goods/netsale/edit/' + item.productSkn + '" class="btn btn-info btn-xs edit-btn">编辑</a>');
HtmArr.push('<a href="javascript:;" class="btn btn-success btn-xs onshelve-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-info btn-xs info-btn">查看</a>');
return HtmArr.join('');
... ... @@ -226,11 +248,11 @@ function shelveModal(title, html) {
});
});
}
//上架
//批量skn上架
$('#onshelve').on('click', function() {
shelveModal('上架', $('#onshelve-template').html());
});
//下架
//批量skn下架
$('#offshelve').on('click', function() {
shelveModal('下架', $('#offshelve-template').html());
});
... ... @@ -238,4 +260,70 @@ $('#offshelve').on('click', function() {
//导出
$('#export-btn').on('click', function() {
});
//单个sku,skc上下架
$('#basicTable').on('click', '.shelve-btn', function() {
var that = this,
skn = $(this).data('skn'),
shelveModalHtml = '',
shelveModal = null;
var shelveModalHtml = common.util.__template($('#template').html());
$(that).addClass('disabled');
common.util.__ajax({
url: '/goods/product/getNetSaleInfo',
data: {
param: skn
}
}, function(res) {
shelveModalHtml = common.util.__template($('#template').html(), res.data.baseProductInfo.baseProduct);
shelveModal = common.dialog.open({
content: shelveModalHtml
});
$(that).removeClass('disabled');
var shelveTable = new common.grid({
el: "#shelve-table",
columns: [{
display: 'SKC(商品信息)',
render: function(item) {
console.log(item);
}
}, {
display: 'SKC上架操作(状态)',
name: 'productSkn'
}, {
display: 'SKU',
name: 'picImgUrl',
render: function(item) {
//return '<img src="' + item.picImgUrl + '">';
}
}, {
display: '尺码',
render: function(item) {
}
}, {
display: '库存',
render: function(item) {
}
}, {
display: 'SKU上架操作',
name: 'stock'
}, {
display: 'SKU上架状态',
name: 'vip_discount_type',
render: function(item) {
//return ENUM.ageLevel[item.ageLevel] + '/' + ENUM.gender[item.gender];
}
}]
});
shelveTable.init(res.data.goodsList);
}, true);
});
\ No newline at end of file
... ...
... ... @@ -435,6 +435,7 @@ $('#sure-change').on('click', function() {
$('#priceTable').hide();
$('.success-wrap').show();
path = res.data;
successList.length = 0;
});
});
... ...
//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'; //品牌合作
//商品管理路由配置
... ... @@ -176,6 +176,14 @@ exports.res = [
type: 'number'
}]
}, {
route: '/goods/product/getNetSaleInfo',
method: 'POST',
url: '/product/getNetSaleInfo',
params: [{
name: 'param',
type: 'number'
}]
}, {
//价格管理 -> 代销变价页面渲染
route: '/goods/pricechange/index',
method: 'GET',
... ...
... ... @@ -209,34 +209,11 @@
</form>
</script>
<script type="text/template" id="template">
{{# baseProductInfo}}
{{# baseProduct}}
<p>SKN{{}} 品牌:{{}}</p>
<p>商品名称:{{}}</p>
{{/ baseProduct}}
{{# baseProductInfo}}
<table class="table table-bordered">
<thead>
<tr>
<th>SKC(商品信息)</th>
<th>SKC上架操作(状态)</th>
<th>SKU</th>
<th>尺码</th>
<th>库存</th>
<th>SKU上架操作</th>
<th>SKU上架状态</th>
</tr>
</thead>
<tbody>
{{# goodsList}}
<tr>
<td>SKC{{productSkc}}<br>颜色:{{goodsName}}</td>
<td></td>
</tr>
{{/ goodsList}}
</tbody>
</table>
<p>SKN{productSkn} 品牌:{brandName}</p>
<p>商品名称:{productName}</p>
<table id="shelve-table" class="table table-bordered"></table>
</script>
\ No newline at end of file
</script>
\ No newline at end of file
... ...