Authored by dongjunjie

店铺销售类目

... ... @@ -13,18 +13,6 @@ module.exports = function (app){
}
});
app.get("/shop/shopCategory/add/:shopId/", "shop.ShopCategory.Edit", ["shopCategory_selectShopNameById", "shopCategory_insertShopsAndLinkCategory"], function (rs1, rs2){
this.$extend={
moduleName:"店铺管理",
pageName:"店铺销售类目管理",
subPageName:"新增店铺销售类目",
shopName: rs1.data,
categoryId: rs2.data
};
return rs2;
});
app.get("/shop/shopCategory/edit/:shopId/:categoryId/", "shop.ShopCategory.Edit", ["shopCategory_selectShopNameById", "shopCategory_selectCategoryNameById"], function (rs1, rs2){
this.$extend={
moduleName:"店铺管理",
... ... @@ -60,7 +48,10 @@ module.exports = function (app){
//店铺销售类目列表
app.post("/shops/shopCategory/list","shopCategory_shopsCategoryList");
//编辑保存店铺销售类目
//新增店铺销售类目
app.post("/shops/shopCategory/add","shopCategory_insertShopsAndLinkCategory");
//编辑店铺销售类目
app.post("/shops/shopCategory/update","shopCategory_updateShopsAndLinkCategory");
//删除店铺销售类目
... ...
... ... @@ -29,7 +29,8 @@ module.exports={
title:"新增店铺销售类目",
url:"/ShopsSalesCategoryRest/insertShopsAndLinkCategory",
params:[
{name:"shopId",type:"Number"}
{name:"shopId",type:"Number"},
{name:"categoryName",type:"String"}
]
},
... ...
... ... @@ -6,35 +6,26 @@
<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>
<span id="shopName" style="margin: 0 20px"><font color="#999">店铺名称:</font><b><%shopName%></b></span>
<span id="categoryName"><font color="#999">销售类目名称:</font><b><%categoryName%></b></span>
<a href="javascript:" class="btn btn-default btn-return" style="float: right">返回</a>
</div>
</div>
<div class="panel-body" style="background: #eeeeee">
<div class="setCategoryName form-inline" style="margin-bottom: 20px">
<div class="form-group">
<label>销售类目名称:</label>
<input id="categoryName" type="text" class="form-control" value="<%categoryName%>" />
</div>
<div class="submit form-group" style="float: right">
<a href="javascript:" class="btn btn-success btn-save">保存并返回</a>
</div>
</div>
<div class="tabheader">
<ul class="nav nav-tabs">
<li class="active"><a href="javascript:">全部商品</a></li>
<li><a href="javascript:">已选&nbsp;(<b class="selectedProductsNum">0</b>)</a></li>
</ul>
</div>
<div class="mainTable" style="padding: 20px 20px 60px; border: 1px solid #ddd; background: #FFFFFF">
<div class="filter form-inline" style="margin-bottom: 20px">
<input id="productSKN" type="text" class="form-control" placeholder="SKN" />&nbsp;&nbsp;
<input id="factoryCode" type="text" class="form-control" placeholder="商家编码" />&nbsp;&nbsp;
<a href="javascript:" class="btn btn-primary filter-btn">查询</a>
<a href="javascript:" class="btn btn-danger cancelAll" style="float: right;display: none">全部取消</a>
</div>
<div id="productTable"></div>
<div class="tabheader">
<ul class="nav nav-tabs">
<li class="active"><a href="javascript:">全部商品</a></li>
<li><a href="javascript:">已选&nbsp;(<b class="selectedProductsNum">0</b>)</a></li>
</ul>
</div>
<div class="mainTable" style="padding: 20px 20px 60px; border: 1px solid #ddd; background: #FFFFFF">
<div class="filter form-inline" style="margin-bottom: 20px">
<input id="productSKN" type="text" class="form-control" placeholder="SKN" />&nbsp;&nbsp;
<input id="factoryCode" type="text" class="form-control" placeholder="商家编码" />&nbsp;&nbsp;
<a href="javascript:" class="btn btn-info filter-btn">查询</a>
<a href="javascript:" class="btn btn-danger cancelAll" style="float: right;display: none">全部取消</a>
</div>
<div id="productTable"></div>
</div>
</div>
</div>
... ...
... ... @@ -24,6 +24,18 @@
</div>
</div>
<script type="text/template" id="addTemplate">
<div class="form-horizontal" id="shopCategoryAdd">
<div class="form-group">
<label for="categoryName" class="col-sm-3 control-label">销售类目名称:</label>
<div class="col-sm-5">
<input type="text" id="categoryName" value="[[data]]" class="form-control" />
</div>
<div class="col-sm-2"><label style="color: #ff0000; line-height: 40px"> * 必填</label></div>
</div>
</div>
</script>
<script type="text/template" id="listTemplate">
<div class="addCategory" style="margin-bottom: 20px">
<a class="btn btn-success addBtn"><i class="fa fa-plus"></i> 新增销售类目</a>
... ... @@ -47,10 +59,11 @@
<tr>
<td style="line-height: 27px">[[item.categoryId]]</td>
<td style="line-height: 27px">[[item.categoryName]]</td>
<td style="line-height: 27px">[[item.createTime]]</td>
<td style="line-height: 27px">[[item.addTime]]</td>
<td style="line-height: 27px">[[item.productNum]]</td>
<td style="line-height: 27px">
<a href='/shop/shopCategory/edit/[[shopId]]/[[item.categoryId]]/' class='btn btn-xs btn-primary'>编辑</a>
<a href='javascript:' class='btn btn-xs btn-primary editCategory' data-categoryid='[[item.categoryId]]'>编辑名称</a>
<a href='/shop/shopCategory/edit/[[shopId]]/[[item.categoryId]]/' class='btn btn-xs btn-info'>关联商品</a>
<a href='/shop/shopCategory/info/[[shopId]]/[[item.categoryId]]/' class='btn btn-xs btn-info' style="display: none">查看</a>
<a href='javascript:' class='btn btn-xs btn-danger deleteBtn' data-categoryid='[[item.categoryId]]'>删除</a>
</td>
... ...
... ... @@ -6,22 +6,13 @@
<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>
<span id="shopName" style="margin: 0 20px"><font color="#999">店铺名称:</font><b><%shopName%></b></span>
<span id="categoryName"><font color="#999">销售类目名称:</font><b><%categoryName%></b></span>
<a href="javascript:" class="btn btn-default btn-return" style="float: right">返回</a>
</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 id="productTable"></div>
</div>
</div>
... ...
... ... @@ -44,7 +44,7 @@ var g1 = new common.grid({
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>'
return '<a href="javascript:" class="btn btn-success btn-xs selectProduct" data-index="'+item.__index+'">选择</a>'
}
}}
],
... ... @@ -217,29 +217,7 @@ $(document).on("click", ".filter-btn", function () {
}
});
//保存
$(document).on("click", ".btn-save", function () {
var categoryName = $.trim($('#categoryName').val());
if(categoryName != ''){
common.util.__ajax({
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
$(document).on("click", ".btn-return", function () {
location.href="/shop/shopCategory/index/" + curShopId;
});
\ No newline at end of file
... ...
... ... @@ -24,12 +24,38 @@ var Bll = {
$('#shopName b').text(rs.data);
$('#select2-shop-select-container').text(rs.data);
},true);
Bll.showList(1);
Bll.showList(0);
}
},
//新增,编辑销售类目名称
toast: function (type, url, name, id) {
var self = this;
common.dialog.confirm(
type == 0 ? "新增销售类目" : "编辑销售类目",
common.util.__template2($("#addTemplate").html(),{data:name}),
function () {
var categoryName = $('#categoryName').val();
if($.trim(categoryName) != ''){
common.util.__ajax({
url:url,
data: {
shopId:currentShopId,
categoryId: id,
categoryName: categoryName
}
},function (rs) {
self.showList(0);
});
}else{
common.util.__tip('店铺销售类目名称不能为空!');
return false;
}
}
)
},
//展示销售类目列表
showList: function (isLoading) {
//if(isLoading==1) loadModal = common.dialog.load();
if(isLoading==1) loadModal = common.dialog.load();
common.util.__ajax({
url:'/shops/shopCategory/list',
... ... @@ -88,7 +114,7 @@ $(document).on('change', '#shop-select', function () {
var shopName = this.options[this.selectedIndex].text;
$('#shopId b').text(shopId);
$('#shopName b').text(shopName);
Bll.showList(1);
Bll.showList(0);
}else{
Bll.destoryCategory();
}
... ... @@ -97,12 +123,20 @@ $(document).on('change', '#shop-select', function () {
//新增类目
$(document).on('click', '.addBtn', function () {
if(currentShopCategoryNum < 20){
location.href = '/shop/shopCategory/add/' + currentShopId + '/';
Bll.toast(0, '/shops/shopCategory/add', '', null);
}else {
common.util.__tip('店铺最多添加只能添加20个销售类目!');
}
});
//编辑类目名称
$(document).on('click', '.editCategory', function () {
var categoryName = $(this).parent().parent().find('td').eq(1).text();
var categoryId = $(this).data('categoryid');
console.log(categoryId)
Bll.toast(1, '/shops/shopCategory/update', categoryName, categoryId);
});
//删除类目
$(document).on('click', '.deleteBtn', function () {
var categoryName = $(this).parent().parent().find('td').eq(1).text();
... ...