/**
|
* 管理初始化
|
*/
|
var TStudent = {
|
id: "TStudentTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
|
/**
|
* 初始化表格的列
|
*/
|
TStudent.initColumn = function () {
|
return [
|
{field: 'selectItem', radio: true},
|
{title: '序号', field: 'id', visible: true, align: 'center', valign: 'middle'},
|
{
|
title: '所属运营商', field: 'operation', visible: true, align: 'center', valign: 'middle',
|
formatter: function(value, row, index) {
|
if (value === null) {
|
return '平台';
|
} else {
|
return value;
|
}
|
}
|
},
|
{title: '省', field: 'province', visible: true, align: 'center', valign: 'middle'},
|
{title: '市', field: 'city', visible: true, align: 'center', valign: 'middle'},
|
{ title: '门店名称', field: 'store', visible: true, align: 'center', valign: 'middle'},
|
{ title: '所属场地', field: 'site', visible: true, align: 'center', valign: 'middle'},
|
{ title: '红方设备二维码', field: 'redCode', visible: false, align: 'center', valign: 'middle'},
|
{ title: '蓝方设备二维码', field: 'blueCode', visible: false, align: 'center', valign: 'middle'},
|
{ title: '蓝方设备ID', field: 'blue', visible: true, align: 'center', valign: 'middle',
|
formatter: function (data,row) {
|
// row.redCode存储的设备二维码连接
|
var temp = row.blueCode;
|
var str = '<button class="btn btn-outline btn-primary" onclick="TStudent.openDetail(\'' + temp + '\')" >'+row.blue+'</button>'
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="" onfocus="TUser.tooltip()">' + str + '</p>']
|
return btn;
|
}
|
},
|
{ title: '红方设备ID', field: 'red', visible: true, align: 'center', valign: 'middle',
|
formatter: function (data,row) {
|
// row.redCode存储的设备二维码连接
|
var temp = row.redCode;
|
var str = '<button class="btn btn-outline btn-primary" onclick="TStudent.openDetail(\'' + temp + '\')" >'+row.red+'</button>'
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="" onfocus="TUser.tooltip()">' + str + '</p>']
|
return btn;
|
}
|
},
|
{
|
title: '设备类型',
|
field: 'deviceType',
|
visible: true,
|
align: 'center',
|
valign: 'middle',
|
formatter: function(value, row, index) {
|
return '智慧球场';
|
}
|
},
|
{
|
title: '状态', field: 'state', visible: true, align: 'center', valign: 'middle',
|
formatter: function(value, row, index) {
|
if (value === 0) {
|
return '开启';
|
} else if (value === 1) {
|
return '关闭';
|
} else {
|
return '';
|
}
|
}
|
}
|
|
|
];
|
};
|
|
/**
|
* 检查是否选中
|
*/
|
TStudent.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length == 0){
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
}else{
|
TStudent.seItem = selected[0];
|
return true;
|
}
|
};
|
|
TStudent.openDetail = function (e) {
|
console.log("看看")
|
console.log(e)
|
var index = layer.load(1,{
|
type: 1
|
, title: '设备二维码'
|
, area: ['100%', '100%']
|
, offset: 'auto' //具体配置参考:http://www.layui.com/doc/modules/layer.html#offset
|
, id: 'layerDemo' //防止重复弹出cge
|
, content: '<div class="form-horizontal">' +
|
' <img src='+ e +'>' +
|
'</img>'+
|
'</div>'
|
, btn: ['关闭', '下载']
|
, btnAlign: 'c' //按钮居中
|
, shade: 0.5 //不显示遮罩
|
,load:1
|
, yes: function () {
|
|
layer.closeAll();
|
},
|
btn2:function () {
|
var a = document.createElement('a');
|
a.href = e;
|
a.download = '设备二维码.jpg'; // 设置下载文件的名称
|
a.style.display = 'none';
|
document.body.appendChild(a);
|
a.click();
|
document.body.removeChild(a);
|
}
|
});
|
this.layerIndex = index;
|
};
|
|
TStudent.editCoursePackageState = function (state) {
|
if (this.check()) {
|
|
if(TStudent.seItem.state == state){
|
Feng.error("不能重复操作");
|
return
|
}
|
parent.layer.confirm(state == 1 ? '是否关闭' : "是否开启" , {
|
btn: ['确定', '取消']
|
}, function (index) {
|
let ajax = new $ax(Feng.ctxPath + "/ball/editCoursePackageState", function (data) {
|
Feng.success(state == 1 ? '关闭' : "开启" + "成功!");
|
TStudent.table.refresh();
|
}, function (data) {
|
Feng.error(state == 1 ? '关闭' : "开启" + "失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("id", TStudent.seItem.id);
|
ajax.set("state", state);
|
ajax.start();
|
parent.layer.close(index);
|
|
}, function (index) {
|
parent.layer.close(index);
|
}
|
|
|
)
|
|
}
|
};
|
/**
|
* 点击添加
|
*/
|
TStudent.openAddTStudent = function () {
|
var index = layer.open({
|
type: 2,
|
title: '添加',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/ball/pre_add'
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 打开修改
|
*/
|
TStudent.openTStudentDetail = function () {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: '详情',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/ball/pre_edit/' + TStudent.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
};
|
|
|
|
|
|
|
TStudent.openTStudentDetail3 = function () {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: '详情',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/ball/pre_info/' + TStudent.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
};
|
|
|
TStudent.openTStudentDetail5 = function () {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: '详情',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/gameData'
|
});
|
this.layerIndex = index;
|
}
|
};
|
|
|
/**
|
* 打开详情
|
*/
|
TStudent.openTStudentDetail1 = function () {
|
var index = layer.open({
|
type: 2,
|
title: '详情',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/ball/jieshao'
|
});
|
this.layerIndex = index;
|
|
};
|
|
|
|
/**
|
* 删除
|
*/
|
TStudent.delete = function () {
|
if (this.check()) {
|
var ajax = new $ax(Feng.ctxPath + "/tStudent/delete", function (data) {
|
Feng.success("删除成功!");
|
TStudent.table.refresh();
|
}, function (data) {
|
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("tStudentId",this.seItem.id);
|
ajax.start();
|
}
|
};
|
|
/**
|
* 查询列表
|
*/
|
TStudent.search = function () {
|
var queryData = {};
|
queryData['provinceCode'] = $("#pCode").val();
|
queryData['cityCode'] = $("#cCode").val();
|
queryData['store'] = $("#store").val();
|
queryData['site'] = $("#site").val();
|
|
|
TStudent.table.refresh({query: queryData});
|
};
|
|
TStudent.resetSearch = function () {
|
$("#pCode").val("");
|
$("#cCode").val("");
|
$("#store").val("");
|
$("#site").val("");
|
TStudent.search();
|
};
|
|
|
$(function () {
|
var defaultColunms = TStudent.initColumn();
|
var table = new BSTable(TStudent.id, "/ball/list", defaultColunms);
|
table.setPaginationType("client");
|
TStudent.table = table.init();
|
});
|