/**
|
* 规格组管理初始化
|
*/
|
var MallGroupSpec = {
|
id: "MallGroupSpecTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
|
/**
|
* 初始化表格的列
|
*/
|
MallGroupSpec.initColumn = function () {
|
return [
|
{field: 'selectItem', checkbox: true},
|
{title: '创建时间', field: 'createTime', visible: true, align: 'center', valign: 'middle'},
|
{title: '规格组名称', field: 'specName', visible: true, align: 'center', valign: 'middle'},
|
{title: '商品分类', field: 'classifyName', visible: true, align: 'center', valign: 'middle'},
|
{title: '商品', field: 'goodsNames', visible: true, align: 'center', valign: 'middle'},
|
{title: '有效期', field: 'startTime', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
return value + " 至 " + row.endTime;
|
}
|
},
|
//{title: '结束时间', field: 'endTime', visible: true, align: 'center', valign: 'middle'},
|
//{title: '商品库存', field: 'stock', visible: true, align: 'center', valign: 'middle'},
|
//{title: '区域城市ID', field: 'areaCityId', visible: true, align: 'center', valign: 'middle'},
|
{title: '备注', field: 'remark', visible: true, align: 'center', valign: 'middle'},
|
{title: '状态', field: 'isLock', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
return {0:"正常", 1:"隐藏"}[value];
|
}
|
},
|
{title: '操作', field: 'opts', visible: true, align: 'left', valign: 'middle',
|
formatter: function (value, row) {
|
var opts = Feng.Opts();
|
if ($("#updateAuth").val() == 'true') {
|
opts.add("MallGroupSpec.openMallGroupSpecUpdate('"+row.id+"');", "编辑");
|
}
|
if ($("#deleteAuth").val() == 'true') {
|
opts.addDanger("MallGroupSpec.delete('"+row.id+"');", "删除");
|
}
|
if ($("#updateStateAuth").val() == 'true') {
|
if(row.isLock != undefined && row.isLock == 1){
|
opts.add("MallGroupSpec.updateState('"+row.id+"','0');", "显示");
|
} else {
|
opts.addDanger("MallGroupSpec.updateState('"+row.id+"','1');", "隐藏");
|
}
|
}
|
return opts.getOpts();
|
}
|
}
|
];
|
};
|
|
/**
|
* 检查是否选中
|
*/
|
MallGroupSpec.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length == 0){
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
}else{
|
MallGroupSpec.seItem = selected[0];
|
return true;
|
}
|
};
|
|
/**
|
* 点击添加规格组
|
*/
|
MallGroupSpec.openMallGroupSpecAdd = function () {
|
var index = layer.open({
|
type: 2,
|
title: '添加规格组',
|
area: ['95%', '95%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/mallGroupSpec/mallGroupSpec_add'
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 点击编辑规格组
|
*/
|
MallGroupSpec.openMallGroupSpecUpdate = function (id) {
|
var index = layer.open({
|
type: 2,
|
title: '编辑规格组',
|
area: ['95%', '95%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/mallGroupSpec/mallGroupSpec_update/' + id
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 打开查看规格组详情
|
*/
|
MallGroupSpec.openMallGroupSpecDetail = function (id) {
|
var index = layer.open({
|
type: 2,
|
title: '规格组详情',
|
area: ['95%', '95%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/mallGroupSpec/detail/' + id
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 删除/批量删除规格组
|
*/
|
MallGroupSpec.delete = function(id){
|
var ids = id;
|
if(id == 0) {
|
// 如果id为0,则为批量删除
|
ids = Feng.checkBoxIds(MallGroupSpec.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 + "/mallGroupSpec/delete", function (data) {
|
// 关闭加载动画层
|
parent.layer.close(index);
|
Feng.success("删除成功!");
|
MallGroupSpec.table.refresh();
|
}, function (data) {
|
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("ids", ids);
|
ajax.start();
|
};
|
Feng.confirm("是否删除所选中的数据?", operation);
|
}
|
};
|
|
/**
|
* 编辑规格组状态
|
*/
|
MallGroupSpec.updateState = function (id, state) {
|
var ajax = new $ax(Feng.ctxPath + "/mallGroupSpec/updateState", function (data) {
|
if(data.code == 200){
|
Feng.success("操作成功!");
|
MallGroupSpec.table.refresh();
|
} else {
|
Feng.error("操作失败!" + data.message);
|
}
|
}, function () {
|
Feng.error("操作失败!");
|
});
|
ajax.set("mallGroupSpecId", id);
|
ajax.set("state", state);
|
ajax.start();
|
};
|
|
/**
|
* 查询规格组列表
|
*/
|
MallGroupSpec.search = function () {
|
var queryData = {};
|
queryData['beginTime'] = $("#beginTime").val();
|
queryData['endTime'] = $("#endTime").val();
|
queryData['condition'] = $("#condition").val();
|
MallGroupSpec.table.refresh({query: queryData});
|
};
|
/**
|
* 重置查询条件
|
*/
|
MallGroupSpec.resetSearch = function () {
|
$("#beginTime").val("");
|
$("#endTime").val("");
|
$("#condition").val("");
|
MallGroupSpec.search();
|
};
|
$(function () {
|
var defaultColunms = MallGroupSpec.initColumn();
|
var table = new BSTable(MallGroupSpec.id, "/mallGroupSpec/list", defaultColunms);
|
// 设置物理分页server(逻辑分页client)
|
table.setPaginationType("server");
|
// 表单提交参数
|
var queryData = {};
|
queryData['beginTime'] = $("#beginTime").val();
|
queryData['endTime'] = $("#endTime").val();
|
queryData['condition'] = $("#condition").val();
|
table.setQueryParams(queryData);
|
MallGroupSpec.table = table.init();
|
|
// 初始化开始时间、结束时间
|
laydate.render({
|
elem: '#beginTime'
|
});
|
laydate.render({
|
elem: '#endTime'
|
});
|
});
|