/**
|
* 管理初始化
|
*/
|
var Generalization = {
|
id: "GeneralizationTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
|
/**
|
* 初始化表格的列
|
*/
|
Generalization.initColumn = function () {
|
return [
|
{field: 'selectItem', radio: true},
|
{title: '主键id', field: 'id', visible: false, align: 'center', valign: 'middle'},
|
{title: '添加时间', field: 'insertTime', visible: true, align: 'center', valign: 'middle'},
|
{title: '活动名称', field: 'activityName', visible: true, align: 'center', valign: 'middle'},
|
{title: '活动时间', field: 'time', visible: true, align: 'center', valign: 'middle'},
|
{title: '最多可参与人数', field: 'participateCount', visible: true, align: 'center', valign: 'middle'},
|
{title: '当前参与人数', field: 'count', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
return '<a href="#" style="color:cornflowerblue">'+row.count+'</a>' +' ' +' '+' '+' '+' '+
|
'<a href="#" onclick="Generalization.activityRecord('+row.id+')" style="color:cornflowerblue">查看领取记录</a>' +' '
|
}
|
},
|
{title: '当前状态', field: 'state', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
if(value==1){
|
return "已开启";
|
}else if(value==2){
|
return "未开启";
|
}else if(value==3){
|
return "已结束";
|
}else if(value==4){
|
return "已暂停";
|
}
|
}
|
},
|
{title: '操作', visible: true, align: 'center', valign: 'middle',width:'16%',
|
formatter: function (value, row) {
|
if(row.state==1){
|
return '<a href="#" onclick="Generalization.openQrCodeGeneralization('+row.id+')" style="color:cornflowerblue">二维码</a>' +' ' +
|
'<a href="#" onclick="Generalization.openGeneralizationDetail('+row.id+')" style="color:cornflowerblue">详情</a>' +' ' +
|
'<a href="#" onclick="Generalization.openUpdateGeneralization('+row.id+')" style="color:cornflowerblue">编辑</a>' +' ' +
|
'<a href="#" onclick="Generalization.delete('+row.id+')" style="color:cornflowerblue">删除</a>'
|
}else{
|
return '<a href="#" onclick="Generalization.openQrCodeGeneralization('+row.id+')" style="color:cornflowerblue">二维码</a>' +' ' +
|
'<a href="#" onclick="Generalization.openGeneralizationDetail('+row.id+')" style="color:cornflowerblue">详情</a>' +' ' +
|
'<a href="#" onclick="Generalization.delete('+row.id+')" style="color:cornflowerblue">删除</a>'
|
}
|
}
|
}
|
];
|
};
|
|
/**
|
* 检查是否选中
|
*/
|
Generalization.check = function (type) {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length == 0){
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
}else{
|
//验证类型null删除,1=审核,2=编辑,3=启动/暂停
|
if(type==null){
|
Generalization.seItem = selected[0];
|
return true;
|
}else if(type==3 && selected[0].state==3){
|
Feng.info("当前状态不能暂停/启动!");
|
return false;
|
}
|
Generalization.seItem = selected[0];
|
return true;
|
}
|
};
|
|
/**
|
* 点击添加
|
*/
|
Generalization.openAddGeneralization = function () {
|
var index = layer.open({
|
type: 2,
|
title: '添加推广活动',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/generalization/addHtml'
|
});
|
this.layerIndex = index;
|
};
|
/**
|
* 打开编辑
|
*/
|
Generalization.openUpdateGeneralization = function (id) {
|
console.log("111222211==="+id);
|
var index = layer.open({
|
type: 2,
|
title: '编辑推广活动',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/generalization/editHtml/' + id
|
});
|
this.layerIndex = index;
|
};
|
/**
|
* 打开二维码
|
*/
|
Generalization.openQrCodeGeneralization = function (id) {
|
var index = layer.open({
|
type: 2,
|
title: '推广二维码',
|
area: ['50%', '50%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/generalization/qrCodeHtml/' + id
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 下载二维码
|
*/
|
Generalization.downQrCode = function () {
|
var imgElement = document.getElementById('qrCode');
|
var imgURL = imgElement.src;
|
console.log(imgURL)
|
// var downloadLink = document.createElement('a');
|
// downloadLink.href = imgURL;
|
// downloadLink.download = '二维码.png'; // 自定义下载文件名
|
// // 将链接添加到文档中(可以是隐藏的)
|
// document.body.appendChild(downloadLink);
|
// // 触发点击
|
// downloadLink.click();
|
// // 清理,可选
|
// document.body.removeChild(downloadLink);
|
// GeneralizationInfoDlg.close();
|
|
var ajax = new $ax(Feng.ctxPath + "/generalization/downQrcode", function(data){
|
Feng.success("下载成功!");
|
GeneralizationInfoDlg.close();
|
},function(data){
|
Feng.error("下载失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("imgURL",imgURL);
|
ajax.start();
|
|
};
|
|
/**
|
* 打开查看详情
|
*/
|
Generalization.openGeneralizationDetail = function (id) {
|
var index = layer.open({
|
type: 2,
|
title: '详情',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/generalization/generalization_detail/' + id
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 删除
|
*/
|
Generalization.delete = function (id) {
|
var ajax = new $ax(Feng.ctxPath + "/generalization/delete", function (data) {
|
Feng.success("删除成功!");
|
Generalization.table.refresh();
|
}, function (data) {
|
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("tActivityGeneralizationId",id);
|
ajax.start();
|
};
|
|
/**
|
* 启动/暂停
|
*/
|
Generalization.updateStatus = function () {
|
if (this.check(3)) {
|
var ajax = new $ax(Feng.ctxPath + "/generalization/updateStatus", function (data) {
|
Feng.success("启动/暂停成功!");
|
Generalization.table.refresh();
|
}, function (data) {
|
Feng.error("启动/暂停失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id",this.seItem.id);
|
ajax.set("status",this.seItem.state==4?1:4);
|
ajax.start();
|
}
|
};
|
/**
|
* 领取记录
|
*/
|
Generalization.receiveRecord= function () {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: '领取记录',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/generalization/receiveRecord?activityId='+ Generalization.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
};
|
|
/**
|
* 查询列表
|
*/
|
Generalization.search = function () {
|
var queryData = {};
|
queryData['createTime'] = $("#createTime").val();
|
queryData['activityName'] = $("#activityName").val();
|
queryData['state'] = $("#state").val();
|
Generalization.table.refresh({query: queryData});
|
};
|
Generalization.resetSearch = function () {
|
$("#createTime").val("");
|
$("#activityName").val("");
|
$("#state").val("");
|
Generalization.search();
|
};
|
$(function () {
|
var defaultColunms = Generalization.initColumn();
|
var table = new BSTable(Generalization.id, "/generalization/list", defaultColunms);
|
table.setPaginationType("server");
|
Generalization.table = table.init();
|
});
|