Commit a4db626d by fsn

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

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