NGToolsCSharp/NGTools/Pages/Z_System/JG_GL.aspx
2024-09-13 16:44:30 +08:00

236 lines
8.1 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JG_GL.aspx.cs" Inherits="NGTools.Pages.Z_System.JG_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', "organization,parent_id~M00", '#tb');
$('#treeWest').tree({
onClick: function (node) {
var url = '../../ASHX/getTreeCombox.ashx?action=getDataGrid';
var parm = "organization,org_parent_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: 'ORG_ID', editor: { type: 'textbox', options: { required: true, } }
},
{
field: 'ORG_Name', editor: { type: 'textbox', options: { required: false, } }
},
//{
// field: 'ORG_PARENT_ID', editor: { type: 'textbox', options: { required: false, } }
//},
{
field: 'ORG_TYPE', editor: { type: 'combobox', options: { valueField: 'ID', textField: 'text', data: orgType, 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: 'ORG_ID', editor: { type: 'textbox', options: { required: true, } }
},
{
field: 'ORG_Name', editor: { type: 'textbox', options: { required: false, } }
},
//{
// field: 'ORG_PARENT_ID', editor: { type: 'textbox', options: { required: false, } }
//},
{
field: 'ORG_TYPE', editor: { type: 'combobox', options: { valueField: 'ID', textField: 'text', data: orgType, required: true } }
}
]);
//if (endEditing()) {
try {
editIndex = $('#dg').datagrid('getRows').length;
} catch (e) {
}
//alert(editIndex);
if (editIndex == 0) { //如果是第一行,添加默认行
//alert($("#treeWest").tree('getSelected').id);
$('#dg').datagrid('appendRow', {
ORG_ID: $("#treeWest").tree('getSelected').id + "01",
ORG_Name: "",
ORG_PARENT_ID: $("#treeWest").tree('getSelected').id,
ORG_TYPE: ""
//PrefixInteger 各位数字补零方法 01 03
//-----------------------------------------------复制注意修改
});
} else { //如果不是第一行,添加部分上一行相关内容
var rows = $("#dg").datagrid("getRows");
//添加行
$('#dg').datagrid('appendRow', {
ORG_ID: PrefixInteger(rows[editIndex - 1].ORG_ID, 2),//PrefixInteger 各位数字补零方法 01 03
Menu_Name: "",
ORG_PARENT_ID: rows[editIndex - 1].ORG_PARENT_ID,
ORG_TYPE: rows[editIndex - 1].ORG_TYPE
});
}
$('#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 = "organization@" + 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>