Authored by qinchao

Merge branch 'dev_qc_6.8.4_menu' into test6.8.4

@@ -47,6 +47,15 @@ @@ -47,6 +47,15 @@
47 <if test="saleCategory.orderBy != null"> 47 <if test="saleCategory.orderBy != null">
48 order_by = #{saleCategory.orderBy}, 48 order_by = #{saleCategory.orderBy},
49 </if> 49 </if>
  50 + <if test="saleCategory.linkType != null">
  51 + link_type = #{saleCategory.linkType},
  52 + </if>
  53 + <if test="saleCategory.linkDetail != null">
  54 + link_detail = #{saleCategory.linkDetail},
  55 + </if>
  56 + <if test="saleCategory.imageUrl != null">
  57 + image_url = #{saleCategory.imageUrl},
  58 + </if>
50 update_time = #{saleCategory.updateTime} 59 update_time = #{saleCategory.updateTime}
51 </set> 60 </set>
52 where id = #{saleCategory.id} 61 where id = #{saleCategory.id}
@@ -5,6 +5,9 @@ import com.yoho.ufo.dal.SaleCategoryMapper; @@ -5,6 +5,9 @@ import com.yoho.ufo.dal.SaleCategoryMapper;
5 import com.yoho.ufo.exception.CommonException; 5 import com.yoho.ufo.exception.CommonException;
6 import com.yoho.ufo.model.salecategory.SaleCategory; 6 import com.yoho.ufo.model.salecategory.SaleCategory;
7 import com.yoho.ufo.service.ISaleCategoryService; 7 import com.yoho.ufo.service.ISaleCategoryService;
  8 +import com.yoho.ufo.util.CollectionUtil;
  9 +import com.yoho.ufo.util.ImagesConstant;
  10 +import com.yoho.ufo.util.ImagesHelper;
