/**
|
* 公告管理初始化
|
*/
|
var TNotice = {
|
id: "TNoticeTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
|
/**
|
* 初始化表格的列
|
*/
|
TNotice.initColumn = function () {
|
return [
|
{field: 'selectItem', checkbox: true},
|
{title: '发布时间', field: 'createTime', visible: true, align: 'center', valign: 'middle'},
|
{title: '所发人群', field: 'source', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
if (value == 1) { return "全部用户"; }
|
if (value == 2) { return "全部商家"; }
|
return "";
|
}
|
},
|
{title: '公告标题', field: 'title', visible: true, align: 'center', valign: 'middle'},
|
{title: '列表图片', field: 'coverPlan', visible: true, align: 'center', valign: 'middle', formatter: Feng.getImageDom },
|
{title: '操作', field: 'opts', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
var opts = Feng.Opts();
|
if ($("#updateAuth").val() == 'true') {
|
opts.add("TNotice.openTContentUpdate('"+row.id+"');", "编辑");
|
}
|
if ($("#deleteAuth").val() == 'true') {
|
opts.add("TNotice.delete('"+row.id+"');", "删除");
|
}
|
return opts.getOpts();
|
}
|
}
|
];
|
};
|
|
/**
|
* 检查是否选中
|
*/
|
TNotice.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length == 0){
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
}else{
|
TNotice.seItem = selected[0];
|
return true;
|
}
|
};
|
|
/**
|
* 点击添加公告
|
*/
|
TNotice.openAddTNotice = function () {
|
var index = layer.open({
|
type: 2,
|
title: '添加公告',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tNotice/tNotice_add'
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 点击编辑公告
|
*/
|
TNotice.openTContentUpdate = function (id) {
|
var index = layer.open({
|
type: 2,
|
title: '编辑公告',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tNotice/tNotice_update/' + id
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 打开查看公告详情
|
*/
|
TNotice.openTNoticeDetail = function () {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: '公告详情',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tNotice/tNotice_update/' + TNotice.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
};
|
|
/**
|
* 删除/批量删除公告
|
*/
|
TNotice.delete = function(id){
|
var ids = id;
|
if ( id == 0) { ids = Feng.checkBoxIds( this.id); }
|
if ( ids.length <= 0) { return ; }
|
|
Feng.confirm( "是否确定".concat("删除").concat("所选中的数据?"), function () {
|
Feng.base_ajax( "/tNotice/delete", { ids: ids}, function ( data) {
|
Feng.success( "删除成功");
|
TNotice.search();
|
});
|
});
|
};
|
|
/**
|
* 修改公告状态
|
*/
|
TNotice.updateState = function () {
|
if (this.check()) {
|
var ajax = new $ax(Feng.ctxPath + "/tNotice/updateState", function (data) {
|
Feng.success("操作成功!");
|
TNotice.table.refresh();
|
}, function (data) {
|
Feng.error("操作失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("tNoticeId",TNotice.seItem.id);
|
ajax.start();
|
}
|
};
|
|
/**
|
* 查询公告列表
|
*/
|
TNotice.search = function () {
|
var queryData = {};
|
queryData['title'] = $("#title").val();
|
queryData['source'] = $("#source").val();
|
queryData['beginTime'] = $("#beginTime").val();
|
queryData['endTime'] = $("#endTime").val();
|
TNotice.table.refresh({query: queryData});
|
};
|
TNotice.resetSearch = function () {
|
$("#title").val("");
|
$("#source").val("");
|
$("#beginTime").val("");
|
$("#endTime").val("");
|
TNotice.search();
|
};
|
$(function () {
|
var defaultColunms = TNotice.initColumn();
|
var table = new BSTable(TNotice.id, "/tNotice/list", defaultColunms);
|
TNotice.table = table.init();
|
});
|