/**
|
* 用户信息管理初始化
|
*/
|
var TUser = {
|
id: "TUserTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
|
/**
|
* 初始化表格的列
|
*/
|
TUser.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: '昵称', field: 'nickName', visible: true, align: 'center', valign: 'middle'},
|
{title: '密码', field: 'password', visible: true, align: 'center', valign: 'middle'},
|
{title: '头像', field: 'avatar', visible: true, align: 'center', valign: 'middle'},
|
{title: '是否锁定', field: 'isLock', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
return Feng.getIsObjFormat(value);
|
}
|
},
|
{title: '是否删除', field: 'isDelete', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
return Feng.getIsObjFormat(value);
|
}
|
},
|
{title: '创建时间', field: 'createTime', visible: true, align: 'center', valign: 'middle'},
|
{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: 'opts', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
var opts = Feng.Opts();
|
if ($("#updateAuth").val() == 'true') {
|
opts.add("TUser.openTUserUpdate('"+row.id+"');", "编辑");
|
}
|
if ($("#deleteAuth").val() == 'true') {
|
opts.add("TUser.delete('"+row.id+"');", "删除");
|
}
|
if ($("#updateStateAuth").val() == 'true') {
|
opts.add("TUser.updateState('"+row.id+"');", "编辑状态");
|
}
|
return opts.getOpts();
|
}
|
}
|
];
|
};
|
|
/**
|
* 检查是否选中
|
*/
|
TUser.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length == 0){
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
}else{
|
TUser.seItem = selected[0];
|
return true;
|
}
|
};
|
|
/**
|
* 点击添加用户信息
|
*/
|
TUser.openTUserAdd = function () {
|
var index = layer.open({
|
type: 2,
|
title: '添加用户信息',
|
area: ['80%', '80%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tUser/tUser_add'
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 点击编辑用户信息
|
*/
|
TUser.openTUserUpdate = function (id) {
|
var index = layer.open({
|
type: 2,
|
title: '编辑用户信息',
|
area: ['80%', '80%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tUser/tUser_update/' + id
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 打开查看用户信息详情
|
*/
|
TUser.openTUserDetail = function (id) {
|
var index = layer.open({
|
type: 2,
|
title: '用户信息详情',
|
area: ['80%', '80%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tUser/detail/' + id
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 删除/批量删除用户信息
|
*/
|
TUser.delete = function(id){
|
var ids = id;
|
if(id == 0) {
|
// 如果id为0,则为批量删除
|
ids = Feng.checkBoxIds(TUser.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 + "/tUser/delete", function (data) {
|
// 关闭加载动画层
|
parent.layer.close(index);
|
Feng.success("删除成功!");
|
TUser.table.refresh();
|
}, function (data) {
|
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("ids", ids);
|
ajax.start();
|
};
|
Feng.confirm("是否删除所选中的数据?", operation);
|
}
|
};
|
|
/**
|
* 编辑用户信息状态
|
*/
|
TUser.updateState = function (id) {
|
var ajax = new $ax(Feng.ctxPath + "/tUser/updateState", function (data) {
|
if(data.code == 200){
|
Feng.success("操作成功!");
|
TUser.table.refresh();
|
} else {
|
Feng.error("操作失败!" + data.message);
|
}
|
}, function () {
|
Feng.error("操作失败!");
|
});
|
ajax.set("tUserId", id);
|
ajax.start();
|
};
|
|
/**
|
* 查询用户信息列表
|
*/
|
TUser.search = function () {
|
var queryData = {};
|
queryData['condition'] = $("#condition").val();
|
TUser.table.refresh({query: queryData});
|
};
|
/**
|
* 重置查询条件
|
*/
|
TUser.resetSearch = function () {
|
$("#condition").val("");
|
TUser.search();
|
};
|
$(function () {
|
var defaultColunms = TUser.initColumn();
|
var table = new BSTable(TUser.id, "/tUser/list", defaultColunms);
|
// 设置物理分页server(逻辑分页client)
|
table.setPaginationType("server");
|
// 表单提交参数
|
var queryData = {};
|
queryData['condition'] = $("#condition").val();
|
table.setQueryParams(queryData);
|
TUser.table = table.init();
|
});
|