Authored by dongjunjie

店铺销售类目增删改查

... ... @@ -13,32 +13,35 @@ module.exports = function (app){
}
});
app.get("/shop/shopCategory/info/:shopId/:categoryId/", "shop.ShopCategory.Info", "shopCategory_selectShopNameById", function (rs){
app.get("/shop/shopCategory/add/:shopId/", "shop.ShopCategory.Edit", ["shopCategory_selectShopNameById", "shopCategory_insertShopsAndLinkCategory"], function (rs1, rs2){
this.$extend={
moduleName:"店铺管理",
pageName:"店铺销售类目管理",
subPageName:"店铺销售类目详情",
shopName: rs.data
}
subPageName:"新增店铺销售类目",
shopName: rs1.data,
categoryId: rs2.data
};
return rs2;
});
app.get("/shop/shopCategory/add/:shopId/", "shop.ShopCategory.Edit", "shopCategory_selectShopNameById", function (rs){
app.get("/shop/shopCategory/edit/:shopId/:categoryId/", "shop.ShopCategory.Edit", ["shopCategory_selectShopNameById", "shopCategory_selectCategoryNameById"], function (rs1, rs2){
this.$extend={
moduleName:"店铺管理",
pageName:"店铺销售类目管理",
subPageName:"新增店铺销售类目",
shopName: rs.data,
categoryName: ""
subPageName:"店铺销售类目编辑",
shopName: rs1.data,
categoryName: rs2.data
}
});
app.get("/shop/shopCategory/edit/:shopId/:categoryId/", "shop.ShopCategory.Edit", "shopCategory_selectShopNameById", function (rs){
app.get("/shop/shopCategory/info/:shopId/:categoryId/", "shop.ShopCategory.Info", ["shopCategory_selectShopNameById", "shopCategory_selectCategoryNameById"], function (rs1, rs2){
this.$extend={
moduleName:"店铺管理",
pageName:"店铺销售类目管理",
subPageName:"店铺销售类目编辑",
shopName: rs.data,
categoryName: "abc"
subPageName:"店铺销售类目详情",
shopName: rs1.data,
categoryName: rs2.data
}
});
... ...
... ... @@ -2,13 +2,21 @@ module.exports={
namespace:"shopCategory",
apis:{
selectShopNameById:{
title:"根据店铺ID获取店铺名称",
url:"/ShopsSalesCategoryRest/selectShopNameById",
title:"根据ID获取店铺名称或者类目名称",
url:"/ShopsSalesCategoryRest/selectNameById",
params:[
{name:"shopId",type:"Number"}
]
},
selectCategoryNameById:{
title:"根据ID获取店铺名称或者类目名称",
url:"/ShopsSalesCategoryRest/selectNameById",
params:[
{name:"categoryId",type:"Number"}
]
},
shopsCategoryList:{
title:"店铺销售类目列表",
url:"/ShopsSalesCategoryRest/shopsCategoryList",
... ... @@ -21,8 +29,7 @@ module.exports={
title:"新增店铺销售类目",
url:"/ShopsSalesCategoryRest/insertShopsAndLinkCategory",
params:[
{name:"shopId",type:"Number"},
{name:"categoryName",type:"String"}
{name:"shopId",type:"Number"}
]
},
... ... @@ -52,7 +59,8 @@ module.exports={
{name:"shopId",type:"Number"},
{name:"categoryId",type:"Number"},
{name:"productSKN",type:"Number"},
{name:"factoryCode",type:"String"}
{name:"factoryCode",type:"String"},
{name:"page",type:"Number"}
]
},
... ... @@ -63,7 +71,8 @@ module.exports={
{name:"shopId",type:"Number"},
{name:"categoryId",type:"Number"},
{name:"productSKN",type:"Number"},
{name:"factoryCode",type:"String"}
{name:"factoryCode",type:"String"},
{name:"page",type:"Number"}
]
},
... ...
... ... @@ -18,7 +18,7 @@
</div>
<div class="submit form-group" style="float: right">
<a href="javascript:" class="btn btn-success btn-save">保存</a>
<a href="javascript:" class="btn btn-default">返回</a>
<a href="javascript:" class="btn btn-default btn-return">返回</a>
</div>
</div>
<div class="tabheader">
... ...
... ... @@ -52,7 +52,7 @@
<td style="line-height: 27px">
<a href='/shop/shopCategory/edit/[[shopId]]/[[item.categoryId]]/' class='btn btn-xs btn-primary'>编辑</a>
<a href='/shop/shopCategory/info/[[shopId]]/[[item.categoryId]]/' class='btn btn-xs btn-info'>查看</a>
<a href='javascript:' class='btn btn-xs btn-danger deleteBtn' data-categoryId='"+item.categoryId+"'>删除</a>
<a href='javascript:' class='btn btn-xs btn-danger deleteBtn' data-categoryid='[[item.categoryId]]'>删除</a>
</td>
</tr>
[[/each]]
... ...
<%include '../../../common/views/__ui/header'%>
<%include '../../../common/views/__partail/ListHeader'%>
<div class="contentpanel">
<div class="panel">
<div class="selectShop" style="font-family:'microsoft yahei';font-size: 18px;line-height: 40px;margin-bottom: 20px">
<div id="shopInfo">
<span id="shopId"><font color="#999">店铺ID:</font><b>--</b></span>
<span id="shopName" style="margin-left: 20px"><font color="#999">店铺名称:</font><b><%shopName%></b></span>
</div>
</div>
<div class="panel-body" style="background: #eeeeee">
<div class="setCategoryName form-inline" style="margin-bottom: 10px">
<div class="form-group" style="line-height: 40px;font-size: 16px;font-family:'microsoft yahei'">
<label>销售类目名称:<b><%categoryName%></b></label>
</div>
<div class="submit form-group" style="float: right">
<a href="javascript:" class="btn btn-default btn-return">返回</a>
</div>
</div>
<div id="productTable"></div>
</div>
</div>
</div>
<%include '../../../common/views/__ui/footer'%>
\ No newline at end of file
... ...
... ... @@ -2,9 +2,9 @@
var $ = require('jquery'),
common = require('../../../common/common');
var operate = 0, //操作,0:新增,1:编辑
curShopId = -1,
var curShopId = -1,
curCategoryId = 0,
selectedNum = 0,
curTab = 0;
var g1 = new common.grid({
... ... @@ -35,7 +35,8 @@ var g1 = new common.grid({
}}
],
complete2: function (res) {
$('.selectedProductsNum').text(res.data.checkedCount);
selectedNum = res.data.checkedCount;
$('.selectedProductsNum').text(selectedNum);
}
});
... ... @@ -63,7 +64,8 @@ var g2 = new common.grid({
}}
],
complete2: function (res) {
$('.selectedProductsNum').text(res.data.checkedCount);
selectedNum = res.data.list.length;
$('.selectedProductsNum').text(selectedNum);
}
});
... ... @@ -113,7 +115,8 @@ $(document).on("click", ".nav-tabs li", function () {
//选择商品
$(document).on("click", ".selectProduct", function () {
var index = $(this).data("index");
var self = this;
var index = $(self).data("index");
var item = g1.rows[index];
common.util.__ajax({
url:'/shops/shopCategory/link',
... ... @@ -122,13 +125,16 @@ $(document).on("click", ".selectProduct", function () {
productSKN: item.productSKN
}
},function(){
g1.reload();
//g1.reload();
$(self).parent().html('<a href="javascript:" class="btn btn-warning btn-xs cancelProduct" data-index="'+index+'">取消选择</a>');
$('.selectedProductsNum').text(++selectedNum);
}, true);
});
//在全部商品中,取消选择商品
$(document).on("click", ".cancelProduct", function () {
var index = $(this).data("index");
var self = this;
var index = $(self).data("index");
var g = curTab == 0 ? g1 : g2;
var item = g.rows[index];
common.util.__ajax({
... ... @@ -138,7 +144,13 @@ $(document).on("click", ".cancelProduct", function () {
productSKN: item.productSKN
}
},function(){
g.reload();
if(curTab == 0){
$(self).parent().html('<a href="javascript:" class="btn btn-info btn-xs selectProduct" data-index="'+index+'">选择</a>');
$('.selectedProductsNum').text(--selectedNum);
}
if(curTab == 1){
g2.reload();
}
}, true);
});
... ... @@ -156,16 +168,24 @@ $(document).on("click", ".btn-save", function () {
var categoryName = $.trim($('#categoryName').val());
if(categoryName != ''){
common.util.__ajax({
url:'/shops/shopCategory/unlink',
url:'/shops/shopCategory/update',
data:{
shopId: curShopId,
categoryId: curCategoryId,
categoryName: categoryName
}
},function(){
setTimeout(function() {
location.href="/shop/shopCategory/index/" + curShopId;
}, 1000);
});
}else{
common.util.__tip("销售类目名称不能为空!");
return false;
}
});
//返回
$(document).on("click", ".btn-return", function () {
location.href="/shop/shopCategory/index/" + curShopId;
});
\ No newline at end of file
... ...
... ... @@ -16,17 +16,24 @@ var Bll = {
init: function () {
this.getShopIdInUrl();
if(currentShopId > 0){
$("#shop-select").val(currentShopId);
Bll.showList(currentShopId,1);
common.util.__ajax({
url:'/shops/shopCategory/getShopName',
data: {shopId:currentShopId}
},function (rs) {
$('#shopId b').text(currentShopId);
$('#shopName b').text(rs.data);
$('#select2-shop-select-container').text(rs.data);
},true);
Bll.showList(1);
}
},
//展示销售类目列表
showList: function (shopId,isLoading) {
showList: function (isLoading) {
if(isLoading==1) loadModal = common.dialog.load();
common.util.__ajax({
url:'/shops/shopCategory/list',
data: {shopId:shopId}
data: {shopId:currentShopId}
}, function (res) {
if(isLoading==1 && loadModal) loadModal.close();
... ... @@ -39,6 +46,7 @@ var Bll = {
},
//删除销售类目
deleteCategory: function (categoryId) {
var self = this;
common.util.__ajax({
url:'/shops/shopCategory/delete',
data: {
... ... @@ -46,7 +54,7 @@ var Bll = {
categoryId:categoryId
}
}, function (res) {
this.showList(0);
self.showList(0);
})
},
//清空店铺数据,初始化店铺数据
... ... @@ -80,7 +88,7 @@ $(document).on('change', '#shop-select', function () {
var shopName = this.options[this.selectedIndex].text;
$('#shopId b').text(shopId);
$('#shopName b').text(shopName);
Bll.showList(shopId,1);
Bll.showList(1);
}else{
Bll.destoryCategory();
}
... ... @@ -89,7 +97,7 @@ $(document).on('change', '#shop-select', function () {
//新增类目
$(document).on('click', '.addBtn', function () {
if(currentShopCategoryNum < 20){
location.href = '/shop/shopCategory/add';
location.href = '/shop/shopCategory/add/' + currentShopId + '/';
}else {
common.util.__tip('店铺最多添加只能添加20个销售类目!');
}
... ... @@ -98,7 +106,7 @@ $(document).on('click', '.addBtn', function () {
//删除类目
$(document).on('click', '.deleteBtn', function () {
var categoryName = $(this).parent().parent().find('td').eq(1).text();
var categoryId = $(this).data('categoryId');
var categoryId = $(this).data('categoryid');
common.dialog.confirm(
"删除店铺销售类目",
... ...
'use strict';
var $ = require('jquery'),
common = require('../../../common/common');
var curShopId = -1,
curCategoryId = 0;
var g = new common.grid({
el: '#productTable',
parms: function() {
return {
shopId: curShopId,
categoryId: curCategoryId
};
},
columns: [
{display: "商品图片", render: function (item) {
return item.productPic ? '<img src="'+item.productPic+'">' : '';
}},
{display: "SKN", name: "productSKN"},
{display: "商品名称", name: "productName"},
{display: "销售价(元)", name: "salePrice"},
{display: "分类", name: "productSort"},
{display: "销售类目", render: function () {
}}
]
});
var Bll = {
init: function () {
this.getUrlParams();
$('#shopId b').text(curShopId);
g.init('/shops/shopCategory/selectedProducts');
},
getUrlParams: function () {
var paramUrl = location.href + "";
var param = paramUrl.substring(paramUrl.indexOf("info"));
var paramList = param.split("/");
curShopId = paramList[1];
curCategoryId = paramList[2];
}
};
Bll.init();
//返回
$(document).on("click", ".btn-return", function () {
location.href="/shop/shopCategory/index/" + curShopId;
});
... ...