/**
|
* 示例功能管理初始化
|
*/
|
var AaaTest = {
|
id: "AaaTestTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
|
/**
|
* 初始化表格的列
|
*/
|
AaaTest.initColumn = function () {
|
return [
|
{field: 'selectItem', checkbox: true},
|
{title: 'ID', field: 'id', visible: true, align: 'center', valign: 'middle'},
|
{title: '手机', field: 'phone', visible: true, align: 'center', valign: 'middle'},
|
{title: '是否锁定“is”前缀', field: 'isLock', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
return Feng.getIsObjFormat(value);
|
}
|
},
|
{title: '复选框示例', field: 'checkBoxEq', visible: true, align: 'center', valign: 'middle'},
|
{title: '复选下拉框示例', field: 'selectMultiEq', visible: true, align: 'center', valign: 'middle'},
|
{title: '是否删除(下拉框)', field: 'isDelete', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
return Feng.getIsObjFormat(value);
|
}
|
},
|
{title: '日期到天“date”前缀', field: 'dateVip', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
return Feng.dateFormat(value);
|
}
|
},
|
{title: '文字缩略“rext”前缀', field: 'textMark', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
return Feng.textFormat(value, 10);
|
}
|
},
|
{title: '图片展示“image”前缀', field: 'imageCover', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
return Feng.getImageDom(value);
|
}
|
},
|
{title: '创建时间', field: 'createTime', visible: true, align: 'center', valign: 'middle'},
|
{title: '操作', field: 'opts', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
var opts = Feng.Opts();
|
if ($("#updateAuth").val() == 'true') {
|
opts.add("AaaTest.openAaaTestUpdate('"+row.id+"');", "编辑");
|
}
|
if ($("#deleteAuth").val() == 'true') {
|
opts.add("AaaTest.delete('"+row.id+"');", "删除");
|
}
|
if ($("#updateStateAuth").val() == 'true') {
|
if(row.isLock == 0) {
|
opts.add("AaaTest.updateState('"+row.id+"','1');", "锁定");
|
} else {
|
opts.add("AaaTest.updateState('"+row.id+"','0');", "解锁");
|
}
|
}
|
return opts.getOpts();
|
}
|
}
|
];
|
};
|
|
/**
|
* 检查是否选中
|
*/
|
AaaTest.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length == 0){
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
}else{
|
AaaTest.seItem = selected[0];
|
return true;
|
}
|
};
|
|
/**
|
* 点击添加示例功能
|
*/
|
AaaTest.openAaaTestAdd = function () {
|
var index = layer.open({
|
type: 2,
|
title: '添加示例功能',
|
area: ['99%', '99%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/aaaTest/aaaTest_add'
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 点击编辑示例功能
|
*/
|
AaaTest.openAaaTestUpdate = function (id) {
|
var index = layer.open({
|
type: 2,
|
title: '编辑示例功能',
|
area: ['99%', '99%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/aaaTest/aaaTest_update/' + id
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 打开查看示例功能详情
|
*/
|
AaaTest.openAaaTestDetail = function (id) {
|
var index = layer.open({
|
type: 2,
|
title: '示例功能详情',
|
area: ['80%', '80%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/aaaTest/detail/' + id
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 删除/批量删除示例功能
|
*/
|
AaaTest.delete = function(id){
|
var ids = id;
|
if(id == 0) {
|
// 如果id为0,则为批量删除
|
ids = Feng.checkBoxIds(AaaTest.id);
|
}
|
if (ids.length != 0) {
|
var operation = function() {
|
// 加载动画层,0代表加载的风格,支持0-2
|
var index = parent.layer.load(0, {shade: false});
|
var ajax = new $ax(Feng.ctxPath + "/aaaTest/delete", function (data) {
|
// 关闭加载动画层
|
parent.layer.close(index);
|
Feng.success("删除成功!");
|
AaaTest.table.refresh();
|
}, function (data) {
|
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("ids", ids);
|
ajax.start();
|
};
|
Feng.confirm("是否删除所选中的数据?", operation);
|
}
|
};
|
|
/**
|
* 编辑示例功能状态
|
*/
|
AaaTest.updateState = function (id, state) {
|
var ajax = new $ax(Feng.ctxPath + "/aaaTest/updateState", function (data) {
|
if(data.code == 200){
|
Feng.success("操作成功!");
|
AaaTest.table.refresh();
|
} else {
|
Feng.error("操作失败!" + data.message);
|
}
|
}, function () {
|
Feng.error("操作失败!");
|
});
|
ajax.set("aaaTestId", id);
|
ajax.set("state", state);
|
ajax.start();
|
};
|
|
/**
|
* 导出记录
|
*/
|
AaaTest.export = function () {
|
var phone = $("#phone").val();
|
window.location.href = Feng.ctxPath + "/aaaTest/export" +
|
"?phone=" + phone;
|
};
|
|
/**
|
* 跳转导入数据页面
|
*/
|
AaaTest.import = function() {
|
var index = layer.open({
|
type: 2,
|
title: '导入数据',
|
area: ['50%', '25%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/aaaTest/import'
|
});
|
this.layerIndex = index;
|
};
|
|
|
/**
|
* 查询示例功能列表
|
*/
|
AaaTest.search = function () {
|
var queryData = {};
|
queryData['phone'] = $("#phone").val();
|
queryData['isLock'] = $("#isLock").val();
|
queryData['beginTime'] = $("#beginTime").val();
|
queryData['endTime'] = $("#endTime").val();
|
AaaTest.table.refresh({query: queryData});
|
};
|
/**
|
* 重置查询条件
|
*/
|
AaaTest.resetSearch = function () {
|
$("#phone").val("");
|
$("#isLock").val("");
|
$("#beginTime").val("");
|
$("#endTime").val("");
|
AaaTest.search();
|
};
|
$(function () {
|
var defaultColunms = AaaTest.initColumn();
|
var table = new BSTable(AaaTest.id, "/aaaTest/list", defaultColunms);
|
// 设置物理分页server(逻辑分页client)
|
table.setPaginationType("server");
|
// 表单提交参数
|
var queryData = {};
|
queryData['phone'] = $("#phone").val();
|
queryData['isLock'] = $("#isLock").val();
|
queryData['beginTime'] = $("#beginTime").val();
|
queryData['endTime'] = $("#endTime").val();
|
table.setQueryParams(queryData);
|
AaaTest.table = table.init();
|
});
|