Authored by 王水玲

商品创建

... ... @@ -39,9 +39,29 @@
color: red;
}
.product-detail-page .group-color {
.product-detail-page .group-color, .product-detail-page .group-size {
display: flex;
align-items: center;
margin-bottom: 10px;
}
.product-detail-page .group-color li {
margin-right: 5px;
float: left;
line-height: 30px;
margin-left: 5px;
padding: 0 5px;
}
.product-detail-page .group-color .actived {
background: #8fa9bb;
color: #fff;
border-radius: 5px;
}
.product-detail-page .group-size .size {
float:left;
margin-left: 10px;
}
</style>
</head>
... ... @@ -82,7 +102,7 @@
</li>
<li>
<div class="label">商品价格限制 <span class="red">*</span></div>
<div class="base-info-item"><input id="editMinPrice" type="text"/><input id="editMaxPrice" type="text"/></div>
<div class="base-info-item"><input id="editMinPrice" type="text"/><span style="margin-right: 20px;c"></span><input id="editMaxPrice" type="text"/></div>
</li>
</ul>
</li>
... ... @@ -91,7 +111,7 @@
<h2>颜色尺码</h2>
<div class="group-color">
<div class="label">*颜色</div>
<ul style="float:left;">
<ul style="float:left; margin-left: 10px;">
</ul>
</div>
<div class="group-size">
... ... @@ -131,8 +151,8 @@
*/
var productDetail = {
initForm: function(detail) {
console.log(detail)
initData: function(detail) {
$("#editSeriesId").myCombobox({
url: contextPath + '/brandSeries/querySeriesByBrandId?brandId=' + detail.brandId,
method: "get",
... ... @@ -154,23 +174,13 @@
$('#editMaxPrice').textbox('setValue', detail.maxPrice);
$('#editProductCode').textbox('setValue', detail.productCode);
$("#editMaxSortId").combobox('select', detail.maxSortId);
$("#editMinSortId").combobox('select', detail.minSortId);
$("#editMinSortId").combobox({
onLoadSuccess: function() {
console.log(122)
}
});
$("#editMidSortId").combobox('select', detail.midSortId);
$("#editSeriesId").combobox('select', detail.seriesId)
this.getSizeInfo(detail.minSortId);
this.getSizeInfo(detail.midSortId);
},
init: function() {
var that = this;
var productId = this.getUrlParam('id');
var ajaxList = [];
$("#editProductName").textbox({
initForm: function() {
$("#editProductName").textbox({
required: true,
missingMessage: "商品名称不能为空",
prompt: "商品名称",
... ... @@ -210,6 +220,38 @@
prompt : "发售时间"
});
$('#editMidSortId').myCombobox({
method: 'get',
editable: false,
valueField: 'id',
textField: 'text',
multiple: true,
prompt:"二级分类",
loadFilter: function(data) {
console.log(data)
return defaultLoadFilter(data);
}
});
$("#editProductCode").textbox({
prompt : "请输入"
});
$("#editMinPrice").textbox({
prompt : "最低价"
});
$("#editMaxPrice").textbox({
prompt : "最高价"
});
$("#editKeyWords").textbox({
prompt : "请输入"
});
},
init: function() {
var that = this;
var productId = this.getUrlParam('id');
var ajaxList = [];
var colorSizeSelected = {}
this.initForm();
this.getColorInfo();
$.when(this.getBrandList(), this.getMaxSortList()).then(function(brand, maxSort) {
... ... @@ -231,7 +273,6 @@
}
if (productId) {
console.log(2)
that.getDetailInfo(productId);
} else {
this.getSizeInfo();
... ... @@ -240,6 +281,10 @@
this.changeColorOrSize();
$(document).on('click', '.group-color li', function() {
$(this).siblings().removeClass('actived');
$(this).addClass('actived');
});
},
changeColorOrSize: function() {
$("#colorSizeTable").myDatagrid({
... ... @@ -272,8 +317,6 @@
}]],
cache: false,
pagination: false,
pageSize: 10,
pageList: [10],
idField: "id",
singleSelect: false,
checkOnSelect: false,
... ... @@ -320,7 +363,7 @@
// 编辑的情况需要根据id查询商品信息
$.get(contextPath + '/product/find?id=' + productId).then(function(ret) {
if (ret && ret.code == 200) {
that.initForm(ret.data);
that.initData(ret.data);
}
});
... ... @@ -345,9 +388,10 @@
type : 'GET',
url: contextPath + '/size/queryAllSize4Goods?sortId=' + sortId,
success: function (ret) {
if (ret.code == 200) {
console.log(ret)
/* $('.group-size .size').append('') */
if (ret && ret.code == 200) {
$.each(ret.data || [], function(index, item) {
$('.group-size .size').append('<label for="size" style="margin-right: 5px;"><input type="checkbox" name="size">'+item.text+'</label>');
});
}
}
});
... ... @@ -361,11 +405,11 @@
url: contextPath + '/productColor/getAllColor',
success: function (ret) {
if (ret && ret.code == 200) {
$.each(ret.data|| [], function(index, item) {
var color = item.colorValue ? 'background: url('+item.colorValue+')' : 'background:' + item.colorCode;
$.each(ret.data || [], function(index, item) {
var color = item.colorValue ? 'background: url('+item.colorValue+')' : 'background:#' + item.colorCode;
$('.group-color ul').append('<li style="vertical-align: middle;margin-right: 5px;float:left; margin-left: 5px;"><i style=" width: 30px; height: 30px;display: inline-block;border-radius: 50%;' + color + '"></i>' + item.colorName + '</li>')
})
$('.group-color ul').append('<li data-color="' + color + '"><i style="float: left;width: 30px; height: 30px;border-radius: 50%; margin-right: 3px;' + color + ';background-size: contain;"></i>' + item.colorName + '</li>')
});
}
}
})
... ... @@ -374,37 +418,6 @@
$(function () {
productDetail.init();
$('#editMidSortId').myCombobox({
editable: false,
valueField: 'id',
textField: 'text',
multiple: true,
prompt:"二级分类"
});
$("#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"/>
});
</script>
... ...