|
|
'use strict';
|
|
|
var $ = require('jquery'),
|
|
|
common = require('../../../common/common');
|
|
|
|
|
|
var curShopId = -1,
|
|
|
curCategoryId = 0,
|
|
|
selectedList = [], //店铺下改类目所有已选商品
|
|
|
selectedSknList = []; //店铺下改类目所有已选商品skn
|
|
|
|
|
|
var g1 = new common.grid({
|
|
|
el: '#productTable',
|
|
|
parms: function() {
|
|
|
return {
|
|
|
shopsId: curShopId,
|
|
|
categoryId: curCategoryId,
|
|
|
productSKN: common.util.__input("productSKN"),
|
|
|
factoryCode: common.util.__input("factoryCode")
|
|
|
};
|
|
|
},
|
|
|
columns: [
|
|
|
{display: "商品图片", render: function (item) {
|
|
|
return item.imageUrl ? '<img src="'+item.imageUrl+'?imageView/0/w/78/h/78">' : '';
|
|
|
}},
|
|
|
{display: "SKN", name: "productSKN"},
|
|
|
{display: "商品名称", name: "productName"},
|
|
|
{display: "销售价(元)", name: "salePrice"},
|
|
|
{display: "分类", name: "productSort"},
|
|
|
{display: "操作", render: function (item) {
|
|
|
if(item.checked){
|
|
|
return '<a href="javascript:" class="btn btn-warning btn-xs cancelProduct" data-index="'+item.__index+'">取消选择</a>'
|
|
|
}else{
|
|
|
return '<a href="javascript:" class="btn btn-info btn-xs selectProduct" data-index="'+item.__index+'">选择</a>'
|
|
|
}
|
|
|
}}
|
|
|
]
|
|
|
});
|
|
|
|
|
|
var g2 = new common.grid({
|
|
|
el: '#productTable',
|
|
|
parms: function() {
|
|
|
return {
|
|
|
shopsId: curShopId,
|
|
|
categoryId: curCategoryId,
|
|
|
productSKN: common.util.__input("productSKN"),
|
|
|
factoryCode: common.util.__input("factoryCode")
|
|
|
};
|
|
|
},
|
|
|
columns: [
|
|
|
{display: "商品图片", render: function (item) {
|
|
|
return item.imageUrl ? '<img src="'+item.imageUrl+'?imageView/0/w/78/h/78">' : '';
|
|
|
}},
|
|
|
{display: "SKN", name: "productSKN"},
|
|
|
{display: "商品名称", name: "productName"},
|
|
|
{display: "销售价(元)", name: "salePrice"},
|
|
|
{display: "分类", name: "productSort"},
|
|
|
{display: "操作", render: function (item) {
|
|
|
return '<a href="javascript:" class="btn btn-warning btn-xs cancelProduct" data-index="'+item.__index+'">取消选择</a>'
|
|
|
}}
|
|
|
]
|
|
|
});
|
|
|
|
|
|
var Bll = {
|
|
|
init: function () {
|
|
|
this.getParamsInUrl();
|
|
|
g1.init('/shops/shopCategory/allProducts');
|
|
|
},
|
|
|
getParamsInUrl: function () {
|
|
|
var paramUrl = location.href + "";
|
|
|
var param = paramUrl.substring(paramUrl.indexOf("edit"));
|
|
|
var paramList = param.split("/");
|
|
|
|
|
|
if(paramList.length > 1){
|
|
|
curShopId = paramList[1];
|
|
|
curCategoryId = paramList[2];
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Bll.init();
|
|
|
|
|
|
//tab切换
|
|
|
$(document).on("click", ".nav-tabs li", function () {
|
|
|
if($(this).hasClass('active')) return false;
|
|
|
|
|
|
$(this).addClass('active').siblings().removeClass('active');
|
|
|
var _index = $(this).index();
|
|
|
switch (_index){
|
|
|
case 0:
|
|
|
$('.cancelAll').hide();
|
|
|
g1.init('/shops/shopCategory/allProducts');
|
|
|
break;
|
|
|
case 1:
|
|
|
$('.cancelAll').show();
|
|
|
g2.init('/shops/shopCategory/selectedProducts');
|
|
|
break;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//选择商品
|
|
|
$(document).on("click", ".selectProduct", function () {
|
|
|
var index = $(this).data("index");
|
|
|
var item = g1.rows[index];
|
|
|
|
|
|
});
|
|
|
|
|
|
//在全部商品中,取消选择商品
|
|
|
$(document).on("click", ".cancelProduct2", function () {
|
|
|
var index = $(this).data("index");
|
|
|
var item = g1.rows[index];
|
|
|
|
|
|
});
|
|
|
|
|
|
//在已选商品中,取消选择商品
|
|
|
$(document).on("click", ".cancelProduct", function () {
|
|
|
var index = $(this).data("index");
|
|
|
var item = g2.rows[index];
|
|
|
|
|
|
});
|
|
|
|
|
|
//筛选
|
|
|
$(document).on("click", ".filter-btn", function () {
|
|
|
var _index = $('.nav-tabs li.active').index();
|
|
|
if(_index == 0){
|
|
|
g1.reload();
|
|
|
}else{
|
|
|
g2.reload();
|
|
|
}
|
|
|
}); |
|
|
\ No newline at end of file |
...
|
...
|
|