/**
|
* 美牙商家服务管理初始化
|
*/
|
var StoreService = {
|
id: "StoreServiceTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
|
/**
|
* 初始化表格的列
|
*/
|
StoreService.initColumn = function () {
|
return [
|
{field: 'selectItem', checkbox: true},
|
{title: '创建时间', field: 'createTime', visible: true, align: 'center', valign: 'middle'},
|
{title: '服务名称', field: 'name', visible: true, align: 'center', valign: 'middle'},
|
{title: '状态', field: 'status', visible: true, align: 'center', valign: 'middle', formatter: function (value, row) {
|
if(value == 1){
|
return "正常"
|
} return "隐藏"
|
}},
|
];
|
};
|
|
/**
|
* 检查是否选中
|
*/
|
StoreService.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length == 0){
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
}else{
|
StoreService.seItem = selected[0];
|
return true;
|
}
|
};
|
|
/**
|
* 点击添加美牙商家服务
|
*/
|
StoreService.openStoreServiceAdd = function () {
|
var index = layer.open({
|
type: 2,
|
title: '添加美牙商家服务',
|
area: ['80%', '80%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/storeService/storeService_add'
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 点击编辑美牙商家服务
|
*/
|
StoreService.openStoreServiceUpdate = function (id) {
|
id = Feng.checkBoxIds(StoreService.id);
|
var index = layer.open({
|
type: 2,
|
title: '编辑美牙商家服务',
|
area: ['80%', '80%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/storeService/storeService_update/' + id
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 打开查看美牙商家服务详情
|
*/
|
StoreService.openStoreServiceDetail = function (id) {
|
var index = layer.open({
|
type: 2,
|
title: '美牙商家服务详情',
|
area: ['80%', '80%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/storeService/detail/' + id
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 删除/批量删除美牙商家服务
|
*/
|
StoreService.delete = function(id){
|
var ids = id;
|
if(id == 0) {
|
// 如果id为0,则为批量删除
|
ids = Feng.checkBoxIds(StoreService.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 + "/storeService/delete", function (data) {
|
// 关闭加载动画层
|
parent.layer.close(index);
|
Feng.success("删除成功!");
|
StoreService.table.refresh();
|
}, function (data) {
|
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("ids", ids);
|
ajax.start();
|
};
|
Feng.confirm("是否删除所选中的数据?", operation);
|
}
|
};
|
|
/**
|
* 编辑美牙商家服务状态
|
*/
|
StoreService.updateState = function (id, state) {
|
var ajax = new $ax(Feng.ctxPath + "/storeService/updateState", function (data) {
|
if(data.code == 200){
|
Feng.success("操作成功!");
|
StoreService.table.refresh();
|
} else {
|
Feng.error("操作失败!" + data.message);
|
}
|
}, function () {
|
Feng.error("操作失败!");
|
});
|
ajax.set("storeServiceId", id);
|
ajax.set("state", state);
|
ajax.start();
|
};
|
|
/**
|
* 查询美牙商家服务列表
|
*/
|
StoreService.search = function () {
|
var queryData = {};
|
queryData['beginTime'] = $("#beginTime").val();
|
queryData['endTime'] = $("#endTime").val();
|
queryData['condition'] = $("#condition").val();
|
StoreService.table.refresh({query: queryData});
|
};
|
/**
|
* 重置查询条件
|
*/
|
StoreService.resetSearch = function () {
|
$("#beginTime").val("");
|
$("#endTime").val("");
|
$("#condition").val("");
|
StoreService.search();
|
};
|
$(function () {
|
var defaultColunms = StoreService.initColumn();
|
var table = new BSTable(StoreService.id, "/storeService/list", defaultColunms);
|
// 设置物理分页server(逻辑分页client)
|
table.setPaginationType("server");
|
// 表单提交参数
|
var queryData = {};
|
queryData['beginTime'] = $("#beginTime").val();
|
queryData['endTime'] = $("#endTime").val();
|
queryData['condition'] = $("#condition").val();
|
table.setQueryParams(queryData);
|
StoreService.table = table.init();
|
|
// 初始化开始时间、结束时间
|
laydate.render({
|
elem: '#beginTime'
|
});
|
laydate.render({
|
elem: '#endTime'
|
});
|
});
|