/**
|
* 商品信息管理初始化
|
*/
|
var MallGoods = {
|
id: "MallGoodsTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
|
/**
|
* 初始化表格的列
|
*/
|
MallGoods.initColumn = function () {
|
return [
|
{field: 'selectItem', checkbox: true},
|
{title: '创建时间', field: 'createTime', visible: true, align: 'center', valign: 'middle'},
|
{title: '商品编号', field: 'goodsNo', visible: true, align: 'center', valign: 'middle', formatter: function (value) { return value; }},
|
{title: '商品分类', field: 'classifyName', visible: true, align: 'center', valign: 'middle'},
|
{title: '商品名称', field: 'goodsName', visible: true, align: 'center', valign: 'middle'},
|
{title: '商品副标题', field: 'goodsTitle', visible: true, align: 'center', valign: 'middle'},
|
{title: '商品图', field: 'goodsImage', visible: true, align: 'center', valign: 'middle', formatter: Feng.getImageDom},
|
{title: '商品标签', field: 'tagIds', visible: true, align: 'center', valign: 'middle'},
|
{title: '销售量', field: 'buyCount', visible: true, align: 'center', valign: 'middle'},
|
{title: '商品库存', field: 'stock', visible: true, align: 'center', valign: 'middle'},
|
{title: '美天销售价', field: 'priceSale', visible: true, align: 'center', valign: 'middle'},
|
{title: '商品状态', field: 'state', visible: true, align: 'center', valign: 'middle', formatter: function (value, row) {
|
return Feng.getOptionFormatter( "#state")(value) + (value == 5 ? ("("+ (row['auditRemark']||"") +")"):"");
|
}},
|
{title: '操作', field: 'opts', visible: true, align: 'left', valign: 'middle',
|
formatter: function (value, row) {
|
var opts = Feng.Opts();
|
if ($("#updateAuth").val() == 'true') {
|
opts.add("MallGoods.openMallGoodsUpdate('"+row.id+"');", "编辑");
|
}
|
if ($("#detailAuth").val() == 'true') {
|
opts.add("MallGoods.openMallGoodsDetail('"+row.id+"');", "查看详情");
|
}
|
if ($("#updateStateAuth").val() == 'true' && [1,4].indexOf( row.state) != -1) {
|
if (row.state == 1) {
|
opts.addDanger("MallGoods.updateState('"+row.id+"','4');", "下架");
|
}
|
if (row.state == 4) {
|
opts.add("MallGoods.updateState('"+row.id+"','1');", "上架");
|
}
|
}
|
if ($("#deleteAuth").val() == 'true') {
|
opts.addDanger("MallGoods.delete('"+row.id+"');", "删除");
|
}
|
return opts.getOpts();
|
}
|
}
|
];
|
};
|
|
/**
|
* 检查是否选中
|
*/
|
MallGoods.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length == 0){
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
}else{
|
MallGoods.seItem = selected[0];
|
return true;
|
}
|
};
|
|
/**
|
* 点击添加商品信息
|
*/
|
MallGoods.openMallGoodsAdd = function () {
|
var index = layer.open({
|
type: 2,
|
title: '添加套餐商品',
|
area: ['95%', '95%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/mallGoodsGroup/mallGoods_add'
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 点击编辑商品信息
|
*/
|
MallGoods.openMallGoodsUpdate = function (id) {
|
var index = layer.open({
|
type: 2,
|
title: '编辑套餐商品',
|
area: ['95%', '95%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/mallGoodsGroup/mallGoods_update/' + id
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 点击编辑商品销售量
|
*/
|
MallGoods.openMallGoodsUpdateBuyCount = function () {
|
var selected = $("#" + MallGoods.id).bootstrapTable('getSelections');
|
if (selected.length != 1) {
|
Feng.info("请勾选1条商品进行修改!");
|
return;
|
}
|
var id = selected[0]['id'];
|
var index = layer.open({
|
type: 2,
|
title: '编辑销售量',
|
area: ['50%', '50%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/mallGoodsGroup/to_buyCount/' + id
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 打开查看商品信息详情
|
*/
|
MallGoods.openMallGoodsDetail = function (id) {
|
var index = layer.open({
|
type: 2,
|
title: '商品信息详情',
|
area: ['95%', '95%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/mallGoodsGroup/detail/' + id
|
});
|
this.layerIndex = index;
|
};
|
|
MallGoods.openArea = function (id) {
|
var index = layer.open({
|
type: 2,
|
title: '查看区域',
|
area: ['95%', '95%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/mallGoodsGroup/area/' + id
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 打开查看商品信息详情
|
*/
|
MallGoods.openMallAppView = function () {
|
var selected = $("#" + MallGoods.id).bootstrapTable('getSelections');
|
if (selected.length != 1) {
|
Feng.info("请勾选1条商品进行查看!");
|
return;
|
}
|
var id = selected[0]['id'];
|
var index = layer.open({
|
type: 2,
|
title: '商品预览',
|
area: ['375px', '812px'], //宽高
|
fix: true, //不固定
|
maxmin: false,
|
content: Feng.ctxPath + '/mallGoodsGroup/appView/' + id
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 删除/批量删除商品信息
|
*/
|
MallGoods.delete = function(id){
|
var ids = id;
|
if(id == 0) {
|
// 如果id为0,则为批量删除
|
ids = Feng.checkBoxIds(MallGoods.id);
|
}
|
if (ids.length != 0) {
|
var operation = function() {
|
// 加载动画层,0代表加载的风格,支持0-2
|
var index = parent.layer.load(0, {shade: false});
|
var ajax = new $ax(Feng.ctxPath + "/mallGoodsGroup/delete", function (data) {
|
// 关闭加载动画层
|
parent.layer.close(index);
|
Feng.success("删除成功!");
|
MallGoods.table.refresh();
|
}, function (data) {
|
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("ids", ids);
|
ajax.start();
|
};
|
Feng.confirm("是否删除所选中的数据?", operation);
|
}
|
};
|
|
/**
|
* 编辑商品信息状态
|
*/
|
MallGoods.updateState = function (id, state) {
|
var msg = state == 1 ? "上架" : "下架";
|
Feng.confirm( "是否确定".concat( msg).concat("所选中的数据?"), function () {
|
Feng.base_ajax( "/mallGoodsGroup/updateState", { mallGoodsId: id, state: state}, function ( data) {
|
Feng.success( msg + "成功");
|
MallGoods.search();
|
});
|
});
|
};
|
|
/**
|
* 编辑商品信息状态
|
*/
|
MallGoods.updateRecommend = function (id, state) {
|
var msg = state != 1 ? "取消推荐" : "设为推荐";
|
if ( state == 1) {
|
return layer.open({
|
id:1,
|
type: 1,
|
title:'设为推荐',
|
content: "" +
|
"<div class='' style='padding: 20px;'>" +
|
"<div class='form-horizontal' id='modal_form_id'>" +
|
" <div class='form-group'>" +
|
" <label class='col-sm-3 control-label'>" +
|
" <span style='color: red;'>*</span>排序" +
|
" </label>" +
|
" <div class='col-sm-9'>" +
|
" <input type='text' class='form-control' name='sort' id='sort'/>" +
|
" </div>" +
|
" </div>" +
|
"</div>" +
|
"</div>" +
|
"",
|
btn:['保存','取消'],
|
success: function() {
|
Feng.initValidator( "modal_form_id", {
|
sort: Feng.def_valid_num()
|
});
|
},
|
yes:function (index) {
|
if ( !Feng.check_form( "modal_form_id")) { return; }
|
Feng.base_ajax( "/mallGoodsGroup/updateRecommend", { mallGoodsId: id, sort: $( "#sort").val(), isRecommend: state}, function ( data) {
|
Feng.success( msg + "成功");
|
layer.close( index);
|
MallGoods.search();
|
});
|
},
|
no:function (index,layero) {
|
layer.close(index);
|
}
|
});
|
}
|
Feng.confirm( "是否确定".concat( msg).concat("所选中的数据?"), function () {
|
Feng.base_ajax( "/mallGoodsGroup/updateRecommend", { mallGoodsId: id, isRecommend: state}, function ( data) {
|
Feng.success( msg + "成功");
|
MallGoods.search();
|
});
|
});
|
};
|
|
function extracted() {
|
var queryData = {};
|
queryData['beginTime'] = $("#beginTime").val();
|
queryData['endTime'] = $("#endTime").val();
|
queryData['id'] = $("#id").val();
|
queryData['goodsName'] = $("#goodsName").val();
|
queryData['merchantName'] = $("#merchantName").val();
|
queryData['state'] = $("#state").val();
|
queryData['goodsNo'] = $("#goodsNo").val();
|
return queryData;
|
}
|
|
/**
|
* 点击 导出方法
|
*/
|
MallGoods.export = function ( id) {
|
Feng.down_export( "/mallGoodsGroup/export", extracted());
|
};
|
|
/**
|
* 查询商品信息列表
|
*/
|
MallGoods.search = function () {
|
var queryData = extracted();
|
MallGoods.table.refresh({query: queryData});
|
};
|
/**
|
* 重置查询条件
|
*/
|
MallGoods.resetSearch = function () {
|
$("#beginTime").val("");
|
$("#endTime").val("");
|
$("#id").val("");
|
$("#goodsName").val("");
|
$("#goodsNo").val("");
|
$("#state").val("");
|
MallGoods.search();
|
};
|
$(function () {
|
(function (val) {
|
if ( !val) { return; }
|
sessionStorage.removeItem( "aaaaaaaaaaaaaaaaaaaaa_top_to_message");
|
$( "#state").val( "0")
|
}) ( sessionStorage.getItem( "aaaaaaaaaaaaaaaaaaaaa_top_to_message"));
|
|
var defaultColunms = MallGoods.initColumn();
|
var table = new BSTable(MallGoods.id, "/mallGoodsGroup/list", defaultColunms);
|
// 设置物理分页server(逻辑分页client)
|
table.setPaginationType("server");
|
// 表单提交参数
|
var queryData = extracted()
|
table.setQueryParams(queryData);
|
MallGoods.table = table.init();
|
|
// 初始化开始时间、结束时间
|
laydate.render({
|
elem: '#beginTime'
|
});
|
laydate.render({
|
elem: '#endTime'
|
});
|
});
|