/**
|
* 角色管理的单例
|
*/
|
var Icon = {
|
id: "IconTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
|
/**
|
* 初始化表格的列
|
*/
|
Icon.initColumn = function () {
|
var columns = [
|
{field: 'select_item', radio: true},
|
{title: 'id', field: 'id', visible: false, align: 'center', valign: 'middle'},
|
{title: 'ID', field: 'code', align: 'center', valign: 'middle', width: '100px'},
|
{title: 'icon名称', field: 'name', align: 'center', valign: 'middle', width: '100px',
|
formatter: function (value, row) {
|
return '<a href="#" onclick="Icon.openIconInfo(\'' + row.id + '\')">' + value + '</a>';
|
}
|
},
|
{title: '位置大类', field: 'position', align: 'center', valign: 'middle', width: '100px',
|
formatter: function (value,row) {
|
if (value == 1) {
|
return "首页顶部";
|
} else if(value==2){
|
return "首页底部";
|
}
|
}
|
},
|
{title: '生效周期', field: 'effectTime', align: 'center', valign: 'middle', width: '300px'},
|
{title: '投放频率', field: 'frequency', align: 'center', valign: 'middle', width: '200px',
|
formatter: function (value,row) {
|
if(value==1){
|
if(row.frequencyTime == "[]"){
|
return "每周";
|
}else {
|
return "每周"+row.frequencyTime.replace("[","(").replace("]",")");
|
}
|
}else if(value==2){
|
if(row.frequencyTime == "[]"){
|
return "每月";
|
}else {
|
return "每月"+row.frequencyTime.replace("[","(").replace("]",")");
|
}
|
}else if(value == 0){
|
return "全部";
|
}
|
}
|
},
|
{title: '投放时间点', field: 'pointTime', align: 'center', valign: 'middle', width: '300px',
|
formatter:function (value,row){
|
if(value!=null && value!=undefined){
|
value = value.replace("[","(").replace("]",")")
|
}
|
return value;
|
}
|
},
|
{title: '排序', field: 'sort', align: 'center', valign: 'middle', width: '100px'},
|
{title: '点击次数', field: 'number2', align: 'center', valign: 'middle', width: '100px'},
|
{title: '点击人数', field: 'userNum2', align: 'center', valign: 'middle', width: '100px',
|
// formatter: function (value, row) {
|
// return '<a href="#" onclick="Icon.openClickUser(\'' + row.id + '\')">' + value + '</a>';
|
// }
|
},
|
{title: '配置人', field: 'createUser', align: 'center', valign: 'middle', width: '100px'},
|
{title: '配置时间', field: 'createTime', align: 'center', valign: 'middle', width: '150px'},
|
{title: '跳转详情', field: 'jumpType', align: 'center', valign: 'middle', width: '100px',
|
formatter: function (value) {
|
switch (value) {
|
case 1:
|
return '签到';
|
case 2:
|
return '会员权益';
|
case 3:
|
return '任务中心';
|
case 4:
|
return '我的';
|
case 5:
|
return '券包';
|
case 6:
|
return '促销活动';
|
case 7:
|
return '集点活动';
|
case 8:
|
return '积分商城';
|
case 9:
|
return '我的优惠券列表';
|
case 10:
|
return '加油站首页';
|
case 11:
|
return '外部H5';
|
case 12:
|
return '外部小程序';
|
case 13:
|
return '一键加油';
|
case 14:
|
return '开发票';
|
case 15:
|
return '领券活动';
|
case 16:
|
return '我的优惠券';
|
case 17:
|
return '我的任务';
|
case 18:
|
return '我的订单';
|
}
|
}
|
},
|
{title: '曝光城市', field: 'city', align: 'center', valign: 'middle', width: '250px',
|
formatter: function (value, row) {
|
if(row.exposureProvince==null || row.exposureProvince==undefined){
|
return "-"
|
}else {
|
return row.exposureProvince+" "+row.exposureCity+" "+row.exposureDistrict;
|
}
|
}
|
},
|
{title: '状态', field: 'state', align: 'center', valign: 'middle', width: '100px',
|
formatter: function (value) {
|
switch (value) {
|
case 1:
|
return '已上架';
|
case 2:
|
return '已下架';
|
}
|
}
|
}
|
]
|
return columns;
|
};
|
|
|
/**
|
* 检查是否选中
|
*/
|
Icon.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if (selected.length == 0) {
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
} else {
|
Icon.seItem = selected[0];
|
return true;
|
}
|
};
|
|
/**
|
* 点击添加
|
*/
|
Icon.openAddIcon = function () {
|
var index = layer.open({
|
type: 2,
|
title: '添加icon',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/icon/openAddIcon'
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 点击修改
|
*/
|
Icon.openChangeIcon = function () {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: '编辑icon',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/icon/openChangeIcon?id=' + this.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
};
|
|
/**
|
* 删除
|
*/
|
Icon.delIcon = function () {
|
if (this.check()) {
|
var operation = function () {
|
var ajax = new $ax(Feng.ctxPath + "/icon/delIcon", function (data) {
|
if(data.code == 200 ){
|
Feng.success("删除成功!");
|
Icon.table.refresh();
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id", Icon.seItem.id);
|
ajax.start();
|
};
|
|
Feng.confirm("是否刪除该icon?", operation);
|
}
|
};
|
|
/**
|
* 上架
|
*/
|
Icon.putIcon = function () {
|
if (this.check()) {
|
var operation = function () {
|
var ajax = new $ax(Feng.ctxPath + "/icon/putIcon", function (data) {
|
if(data.code == 200 ){
|
Feng.success("上架成功!");
|
Icon.table.refresh();
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("上架失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id", Icon.seItem.id);
|
ajax.start();
|
};
|
|
Feng.confirm("是否确认上架?", operation);
|
}
|
};
|
|
/**
|
* 下架
|
*/
|
Icon.offIcon = function () {
|
if (this.check()) {
|
var operation = function () {
|
var ajax = new $ax(Feng.ctxPath + "/icon/offIcon", function (data) {
|
if(data.code == 200 ){
|
Feng.success("下架成功!");
|
Icon.table.refresh();
|
}else{
|
Feng.error(data.msg);
|
}
|
}, function (data) {
|
Feng.error("下架失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id", Icon.seItem.id);
|
ajax.start();
|
};
|
|
Feng.confirm("是否确认下架?", operation);
|
}
|
};
|
|
|
/**
|
* 详情
|
* @param id
|
*/
|
Icon.openIconInfo = function(id){
|
var index = layer.open({
|
type: 2,
|
title: 'icon详情',
|
area: ['60%', '90%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/icon/openIconInfo?id=' + id
|
});
|
this.layerIndex = index;
|
}
|
|
|
/**
|
* 导出
|
*/
|
Icon.exportIcon = function(){
|
const code = $("#code").val();
|
const name = $("#name").val();
|
const state = $("#state").val();
|
const createUser = $("#createUser").val();
|
const position = $("#position").val();
|
const exposureProvince = $('#province').find("option:selected").text();
|
const exposureCity = $('#city').find("option:selected").text();
|
const exposureDistrict = $('#district').find("option:selected").text();
|
window.location.href = Feng.ctxPath + "/icon/exportIcon?code=" + code + "&name=" + name + "&state=" + state + "&createUser=" + createUser+
|
"&position="+position+"&exposureProvince=" + exposureProvince + "&exposureCity=" + exposureCity + "&exposureDistrict=" + exposureDistrict;
|
}
|
|
/**
|
* 点击用户列表
|
*/
|
Icon.openClickUser = function(id){
|
var index = layer.open({
|
type: 2,
|
title: 'icon点击用户',
|
area: ['80%', '90%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/icon/openClickUser?id=' + id
|
});
|
this.layerIndex = index;
|
}
|
|
|
|
/**
|
* 搜索
|
*/
|
Icon.search = function () {
|
var queryData = {};
|
queryData['code'] = $("#code").val();
|
queryData['name'] = $("#name").val();
|
queryData['state'] = $("#state").val();
|
queryData['createUser'] = $("#createUser").val();
|
queryData['position'] = $("#position").val();
|
queryData['exposureProvince'] = $('#province').find("option:selected").text();
|
queryData['exposureCity'] = $('#city').find("option:selected").text();
|
queryData['exposureDistrict'] = $('#district').find("option:selected").text();
|
Icon.table.setQueryParams({});
|
Icon.table.refresh({query: queryData});
|
}
|
|
Icon.resetSearch = function(){
|
var queryData = {};
|
$("#code").val('');
|
$("#name").val('');
|
$("#state").val('');
|
$("#createUser").val('');
|
$("#position").val('');
|
$('#province').val('');
|
$('#city').val('');
|
$('#district').val('');
|
Icon.table.setQueryParams({});
|
Icon.table.refresh({query: queryData});
|
}
|
|
|
//选择城市
|
Icon.selectCity=function(e,name){
|
var parentId=$(e).val();
|
var ajax = new $ax(Feng.ctxPath + "/region/cityList", function(data){
|
if(data!=null){
|
var content="<option value=''>全部</option>";
|
$.each(data, function(k,v) {
|
content += "<option value='"+v.id+"'>"+v.name+"</option>";
|
});
|
$("#"+name+"").empty().append(content);
|
}
|
});
|
ajax.set("parentId",parentId);
|
ajax.start();
|
}
|
|
$(function () {
|
var defaultColunms = Icon.initColumn();
|
var table = new BSTable(Icon.id, "/icon/queryIconList", defaultColunms);
|
table.setPaginationType("server");
|
Icon.table = table.init();
|
//省市区初始化
|
Icon.selectCity($("#province"),"province");
|
});
|