Commit a4db626d by fsn

更新判断表格中是否选中条目的机制

parent afc2e240
......@@ -23,22 +23,15 @@ Dept.initColumn = function () {
};
/**
* 绑定表格的事件
*/
Dept.bindEvent = function () {
$('#' + this.id).on('click-row.bs.table', function (e, row) {
Dept.seItem = row;
});
};
/**
* 检查是否选中
*/
Dept.check = function () {
if (this.seItem == null) {
var selected = $('#' + this.id).bootstrapTable('getSelections');
if(selected.length == 0){
Feng.info("请先选中表格中的某一记录!");
return false;
} else {
}else{
Dept.seItem = selected[0];
return true;
}
};
......@@ -95,9 +88,7 @@ Dept.delete = function () {
*/
Dept.search = function () {
var queryData = {};
queryData['condition'] = $("#condition").val();
Dept.table.refresh({query: queryData});
};
......@@ -106,5 +97,4 @@ $(function () {
var table = new BSTable(Dept.id, "/dept/list", defaultColunms);
table.setPaginationType("client");
Dept.table = table.init();
Dept.bindEvent();
});
......@@ -25,22 +25,15 @@ OptLog.initColumn = function () {
};
/**
* 绑定表格的事件
*/
OptLog.bindEvent = function () {
$('#' + this.id).on('click-row.bs.table', function (e, row) {
OptLog.seItem = row;
});
};
/**
* 检查是否选中
*/
OptLog.check = function () {
if (this.seItem == null) {
var selected = $('#' + this.id).bootstrapTable('getSelections');
if(selected.length == 0){
Feng.info("请先选中表格中的某一记录!");
return false;
} else {
}else{
OptLog.seItem = selected[0];
return true;
}
};
......@@ -88,5 +81,4 @@ $(function () {
var table = new BSTable(OptLog.id, "/log/list", defaultColunms);
table.setPaginationType("server");
OptLog.table = table.init();
OptLog.bindEvent();
});
......@@ -25,23 +25,17 @@ Menu.initColumn = function () {
return columns;
};
/**
* 绑定表格的事件
*/
Menu.bindEvent = function () {
$('#' + this.id).on('click-row.bs.table', function (e, row, $element) {
Menu.seItem = row;
});
};
/**
* 检查是否选中
*/
Menu.check = function () {
if (this.seItem == null) {
var selected = $('#' + this.id).bootstrapTable('getSelections');
if (selected.length == 0) {
Feng.info("请先选中表格中的某一记录!");
return false;
} else {
Menu.seItem = selected[0];
return true;
}
};
......@@ -110,6 +104,5 @@ $(function () {
var table = new BSTable(Menu.id, "/menu/list", defaultColunms);
table.setPaginationType("client");
table.init();
Menu.bindEvent();
Menu.table = table;
});
......@@ -2,125 +2,118 @@
* 角色管理的单例
*/
var Role = {
id : "roleTable", //表格id
seItem : null, //选中的条目
table : null,
layerIndex : -1
id: "roleTable", //表格id
seItem: null, //选中的条目
table: null,
layerIndex: -1
};
/**
* 初始化表格的列
*/
Role.initColumn = function(){
var columns = [
{field: 'selectItem',radio:true},
{title: 'id',field: 'id', visible: false, align: 'center',valign: 'middle'},
{title: '名称',field: 'name',align: 'center',valign: 'middle'},
{title: '上级角色',field: 'pName',align: 'center',valign: 'middle'},
{title: '所在部门',field: 'deptName',align: 'center',valign: 'middle'},
{title: '别名',field: 'tips',align: 'center',valign: 'middle'}]
return columns;
Role.initColumn = function () {
var columns = [
{field: 'selectItem', radio: true},
{title: 'id', field: 'id', visible: false, align: 'center', valign: 'middle'},
{title: '名称', field: 'name', align: 'center', valign: 'middle'},
{title: '上级角色', field: 'pName', align: 'center', valign: 'middle'},
{title: '所在部门', field: 'deptName', align: 'center', valign: 'middle'},
{title: '别名', field: 'tips', align: 'center', valign: 'middle'}]
return columns;
};
/**
* 绑定表格的事件
*/
Role.bindEvent = function(){
$('#' + this.id).on('click-row.bs.table', function(e, row, $element) {
Role.seItem = row;
});
};
/**
* 检查是否选中
*/
Role.check = function(){
if(this.seItem == null){
Feng.info("请先选中表格中的某一记录!");
return false;
}else{
return true;
}
Role.check = function () {
var selected = $('#' + this.id).bootstrapTable('getSelections');
if (selected.length == 0) {
Feng.info("请先选中表格中的某一记录!");
return false;
} else {
Role.seItem = selected[0];
return true;
}
};
/**
* 点击添加管理员
*/
Role.openAddRole = function(){
var index = layer.open({
type: 2,
title: '添加角色',
area: ['800px', '450px'], //宽高
fix: false, //不固定
maxmin: true,
content :Feng.ctxPath + '/role/role_add'
});
this.layerIndex = index;
Role.openAddRole = function () {
var index = layer.open({
type: 2,
title: '添加角色',
area: ['800px', '450px'], //宽高
fix: false, //不固定
maxmin: true,
content: Feng.ctxPath + '/role/role_add'
});
this.layerIndex = index;
};
/**
* 点击修改按钮时
*/
Role.openChangeRole = function(){
if(this.check()){
var index = layer.open({
type: 2,
title: '修改角色',
area: ['800px', '450px'], //宽高
fix: false, //不固定
maxmin: true,
content :Feng.ctxPath + '/role/role_edit/' + this.seItem.id
});
this.layerIndex = index;
}
Role.openChangeRole = function () {
if (this.check()) {
var index = layer.open({
type: 2,
title: '修改角色',
area: ['800px', '450px'], //宽高
fix: false, //不固定
maxmin: true,
content: Feng.ctxPath + '/role/role_edit/' + this.seItem.id
});
this.layerIndex = index;
}
};
/**
* 删除角色
*/
Role.delRole = function(){
if(this.check()){
var ajax = new $ax(Feng.ctxPath + "/role/remove/" + this.seItem.id, function(data){
Feng.success("删除成功!");
Role.table.refresh();
},function(data){
Feng.error("删除失败!");
});
ajax.start();
}
Role.delRole = function () {
if (this.check()) {
var ajax = new $ax(Feng.ctxPath + "/role/remove/" + this.seItem.id, function (data) {
Feng.success("删除成功!");
Role.table.refresh();
}, function (data) {
Feng.error("删除失败!");
});
ajax.start();
}
};
/**
* 权限配置
*/
Role.assign = function(){
if(this.check()){
var index = layer.open({
type: 2,
title: '权限配置',
area: ['300px', '450px'], //宽高
fix: false, //不固定
maxmin: true,
content :Feng.ctxPath + '/role/role_assign/' + this.seItem.id
});
this.layerIndex = index;
}
Role.assign = function () {
if (this.check()) {
var index = layer.open({
type: 2,
title: '权限配置',
area: ['300px', '450px'], //宽高
fix: false, //不固定
maxmin: true,
content: Feng.ctxPath + '/role/role_assign/' + this.seItem.id
});
this.layerIndex = index;
}
};
/**
* 搜索角色
*/
Role.search = function(){
Role.search = function () {
var queryData = {};
queryData['roleName'] = $("#roleName").val();
Role.table.refresh({query: queryData});
}
$(function(){
var defaultColunms = Role.initColumn();
var table = new BSTable(Role.id,"/role/list",defaultColunms);
table.setPaginationType("client");
table.init();
Role.bindEvent();
Role.table = table;
$(function () {
var defaultColunms = Role.initColumn();
var table = new BSTable(Role.id, "/role/list", defaultColunms);
table.setPaginationType("client");
table.init();
Role.table = table;
});
......@@ -28,22 +28,15 @@ MgrUser.initColumn = function () {
};
/**
* 绑定表格的事件
*/
MgrUser.bindEvent = function () {
$('#' + this.id).on('click-row.bs.table', function (e, row, $element) {
MgrUser.seItem = row;
});
};
/**
* 检查是否选中
*/
MgrUser.check = function () {
if (this.seItem == null) {
var selected = $('#' + this.id).bootstrapTable('getSelections');
if (selected.length == 0) {
Feng.info("请先选中表格中的某一记录!");
return false;
} else {
MgrUser.seItem = selected[0];
return true;
}
};
......@@ -184,5 +177,4 @@ $(function () {
var table = new BSTable("managerTable", "/mgr/list", defaultColunms);
table.setPaginationType("client");
MgrUser.table = table.init();
MgrUser.bindEvent();
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment