You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
445 lines
19 KiB
445 lines
19 KiB
3 months ago
|
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="User.aspx.cs" Inherits="MESWebSite.Manage.User" %>
|
||
|
|
||
|
<!DOCTYPE html>
|
||
|
|
||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
|
<head runat="server">
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
|
<link href="/CSS/Basics.css" rel="stylesheet" />
|
||
|
<link href="/Scripts/jquery-easyui-1.4.3/themes/metro/easyui.css" rel="stylesheet" type="text/css" />
|
||
|
<link href="/Scripts/jquery-easyui-1.4.3/themes/icon.css" rel="stylesheet" type="text/css" />
|
||
|
<link href="/Scripts/jquery-easyui-1.4.3/themes/color.css" rel="stylesheet" type="text/css" />
|
||
|
<script src="/Scripts/jquery-easyui-1.4.3/jquery.min.js" type="text/javascript"></script>
|
||
|
<script src="/Scripts/jquery-easyui-1.4.3/jquery.easyui.min.js" type="text/javascript"></script>
|
||
|
<script src="/Scripts/jquery-easyui-1.4.3/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
|
||
|
<script src="/Scripts/MyJs.js" type="text/javascript"></script>
|
||
|
<title>用户管理</title>
|
||
|
<style>
|
||
|
#w td {
|
||
|
padding: 5px 5px;
|
||
|
text-align: left;
|
||
|
vertical-align: middle;
|
||
|
}
|
||
|
|
||
|
#w .title {
|
||
|
vertical-align: middle;
|
||
|
text-align: right;
|
||
|
width: 80px;
|
||
|
height: 40px;
|
||
|
}
|
||
|
|
||
|
p {
|
||
|
padding: 5px;
|
||
|
font-size: small;
|
||
|
font-family: 微软雅黑;
|
||
|
}
|
||
|
|
||
|
.datagrid {
|
||
|
text-align: center;
|
||
|
}
|
||
|
</style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<form id="form1" runat="server">
|
||
|
<div class="top">
|
||
|
<table style="width: 100%">
|
||
|
<tr style="display: flex;flex-direction: row; flex-wrap: wrap;">
|
||
|
|
||
|
<td><span class="title">用户档案</span>
|
||
|
</td>
|
||
|
<td></td>
|
||
|
<td style="width: 230px;">用户名:
|
||
|
<input type="text" id="SearchVaule" style="width: 140px;" /></td>
|
||
|
<td style="width: 80px;"><a class="topsearchBtn">查询</a></td>
|
||
|
<td style="width: 80px">
|
||
|
<a class="topaddBtn">新增</a>
|
||
|
</td>
|
||
|
<td style="width: 80px">
|
||
|
<a class="toppenBtn">编辑</a>
|
||
|
</td>
|
||
|
<td style="width: 85px">
|
||
|
<a class="topdelBtn">删除</a>
|
||
|
</td>
|
||
|
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
<table id="tb" title="用户列表" style="width: 99%;">
|
||
|
</table>
|
||
|
<!-- 编辑窗口 -->
|
||
|
<div id="w" style="padding: 10px; visibility: hidden;" title="编辑">
|
||
|
<table>
|
||
|
<tr>
|
||
|
<td>
|
||
|
<table cellpadding="0" cellspacing="0">
|
||
|
<tr>
|
||
|
<td class="title" style="width: 110px;">
|
||
|
<p>
|
||
|
用户名:
|
||
|
</p>
|
||
|
</td>
|
||
|
<td colspan="2">
|
||
|
<input id="UserName" type="text" class="text" style="width: 230px; height: 30px;" /><span style="color: red; font-size: 18px; vertical-align: middle;">*</span>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td class="title">
|
||
|
<p>
|
||
|
密码:
|
||
|
</p>
|
||
|
</td>
|
||
|
<td colspan="2">
|
||
|
<input id="Password" type="text" class="text" style="width: 230px; height: 30px;" /><span style="color: red; font-size: 18px; vertical-align: middle;">*</span>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td class="title" style="width: 110px;">
|
||
|
<p>
|
||
|
真实姓名:
|
||
|
</p>
|
||
|
</td>
|
||
|
<td colspan="2">
|
||
|
<input id="RealName" type="text" class="text" style="width: 230px; height: 30px;" /><span style="color: red; font-size: 18px; vertical-align: middle;">*</span>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td class="title" style="width: 110px;">
|
||
|
<p>
|
||
|
性别:
|
||
|
</p>
|
||
|
</td>
|
||
|
<td colspan="2">
|
||
|
<label>
|
||
|
<input id="Sex1" type="radio" name="sex" value="1" class="text" />男</label>
|
||
|
<label>
|
||
|
<input id="Sex2" type="radio" name="sex" value="2" class="text" />女</label>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td class="title" style="width: 110px;">
|
||
|
<p>
|
||
|
电话:
|
||
|
</p>
|
||
|
</td>
|
||
|
<td colspan="2">
|
||
|
<input id="Tel" type="text" class="text" style="width: 230px; height: 30px;" /><span style="color: red; font-size: 18px; vertical-align: middle;">*</span>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td class="title" style="width: 110px;">
|
||
|
<p>
|
||
|
部门:
|
||
|
</p>
|
||
|
</td>
|
||
|
<td colspan="2">
|
||
|
<input id="Department" type="text" class="easyui-combobox" style="width: 230px;"
|
||
|
data-options="valueField: 'GUID',textField: 'DeptName', url: '/HttpHandlers/DeptHandler.ashx?method=QueryForCombobox'">
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td class="title" style="width: 110px;">
|
||
|
<p>
|
||
|
启用:
|
||
|
</p>
|
||
|
</td>
|
||
|
<td colspan="2">
|
||
|
<input id="IsEnabled" type="checkbox" checked="checked" class="text" />
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</td>
|
||
|
<td style="vertical-align: top; padding-top: 20px">
|
||
|
<ul id="menuTree" class="easyui-tree" data-options="checkbox:true, url: '/HttpHandlers/UserHandler.ashx?method=QueryMenuTree'"></ul>
|
||
|
</td>
|
||
|
|
||
|
</tr>
|
||
|
|
||
|
</table>
|
||
|
|
||
|
</div>
|
||
|
<!-- 编辑窗口 - footer -->
|
||
|
<div id="ft" style="padding: 10px; text-align: center; background-color: #f9f9f9; visibility: hidden">
|
||
|
<a class="saveBtn" id="saveBtn">保存</a>
|
||
|
</div>
|
||
|
|
||
|
<input id="UserID" type="text" hidden="hidden" runat="server" />
|
||
|
<script>
|
||
|
|
||
|
/**************** 全局变量 ***************/
|
||
|
var PrimaryID; //要编辑的id
|
||
|
var dg = $('#tb'); //表格
|
||
|
var isEdit = false; //是否为编辑状态
|
||
|
|
||
|
/**************** DOM加载 ***************/
|
||
|
$(function () {
|
||
|
$.ajaxSetup({
|
||
|
cache: false //关闭AJAX缓存
|
||
|
});
|
||
|
//搜索按钮
|
||
|
$('.topsearchBtn').first().click(function () {
|
||
|
SearchInfo();
|
||
|
});
|
||
|
|
||
|
//新增按钮点击
|
||
|
$('.topaddBtn').first().click(function () {
|
||
|
isEdit = false;
|
||
|
clearw();
|
||
|
getMenuTree('');
|
||
|
$('#w').window('open');
|
||
|
});
|
||
|
|
||
|
//编辑按钮点击
|
||
|
$('.toppenBtn').first().click(function () {
|
||
|
isEdit = true;
|
||
|
initEidtWidget();
|
||
|
});
|
||
|
|
||
|
//删除按钮
|
||
|
$('.topdelBtn').first().click(function () {
|
||
|
$.messager.confirm('提示框', '你确定要删除吗?', function (r) {
|
||
|
if (r) {
|
||
|
deleteInfos();
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
|
||
|
//保存按钮
|
||
|
$('#saveBtn').bind('click', function () {
|
||
|
SaveInfo(isEdit);
|
||
|
});
|
||
|
|
||
|
//编辑窗口加载
|
||
|
$('#w').window({
|
||
|
modal: true,
|
||
|
closed: true,
|
||
|
minimizable: false,
|
||
|
maximizable: false,
|
||
|
collapsible: false,
|
||
|
width: 700,
|
||
|
height: 560,
|
||
|
footer: '#ft',
|
||
|
top: 20,
|
||
|
onBeforeClose: function () { clearw(); },
|
||
|
onBeforeOpen: function () {
|
||
|
$('#w').css('visibility', 'visible'); $('#ft').css('visibility', 'visible');
|
||
|
}
|
||
|
|
||
|
});
|
||
|
|
||
|
dg = $('#tb').datagrid({
|
||
|
fitColumns: true,
|
||
|
nowrap: false,
|
||
|
striped: true,
|
||
|
collapsible: false,
|
||
|
url: "/HttpHandlers/UserHandler.ashx?method=QueryList",
|
||
|
//sortName: 'sortNumber',
|
||
|
//sortOrder: 'asc'
|
||
|
columns: [[
|
||
|
{ field: 'UserID', title: 'UserID', hidden: true },
|
||
|
{ field: 'UserName', title: '用户名', width: 100 },
|
||
|
{ field: 'Password', title: '密码', width: 100, hidden: true },
|
||
|
{ field: 'RealName', title: '真实姓名', width: 100 },
|
||
|
{ field: 'SexText', title: '性别', width: 100 },
|
||
|
{ field: 'Tel', title: '电话', width: 100 },
|
||
|
{ field: 'Department', title: '部门', width: 150 },
|
||
|
{ field: 'DepartmentID', title: '部门ID', width: 150, hidden: true },
|
||
|
{ field: 'IsEnabledText', title: '启用', width: 100 }
|
||
|
]],
|
||
|
|
||
|
pagination: true,//表示在datagrid设置分页
|
||
|
rownumbers: true,
|
||
|
singleSelect: true
|
||
|
});
|
||
|
|
||
|
dg.datagrid('getPager').pagination({
|
||
|
pageSize: 10,
|
||
|
pageNumber: 1,
|
||
|
pageList: [10, 20, 30, 40, 50],
|
||
|
beforePageText: '第',//页数文本框前显示的汉字
|
||
|
afterPageText: '页 共 {pages} 页',
|
||
|
displayMsg: '当前显示 {from} - {to} 条记录 共 {total} 条记录',
|
||
|
});
|
||
|
});
|
||
|
|
||
|
/**************** 主要业务程序 ***************/
|
||
|
//新增 / 编辑
|
||
|
function SaveInfo(isEdit) {
|
||
|
|
||
|
var ID = isEdit == true ? PrimaryID : '';
|
||
|
var UserName = $('#UserName').val();
|
||
|
var Password = $('#Password').val();
|
||
|
var RealName = $('#RealName').val();
|
||
|
var Sex = $('input:radio[name="sex"]:checked').val();
|
||
|
var Tel = $('#Tel').val();
|
||
|
var Department = $("#Department").combobox('getText');
|
||
|
var DepartmentID = $('#Department').combo('getValue');
|
||
|
var IsEnabled = $('#IsEnabled').prop("checked") == true ? '1' : '0';
|
||
|
|
||
|
var nodes = $("#menuTree").tree('getChecked');
|
||
|
var mlist = '';
|
||
|
for (i = 0; i < nodes.length; i++) {
|
||
|
mlist += '<item><id>' + nodes[i].id + '</id></item>';
|
||
|
}
|
||
|
alert(mlist);
|
||
|
mlist = escape('<root>' + mlist + '</root>');
|
||
|
|
||
|
if (UserName == "") {
|
||
|
$.messager.alert('提示', '用户名不能为空,请重新输入', 'warning');
|
||
|
return;
|
||
|
}
|
||
|
if (Password == "") {
|
||
|
$.messager.alert('提示', '密码不能为空,请重新输入', 'warning');
|
||
|
return;
|
||
|
}
|
||
|
if (RealName == "") {
|
||
|
$.messager.alert('提示', '真实姓名不能为空,请重新输入', 'warning');
|
||
|
return;
|
||
|
}
|
||
|
if (Tel == "") {
|
||
|
$.messager.alert('提示', '电话不能为空,请重新输入', 'warning');
|
||
|
return;
|
||
|
}
|
||
|
if (Department == "") {
|
||
|
$.messager.alert('提示', '部门不能为空,请重新输入', 'warning');
|
||
|
return;
|
||
|
}
|
||
|
var model = {
|
||
|
ID: ID,
|
||
|
UserName: UserName,
|
||
|
Password: Password,
|
||
|
RealName: RealName,
|
||
|
Sex: Sex,
|
||
|
Tel: Tel,
|
||
|
Department: Department,
|
||
|
DepartmentID: DepartmentID,
|
||
|
IsEnabled: IsEnabled,
|
||
|
MenuList: mlist,
|
||
|
method: 'SaveInfo'
|
||
|
};
|
||
|
SaveModel(model);
|
||
|
}
|
||
|
function SaveModel(model) {
|
||
|
$.ajax({
|
||
|
type: "POST",
|
||
|
async: false,
|
||
|
url: "/HttpHandlers/UserHandler.ashx",
|
||
|
data: model,
|
||
|
success: function (data) {
|
||
|
if (data == 'true') {
|
||
|
$.messager.alert('提示', '已保存', 'info');
|
||
|
dg.datagrid('reload');
|
||
|
$('#w').window('close');
|
||
|
}
|
||
|
else {
|
||
|
$.messager.alert('提示', data, 'warning');
|
||
|
}
|
||
|
},
|
||
|
error: function () {
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
//查询方法
|
||
|
function SearchInfo() {
|
||
|
var parm_UserName = $('#SearchVaule').val();
|
||
|
var queryParams = {
|
||
|
UserName: parm_UserName
|
||
|
};
|
||
|
dg.datagrid({
|
||
|
queryParams: queryParams
|
||
|
});
|
||
|
dg.datagrid('reload');
|
||
|
}
|
||
|
//编辑时加载窗体数据
|
||
|
function initEidtWidget() {
|
||
|
var selRows = dg.datagrid('getSelections');
|
||
|
if (selRows.length > 1) {
|
||
|
$.messager.alert('提示', '每次只能编辑一条记录,请重新选取', 'warning');
|
||
|
return;
|
||
|
} else if (selRows.length == 0) {
|
||
|
$.messager.alert('提示', '请选择一条记录进行编辑', 'warning');
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
//窗体数据初始化
|
||
|
var row = selRows[0];
|
||
|
PrimaryID = row.UserID;
|
||
|
$('#UserName').val(row.UserName);
|
||
|
$('#Password').val(row.Password);
|
||
|
$('#RealName').val(row.RealName);
|
||
|
if (row.Sex == "1")
|
||
|
$("#Sex1").prop("checked", true);
|
||
|
else
|
||
|
$("#Sex2").prop("checked", true);
|
||
|
$('#Tel').val(row.Tel);
|
||
|
|
||
|
$('#Department').combobox('select', row.DepartmentID);
|
||
|
|
||
|
if (row.IsEnabled == "1")
|
||
|
$('#IsEnabled').prop("checked", true);
|
||
|
else
|
||
|
$('#IsEnabled').prop("checked", false);
|
||
|
getMenuTree(row.UserID);
|
||
|
$('#w').window('open');
|
||
|
}
|
||
|
//获得菜单树
|
||
|
function getMenuTree(UserID) {
|
||
|
if (UserID == "")
|
||
|
$("#menuTree").tree({ queryParams: {} }).tree('reload');
|
||
|
else
|
||
|
$("#menuTree").tree({ queryParams: { UserID: UserID } }).tree('reload');
|
||
|
}
|
||
|
//删除方法
|
||
|
function deleteInfos() {
|
||
|
var selRows = dg.datagrid('getSelections');
|
||
|
if (selRows.length > 1) {
|
||
|
$.messager.alert('提示', '每次只能删除一条记录,请重新选取', 'warning');
|
||
|
return;
|
||
|
} else if (selRows.length == 0) {
|
||
|
$.messager.alert('提示', '请选择一条记录进行删除', 'warning');
|
||
|
return;
|
||
|
}
|
||
|
var row = selRows[0];
|
||
|
var model = {
|
||
|
ID: row.UserID,
|
||
|
method: 'DelInfo'
|
||
|
};
|
||
|
|
||
|
$.ajax({
|
||
|
url: "/HttpHandlers/UserHandler.ashx",
|
||
|
data: model,
|
||
|
async: false,
|
||
|
success: function (data) {
|
||
|
if (data == 'true') {
|
||
|
$.messager.alert('提示', '已删除', 'info');
|
||
|
dg.datagrid('reload');
|
||
|
}
|
||
|
else {
|
||
|
$.messager.alert('提示', data, 'warning');
|
||
|
}
|
||
|
},
|
||
|
error: function () {
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
/**************** 辅助业务程序 ***************/
|
||
|
/**********************************************/
|
||
|
/***************** 窗体程序 *******************/
|
||
|
/**********************************************/
|
||
|
//编辑窗口关闭清空数据
|
||
|
function clearw() {
|
||
|
$('#UserName').val('');
|
||
|
$('#Password').val('');
|
||
|
$('#RealName').val('');
|
||
|
var sex = $("#Sex1");
|
||
|
$("#Sex1").prop("checked", true);
|
||
|
$('#Tel').val('');
|
||
|
$('#Department').combobox('clear').combobox('reload');
|
||
|
$('#IsEnabled').prop("checked", true);
|
||
|
$('#menuTree').tree('loadData', []);
|
||
|
}
|
||
|
</script>
|
||
|
</form>
|
||
|
</body>
|
||
|
</html>
|