Authored by leo

Update: 店铺商品分类需求,编号: 13005

@@ -2,22 +2,22 @@ module.exports = function (app){ @@ -2,22 +2,22 @@ module.exports = function (app){
2 app.get("/shop/shopCategory/index", "shop.ShopCategory.Index", function (req,res){ 2 app.get("/shop/shopCategory/index", "shop.ShopCategory.Index", function (req,res){
3 this.$extend={ 3 this.$extend={
4 moduleName:"店铺管理", 4 moduleName:"店铺管理",
5 - pageName:"店铺销售类目管理" 5 + pageName:"店铺商品分类"
6 } 6 }
7 }); 7 });
8 8
9 app.get("/shop/shopCategory/index/:shopId", "shop.ShopCategory.Index", function (req,res){ 9 app.get("/shop/shopCategory/index/:shopId", "shop.ShopCategory.Index", function (req,res){
10 this.$extend={ 10 this.$extend={
11 moduleName:"店铺管理", 11 moduleName:"店铺管理",
12 - pageName:"店铺销售类目管理" 12 + pageName:"店铺商品分类"
13 } 13 }
14 }); 14 });
15 15
16 app.get("/shop/shopCategory/edit/:shopId/:categoryId/", "shop.ShopCategory.Edit", ["shopCategory_selectShopNameById", "shopCategory_selectCategoryNameById"], function (rs1, rs2){ 16 app.get("/shop/shopCategory/edit/:shopId/:categoryId/", "shop.ShopCategory.Edit", ["shopCategory_selectShopNameById", "shopCategory_selectCategoryNameById"], function (rs1, rs2){
17 this.$extend={ 17 this.$extend={
18 moduleName:"店铺管理", 18 moduleName:"店铺管理",
19 - pageName:"店铺销售类目管理",  
20 - subPageName:"店铺销售类目编辑", 19 + pageName:"店铺商品分类",
  20 + subPageName:"店铺商品分类编辑",
21 shopName: rs1.data, 21 shopName: rs1.data,
22 categoryName: rs2.data 22 categoryName: rs2.data
23 } 23 }
@@ -26,19 +26,26 @@ module.exports = function (app){ @@ -26,19 +26,26 @@ module.exports = function (app){
26 app.get("/shop/shopCategory/info/:shopId/:categoryId/", "shop.ShopCategory.Info", ["shopCategory_selectShopNameById", "shopCategory_selectCategoryNameById"], function (rs1, rs2){ 26 app.get("/shop/shopCategory/info/:shopId/:categoryId/", "shop.ShopCategory.Info", ["shopCategory_selectShopNameById", "shopCategory_selectCategoryNameById"], function (rs1, rs2){
27 this.$extend={ 27 this.$extend={
28 moduleName:"店铺管理", 28 moduleName:"店铺管理",
29 - pageName:"店铺销售类目管理",  
30 - subPageName:"店铺销售类目详情", 29 + pageName:"店铺商品分类",
  30 + subPageName:"店铺商品分类详情",
31 shopName: rs1.data, 31 shopName: rs1.data,
32 categoryName: rs2.data 32 categoryName: rs2.data
33 } 33 }
34 }); 34 });
35 35
  36 + app.get("/shop/shopCategory/batch", "shop.ShopCategory.Batch", function (req,res){
  37 + this.$extend={
  38 + moduleName:"店铺管理",
  39 + pageName:"批量设置"
  40 + }
  41 + });
  42 +
36 /*****************************Vue单页面写法*****************************/ 43 /*****************************Vue单页面写法*****************************/
37 44
38 app.vue("/shop/shopCategory", "shop.ShopCategory", function (req,res){ 45 app.vue("/shop/shopCategory", "shop.ShopCategory", function (req,res){
39 this.$extend={ 46 this.$extend={
40 moduleName:"店铺管理", 47 moduleName:"店铺管理",
41 - pageName:"店铺销售类目管理" 48 + pageName:"店铺商品分类"
42 } 49 }
43 }); 50 });
44 51
@@ -60,7 +60,7 @@ module.exports={ @@ -60,7 +60,7 @@ module.exports={
60 {name:"shopId",type:"Number"}, 60 {name:"shopId",type:"Number"},
61 {name:"categoryId",type:"Number"}, 61 {name:"categoryId",type:"Number"},
62 {name:"productSKN",type:"Number"}, 62 {name:"productSKN",type:"Number"},
63 - {name:"factoryCode",type:"String"}, 63 + {name:"productName",type:"String"},
64 {name:"page",type:"Number"} 64 {name:"page",type:"Number"}
65 ] 65 ]
66 }, 66 },
  1 +<%include '../../../common/views/__ui/header'%>
  2 +<%include '../../../common/views/__partail/ListHeader'%>
  3 +<div class="contentpanel">
  4 + <div class="panel" style="margin-bottom:10px;">
  5 + <a href="javascript:;" class="btn btn-info btn-return">返回列表</a>
  6 + <table class="table table-bordered" style="border:1px solid #ddd; margin-top: 10px">
  7 + <tr>
  8 + <td rowspan="2">商品关联导表</td>
  9 + <td>上传EXCEL:</td>
  10 + <td style="position: relative;"><input id="shop-category-skn" name="file" data-type="shopCategorySkn" type="file" style="cursor: pointer; height: 37px; top: 8px;"></td>
  11 + </tr>
  12 + <tr>
  13 + <td>说明:</td>
  14 + <td colspan="2">
  15 + 1、上传文件必须是<span style="color:red;">.xlsx</span>文件<br>
  16 + 2、Excel表头为:<span style="color: #67D267;">类目ID,SKN</span><br>
  17 + 3、第一行为表头内容,第二行开始为正式内容<br>
  18 + 4、每个文件控制在2500行以内<br>
  19 + 5、<a href="/ajax/link/categoryLinkProduct">下载样例</a>
  20 + </td>
  21 + </tr>
  22 + </table>
  23 + </div>
  24 +</div>
  25 +<%include '../../../common/views/__ui/footer'%>
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 <div id="shopInfo"> 7 <div id="shopInfo">
8 <span id="shopId"><font color="#999">店铺ID:</font><b>--</b></span> 8 <span id="shopId"><font color="#999">店铺ID:</font><b>--</b></span>
9 <span id="shopName" style="margin: 0 20px"><font color="#999">店铺名称:</font><b><%shopName%></b></span> 9 <span id="shopName" style="margin: 0 20px"><font color="#999">店铺名称:</font><b><%shopName%></b></span>
10 - <span id="categoryName"><font color="#999">销售类目名称:</font><b><%categoryName%></b></span> 10 + <span id="categoryName"><font color="#999">商品分类名称:</font><b><%categoryName%></b></span>
11 <a href="javascript:" class="btn btn-default btn-return" style="float: right">返回</a> 11 <a href="javascript:" class="btn btn-default btn-return" style="float: right">返回</a>
12 </div> 12 </div>
13 </div> 13 </div>
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 <div class="mainTable" style="padding: 20px 20px 60px; border: 1px solid #ddd; background: #FFFFFF"> 21 <div class="mainTable" style="padding: 20px 20px 60px; border: 1px solid #ddd; background: #FFFFFF">
22 <div class="filter form-inline" style="margin-bottom: 20px"> 22 <div class="filter form-inline" style="margin-bottom: 20px">
23 <input id="productSKN" type="text" class="form-control" placeholder="SKN" />&nbsp;&nbsp; 23 <input id="productSKN" type="text" class="form-control" placeholder="SKN" />&nbsp;&nbsp;
24 - <input id="factoryCode" type="text" class="form-control" placeholder="商家编码" />&nbsp;&nbsp; 24 + <input id="productName" type="text" class="form-control" placeholder="商品名称" />&nbsp;&nbsp;
25 <a href="javascript:" class="btn btn-info filter-btn">查询</a> 25 <a href="javascript:" class="btn btn-info filter-btn">查询</a>
26 <a id="all-btn" href="" class="btn btn-info">全部</a> 26 <a id="all-btn" href="" class="btn btn-info">全部</a>
27 <a href="javascript:" class="btn btn-danger cancelAll" style="float: right;display: none">全部取消</a> 27 <a href="javascript:" class="btn btn-danger cancelAll" style="float: right;display: none">全部取消</a>
@@ -27,7 +27,7 @@ @@ -27,7 +27,7 @@
27 <script type="text/template" id="addTemplate"> 27 <script type="text/template" id="addTemplate">
28 <div class="form-horizontal" id="shopCategoryAdd"> 28 <div class="form-horizontal" id="shopCategoryAdd">
29 <div class="form-group"> 29 <div class="form-group">
30 - <label for="categoryName" class="col-sm-3 control-label">销售类目名称:</label> 30 + <label for="categoryName" class="col-sm-3 control-label">商品分类名称:</label>
31 <div class="col-sm-5"> 31 <div class="col-sm-5">
32 <input type="text" id="categoryName" value="[[data]]" class="form-control" maxlength="30" /> 32 <input type="text" id="categoryName" value="[[data]]" class="form-control" maxlength="30" />
33 </div> 33 </div>
@@ -38,9 +38,10 @@ @@ -38,9 +38,10 @@
38 38
39 <script type="text/template" id="listTemplate"> 39 <script type="text/template" id="listTemplate">
40 <div class="addCategory" style="margin-bottom: 20px"> 40 <div class="addCategory" style="margin-bottom: 20px">
41 - <a class="btn btn-success addBtn"><i class="fa fa-plus"></i> 新增销售类目</a> 41 + <a class="btn btn-success addBtn"><i class="fa fa-plus"></i> 新增商品分类</a>
  42 + <a href="javascript:;" class="btn btn-primary large btn-batch-import">批量(关联商品分类)</a>
42 <span style="float: right;font-size: 16px;line-height:37px;font-family:'simhei'"> 43 <span style="float: right;font-size: 16px;line-height:37px;font-family:'simhei'">
43 - 当前店铺共有:<b style="color: #5cb85c;font-size: 20px">[[data.length]]</b>&nbsp;条销售类目,<font color="#f0ad4e">最多可以添加20条</font> 44 + 当前店铺共有:<b style="color: #5cb85c;font-size: 20px">[[data.length]]</b>&nbsp;条商品分类,<font color="#f0ad4e">最多可以添加20条</font>
44 </span> 45 </span>
45 </div> 46 </div>
46 <table class="table table-striped table-bordered responsive dataTable no-footer" style="text-align: center"> 47 <table class="table table-striped table-bordered responsive dataTable no-footer" style="text-align: center">
@@ -70,7 +71,7 @@ @@ -70,7 +71,7 @@
70 </tr> 71 </tr>
71 [[/each]] 72 [[/each]]
72 [[else]] 73 [[else]]
73 - <tr><td colspan="6">当前店铺暂无销售类目</td></tr> 74 + <tr><td colspan="6">当前店铺暂无商品分类</td></tr>
74 [[/if]] 75 [[/if]]
75 </tbody> 76 </tbody>
76 </table> 77 </table>
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 <div id="shopInfo"> 7 <div id="shopInfo">
8 <span id="shopId"><font color="#999">店铺ID:</font><b>--</b></span> 8 <span id="shopId"><font color="#999">店铺ID:</font><b>--</b></span>
9 <span id="shopName" style="margin: 0 20px"><font color="#999">店铺名称:</font><b><%shopName%></b></span> 9 <span id="shopName" style="margin: 0 20px"><font color="#999">店铺名称:</font><b><%shopName%></b></span>
10 - <span id="categoryName"><font color="#999">销售类目名称:</font><b><%categoryName%></b></span> 10 + <span id="categoryName"><font color="#999">商品分类名称:</font><b><%categoryName%></b></span>
11 <a href="javascript:" class="btn btn-default btn-return" style="float: right">返回</a> 11 <a href="javascript:" class="btn btn-default btn-return" style="float: right">返回</a>
12 </div> 12 </div>
13 </div> 13 </div>
  1 +'use strict';
  2 +var $ = require('jquery'),
  3 + common = require('../../../common/common');
  4 +
  5 +$('input[type="file"]').after('<div class="file-name btn btn-default">请选择文件</div>');
  6 +
  7 +function batchExport(el, type) {
  8 + var loadModal = null;
  9 + var shopId = getShopIdInUri();
  10 +
  11 + return {
  12 + params: {
  13 + type: type,
  14 + __type: "batch-import",
  15 + args: shopId
  16 + },
  17 + onStart: function() {
  18 + loadModal = common.dialog.load();
  19 +
  20 + $(el).parents('td').find('.file-name').text($(el).val().replace("C:\\fakepath\\", ""));
  21 + },
  22 + onComplete: function(response) {
  23 + console.log(response);
  24 + if (loadModal) {
  25 + loadModal.close();
  26 + }
  27 + if (response.code == 200) {
  28 + common.util.__tip(response.message, 'success');
  29 + } else {
  30 + common.util.__tip(response.message, 'warning');
  31 + }
  32 +
  33 + $(el).parents('td').find('.file-name').text("请选择文件");
  34 + }
  35 + }
  36 +}
  37 +
  38 +common.edit.ajaxfileupload('#shop-category-skn', batchExport('#shop-category-skn', 'categoryLinkProduct'));
  39 +
  40 +function getShopIdInUri() {
  41 + var shopId = null;
  42 + // shop/shopCategory/batch?shopId=15
  43 + var uri = location.href + "";
  44 + var param = uri.substring(uri.indexOf('?shopId'));
  45 + var paramList = param.split("=");
  46 +
  47 + if(paramList.length > 0) {
  48 + shopId = paramList[1];
  49 + }
  50 +
  51 + return shopId;
  52 +}
  53 +
  54 +// 返回至index页面,并选择店铺
  55 +$(document).on('click', '.btn-return', function() {
  56 + var shopId = getShopIdInUri();
  57 +
  58 + location.href = "/shop/shopCategory/index/" + shopId;
  59 +})
@@ -14,7 +14,7 @@ var g1 = new common.grid({ @@ -14,7 +14,7 @@ var g1 = new common.grid({
14 shopId: curShopId, 14 shopId: curShopId,
15 categoryId: curCategoryId, 15 categoryId: curCategoryId,
16 productSKN: common.util.__input("productSKN"), 16 productSKN: common.util.__input("productSKN"),
17 - factoryCode: common.util.__input("factoryCode") 17 + productName: common.util.__input("productName")
18 }; 18 };
19 }, 19 },
20 columns: [ 20 columns: [
@@ -22,11 +22,10 @@ var g1 = new common.grid({ @@ -22,11 +22,10 @@ var g1 = new common.grid({
22 return item.productPic ? '<img src="'+item.productPic+'?imageView/0/w/40/h/60">' : ''; 22 return item.productPic ? '<img src="'+item.productPic+'?imageView/0/w/40/h/60">' : '';
23 }}, 23 }},
24 {display: "SKN", name: "productSKN"}, 24 {display: "SKN", name: "productSKN"},
25 - {display: "厂家编号", name: "factoryCode"},  
26 {display: "商品名称", name: "productName"}, 25 {display: "商品名称", name: "productName"},
27 {display: "销售价(元)", name: "salePrice"}, 26 {display: "销售价(元)", name: "salePrice"},
28 {display: "分类", name: "productSort"}, 27 {display: "分类", name: "productSort"},
29 - {display: "销售类目", render: function (item) { 28 + {display: "商品分类", render: function (item) {
30 var name = item.categoryName ? item.categoryName : '未分类'; 29 var name = item.categoryName ? item.categoryName : '未分类';
31 var categoryList = '<span class="name" style="display: block; text-align: center">'+ name +'</span>'; 30 var categoryList = '<span class="name" style="display: block; text-align: center">'+ name +'</span>';
32 if(item.saleCategory && item.saleCategory.length > 1){ 31 if(item.saleCategory && item.saleCategory.length > 1){
@@ -61,7 +60,7 @@ var g2 = new common.grid({ @@ -61,7 +60,7 @@ var g2 = new common.grid({
61 shopId: curShopId, 60 shopId: curShopId,
62 categoryId: curCategoryId, 61 categoryId: curCategoryId,
63 productSKN: common.util.__input("productSKN"), 62 productSKN: common.util.__input("productSKN"),
64 - factoryCode: common.util.__input("factoryCode") 63 + productName: common.util.__input("productName")
65 }; 64 };
66 }, 65 },
67 columns: [ 66 columns: [
@@ -69,11 +68,10 @@ var g2 = new common.grid({ @@ -69,11 +68,10 @@ var g2 = new common.grid({
69 return item.productPic ? '<img src="'+item.productPic+'?imageView/0/w/40/h/60">' : ''; 68 return item.productPic ? '<img src="'+item.productPic+'?imageView/0/w/40/h/60">' : '';
70 }}, 69 }},
71 {display: "SKN", name: "productSKN"}, 70 {display: "SKN", name: "productSKN"},
72 - {display: "厂家编号", name: "factoryCode"},  
73 {display: "商品名称", name: "productName"}, 71 {display: "商品名称", name: "productName"},
74 {display: "销售价(元)", name: "salePrice"}, 72 {display: "销售价(元)", name: "salePrice"},
75 {display: "分类", name: "productSort"}, 73 {display: "分类", name: "productSort"},
76 - {display: "销售类目", render: function (item) { 74 + {display: "商品分类", render: function (item) {
77 var name = item.categoryName ? item.categoryName : '未分类'; 75 var name = item.categoryName ? item.categoryName : '未分类';
78 var categoryList = '<span class="name" style="display: block; text-align: center">'+ name +'</span>'; 76 var categoryList = '<span class="name" style="display: block; text-align: center">'+ name +'</span>';
79 if(item.saleCategory && item.saleCategory.length > 1){ 77 if(item.saleCategory && item.saleCategory.length > 1){
@@ -192,7 +190,7 @@ $(document).on("click", ".cancelAll", function () { @@ -192,7 +190,7 @@ $(document).on("click", ".cancelAll", function () {
192 ); 190 );
193 }); 191 });
194 192
195 -//查看更多销售类目 193 +//查看更多商品分类
196 $(document).on("click", ".moreCategory", function () { 194 $(document).on("click", ".moreCategory", function () {
197 var num = $(this).data('num'); 195 var num = $(this).data('num');
198 if($(this).hasClass('open')){ 196 if($(this).hasClass('open')){
@@ -27,11 +27,11 @@ var Bll = { @@ -27,11 +27,11 @@ var Bll = {
27 Bll.showList(0); 27 Bll.showList(0);
28 } 28 }
29 }, 29 },
30 - //新增,编辑销售类目名称 30 + //新增,编辑商品分类名称
31 toast: function (type, url, name, id) { 31 toast: function (type, url, name, id) {
32 var self = this; 32 var self = this;
33 common.dialog.confirm( 33 common.dialog.confirm(
34 - type == 0 ? "新增销售类目" : "编辑销售类目", 34 + type == 0 ? "新增商品分类" : "编辑商品分类",
35 common.util.__template2($("#addTemplate").html(),{data:name}), 35 common.util.__template2($("#addTemplate").html(),{data:name}),
36 function () { 36 function () {
37 var categoryName = $('#categoryName').val(); 37 var categoryName = $('#categoryName').val();
@@ -47,7 +47,7 @@ var Bll = { @@ -47,7 +47,7 @@ var Bll = {
47 self.showList(0); 47 self.showList(0);
48 }); 48 });
49 }else{ 49 }else{
50 - common.util.__tip('店铺销售类目名称不能为空!'); 50 + common.util.__tip('店铺商品分类名称不能为空!');
51 return false; 51 return false;
52 } 52 }
53 } 53 }
@@ -124,7 +124,7 @@ $(document).on('click', '.addBtn', function () { @@ -124,7 +124,7 @@ $(document).on('click', '.addBtn', function () {
124 if(currentShopCategoryNum < 20){ 124 if(currentShopCategoryNum < 20){
125 Bll.toast(0, '/shops/shopCategory/add', '', null); 125 Bll.toast(0, '/shops/shopCategory/add', '', null);
126 }else { 126 }else {
127 - common.util.__tip('店铺最多添加只能添加20个销售类目!'); 127 + common.util.__tip('店铺最多添加只能添加20个商品分类!');
128 } 128 }
129 }); 129 });
130 130
@@ -141,10 +141,17 @@ $(document).on('click', '.deleteBtn', function () { @@ -141,10 +141,17 @@ $(document).on('click', '.deleteBtn', function () {
141 var categoryId = $(this).data('categoryid'); 141 var categoryId = $(this).data('categoryid');
142 142
143 common.dialog.confirm( 143 common.dialog.confirm(
144 - "删除店铺销售类目",  
145 - "你确定<b style='color: #ff0000'>&nbsp;删除&nbsp;</b>销售类目<b style='color:#428bca'>&nbsp;"+categoryName+"&nbsp;</b>么?", 144 + "删除店铺商品分类",
  145 + "你确定<b style='color: #ff0000'>&nbsp;删除&nbsp;</b>商品分类<b style='color:#428bca'>&nbsp;"+categoryName+"&nbsp;</b>么?",
146 function () { 146 function () {
147 Bll.deleteCategory(categoryId); 147 Bll.deleteCategory(categoryId);
148 } 148 }
149 ) 149 )
150 }); 150 });
  151 +
  152 +// 跳转到批量操作页面,此处需要在URL中追加当前选择的ShopId
  153 +$(document).on('click', '.btn-batch-import', function () {
  154 + var uri = "/shop/shopCategory/batch?shopId=" + currentShopId;
  155 +
  156 + location.href = uri;
  157 +})