8 import com.yoho.ufo.util.OrikaUtils; 11 import com.yoho.ufo.util.OrikaUtils;
9 import com.yohobuy.ufo.model.response.salecategory.SaleCategoryResponseBo; 12 import com.yohobuy.ufo.model.response.salecategory.SaleCategoryResponseBo;
10 import com.yohobuy.ufo.model.response.salecategory.SaleCategoryTreeViewResponseBo; 13 import com.yohobuy.ufo.model.response.salecategory.SaleCategoryTreeViewResponseBo;
@@ -71,6 +74,10 @@ public class SaleCategoryServiceImpl implements ISaleCategoryService { @@ -71,6 +74,10 @@ public class SaleCategoryServiceImpl implements ISaleCategoryService {
71 public void saveOrUpdateSaleCategory(SaleCategoryResponseBo saleCategoryResponseBo){ 74 public void saveOrUpdateSaleCategory(SaleCategoryResponseBo saleCategoryResponseBo){
72 log.info("saveOrUpdateSaleCategory param = {}", saleCategoryResponseBo); 75 log.info("saveOrUpdateSaleCategory param = {}", saleCategoryResponseBo);
73 SaleCategory saleCategory = OrikaUtils.map(saleCategoryResponseBo, SaleCategory.class); 76 SaleCategory saleCategory = OrikaUtils.map(saleCategoryResponseBo, SaleCategory.class);
  77 + saleCategory.setImageUrl(ImagesHelper.getImageRelativeUrl(saleCategory.getImageUrl(), ImagesConstant.BUCKET_SALE_CATEGORY_IMG));
  78 + if(StringUtils.isBlank(saleCategory.getLinkType())){
  79 + saleCategory.setLinkType(StringUtils.EMPTY);
  80 + }
74 if (saleCategory.getId() == null || saleCategory.getId() == 0) { 81 if (saleCategory.getId() == null || saleCategory.getId() == 0) {
75 // 新增 82 // 新增
76 if (saleCategory.getParentId() == null || saleCategory.getParentId() == 0) { 83 if (saleCategory.getParentId() == null || saleCategory.getParentId() == 0) {
@@ -101,8 +108,11 @@ public class SaleCategoryServiceImpl implements ISaleCategoryService { @@ -101,8 +108,11 @@ public class SaleCategoryServiceImpl implements ISaleCategoryService {
101 if(db_saleCategory==null){ 108 if(db_saleCategory==null){
102 throw new CommonException(201, "找不到销售类目!"); 109 throw new CommonException(201, "找不到销售类目!");
103 } 110 }
104 - db_saleCategory.setCategoryName(saleCategoryResponseBo.getCategoryName());  
105 - db_saleCategory.setOrderBy(saleCategoryResponseBo.getOrderBy()); 111 + db_saleCategory.setCategoryName(saleCategory.getCategoryName());
  112 + db_saleCategory.setOrderBy(saleCategory.getOrderBy());
  113 + db_saleCategory.setImageUrl(saleCategory.getImageUrl());
  114 + db_saleCategory.setLinkType(saleCategory.getLinkType());
  115 + db_saleCategory.setLinkDetail(saleCategory.getLinkDetail());
106 db_saleCategory.setUpdateTime(DateUtil.currentTimeSeconds()); 116 db_saleCategory.setUpdateTime(DateUtil.currentTimeSeconds());
107 117
108 List<SaleCategory> sameNameList = saleCategoryMapper.selectByNameAndParentId(saleCategory.getCategoryName(),saleCategory.getParentId()); 118 List<SaleCategory> sameNameList = saleCategoryMapper.selectByNameAndParentId(saleCategory.getCategoryName(),saleCategory.getParentId());
@@ -123,6 +133,7 @@ public class SaleCategoryServiceImpl implements ISaleCategoryService { @@ -123,6 +133,7 @@ public class SaleCategoryServiceImpl implements ISaleCategoryService {
123 log.info("enter getSaleCategoryById param = {}",id); 133 log.info("enter getSaleCategoryById param = {}",id);
124 SaleCategory saleCategory = saleCategoryMapper.selectById(id); 134 SaleCategory saleCategory = saleCategoryMapper.selectById(id);
125 if(saleCategory!=null){ 135 if(saleCategory!=null){
  136 + saleCategory.setImageUrl(ImagesHelper.getImageAbsoluteUrl(saleCategory.getImageUrl(), ImagesConstant.BUCKET_SALE_CATEGORY_IMG));
126 return OrikaUtils.map(saleCategory, SaleCategoryResponseBo.class); 137 return OrikaUtils.map(saleCategory, SaleCategoryResponseBo.class);
127 } 138 }
128 return null; 139 return null;
  1 +<!DOCTYPE html>
  2 +
  3 +<style>
  4 +.sale-category-detail-page .goods-image {
  5 + display: flex;
  6 +}
  7 +
  8 +
  9 +.sale-category-detail-page .goods-image .img {
  10 + width: 104px;
  11 + height: 104px;
  12 + margin-right: 10px;
  13 + background-size: cover;
  14 + background-repeat: no-repeat;
  15 + background-position: center;
  16 + position: relative;
  17 +}
  18 +
  19 +.sale-category-detail-page .goods-image .img:hover:before {
  20 + content: "删除";
  21 + width: 100%;
  22 + display: block;
  23 + position: absolute;
  24 + top: 0;
  25 + background: #000;
  26 + opacity: 0.5;
  27 + color: #fff;
  28 + text-align: center;
  29 + line-height: 104px;
  30 +}
  31 +</style>
  32 +<div class="sale-category-detail-page" style="overflow-y: scroll">
  33 + <form name="categoryEditForm" id="categoryEditForm" method="post" enctype="multipart/form-data">
  34 + <input type="hidden" name="id" />
  35 + <input type="hidden" name="parentId" id="parentId"/>
  36 + <input type="hidden" name="imageUrl" id="imageUrl"/>
  37 + <div style="margin-top: 5px;margin-left: 30px">
  38 + <table border="0" style="width:95%;margin-top:5px;line-height:30px;" id="tab">
  39 + <tr style="height: 60px">
  40 + <td width="20%"><span style="color:red">*</span><label>名称</label></td>
  41 + <td>
  42 + <div style="width:200px;">
  43 + <input class="easyui-textbox" id="categoryName" name="categoryName" data-options="validType:'length[1,30]'" />
  44 + </div>
  45 + </td>
  46 + </tr>
  47 + <tr style="height: 60px">
  48 + <td width="20%"><span style="color:red">*</span><label>排序值</label></td>
  49 + <td>
  50 + <input class="easyui-numberbox" id="orderBy" name="orderBy" data-options="validType:'length[1,10]'" />
  51 + </td>
  52 + </tr>
  53 + </table>
  54 + </div>
  55 +
  56 + <div class="goods-image" style="margin-top: 5px;margin-left: 30px">
  57 + <div style="width:20%;margin-top:5px;line-height:30px;" >
  58 + <span style="color:red">*</span><label>分类图标</label>
  59 + </div>
  60 + <div id="imageUpload"></div>
  61 + </div>
  62 +
  63 + <div style="margin-top: 5px;margin-left: 30px">
  64 + <table border="0" style="width:95%;margin-top:5px;line-height:30px;" >
  65 + <tr style="height: 60px">
  66 + <td width="20%"><span style="color:red">*</span><label>跳转类型</label></td>
  67 + <td>
  68 + <div style="width:200px;">
  69 + <select name="linkType" class="easyui-combobox" style="width:200px;" panelHeight="auto" required="true">
  70 + <option value="series" selected>系列</option>
  71 + <option value="brand">品牌</option>
  72 + <option value="sort">品类</option>
  73 + <option value="productPool">商品池</option>
  74 + <option value="h5">h5</option>
  75 + </select>
  76 + </div>
  77 + </td>
  78 + </tr>
  79 + <tr style="height: 60px">
  80 + <td width="20%"><span style="color:red">*</span><label>跳转目的</label></td>
  81 + <td>
  82 + <input class="easyui-textbox" name="linkDetail" data-options="validType:'length[1,500]'" style="width:500px;" required="true"/>
  83 + </td>
  84 + </tr>
  85 + </table>
  86 + </div>
  87 + </form>
  88 +</div>
  89 +<script>
  90 + $(function () {
  91 + this.dom = {
  92 + imageUpload: $('#categoryEditForm #imageUpload')
  93 + };
  94 +
  95 + $("#categoryEditForm #categoryName").textbox({
  96 + required: true,
  97 + missingMessage: "销售类目名称不能为空",
  98 + prompt: "请输入",
  99 + width: "200px"
  100 + });
  101 +
  102 + $("#categoryEditForm #orderBy").numberbox({
  103 + required: true,
  104 + precision:0,
  105 + min:1,
  106 + missingMessage: "排序值不能为空",
  107 + prompt: "请输入",
  108 + width:"200px"
  109 + });
  110 +
  111 +
  112 + this.dom.imageUpload.imageUpload({
  113 + width: 104,
  114 + height: 104,
  115 + realInputName: "imageUrl",
  116 + url: contextPath + '/fileupload/upload',
  117 + queryParams: {
  118 + bucket: "salecategoryimg"
  119 + },
  120 + onBeforeSubmit: function () {
  121 + $.messager.progress({
  122 + title: "正在执行",
  123 + msg: "正在执行,请稍后...",
  124 + interval: 500,
  125 + text: ""
  126 + });
  127 + },
  128 + filterFileName: function (data) {
  129 + if (!data || data.code != 200) {
  130 + $.messager.progress("close");
  131 + $.messager.alert("错误", data.message);
  132 + return "";
  133 + }
  134 + return data.data.url;
  135 + },
  136 + onLoadSuccess: function (data) {
  137 + console.log(data.data );
  138 + $.messager.progress("close");
  139 + $(document).find('.file-close').click();
  140 + //只保留最佳的成功的
  141 + $(".sale-category-detail-page .goods-image .img").remove();
  142 + $('#categoryEditForm #imageUpload').before('<div class="img" data-url="' + data.data + '" style="background-image:url(' + data.data + ');">');
  143 + return false;
  144 + }
  145 + });
  146 +
  147 + $(document).on('click', '.goods-image .img', function() {
  148 + $(this).remove();
  149 + });
  150 +
  151 +
  152 + $("#categoryEditForm #parentId").val(saleCategoryParentId);
  153 +
  154 + if (saleCategoryId > 0) {
  155 + $.post(contextPath + "/saleCategory/getSaleCategoryById", {
  156 + id: saleCategoryId
  157 + }, function (data) {
  158 + $("#categoryEditForm").form("load", data.data);
  159 +
  160 + if (data.data.imageUrl && data.data.imageUrl.length > 0) {
  161 + const item = data.data.imageUrl;
  162 + $('#categoryEditForm #imageUpload').before('<div class="img" data-url="' + item + '" style="background-image:url(' + item + ');">');
  163 + }
  164 + });
  165 + }
  166 + });
  167 +
  168 +</script>
@@ -23,6 +23,16 @@ @@ -23,6 +23,16 @@
23 .div_search .easyui-linkbutton { 23 .div_search .easyui-linkbutton {
24 margin-top: 20px; 24 margin-top: 20px;
25 } 25 }
  26 +
  27 + .sale-category-detail-page .img222 {
  28 + width: 104px;
  29 + height: 104px;
  30 + margin-right: 10px;
  31 + background-size: cover;
  32 + background-repeat: no-repeat;
  33 + background-position: center;
  34 + position: relative;
  35 + }
26 </style> 36 </style>
27 <div style="margin-left: 30px;" class="div_search"> 37 <div style="margin-left: 30px;" class="div_search">
28 <a id="addSaleCategory" class="easyui-linkbutton btn-success">添加一级销售类目</a> 38 <a id="addSaleCategory" class="easyui-linkbutton btn-success">添加一级销售类目</a>
@@ -117,17 +127,16 @@ @@ -117,17 +127,16 @@
117 127
118 128
119 if(1== rowData.level||2==rowData.level) { 129 if(1== rowData.level||2==rowData.level) {
120 - str += "<a role='edit' dataId='" + rowData.id + "' dataParentId='"+rowData.parentId+"' style='margin-left:10px;background-color: #5bc0de'>编辑</a>" 130 + str += "<a role='edit' dataId='" + rowData.id + "' dataParentId='"+rowData.parentId+"' style='margin-left:10px;background-color: #5bc0de'>编辑</a>";
121 }else{ 131 }else{
122 - str += "<a role='addOrEditThirdLevel' dataId='" + rowData.id + "' dataParentId='"+rowData.parentId+"' style='margin-left:10px;background-color: #5bc0de'>编辑</a>" 132 + str += "<a role='editThirdLevel' dataId='" + rowData.id + "' dataParentId='"+rowData.parentId+"' style='margin-left:10px;background-color: #5bc0de'>编辑</a>"
123 } 133 }
124 134
125 if(1== rowData.level||2==rowData.level) { 135 if(1== rowData.level||2==rowData.level) {
126 - str = "<a role='edit' dataId='" + rowData.id + "' dataParentId='"+rowData.parentId+"' style='margin-left:10px;background-color: #5bc0de'>编辑</a>";  
127 if(1==rowData.level){ 136 if(1==rowData.level){
128 str += "<a role='addSecondLevel' dataId='" + rowData.id + "' style='margin-left:10px;background-color: #5bc0de;color:white;'>添加子类</a>"; 137 str += "<a role='addSecondLevel' dataId='" + rowData.id + "' style='margin-left:10px;background-color: #5bc0de;color:white;'>添加子类</a>";
129 }else { 138 }else {
130 - str += "<a role='addOrEditThirdLevel' dataId='" + rowData.id + "' style='margin-left:10px;background-color: #5bc0de;color:white;'>添加子类</a>"; 139 + str += "<a role='addThirdLevel' dataId='" + rowData.id + "' style='margin-left:10px;background-color: #5bc0de;color:white;'>添加子类</a>";
131 } 140 }
132 } 141 }
133 142
@@ -159,12 +168,22 @@ @@ -159,12 +168,22 @@
159 } 168 }
160 }); 169 });
161 170
162 - $(this).myDatagrid("getPanel").find("a[role='addOrEditThirdLevel']").linkbutton({ 171 + $(this).myDatagrid("getPanel").find("a[role='addThirdLevel']").linkbutton({
  172 + iconCls: "icon-edit",
  173 + onClick: function () {
  174 + //添加子类,当前类的id作为pid
  175 + var id = $(this).attr("dataId");
  176 + editRowThird(0,id);
  177 + }
  178 + });
  179 +
  180 + $(this).myDatagrid("getPanel").find("a[role='editThirdLevel']").linkbutton({
163 iconCls: "icon-edit", 181 iconCls: "icon-edit",
164 onClick: function () { 182 onClick: function () {
165 //添加子类,当前类的id作为pid 183 //添加子类,当前类的id作为pid
166 var id = $(this).attr("dataId"); 184 var id = $(this).attr("dataId");
167 - alert("开发中"+id); 185 + var pid = $(this).attr("dataParentId");
  186 + editRowThird(id,pid);
168 } 187 }
169 }); 188 });
170 189
@@ -201,10 +220,10 @@ @@ -201,10 +220,10 @@
201 saleCategoryId = id; 220 saleCategoryId = id;
202 saleCategoryParentId = pid; 221 saleCategoryParentId = pid;
203 var div = $("<div>").appendTo($(document.body)); 222 var div = $("<div>").appendTo($(document.body));
204 - var title = "编辑品类"; 223 + var title = "编辑销售类目";
205 var message = "确认修改销售类目信息吗?"; 224 var message = "确认修改销售类目信息吗?";
206 if (id == 0) { 225 if (id == 0) {
207 - title = "添加品类"; 226 + title = "添加销售类目";
208 message = "确认添加销售类目信息吗?"; 227 message = "确认添加销售类目信息吗?";
209 } 228 }
210 $(div).myDialog({ 229 $(div).myDialog({
@@ -266,6 +285,87 @@ @@ -266,6 +285,87 @@
266 }); 285 });
267 } 286 }
268 287
  288 +
  289 + function editRowThird(id,pid) {
  290 + saleCategoryId = id;
  291 + saleCategoryParentId = pid;
  292 + var div = $("<div>").appendTo($(document.body));
  293 + var title = "编辑销售类目";
  294 + var message = "确认修改销售类目信息吗?";
  295 + if (id == 0) {
  296 + title = "添加销售类目";
  297 + message = "确认添加销售类目信息吗?";
  298 + }
  299 + $(div).myDialog({
  300 + width: "850px",
  301 + height: "500px",
  302 + title: title,
  303 + href: contextPath + "/html/saleCategory/addOrEditThirdLevel.html",
  304 + queryParams: {
  305 + saleCategoryParentId:saleCategoryParentId,
  306 + id: id
  307 + },
  308 + modal: true,
  309 + collapsible: true,
  310 + cache: false,
  311 + buttons: [{
  312 + id: "saveBtn",
  313 + text: "保存",
  314 + handler: function () {
  315 + $.messager.confirm("确认", message, function (flag) {
  316 + if(flag) {
  317 + $("#categoryEditForm").form("submit", {
  318 + url: contextPath + "/saleCategory/saveOrUpdateSaleCategory",
  319 + onSubmit: function () {
  320 + if (!$("#categoryEditForm").form("validate")) {
  321 + return false;
  322 + }
  323 + var imageUrlList = [];
  324 + $('.goods-image .img').each(function(index, item) {
  325 + imageUrlList.push($(item).data('url'));
  326 + });
  327 + if(imageUrlList.length!=1){
  328 + $.messager.alert('操作提示', '必须要上传1张图片,而且只允许有1张!',"warning");
  329 + return false;
  330 + }
  331 +
  332 + $("#categoryEditForm #imageUrl").val(imageUrlList[0]);
  333 +
  334 + $.messager.progress({
  335 + title: "正在执行",
  336 + msg: "正在执行,请稍后..."
  337 + });
  338 + return true;
  339 + },
  340 + success: function (data) {
  341 + $.messager.progress("close");
  342 + data = JSON.parse(data);
  343 + if (data.code == 200) {
  344 + $(div).dialog("close");
  345 + $("#saleCategoryTable").treegrid("reload");
  346 + $.messager.show({
  347 + title: "提示",
  348 + msg: title + "成功!",
  349 + height: 120
  350 + });
  351 + } else {
  352 + $.messager.alert("失败", data.message, "error");
  353 + }
  354 + }
  355 + });
  356 + }
  357 + });
  358 + }
  359 + }, {
  360 + text: "关闭",
  361 + iconCls: "icon-cancel",
  362 + handler: function () {
  363 + $(div).dialog("close");
  364 + }
  365 + }]
  366 + });
  367 + }
  368 +
269 function updateBrandStatus(id, status, parentId) { 369 function updateBrandStatus(id, status, parentId) {
270 var message = ""; 370 var message = "";
271 var msg = ""; 371 var msg = "";