Authored by qinchao

add 销售类目功能

<!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" fit="true" 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"/>
<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">
<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>
<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;">
<input class="easyui-textbox" name="linkType" 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-textbox" name="linkDetail" data-options="validType:'length[1,10]'" />
</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();
$('#categoryEditForm #imageUpload').before('<div class="img" data-url="' + data.data + '" style="background-image:url(' + data.data + ');">');
return false;
}
});
$("#categoryEditForm #parentId").val(saleCategoryParentId);
if (saleCategoryId > 0) {
$.post(contextPath + "/saleCategory/getSaleCategoryById", {
id: saleCategoryId
}, function (data) {
$("#categoryEditForm").form("load", data.data);
});
}
});
</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>
... ... @@ -164,7 +174,7 @@
onClick: function () {
//添加子类,当前类的id作为pid
var id = $(this).attr("dataId");
alert("开发中"+id);
editRowThird(0,id);
}
});
... ... @@ -201,10 +211,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 +276,76 @@
});
}
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;
}
$.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 = "";
... ...