/**
|
* 管理初始化
|
*/
|
var TCommercial = {
|
id: "TCommercialTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
|
/**
|
* 初始化表格的列
|
*/
|
TCommercial.initColumn = function () {
|
return [
|
{field: 'selectItem', radio: true},
|
{title: '主键', field: 'id', visible: false, align: 'center', valign: 'middle'},
|
{title: '添加时间', field: 'createTime', visible: true, align: 'center', valign: 'middle'},
|
{title: '广告图名称', field: 'name', visible: true, align: 'center', valign: 'middle'},
|
{title: '广告类型', field: 'type', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
if (row.type === 1){
|
return '<span>弹窗广告</span>'
|
}else if(row.type === 2){
|
return '<span>底部广告</span>'
|
}
|
}
|
},
|
{title: '广告图图片', field: 'url', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
return '<img src="'+row.url+'" style="height: 60px;width: 60px"/>'
|
}
|
},
|
{title: '端口(设备)', field: 'device', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
if (row.device === 1){
|
return '<span>小程序</span>'
|
}else if(row.device === 2){
|
return '<span>司机端</span>'
|
}
|
}
|
},
|
{title: '是否跳转', field: 'isJump', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
if (row.isJump === 0){
|
return '<span>否</span>'
|
}else if(row.isJump === 1){
|
return '<span>是</span>'
|
}
|
}
|
},
|
{title: '跳转类型', field: 'jumpType', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
if (row.jumpType === 1){
|
return '<span>内部跳转</span>'
|
}else if(row.jumpType === 2){
|
return '<span>外部跳转</span>'
|
}
|
}
|
},
|
{title: '跳转内容', field: 'jumpUrl', visible: true, align: 'center', valign: 'middle'},
|
{title: '状态', field: 'onOffLine', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
if (row.onOffLine === 1){
|
return '<span>已上线</span>'
|
}else if(row.onOffLine === 2){
|
return '<span>已下线</span>'
|
}
|
}
|
},
|
{title: '富文本', field: 'html', visible: false, align: 'center', valign: 'middle'},
|
{title: '排序', field: 'sort', visible: false, align: 'center', valign: 'middle'},
|
{title: '状态(1=正常,2=冻结,3=删除)', field: 'status', visible: false, align: 'center', valign: 'middle'},
|
{title: '添加人员id', field: 'createUserId', visible: false, align: 'center', valign: 'middle'},
|
{title: '更新时间', field: 'updateTime', visible: false, align: 'center', valign: 'middle'},
|
{title: '更新人员id', field: 'updateUserId', visible: false, align: 'center', valign: 'middle'},
|
{title: '操作', visible: true, align: 'center', valign: 'middle',width:150,
|
formatter: function (value, row) {
|
if (row.onOffLine === 1){
|
return '<a href="#" onclick="TCommercial.offLineState('+row.id+')" style="color:red">下线</a>' +' ' +
|
'<a href="#" onclick="TCommercial.delete('+row.id+','+row.onOffLine+')" style="color:red">删除</a>'
|
}else if(row.onOffLine === 2){
|
return '<a href="#" onclick="TCommercial.onLineState('+row.id+')" style="color:blue">上线</a>' +' ' +
|
'<a href="#" onclick="TCommercial.delete('+row.id+','+row.onOffLine+')" style="color:red">删除</a>'
|
}
|
}
|
}
|
];
|
};
|
|
/**
|
* 检查是否选中
|
*/
|
TCommercial.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length == 0){
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
}else{
|
TCommercial.seItem = selected[0];
|
return true;
|
}
|
};
|
|
/**
|
* 点击添加
|
*/
|
TCommercial.openAddTCommercial = function () {
|
var index = layer.open({
|
type: 2,
|
title: '添加',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tCommercial/tCommercial_add'
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 打开查看详情
|
*/
|
TCommercial.openTCommercialDetail = function (id) {
|
if(this.check()){
|
var index = layer.open({
|
type: 2,
|
title: '详情',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tCommercial/tCommercial_update/' + TCommercial.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
};
|
|
/**
|
* 删除
|
*/
|
TCommercial.delete = function (id,onOffLine) {
|
if(1 == onOffLine){
|
Feng.error("已上线广告不可删除!");
|
return;
|
}
|
var ajax = new $ax(Feng.ctxPath + "/tCommercial/delete", function (data) {
|
Feng.success("删除成功!");
|
TCommercial.table.refresh();
|
}, function (data) {
|
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("tCommercialId",id);
|
ajax.start();
|
};
|
|
|
/**
|
* 上线
|
*/
|
TCommercial.onLineState = function (id) {
|
var ajax = new $ax(Feng.ctxPath + "/tCommercial/onLine", function (data) {
|
if(500 == data.code){
|
Feng.error(data.message)
|
return;
|
}else {
|
Feng.success("上线成功!");
|
TCommercial.table.refresh();
|
}
|
}, function (data) {
|
Feng.error("上线失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("tCommercialId",id);
|
ajax.start();
|
};
|
|
/**
|
* 下线
|
*/
|
TCommercial.offLineState = function (id) {
|
var ajax = new $ax(Feng.ctxPath + "/tCommercial/offLine", function (data) {
|
if(500 == data.code){
|
Feng.error(data.message)
|
return;
|
}else {
|
Feng.success("下线成功!");
|
TCommercial.table.refresh();
|
}
|
}, function (data) {
|
Feng.error("下线失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("tCommercialId",id);
|
ajax.start();
|
};
|
|
|
/**
|
* 查询列表
|
*/
|
TCommercial.search = function () {
|
var queryData = {};
|
queryData['condition'] = $("#condition").val();
|
TCommercial.table.refresh({query: queryData});
|
};
|
|
$(function () {
|
var defaultColunms = TCommercial.initColumn();
|
var table = new BSTable(TCommercial.id, "/tCommercial/list", defaultColunms);
|
table.setPaginationType("client");
|
TCommercial.table = table.init();
|
});
|