|
|
<!DOCTYPE html>
|
|
|
<html>
|
|
|
<head>
|
|
|
<meta charset="UTF-8"/>
|
|
|
<title>Yoho!Buy运营平台</title>
|
|
|
<script src="/ufoPlatform/js/include.js"></script>
|
|
|
<script src="/ufoPlatform/js/ajaxfileupload.js"></script>
|
|
|
</head>
|
|
|
<body class="easyui-layout" fit="true">
|
|
|
<div region="north" style="height: 230px">
|
|
|
<script>
|
|
|
document.write(addHead('商品管理 /基础商品', ''));
|
|
|
</script>
|
|
|
<div style="margin-left: 30px;" class="div_search">
|
|
|
<a id="addProduct" class="easyui-linkbutton btn-success">+创建商品</a>
|
|
|
</div>
|
|
|
<div style="margin-left: 30px;" class="div_search">
|
|
|
<input id="productId" type="text">
|
|
|
<input id="productName" type="text"/>
|
|
|
<input id="maxSortId" type="text"/>
|
|
|
<input id="midSortId" type="text"/>
|
|
|
<input id="brandId" type="text"/>
|
|
|
<input id="shelveStatus" type="text"/>
|
|
|
|
|
|
<a id="searchLinkButton" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-search'">筛选</a>
|
|
|
<a id="searchAllLinkButton" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-search'">全部</a>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div region="center">
|
|
|
<div style="margin-left: 30px;margin-top: 20px;height: 660px">
|
|
|
<table id="productTable"></table>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
var brandSeriesId;
|
|
|
$(function () {
|
|
|
$("#productId").textbox({
|
|
|
prompt: "商品编码"
|
|
|
});
|
|
|
$("#productName").textbox({
|
|
|
prompt: "商品名称"
|
|
|
});
|
|
|
var sortComboboxUrl = contextPath + "/product/queryPSListByParentIdWhenStatusGet?param=";
|
|
|
$('#maxSortId').myCombobox({
|
|
|
url: sortComboboxUrl + "0",
|
|
|
method: "get",
|
|
|
editable: false,
|
|
|
valueField: 'id',
|
|
|
textField: 'text',
|
|
|
prompt:"一级分类",
|
|
|
loadFilter: function (data) {
|
|
|
return defaultLoadFilter(data);
|
|
|
},
|
|
|
onSelect: function (rec) {
|
|
|
if (0 === rec.id) {
|
|
|
try {
|
|
|
mdSortCombobox.combobox('disable');
|
|
|
} catch (e) { }
|
|
|
return;
|
|
|
}
|
|
|
try {
|
|
|
$('#midSortId').combobox('clear');
|
|
|
$('#midSortId').combobox('reload', sortComboboxUrl + rec.id);
|
|
|
$('#midSortId').combobox('enable');
|
|
|
} catch (e) { }
|
|
|
}
|
|
|
});
|
|
|
$('#midSortId').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 ++) {
|
|
|
$('#midSortId').combobox('select', data[i].id);
|
|
|
}
|
|
|
return data;
|
|
|
}
|
|
|
});
|
|
|
$('#midSortId').combobox('disable');
|
|
|
$("#brandId").myCombobox({
|
|
|
url: contextPath + '/brand/getBrandName',
|
|
|
method: "get",
|
|
|
editable: false,
|
|
|
prompt: "选择品牌",
|
|
|
width: 200,
|
|
|
valueField: "id",
|
|
|
textField: "text",
|
|
|
loadFilter: function (data) {
|
|
|
return defaultLoadFilter(data);
|
|
|
}
|
|
|
});
|
|
|
$("#shelveStatus").combobox({
|
|
|
prompt: "商品状态",
|
|
|
width: 150,
|
|
|
editable : false,
|
|
|
data: [
|
|
|
{"text" : "商品状态", "value" : "-1", "selected": true},
|
|
|
{"text" : "待上架", "value" : 0},
|
|
|
{"text" : "已上架", "value" : 1},
|
|
|
{"text" : "已下架", "value" : 2}
|
|
|
]
|
|
|
});
|
|
|
$("#productTable").myDatagrid({
|
|
|
fit: true,
|
|
|
fitColumns: true,
|
|
|
nowrap: false,
|
|
|
url: contextPath + "/product/list",
|
|
|
method: 'POST',
|
|
|
loadFilter: function (data) {
|
|
|
var temp = defaultLoadFilter(data);
|
|
|
temp.rows = temp.list;
|
|
|
return temp;
|
|
|
},
|
|
|
columns: [[{
|
|
|
title: "商品编码",
|
|
|
field: "id",
|
|
|
width: 40,
|
|
|
align: "center"
|
|
|
}, {
|
|
|
title: "商品图片",
|
|
|
field: "colorImage",
|
|
|
width: 80,
|
|
|
align: "center"
|
|
|
}, {
|
|
|
title: "商品名称",
|
|
|
field: "productName",
|
|
|
width: 100,
|
|
|
align: "center"
|
|
|
}, {
|
|
|
title: "分类",
|
|
|
field: "sortName",
|
|
|
width: 80,
|
|
|
align: "center"
|
|
|
}, {
|
|
|
title: "品牌",
|
|
|
field: "brandName",
|
|
|
width: 80,
|
|
|
align: "center",
|
|
|
}, {
|
|
|
title: "商品状态",
|
|
|
field: "shelveStatus",
|
|
|
width: 170,
|
|
|
align: "center"
|
|
|
}, {
|
|
|
title: "操作",
|
|
|
field: "operations",
|
|
|
width: 80,
|
|
|
align: "center",
|
|
|
formatter: function (value, rowData) {
|
|
|
var str = "<a role='edit' dataId='" + rowData.id + "' style='margin-left:10px;background-color: #5bc0de'>编辑</a>";
|
|
|
if (1 == rowData.status) {
|
|
|
str += "<a role='closeBrandSeries' dataId='" + rowData.id + "' style='margin-left:10px;background-color: red'>关闭</a>";
|
|
|
} else {
|
|
|
str += "<a role='openBrandSeries' dataId='" + rowData.id + "' style='margin-left:10px;background-color: orange'>开启</a>";
|
|
|
}
|
|
|
return str;
|
|
|
}
|
|
|
}]],
|
|
|
cache: false,
|
|
|
pagination: true,
|
|
|
pageSize: 10,
|
|
|
pageList: [10],
|
|
|
idField: "id",
|
|
|
singleSelect: false,
|
|
|
checkOnSelect: false,
|
|
|
onLoadSuccess: function () {
|
|
|
// 编辑
|
|
|
$(this).myDatagrid("getPanel").find("a[role='edit']").linkbutton({
|
|
|
iconCls: "icon-edit",
|
|
|
onClick: function () {
|
|
|
var id = $(this).attr("dataId");
|
|
|
editRow(id);
|
|
|
}
|
|
|
});
|
|
|
// 关闭品牌
|
|
|
$(this).myDatagrid("getPanel").find("a[role='closeBrandSeries']").linkbutton({
|
|
|
iconCls: "icon-more",
|
|
|
onClick: function () {
|
|
|
updateBrandSeriesStatus($(this).attr("dataId"), 2);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 开启品牌
|
|
|
$(this).myDatagrid("getPanel").find("a[role='openBrandSeries']").linkbutton({
|
|
|
iconCls: "icon-more",
|
|
|
onClick: function () {
|
|
|
updateBrandSeriesStatus($(this).attr("dataId"), 1);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
// 搜索
|
|
|
$("#searchLinkButton").linkbutton({
|
|
|
onClick: function () {
|
|
|
var param = {};
|
|
|
param.id = $('#productId').textbox('getValue');
|
|
|
param.productName = $('#productName').textbox('getText');
|
|
|
param.maxSortId = $('#maxSortId').combobox('getValue');
|
|
|
param.midSortId = $('#midSortId').combobox('getValue');
|
|
|
param.brandId = $('#brandId').combobox('getValue');
|
|
|
param.shelveStatus = $('#shelveStatus').combobox('getValue');
|
|
|
$("#productTable").myDatagrid("load", param);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 搜索全部
|
|
|
$("#searchAllLinkButton").linkbutton({
|
|
|
onClick: function () {
|
|
|
var param = {};
|
|
|
$("#productTable").myDatagrid("load", param);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
function editRow(id) {
|
|
|
brandSeriesId = id;
|
|
|
var div = $("<div>").appendTo($(document.body));
|
|
|
var title = "编辑品牌系列";
|
|
|
var message = "确认修改品牌系列信息吗?";
|
|
|
if (id == 0) {
|
|
|
title = "添加品牌系列";
|
|
|
message = "确认添加品牌系列信息吗?";
|
|
|
}
|
|
|
$(div).myDialog({
|
|
|
width: "600px",
|
|
|
height: "380px",
|
|
|
title: title,
|
|
|
href: contextPath + "/html/brandManage/brandSeries/editBrandSeries.html",
|
|
|
queryParams: {
|
|
|
id: id
|
|
|
},
|
|
|
modal: true,
|
|
|
collapsible: true,
|
|
|
cache: false,
|
|
|
buttons: [{
|
|
|
id: "saveBtn",
|
|
|
text: "保存",
|
|
|
handler: function () {
|
|
|
$.messager.confirm("确认", message, function (flag) {
|
|
|
if (flag) {
|
|
|
var sortId = $('#brandSeriesEditForm #brandId').combobox("getValue");
|
|
|
if (sortId == '' || sortId == null || sortId == undefined) {
|
|
|
$.messager.alert("提示", '请选择品牌!', "error");
|
|
|
return false;
|
|
|
}
|
|
|
var url = contextPath + "/brandSeries/saveOrUpdateBrandSeries";
|
|
|
$("#brandSeriesEditForm").form("submit", {
|
|
|
url: url,
|
|
|
onSubmit: function () {
|
|
|
if (!$("#brandSeriesEditForm").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");
|
|
|
$("#productTable").myDatagrid("reload");
|
|
|
$.messager.show({
|
|
|
title: "提示",
|
|
|
msg: title + "成功!",
|
|
|
height: 120
|
|
|
});
|
|
|
} else {
|
|
|
$.messager.alert("失败", data.message, "error");
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}, {
|
|
|
text: "关闭",
|
|
|
iconCls: "icon-cancel",
|
|
|
handler: function () {
|
|
|
$(div).dialog("close");
|
|
|
}
|
|
|
}]
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function updateBrandSeriesStatus(id, status) {
|
|
|
var message = "";
|
|
|
var msg = "";
|
|
|
if (status == 1) {
|
|
|
message = "确认要开启吗?";
|
|
|
msg = "开启成功!";
|
|
|
} else {
|
|
|
message = "确认要关闭吗?";
|
|
|
msg = "关闭成功!";
|
|
|
}
|
|
|
window.top.$.messager.confirm("确认", message, function (flag) {
|
|
|
if (flag) {
|
|
|
window.top.$.messager.progress({
|
|
|
title: "正在执行",
|
|
|
msg: "正在执行,请稍后...",
|
|
|
interval: 500,
|
|
|
text: ""
|
|
|
});
|
|
|
$.post(contextPath + "/brandSeries/updateBrandSeriesStatus", {
|
|
|
"id": id,
|
|
|
"status": status
|
|
|
}, function (data) {
|
|
|
window.top.$.messager.progress("close");
|
|
|
if (data.code == 200) {
|
|
|
$("#productTable").myDatagrid("reload");
|
|
|
window.top.$.messager.show({
|
|
|
title: "提示",
|
|
|
msg: msg,
|
|
|
height: 120
|
|
|
});
|
|
|
} else {
|
|
|
window.top.$.messager.alert("失败", data.message, "error");
|
|
|
}
|
|
|
}, "json");
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
</script>
|
|
|
|
|
|
</body>
|
|
|
</html> |
|
|
\ No newline at end of file |
...
|
...
|
|