NGToolsCSharp/NGTools/Pages/Z_System/USER_GL.aspx

227 lines
7.5 KiB
Plaintext
Raw Normal View History

2024-09-13 08:44:13 +00:00

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="USER_GL.aspx.cs" Inherits="NGTools.Pages.Z_System.USER_GL" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>用户管理</title>
<link rel="stylesheet" type="text/css" href="../../Scripts/EASYUI/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="../../Scripts/EASYUI/themes/icon.css" />
<!--2个js文件 ,要先引入jquery,然后再引入easyui-->
<script src="../../Scripts/EASYUI/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../Scripts/EASYUI/jquery.easyui.min.js"></script>
<script src="../../MYJS/MyTools.js"></script>
<script src="../../Scripts/EASYUI/locale/easyui-lang-zh_CN.js"></script>
<script src="../../MYJS/constant.js"></script>
</head>
<body class="easyui-layout">
<div id="west"data-options="region:'west', split:true" title="用户列表" style="width: 200px;">
<div id="treeWest" style="width: 300px;"></div>
</div>
<div id="center"data-options="region:'center', split:true" title="">
<table id="dg" style="width: 700px; height: auto" data-options="
singleSelect:false,
multiSort:true,
remoteSort:false,
onClickRow: onClickRow,
onEndEdit: onEndEdit">
<thead>
<tr>
</tr>
</thead>
</table>
</div>
<div id="tb" style="height: auto; display: none">
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="append()">添加</a>
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="removeit()">删除</a>
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true" onclick="accept()">保存</a>
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-undo',plain:true" onclick="reject()">取消</a>
</div>
<script>
var inserted = undefined;// $('#dg').datagrid('getChanges', inserted);
var updated = undefined;// $('#dg').datagrid('getChanges', updated);
var deleted = undefined;//$('#dg').datagrid('getChanges', deleted);
$(function () { //动态加载二级菜单
var url = '../../ASHX/getTreeCombox.ashx?action=getORG';
getTree($('#treeWest'), url);
//初始化网格 根数据
//getDataGrid($('#dg'), '../../ASHX/getTreeCombox.ashx?action=getDataGrid', "system_menu,parent_id~M00", '#tb');
$('#treeWest').tree({
onClick: function (node) {
var url = '../../ASHX/getTreeCombox.ashx?action=getDataGrid';
var parm = "user,ORG_ID~" + node.id;// 格式 表名,条件字段名~条件字段值
var toobar = '#tb';
getDataGrid($('#dg'), url, parm, toobar);
}
})
});
$(document).ready(function () { //动态加载二级菜单
});
var editIndex = undefined;
function endEditing() {
if (editIndex == undefined) { return true }
if ($('#dg').datagrid('validateRow', editIndex)) {
$('#dg').datagrid('endEdit', editIndex);
editIndex = undefined;
return true;
} else {
return false;
}
}
function onClickRow(rowIndex, rowData) {
$('#dg').datagrid('addEditor',
[ //添加cardNo列editor
{
field: 'user_account', editor: { type: 'textbox', options: { required: true, } }
},
{
field: 'user_name', editor: { type: 'textbox', options: { required: false, } }
},
//{
// field: 'ORG_ID', editor: { type: 'textbox', options: { required: false, } }
//},
{
field: 'phoneNo', editor: { type: 'textbox', options: { required: true, } }
},
{
field: 'authority', editor: { type: 'combobox', options: { valueField: 'ID', textField: 'text', data: qxData, required: true } }
}
]);
//让选中行进入编辑状态
if (editIndex != rowIndex) {
if (endEditing()) {
$('#dg').datagrid('selectRow', rowIndex)
.datagrid('beginEdit', rowIndex);
editIndex = rowIndex;
} else {
$('#dg').datagrid('selectRow', editIndex);
}
}
}
function onEndEdit(index, row) {
//$.messager.alert("提示",2222);
}
function append() {
$('#dg').datagrid('addEditor',
[ //添加cardNo列editor
{
field: 'user_account', editor: { type: 'textbox', options: { required: true, } }
},
{
field: 'user_name', editor: { type: 'textbox', options: { required: false, } }
},
//{
// field: 'ORG_ID', editor: { type: 'textbox', options: { required: false, } }
//},
{
field: 'phoneNo', editor: { type: 'textbox', options: { required: true, } }
},
{
field: 'authority', editor: { type: 'combobox', options: { valueField: 'ID', textField: 'text', data: qxData, required: true } }
}
]);
if (endEditing()) {
try {
editIndex = $('#dg').datagrid('getRows').length;
} catch (e) {
}
$('#dg').datagrid('appendRow', {
user_account: "",
user_name: "",
PhoneNo: "",
ORG_ID: $("#treeWest").tree('getSelected').id,
authority: "",
//PrefixInteger 各位数字补零方法 01 03
//-----------------------------------------------复制注意修改
});
$('#dg').datagrid('selectRow', editIndex)
.datagrid('beginEdit', editIndex); //进入编辑状态
}
}
function removeit() {
if (confirm("确定删除选中的这行数据吗?")) {
var rows = $("#dg").datagrid('getSelected');
var index = $("#dg").datagrid('getRowIndex', rows);
//$('#dg').datagrid('deleteRow', index);
$('#dg').datagrid('cancelEdit', index)
.datagrid('deleteRow', index);
//getChanges();
}
editIndex = undefined;
}
function accept() { //批量保存 高效率地 同时保存修改,删除和插入的行,
if (endEditing()) {
var url = "";
url = '../../ASHX/getTreeCombox.ashx?action=SaveDataGrid' + "&t=" + Date.parse(new Date());
var parm = "user@" + getChanges(); // 格式 表名,条件字段名~条件字段值
if (confirm("确定更新选中的这行数据吗?")) {
$.ajax({
type: "post",
url: url,
//dataType: "json",
//async: true,//异步请求默认为true。如果需要发送同步请求发送false
data: { par: parm },
success: function (data) {
$.messager.alert("提示", data);
}
})
//getChanges();
}
else {
reject();
}
}
}
function reject() {
$('#dg').datagrid('rejectChanges');
editIndex = undefined;
}
function getChanges() {
var rows = $('#dg').datagrid('getChanges');
inserted = $('#dg').datagrid('getChanges', "inserted");
updated = $('#dg').datagrid('getChanges', "updated");
deleted = $('#dg').datagrid('getChanges', "deleted");
var effectRow = new Array();
effectRow.push(JSON.stringify(inserted));
effectRow.push(JSON.stringify(updated));
effectRow.push(JSON.stringify(deleted));
return effectRow.join('@');
}
</script>
</body>
</html>