Authored by qinchao

add 销售类目功能

... ... @@ -47,6 +47,15 @@
<if test="saleCategory.orderBy != null">
order_by = #{saleCategory.orderBy},
</if>
<if test="saleCategory.linkType != null">
link_type = #{saleCategory.linkType},
</if>
<if test="saleCategory.linkDetail != null">
link_detail = #{saleCategory.linkDetail},
</if>
<if test="saleCategory.imageUrl != null">
image_url = #{saleCategory.imageUrl},
</if>
update_time = #{saleCategory.updateTime}
</set>
where id = #{saleCategory.id}
... ...
... ... @@ -5,6 +5,9 @@ import com.yoho.ufo.dal.SaleCategoryMapper;
import com.yoho.ufo.exception.CommonException;
import com.yoho.ufo.model.salecategory.SaleCategory;
import com.yoho.ufo.service.ISaleCategoryService;
import com.yoho.ufo.util.CollectionUtil;
import com.yoho.ufo.util.ImagesConstant;
import com.yoho.ufo.util.ImagesHelper;
import com.yoho.ufo.util.OrikaUtils;
import com.yohobuy.ufo.model.response.salecategory.SaleCategoryResponseBo;
import com.yohobuy.ufo.model.response.salecategory.SaleCategoryTreeViewResponseBo;
... ... @@ -71,6 +74,10 @@ public class SaleCategoryServiceImpl implements ISaleCategoryService {
public void saveOrUpdateSaleCategory(SaleCategoryResponseBo saleCategoryResponseBo){
log.info("saveOrUpdateSaleCategory param = {}", saleCategoryResponseBo);
SaleCategory saleCategory = OrikaUtils.map(saleCategoryResponseBo, SaleCategory.class);
saleCategory.setImageUrl(ImagesHelper.getImageRelativeUrl(saleCategory.getImageUrl(), ImagesConstant.BUCKET_SALE_CATEGORY_IMG));
if(StringUtils.isBlank(saleCategory.getLinkType())){
saleCategory.setLinkType(StringUtils.EMPTY);
}
if (saleCategory.getId() == null || saleCategory.getId() == 0) {
// 新增
if (saleCategory.getParentId() == null || saleCategory.getParentId() == 0) {
... ... @@ -101,8 +108,11 @@ public class SaleCategoryServiceImpl implements ISaleCategoryService {
if(db_saleCategory==null){
throw new CommonException(201, "找不到销售类目!");
}
db_saleCategory.setCategoryName(saleCategoryResponseBo.getCategoryName());
db_saleCategory.setOrderBy(saleCategoryResponseBo.getOrderBy());
db_saleCategory.setCategoryName(saleCategory.getCategoryName());
db_saleCategory.setOrderBy(saleCategory.getOrderBy());
db_saleCategory.setImageUrl(saleCategory.getImageUrl());
db_saleCategory.setLinkType(saleCategory.getLinkType());
db_saleCategory.setLinkDetail(saleCategory.getLinkDetail());
db_saleCategory.setUpdateTime(DateUtil.currentTimeSeconds());
List<SaleCategory> sameNameList = saleCategoryMapper.selectByNameAndParentId(saleCategory.getCategoryName(),saleCategory.getParentId());
... ... @@ -123,6 +133,7 @@ public class SaleCategoryServiceImpl implements ISaleCategoryService {
log.info("enter getSaleCategoryById param = {}",id);
SaleCategory saleCategory = saleCategoryMapper.selectById(id);
if(saleCategory!=null){
saleCategory.setImageUrl(ImagesHelper.getImageAbsoluteUrl(saleCategory.getImageUrl(), ImagesConstant.BUCKET_SALE_CATEGORY_IMG));
return OrikaUtils.map(saleCategory, SaleCategoryResponseBo.class);
}
return null;
... ...
... ... @@ -29,10 +29,11 @@
line-height: 104px;
}
</style>
<div class="sale-category-detail-page" fit="true" style="overflow-y: scroll">
<div class="sale-category-detail-page" style="overflow-y: scroll">
<form name="categoryEditForm" id="categoryEditForm" method="post" enctype="multipart/form-data">
<input type="hidden" name="id" />
<input type="hidden" name="parentId" id="parentId"/>
<input type="hidden" name="imageUrl" id="imageUrl"/>
<div style="margin-top: 5px;margin-left: 30px">
<table border="0" style="width:95%;margin-top:5px;line-height:30px;" id="tab">
<tr style="height: 60px">
... ... @@ -53,17 +54,10 @@
</div>
<div class="goods-image" style="margin-top: 5px;margin-left: 30px">
<table border="0" style="width:95%;margin-top:5px;line-height:30px;" >
<tr style="height: 60px">
<td width="20%"><span style="color:red">*</span><label>分类图标</label></td>
<td width="80%">
<!--<div class="img" data-url="http://img11.static.yhbimg.com/salecategoryimg/2018/12/18/11/01a8ea37ad7b8f112d2727ff1ee507a926.png"
style="background-image:url(http://img11.static.yhbimg.com/salecategoryimg/2018/12/18/11/01a8ea37ad7b8f112d2727ff1ee507a926.png);"></div>-->
<div id="imageUpload"></div>
</td>
</tr>
</table>
<div style="width:20%;margin-top:5px;line-height:30px;" >
<span style="color:red">*</span><label>分类图标</label>
</div>
<div id="imageUpload"></div>
</div>
<div style="margin-top: 5px;margin-left: 30px">
... ... @@ -72,14 +66,20 @@
<td width="20%"><span style="color:red">*</span><label>跳转类型</label></td>
<td>
<div style="width:200px;">
<input class="easyui-textbox" name="linkType" data-options="validType:'length[1,30]'" />
<select name="linkType" class="easyui-combobox" style="width:200px;" panelHeight="auto" required="true">
<option value="series" selected>系列</option>
<option value="brand">品牌</option>
<option value="sort">品类</option>
<option value="productPool">商品池</option>
<option value="h5">h5</option>
</select>
</div>
</td>
</tr>
<tr style="height: 60px">
<td width="20%"><span style="color:red">*</span><label>跳转目的</label></td>
<td>
<input class="easyui-textbox" name="linkDetail" data-options="validType:'length[1,10]'" />
<input class="easyui-textbox" name="linkDetail" data-options="validType:'length[1,500]'" style="width:500px;" required="true"/>
</td>
</tr>
</table>
... ... @@ -137,12 +137,16 @@
console.log(data.data );
$.messager.progress("close");
$(document).find('.file-close').click();
//只保留最佳的成功的
$(".sale-category-detail-page .goods-image .img").remove();
$('#categoryEditForm #imageUpload').before('<div class="img" data-url="' + data.data + '" style="background-image:url(' + data.data + ');">');
return false;
}
});
$(document).on('click', '.goods-image .img', function() {
$(this).remove();
});
$("#categoryEditForm #parentId").val(saleCategoryParentId);
... ... @@ -153,6 +157,10 @@
}, function (data) {
$("#categoryEditForm").form("load", data.data);
if (data.data.imageUrl && data.data.imageUrl.length > 0) {
const item = data.data.imageUrl;
$('#categoryEditForm #imageUpload').before('<div class="img" data-url="' + item + '" style="background-image:url(' + item + ');">');
}
});
}
});
... ...
... ... @@ -127,17 +127,16 @@
if(1== rowData.level||2==rowData.level) {
str += "<a role='edit' dataId='" + rowData.id + "' dataParentId='"+rowData.parentId+"' style='margin-left:10px;background-color: #5bc0de'>编辑</a>"
str += "<a role='edit' dataId='" + rowData.id + "' dataParentId='"+rowData.parentId+"' style='margin-left:10px;background-color: #5bc0de'>编辑</a>";
}else{
str += "<a role='addOrEditThirdLevel' dataId='" + rowData.id + "' dataParentId='"+rowData.parentId+"' style='margin-left:10px;background-color: #5bc0de'>编辑</a>"
str += "<a role='editThirdLevel' dataId='" + rowData.id + "' dataParentId='"+rowData.parentId+"' style='margin-left:10px;background-color: #5bc0de'>编辑</a>"
}
if(1== rowData.level||2==rowData.level) {
str = "<a role='edit' dataId='" + rowData.id + "' dataParentId='"+rowData.parentId+"' style='margin-left:10px;background-color: #5bc0de'>编辑</a>";
if(1==rowData.level){
str += "<a role='addSecondLevel' dataId='" + rowData.id + "' style='margin-left:10px;background-color: #5bc0de;color:white;'>添加子类</a>";
}else {
str += "<a role='addOrEditThirdLevel' dataId='" + rowData.id + "' style='margin-left:10px;background-color: #5bc0de;color:white;'>添加子类</a>";
str += "<a role='addThirdLevel' dataId='" + rowData.id + "' style='margin-left:10px;background-color: #5bc0de;color:white;'>添加子类</a>";
}
}
... ... @@ -169,7 +168,7 @@
}
});
$(this).myDatagrid("getPanel").find("a[role='addOrEditThirdLevel']").linkbutton({
$(this).myDatagrid("getPanel").find("a[role='addThirdLevel']").linkbutton({
iconCls: "icon-edit",
onClick: function () {
//添加子类,当前类的id作为pid
... ... @@ -178,6 +177,16 @@
}
});
$(this).myDatagrid("getPanel").find("a[role='editThirdLevel']").linkbutton({
iconCls: "icon-edit",
onClick: function () {
//添加子类,当前类的id作为pid
var id = $(this).attr("dataId");
var pid = $(this).attr("dataParentId");
editRowThird(id,pid);
}
});
$(this).myDatagrid("getPanel").find("a[role='addSecondLevel']").linkbutton({
iconCls: "icon-edit",
onClick: function () {
... ... @@ -311,6 +320,17 @@
if (!$("#categoryEditForm").form("validate")) {
return false;
}
var imageUrlList = [];
$('.goods-image .img').each(function(index, item) {
imageUrlList.push($(item).data('url'));
});
if(imageUrlList.length!=1){
$.messager.alert('操作提示', '必须要上传1张图片,而且只允许有1张!',"warning");
return false;
}
$("#categoryEditForm #imageUrl").val(imageUrlList[0]);
$.messager.progress({
title: "正在执行",
msg: "正在执行,请稍后..."
... ...