Authored by Lixiaodi

商品创建、编辑页面

... ... @@ -60,6 +60,7 @@ public interface BrandMapper {
* @return
*/
List<Brand> getAllBrand();
List<Brand> getAllValidBrand();
List<Brand> selectBrandByIdList(@Param("list") List<Integer> brandIdList);
}
... ...
... ... @@ -94,6 +94,10 @@
select id, brand_name
from brand
</select>
<select id="getAllValidBrand" resultMap="brandMap">
select id, brand_name
from brand where status = 1
</select>
<select id="selectBrandByIdList" resultMap="brandMap">
select id, brand_name
from brand where id in
... ...
... ... @@ -62,4 +62,10 @@ public class BrandController {
public ApiResponse<List<JSONObject>> getBrandName() {
return new ApiResponse<>(brandService.getBrandIdAndName());
}
@RequestMapping(value = "/getBrandSelector", method = RequestMethod.GET)
public ApiResponse<List<JSONObject>> getBrandSelector() {
return new ApiResponse<>(brandService.getValidBrandIdAndName());
}
}
... ...
... ... @@ -46,4 +46,6 @@ public interface IBrandService {
* @return
*/
List<JSONObject> getBrandIdAndName();
List<JSONObject> getValidBrandIdAndName();
}
... ...
... ... @@ -107,4 +107,19 @@ public class BrandServiceImpl implements IBrandService {
}
return result;
}
@Override
public List<JSONObject> getValidBrandIdAndName() {
// TODO 可以添加缓存
List<Brand> brands = brandMapper.getAllValidBrand();
List<JSONObject> result = new ArrayList<>();
JSONObject jsonObject;
for (Brand brand : brands) {
jsonObject = new JSONObject();
jsonObject.put("id", brand.getId());
jsonObject.put("text", brand.getBrandName());
result.add(jsonObject);
}
return result;
}
}
... ...
<!DOCTYPE html>
<div id="tt" class="easyui-layout" fit="true" style="overflow-y: scroll">
<input id="editBrandId" type="text">
<input id="editSeriesId" type="text">
<input id="editProductName" type="text"/>
<input id="editSaleTime" type="text"/>
<input id="editGender" type="text"/>
<input id="editMaxSortId" type="text"/>
<input id="editMidSortId" type="text"/>
<input id="editProductCode" type="text"/>
<input id="editMinPrice" type="text"/>
<input id="editMaxPrice" type="text"/>
<input id="editColorId" type="text"/>
<input id="editColorName" type="text"/>
<input id="editGoodsName" type="text"/>
<input id="editSizeIdList" type="text"/>
<input id="editImageUrlList" type="text"/>
<input id="editKeyWords" type="text"/>
<input id="editGoodsId" type="hidden"/>
<input id="editId" type="hidden"/>
</div>
<script>
/* 新增,修改公用页面
editImage代表图片是否修改过,新增固定传1。修改的时候根据是否修改,修改传1,无修改传0
1.新增,所有参数之前为空值,
提交地址:product/addOrUpdate
提交参数:{"brandId":78,"colorId":1,"colorName":"红色","editImage":1,"gender":3,"goodsName":"自定义红色","imageUrlList":["https://img10.static.yhbimg.com/goodsimg/2018/08/25/16/01e99496407347514356e5fe327d1f661d.jpg","https://img12.static.yhbimg.com/goodsimg/2018/08/25/16/0292fcebd071444401e6de340bcf2d8c19.jpg"],"keyWords":"球鞋,adidas","maxPrice":"899","maxSortId":10,"midSortId":18,"minPrice":"599","productCode":"009-009-009","productName":"测试商品009","saleTime":"2018-11-11","seriesId":8,"sizeIdList":[28,29]}
2.修改:首先根据传进来的id,获取商品信息把页面控件填写好。hidden记录id、goodsId、等参数
提交参数:{"brandId":78,"colorId":2,"colorName":"蓝色","editImage":1,"gender":3,"goodsId":6,"goodsName":"自定义蓝色","id":10000004,"imageUrlList":["https://img10.static.yhbimg.com/goodsimg/2018/08/25/16/01e99496407347514356e5fe327d1f661d.jpg","https://img12.static.yhbimg.com/goodsimg/2018/08/25/16/0292fcebd071444401e6de340bcf2d8c19.jpg"],"keyWords":"球鞋,adidas2","maxPrice":"898","maxSortId":10,"midSortId":18,"minPrice":"598","productCode":"009-009-009-e","productName":"测试商品009-e","saleTime":"2018-11-12","seriesId":8}
不可修改:品牌、分类、颜色、尺码、SKU(颜色展示名称除外:goodsName)
*/
$(function () {
$("#editBrandId").myCombobox({
url: contextPath + '/brand/getBrandName',
method: "get",
editable: false,
prompt: "选择品牌",
width: 200,
valueField: "id",
textField: "text",
loadFilter: function (data) {
return defaultLoadFilter(data);
}
});
$("#editSeriesId").myCombobox({
url: contextPath + '/brandSeries/querySeriesByBrandId?brandId=',
method: "get",
editable: false,
prompt: "选择品牌",
width: 200,
valueField: "id",
textField: "text",
loadFilter: function (data) {
return defaultLoadFilter(data);
}
});
$("#editProductName").textbox({
required: true,
missingMessage: "商品名称不能为空",
prompt: "商品名称"
//width: 240
});
$("#editSaleTime").myDatebox({
prompt : "发售时间"
});
$("#editGender").textbox({
prompt : "性别"
});
$('#editMaxSortId').myCombobox({
url: contextPath + "/productSort/getLevel1SortIdAndName",
method: "get",
editable: false,
valueField: 'id',
textField: 'text',
prompt:"一级分类",
loadFilter: function (data) {
return defaultLoadFilter(data);
},
onSelect: function (rec) {
if (0 === rec.id) {
try {
$('#midSortId').combobox('disable');
} catch (e) { }
return;
}
try {
$('#editMidSortId').combobox('clear');
$('#editMidSortId').combobox('reload', contextPath + "/productSort/getLevel2SortBySortId?sortId=" + rec.id);
$('#editMidSortId').combobox('enable');
} catch (e) { }
}
});
$('#editMidSortId').myCombobox({
method: "get",
editable: false,
valueField: 'id',
textField: 'text',
multiple: true,
prompt:"二级分类",
loadFilter: function (data) {
data = defaultLoadFilter(data);
/* for (var i = 0; i < data.length; i ++) {
$('#editMidSortId').combobox('select', data[i].id);
} */
return data;
}
});
$("#editProductCode").textbox({
prompt : "请输入"
});
$("#editMinPrice").textbox({
prompt : "最低价"
});
$("#editMaxPrice").textbox({
prompt : "最高价"
});
//<input id="editColorId" type="text"/>
//<input id="editSizeIdList" type="text"/>
//<input id="editImageUrlList" type="text"/>
//<input id="editKeyWords" type="text"/>
$("#editKeyWords").textbox({
prompt : "请输入"
});
//<input id="goodsId" type="hidden"/>
// 编辑的情况需要根据id查询商品信息
$.ajax({
contentType: "application/json",
dataType: "json",
type: "GET",
url: contextPath + '/product/find?id=10000004',
success: function (data) {
if (data.code != 200) {
return;
}
// 设置页面上面所有属性值和hidden属性
}
});
});
</script>
\ No newline at end of file
... ...
... ... @@ -41,7 +41,7 @@
$("#productName").textbox({
prompt: "商品名称"
});
var sortComboboxUrl = contextPath + "/product/queryPSListByParentIdWhenStatusGet?param=";
var sortComboboxUrl = contextPath + "/productSort/getLevel1SortIdAndName?";
$('#maxSortId').myCombobox({
url: sortComboboxUrl + "0",
method: "get",
... ... @@ -55,13 +55,13 @@
onSelect: function (rec) {
if (0 === rec.id) {
try {
mdSortCombobox.combobox('disable');
$('#midSortId').combobox('disable');
} catch (e) { }
return;
}
try {
$('#midSortId').combobox('clear');
$('#midSortId').combobox('reload', sortComboboxUrl + rec.id);
$('#midSortId').combobox('reload', contextPath + "/productSort/getLevel2SortBySortId?sortId=" + rec.id);
$('#midSortId').combobox('enable');
} catch (e) { }
}
... ... @@ -75,9 +75,9 @@
prompt:"二级分类",
loadFilter: function (data) {
data = defaultLoadFilter(data);
for (var i = 0; i < data.length; i ++) {
/* for (var i = 0; i < data.length; i ++) {
$('#midSortId').combobox('select', data[i].id);
}
} */
return data;
}
});
... ... @@ -145,7 +145,13 @@
title: "商品状态",
field: "shelveStatus",
width: 170,
align: "center"
align: "center",
formatter: function (value) {
if(value == "0" ) return "待上架";
if(value == "1" ) return "已上架";
if(value == "2" ) return "已下架";
return "";
}
}, {
title: "操作",
field: "operations",
... ...