var Person = {
id: "table", //表格id
seItem: null, //选中的条目
table: null,
layerIndex: -1
};
Person.initColumn = function () {
return [
{field: 'selectItem', radio: true},
{title: 'id', field: 'id', visible: false, align: 'center', valign: 'middle'},
{title: '用户名/账号', field: 'username', align: 'center', width: 120, valign: 'middle', 'class': 'uitd_showTip'},
{title: '姓名', field: 'name', align: 'center', width: 120, valign: 'middle', 'class': 'uitd_showTip'},
{title: '性别', field: 'sex', align: 'center', width: 120, valign: 'middle', 'class': 'uitd_showTip',
formatter: function (value, row, index) {
if (value == null || value == '') {
return "";
} else if (value == 1) {
return "男";
} else if (value == 2) {
return "女";
} else {
return "";
}
}
},
{title: '证件号码', field: 'idCard', align: 'center', width: 120, valign: 'middle', 'class': 'uitd_showTip'},
{title: '电话号码', field: 'phone', align: 'center', width: 120, valign: 'middle', 'class': 'uitd_showTip'},
{title: '联系地址', field: 'address', align: 'center', width: 120, valign: 'middle', 'class': 'uitd_showTip'},
{title: '账号状态', field: 'active', align: 'center', width: 120, valign: 'middle', 'class': 'uitd_showTip',
formatter: function (value, row, index) {
if (value == null || value == '') {
return "";
} else if (value == 1) {
return "账号有效";
} else if (value == 2) {
return "被冻结/拉黑";
} else {
return "";
}
},
cellStyle: function (value, row, index) {
if (value == null || value == '') {
return {css: {}};
} else if (value == 1) {
return {css: {'background-color': 'LightGreen'}};
} else if (value == 2) {
return {css: {"background-color": "Orange"}};
} else {
return {css: {}};
}
}
},
{title: '注册时间', field: 'createTime', align: 'center', width: 120, valign: 'middle', 'class': 'uitd_showTip'}
];
};
Person.search = function () {
var queryData = {};
queryData['username'] = $("#username").val();
queryData['name'] = $("#name").val();
queryData['sex'] = $("#sex").val();
queryData['idCard'] = $("#idCard").val();
queryData['phone'] = $("#phone").val();
Person.table.refresh({"query": queryData});
};
Person.reset = function () {
$("#username").val("");
$("#name").val("");
$("#sex").val("");
$("#idCard").val("");
$("#phone").val("");
};
Person.check = function () {
var selected = $('#' + Person.id).bootstrapTable('getSelections');
if (selected.length == 0) {
Feng.info("请先选中表格中的某一记录!");
return false;
} else {
Person.seItem = selected[0];
return true;
}
};
Person.gotoPersonDetailPage = function () {
if (!Person.check()) {
return;
}
var index = layer.open({
type: 2,
title: '查看详情',
area: ['830px', '450px'], //宽高
fix: false, //不固定
maxmin: true,
content: Feng.ctxPath + '/admin/person/detail/id/' + Person.seItem.id,
btn: [' 关闭'],
yes: function (index, layero) {
layer.close(index);
}
});
layer.full(index);
Person.layerIndex = index;
};
Person.setActive = function () {
if (!Person.check()) {
return;
}
var index = layer.open({
type: 2,
title: '设置冻结',
area: ['830px', '580px'], //宽高
fix: false, //不固定
maxmin: true,
content: Feng.ctxPath + '/admin/person/setActive/id/' + Person.seItem.id,
btn: [' 确定', ' 取消'],
yes: function (index, layero) {
//按钮【按钮一】的回调
var iframeWin = window[layero.find('iframe')[0]['name']];
iframeWin.PsActive.addSubmit();
}
});
// layer.full(index);
this.layerIndex = index;
};
Person.resetPassword = function () {
if (!Person.check()) {
return;
}
Feng.confirm(
"确定要重置吗?",
function () {
var ajax = new $ax(Feng.ctxPath + "/admin/person/resetPassword/id/" + Person.seItem.id, function (data) {
Feng.info(data.msg);
if (data.code == 200) {
Person.table.refresh();
}
}, function (data) {
Feng.error("操作失败!");
});
ajax.set(null);
ajax.start();
}
);
};
$(function () {
var defaultColunms = Person.initColumn();
var table = new BSTable(Person.id, "/admin/person/list", defaultColunms);
table.setPaginationType("server");
Person.table = table.init();
});