|
|
$(function() {
|
|
|
//datagrid初始化
|
|
|
$('#dataList').datagrid({
|
|
|
title:'老师列表',
|
|
|
iconCls:'icon-more',//图标
|
|
|
border: true,
|
|
|
collapsible: false,//是否可折叠的
|
|
|
fit: true,//自动大小
|
|
|
method: "post",
|
|
|
url:"TeacherServlet?method=getUsersList&t="+new Date().getTime(),
|
|
|
idField:'id',
|
|
|
singleSelect: true,//是否单选
|
|
|
pagination: true,//分页控件
|
|
|
rownumbers: true,//行号
|
|
|
sortName: 'id',
|
|
|
sortOrder: 'DESC',
|
|
|
remoteSort: false,
|
|
|
columns: [[
|
|
|
{field:'chk',checkbox: true,width:50},
|
|
|
{field:'id',title:'ID',width:50, sortable: true},
|
|
|
{field:'name',title:'姓名',width:200},
|
|
|
{field:'identity',title:'政治面貌',width:100},
|
|
|
{field:'location',title:'所在学院',width:100},
|
|
|
{field:'major',title:'专业',width:100},
|
|
|
{field:'fenlei',title:'指导社团分类',width:100},
|
|
|
]],
|
|
|
toolbar: "#toolbar"
|
|
|
});
|
|
|
//设置分页控件
|
|
|
var p = $('#dataList').datagrid('getPager');
|
|
|
$(p).pagination({
|
|
|
pageSize: 10,//每页显示的记录条数,默认为10
|
|
|
pageList: [10,20,30,50,100],//可以设置每页记录条数的列表
|
|
|
beforePageText: '第',//页数文本框前显示的汉字
|
|
|
afterPageText: '页 共 {pages} 页',
|
|
|
displayMsg: '当前显示 {from} - {to} 条记录 共 {total} 条记录',
|
|
|
});
|
|
|
//设置工具类按钮
|
|
|
$("#add").click(function(){
|
|
|
$("#addDialog").dialog("open");
|
|
|
});
|
|
|
//删除
|
|
|
$("#delete").click(function(){
|
|
|
var selectRow = $("#dataList").datagrid("getSelected");
|
|
|
//console.log(selectRow);
|
|
|
if(selectRow == null){
|
|
|
$.messager.alert("消息提醒", "请选择数据进行删除!", "warning");
|
|
|
} else{
|
|
|
var Usersid = selectRow.id;
|
|
|
$.messager.confirm("消息提醒", "将删除用户信息,确认继续?", function(r){
|
|
|
if(r){
|
|
|
$.ajax({
|
|
|
type: "post",
|
|
|
url: "TeacherServlet?method=DeleteUsers",
|
|
|
data: {Usersid: Usersid},
|
|
|
success: function(msg){
|
|
|
if(msg == "success"){
|
|
|
$.messager.alert("消息提醒","删除成功!","info");
|
|
|
//刷新表格
|
|
|
$("#dataList").datagrid("reload");
|
|
|
} else{
|
|
|
$.messager.alert("消息提醒","删除失败!","warning");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//设置添加用户窗口
|
|
|
$("#addDialog").dialog({
|
|
|
title: "添加用户",
|
|
|
width: 500,
|
|
|
height: 400,
|
|
|
iconCls: "icon-add",
|
|
|
modal: true,
|
|
|
collapsible: false,
|
|
|
minimizable: false,
|
|
|
maximizable: false,
|
|
|
draggable: true,
|
|
|
closed: true,
|
|
|
buttons: [
|
|
|
{
|
|
|
text:'添加',
|
|
|
plain: true,
|
|
|
iconCls:'icon-add',
|
|
|
handler:function(){
|
|
|
var validate = $("#addForm").form("validate");
|
|
|
if(!validate){
|
|
|
$.messager.alert("消息提醒","请检查你输入的数据!","warning");
|
|
|
return;
|
|
|
} else{
|
|
|
//var gradeid = $("#add_gradeList").combobox("getValue");
|
|
|
$.ajax({
|
|
|
type: "post",
|
|
|
url: "TeacherServlet?method=AddUsers",
|
|
|
//data: $("#addForm").serialize(),
|
|
|
data:{
|
|
|
name:$('#add_name').val(),
|
|
|
sex:$('#sex').val(),
|
|
|
identity:$('#identity').val(),
|
|
|
location:$('#location').val(),
|
|
|
major:$('#major').val(),
|
|
|
fenlei:$('#fenlei').val(),
|
|
|
|
|
|
|
|
|
id:$('#edit-id').val()
|
|
|
},
|
|
|
success: function(msg){
|
|
|
if(msg == "success"){
|
|
|
$.messager.alert("消息提醒","添加成功!","info");
|
|
|
//关闭窗口
|
|
|
$("#addDialog").dialog("close");
|
|
|
//清空原表格数据
|
|
|
$("#add_name").textbox('setValue', "");
|
|
|
$("#add_sex").textbox('setValue', "");
|
|
|
$("#add_identity").textbox('setValue', "");
|
|
|
$("#add_identity").textbox('setValue', "");
|
|
|
$("#add_location").textbox('setValue', "");
|
|
|
$("#add_major").textbox('setValue', "");
|
|
|
$("#add_fenlei").textbox('setValue', "");
|
|
|
|
|
|
|
|
|
//重新刷新页面数据
|
|
|
//$('#gradeList').combobox("setValue", gradeid);
|
|
|
$('#dataList').datagrid("reload");
|
|
|
|
|
|
} else{
|
|
|
$.messager.alert("消息提醒","添加失败!","warning");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
text:'重置',
|
|
|
plain: true,
|
|
|
iconCls:'icon-reload',
|
|
|
handler:function(){
|
|
|
$("#add_name").textbox('setValue', "");
|
|
|
//重新加载年级
|
|
|
$("#info").val("");
|
|
|
}
|
|
|
},
|
|
|
]
|
|
|
});
|
|
|
|
|
|
|
|
|
//搜索按钮监听事件
|
|
|
$("#search-btn").click(function(){
|
|
|
$('#dataList').datagrid('load',{
|
|
|
UsersName: $('#UsersName').val()
|
|
|
});
|
|
|
});
|
|
|
//角色下拉框
|
|
|
$("#add_rolename").combobox({
|
|
|
url: "RoleServlet?method=getRoleList&t="+new Date().getTime()+"&from=combox",
|
|
|
valueField: "id",
|
|
|
textField: "rolename",
|
|
|
onLoadSuccess: function(){
|
|
|
//默认选择第一条数据
|
|
|
var data = $(this).combobox("getData");;
|
|
|
$(this).combobox("setValue", data[0].id);
|
|
|
}
|
|
|
});
|
|
|
//角色下拉框
|
|
|
$("#edit_rolename").combobox({
|
|
|
url: "RoleServlet?method=getRoleList&t="+new Date().getTime()+"&from=combox",
|
|
|
valueField: "id",
|
|
|
textField: "rolename",
|
|
|
onLoadSuccess: function(){
|
|
|
//默认选择第一条数据
|
|
|
var data = $(this).combobox("getData");;
|
|
|
$(this).combobox("setValue", data[0].id);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
//修改按钮监听事件
|
|
|
$("#edit-btn").click(function(){
|
|
|
var selectRow = $("#dataList").datagrid("getSelected");
|
|
|
//console.log(selectRow);
|
|
|
if(selectRow == null){
|
|
|
$.messager.alert("消息提醒", "请选择数据进行修改!", "warning");
|
|
|
return;
|
|
|
}
|
|
|
$("#editDialog").dialog("open");
|
|
|
});
|
|
|
|
|
|
//设置编辑用户窗口
|
|
|
$("#editDialog").dialog({
|
|
|
title: "编辑用户",
|
|
|
width: 500,
|
|
|
height: 400,
|
|
|
iconCls: "icon-add",
|
|
|
modal: true,
|
|
|
collapsible: false,
|
|
|
minimizable: false,
|
|
|
maximizable: false,
|
|
|
draggable: true,
|
|
|
closed: true,
|
|
|
buttons: [
|
|
|
{
|
|
|
text:'确定修改',
|
|
|
plain: true,
|
|
|
iconCls:'icon-add',
|
|
|
handler:function(){
|
|
|
var validate = $("#editForm").form("validate");
|
|
|
if(!validate){
|
|
|
$.messager.alert("消息提醒","请检查你输入的数据!","warning");
|
|
|
return;
|
|
|
} else{
|
|
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
type: "post",
|
|
|
url: "TeacherServlet?method=EditUsers",
|
|
|
//data: $("#editForm").serialize(),
|
|
|
data:{
|
|
|
|
|
|
name:$('#add_name').val(),
|
|
|
sex:$('#sex').val(),
|
|
|
identity:$('#identity').val(),
|
|
|
location:$('#location').val(),
|
|
|
major:$('#major').val(),
|
|
|
fenlei:$('#fenlei').val(),
|
|
|
id:$('#edit-id').val()
|
|
|
},
|
|
|
success: function(msg){
|
|
|
if(msg == "success"){
|
|
|
$.messager.alert("消息提醒","修改成功!","info");
|
|
|
//关闭窗口
|
|
|
$("#editDialog").dialog("close");
|
|
|
//清空原表格数据
|
|
|
$("#edit_name").textbox('setValue', "");
|
|
|
$("#edit_sex").textbox('setValue', "");
|
|
|
$("#edit_identity").textbox('setValue', "");
|
|
|
$("#edit_location").textbox('setValue', "");
|
|
|
$("#edit_major").textbox('setValue', "");
|
|
|
$("#edit_fenlei").textbox('setValue', "");
|
|
|
|
|
|
|
|
|
//重新刷新页面数据
|
|
|
//$('#gradeList').combobox("setValue", gradeid);
|
|
|
$('#dataList').datagrid("reload");
|
|
|
|
|
|
} else{
|
|
|
$.messager.alert("消息提醒","修改失败!","warning");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
text:'重置',
|
|
|
plain: true,
|
|
|
iconCls:'icon-reload',
|
|
|
handler:function(){
|
|
|
$("#edit_name").textbox('setValue', "");
|
|
|
//重新加载年级
|
|
|
$("#edit_info").val("");
|
|
|
}
|
|
|
},
|
|
|
],
|
|
|
onBeforeOpen: function(){
|
|
|
var selectRow = $("#dataList").datagrid("getSelected");
|
|
|
//console.log(selectRow);
|
|
|
//设置值
|
|
|
|
|
|
$("#edit_name").textbox('setValue', "");
|
|
|
$("#edit_sex").textbox('setValue', "");
|
|
|
$("#edit_identity").textbox('setValue', "");
|
|
|
$("#edit_location").textbox('setValue', "");
|
|
|
$("#edit_major").textbox('setValue', "");
|
|
|
$("#edit_fenlei").textbox('setValue', "");
|
|
|
////
|
|
|
$("#edit_name").textbox('setValue',selectRow.name);
|
|
|
|
|
|
$("#edit_sex").textbox('setValue',selectRow.sex);
|
|
|
$("#edit_identity").textbox('setValue',selectRow.identity);
|
|
|
$("#edit_location").textbox('setValue',selectRow.location);
|
|
|
$("#edit_major").textbox('setValue',selectRow.major);
|
|
|
$("#edit_fenlei").textbox('setValue',selectRow.fenlei);
|
|
|
|
|
|
|
|
|
|
|
|
$('#edit_rolename').combobox("setValue", selectRow.roleid);
|
|
|
|
|
|
$("#edit-id").val(selectRow.id);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
}); |