/**
|
* 管理初始化
|
*/
|
var TDriverPromotionActivity = {
|
id: "TDriverPromotionActivityTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
|
/**
|
* 初始化表格的列
|
*/
|
TDriverPromotionActivity.initColumn = function () {
|
return [
|
{field: 'selectItem', radio: true},
|
{title: '推广活动ID', field: 'id', visible: false, align: 'center', valign: 'middle'},
|
{title: '添加时间', field: 'createTime', visible: true, align: 'center', valign: 'middle'},
|
{
|
title: '活动区域-省', field: 'province', visible: true, align: 'center', valign: 'middle',
|
|
formatter: function (value, row, index) {
|
if (row.province != null && row.city != null && row.district != null) {
|
return row.province + "-" + row.city + "-" + row.district;
|
}
|
if (row.province != null && row.city != null) {
|
return row.province + "-" + row.city;
|
}
|
if (row.province != null) {
|
return row.province;
|
}
|
|
}
|
},
|
{title: '活动名称', field: 'activityTitle', visible: true, align: 'center', valign: 'middle'},
|
{
|
title: '活动时间', field: 'startTime', visible: true, align: 'center', valign: 'middle',
|
|
formatter: function (value, row, index) {
|
return row.startTime + " - " + row.endTime;
|
}
|
|
},
|
{title: '当前状态', field: 'status', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row, index) {
|
return {1:"已开启",2:"暂停",3:"未开启",4:"已结束"}[value];
|
}
|
},
|
{
|
title: '操作', field: 'opt', visible: true, align: 'left', valign: 'middle', width: "10%",
|
formatter: function (value, row) {
|
if(row.status==1){
|
var btn = [];
|
btn += '<a href="javascript:void(0);" onclick="TDriverPromotionActivity.stop(' + row.id + ')" style="color: #0e9aef">暂停</a> ';
|
btn += '<a href="javascript:void(0);" onclick="TDriverPromotionActivity.info(' + row.id + ')" style="color: #0e9aef">详情</a> ';
|
return btn;
|
}
|
if(row.status==2){
|
var btn = [];
|
btn += '<a href="javascript:void(0);" onclick="TDriverPromotionActivity.start(' + row.id + ')" style="color: #0e9aef">开启</a> ';
|
btn += '<a href="javascript:void(0);" onclick="TDriverPromotionActivity.info(' + row.id + ')" style="color: #0e9aef">详情</a> ';
|
btn += '<a href="javascript:void(0);" onclick="TDriverPromotionActivity.update(' + row.id + ')" style="color: #0e9aef">编辑</a> ';
|
return btn;
|
}
|
if(row.status==3){
|
var btn = [];
|
btn += '<a href="javascript:void(0);" onclick="TDriverPromotionActivity.info(' + row.id + ')" style="color: #0e9aef">详情</a> ';
|
btn += '<a href="javascript:void(0);" onclick="TDriverPromotionActivity.update(' + row.id + ')" style="color: #0e9aef">编辑</a> ';
|
btn += '<a href="javascript:void(0);" onclick="TDriverPromotionActivity.delete(' + row.id + ')" style="color: #0e9aef">删除</a> ';
|
return btn;
|
}
|
if(row.status==4){
|
var btn = [];
|
btn += '<a href="javascript:void(0);" onclick="TDriverPromotionActivity.info(' + row.id + ')">详情</a> ';
|
btn += '<a href="javascript:void(0);" onclick="TDriverPromotionActivity.delete(' + row.id + ')">删除</a> ';
|
return btn;
|
}
|
|
}
|
}
|
|
];
|
};
|
|
/**
|
* 检查是否选中
|
*/
|
TDriverPromotionActivity.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if (selected.length == 0) {
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
} else {
|
TDriverPromotionActivity.seItem = selected[0];
|
return true;
|
}
|
};
|
|
/**
|
* 点击添加
|
*/
|
TDriverPromotionActivity.openAddTDriverPromotionActivity = function () {
|
var index = layer.open({
|
type: 2,
|
title: '添加',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tDriverPromotionActivity/tDriverPromotionActivity_add'
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 打开查看详情
|
*/
|
TDriverPromotionActivity.update = function (e) {
|
var index = layer.open({
|
type: 2,
|
title: '编辑',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tDriverPromotionActivity/tDriverPromotionActivity_update/' + e
|
});
|
this.layerIndex = index;
|
};
|
TDriverPromotionActivity.info = function (e) {
|
var index = layer.open({
|
type: 2,
|
title: '编辑',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tDriverPromotionActivity/tDriverPromotionActivity_info/' + e
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 删除
|
*/
|
TDriverPromotionActivity.delete = function (e) {
|
var ajax = new $ax(Feng.ctxPath + "/tDriverPromotionActivity/delete", function (data) {
|
Feng.success("删除成功!");
|
TDriverPromotionActivity.table.refresh();
|
}, function (data) {
|
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("tDriverPromotionActivityId", e);
|
ajax.start();
|
};
|
TDriverPromotionActivity.stop = function (e) {
|
var ajax = new $ax(Feng.ctxPath + "/tDriverPromotionActivity/stop", function (data) {
|
Feng.success("暂停成功!");
|
TDriverPromotionActivity.table.refresh();
|
}, function (data) {
|
Feng.error("暂停失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id", e);
|
ajax.start();
|
};
|
|
TDriverPromotionActivity.start = function (e) {
|
var ajax = new $ax(Feng.ctxPath + "/tDriverPromotionActivity/start", function (data) {
|
Feng.success("暂停成功!");
|
TDriverPromotionActivity.table.refresh();
|
}, function (data) {
|
Feng.error("暂停失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id", e);
|
ajax.start();
|
};
|
|
|
TDriverPromotionActivity.startOrStop = function () {
|
if (this.check()) {
|
if (TDriverPromotionActivity.seItem.status == 1) {
|
TDriverPromotionActivity.stop(TDriverPromotionActivity.seItem.id);
|
} else {
|
TDriverPromotionActivity.start(TDriverPromotionActivity.seItem.id);
|
}
|
}
|
};
|
|
/**
|
* 查询列表
|
*/
|
TDriverPromotionActivity.search = function () {
|
var queryData = {};
|
queryData['insertTime'] = $("#insertTime").val();
|
queryData['name'] = $("#name").val();
|
queryData['status'] = $("#status").val();
|
TDriverPromotionActivity.table.refresh({query: queryData});
|
};
|
TDriverPromotionActivity.research = function () {
|
$("#insertTime").val('');
|
$("#name").val('');
|
$("#status").val('');
|
TDriverPromotionActivity.search()
|
};
|
|
|
$(function () {
|
var defaultColunms = TDriverPromotionActivity.initColumn();
|
var table = new BSTable(TDriverPromotionActivity.id, "/tDriverPromotionActivity/list", defaultColunms);
|
table.setPaginationType("client");
|
TDriverPromotionActivity.table = table.init();
|
});
|