Authored by qinchao

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

... ... @@ -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;
... ...
<!DOCTYPE html>
<style>
.sale-category-detail-page .goods-image {
display: flex;
}
.sale-category-detail-page .goods-image .img {
width: 104px;
height: 104px;
margin-right: 10px;
background-size: cover;
background-repeat: no-repeat;
background-position: center;
position: relative;
}
.sale-category-detail-page .goods-image .img:hover:before {
content: "删除";
width: 100%;
display: block;
position: absolute;
top: 0;
background: #000;
opacity: 0.5;
color: #fff;
text-align: center;
line-height: 104px;
}
</style>
<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">
<td width="20%"><span style="color:red">*</span><label>名称</label></td>
<td>
<div style="width:200px;">
<input class="easyui-textbox" id="categoryName" name="categoryName" data-options="validType:'length[1,30]'" />
</div>
</td>
</tr>
<tr style="height: 60px">
<td width="20%"><span style="color:red">*</span><label>排序值</label></td>
<td>
<input class="easyui-numberbox" id="orderBy" name="orderBy" data-options="validType:'length[1,10]'" />
</td>
</tr>
</table>
</div>
<div class="goods-image" style="margin-top: 5px;margin-left: 30px">
<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">
<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>
<div style="width:200px;">
<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,500]'" style="width:500px;" required="true"/>
</td>
</tr>
</table>
</div>
</form>
</div>
<script>
$(function () {
this.dom = {
imageUpload: $('#categoryEditForm #imageUpload')
};
$("#categoryEditForm #categoryName").textbox({
required: true,
missingMessage: "销售类目名称不能为空",
prompt: "请输入",
width: "200px"
});
$("#categoryEditForm #orderBy").numberbox({
required: true,
precision:0,
min:1,
missingMessage: "排序值不能为空",
prompt: "请输入",
width:"200px"
});
this.dom.imageUpload.imageUpload({
width: 104,
height: 104,
realInputName: "imageUrl",
url: contextPath + '/fileupload/upload',
queryParams: {
bucket: "salecategoryimg"
},
onBeforeSubmit: function () {
$.messager.progress({
title: "正在执行",
msg: "正在执行,请稍后...",
interval: 500,
text: ""
});
},
filterFileName: function (data) {
if (!data || data.code != 200) {
$.messager.progress("close");
$.messager.alert("错误", data.message);
return "";
}
return data.data.url;
},
onLoadSuccess: function (data) {
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);
if (saleCategoryId > 0) {
$.post(contextPath + "/saleCategory/getSaleCategoryById", {
id: saleCategoryId
}, 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 + ');">');
}
});
}
});
</script>
\ No newline at end of file
... ...
... ... @@ -23,6 +23,16 @@
.div_search .easyui-linkbutton {
margin-top: 20px;
}
.sale-category-detail-page .img222 {
width: 104px;
height: 104px;
margin-right: 10px;
background-size: cover;
background-repeat: no-repeat;
background-position: center;
position: relative;
}
</style>
<div style="margin-left: 30px;" class="div_search">
<a id="addSaleCategory" class="easyui-linkbutton btn-success">添加一级销售类目</a>
... ... @@ -117,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>";
}
}
... ... @@ -159,12 +168,22 @@
}
});
$(this).myDatagrid("getPanel").find("a[role='addOrEditThirdLevel']").linkbutton({
$(this).myDatagrid("getPanel").find("a[role='addThirdLevel']").linkbutton({
iconCls: "icon-edit",
onClick: function () {
//添加子类,当前类的id作为pid
var id = $(this).attr("dataId");
editRowThird(0,id);
}
});
$(this).myDatagrid("getPanel").find("a[role='editThirdLevel']").linkbutton({
iconCls: "icon-edit",
onClick: function () {
//添加子类,当前类的id作为pid
var id = $(this).attr("dataId");
alert("开发中"+id);
var pid = $(this).attr("dataParentId");
editRowThird(id,pid);
}
});
... ... @@ -201,10 +220,10 @@
saleCategoryId = id;
saleCategoryParentId = pid;
var div = $("<div>").appendTo($(document.body));
var title = "编辑品类";
var title = "编辑销售类目";
var message = "确认修改销售类目信息吗?";
if (id == 0) {
title = "添加品类";
title = "添加销售类目";
message = "确认添加销售类目信息吗?";
}
$(div).myDialog({
... ... @@ -266,6 +285,87 @@
});
}
function editRowThird(id,pid) {
saleCategoryId = id;
saleCategoryParentId = pid;
var div = $("<div>").appendTo($(document.body));
var title = "编辑销售类目";
var message = "确认修改销售类目信息吗?";
if (id == 0) {
title = "添加销售类目";
message = "确认添加销售类目信息吗?";
}
$(div).myDialog({
width: "850px",
height: "500px",
title: title,
href: contextPath + "/html/saleCategory/addOrEditThirdLevel.html",
queryParams: {
saleCategoryParentId:saleCategoryParentId,
id: id
},
modal: true,
collapsible: true,
cache: false,
buttons: [{
id: "saveBtn",
text: "保存",
handler: function () {
$.messager.confirm("确认", message, function (flag) {
if(flag) {
$("#categoryEditForm").form("submit", {
url: contextPath + "/saleCategory/saveOrUpdateSaleCategory",
onSubmit: function () {
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: "正在执行,请稍后..."
});
return true;
},
success: function (data) {
$.messager.progress("close");
data = JSON.parse(data);
if (data.code == 200) {
$(div).dialog("close");
$("#saleCategoryTable").treegrid("reload");
$.messager.show({
title: "提示",
msg: title + "成功!",
height: 120
});
} else {
$.messager.alert("失败", data.message, "error");
}
}
});
}
});
}
}, {
text: "关闭",
iconCls: "icon-cancel",
handler: function () {
$(div).dialog("close");
}
}]
});
}
function updateBrandStatus(id, status, parentId) {
var message = "";
var msg = "";
... ...