SelectUser.aspx
资源名称:H3_OA.rar [点击查看]
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:10k
源码类别:
OA系统
开发平台:
C#
- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="SelectUser.aspx.cs" Inherits="OThinker.H3.Portal.SelectUser" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" >
- <head runat="server">
- <title>请选择</title>
- <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
- <meta name="CODE_LANGUAGE" Content="C#">
- <meta name="vs_defaultClientScript" content="JavaScript">
- <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
- <LINK href="css/style.CSS" type="text/css" rel="stylesheet">
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
- <script>
- // 选中了一个用户的时候触发
- function selectedUser(Text, Value)
- {
- var mode = getQueryString("Mode");
- nameControlId = getQueryString("UserControl");
- if(mode == null || mode == "" || mode.toLowerCase() == "single")
- {
- window.opener.document.getElementById(nameControlId).value=Text;
- // 获得隐藏控件的ID
- var idControlId = getQueryString("UserIDControl");
- var idControl = window.opener.document.getElementById(idControlId);
- if(idControl != null)
- {
- idControl.value = Value;
- }
- window.close();
- }
- else
- {
- addUser(Text, Value);
- }
- }
- // 向List中添加选定的用户
- function addUser(Text, Value)
- {
- var objlist=document.getElementById("SelectedUsers");
- for(i=objlist.length-1;i>=0;i--)
- {
- if(objlist.options[i].value == Value)
- {
- return;
- }
- }
- node = document.createElement("<option value='" + Value + "'>");
- text = document.createTextNode(Text);
- node.appendChild(text);
- objlist.appendChild(node);
- }
- function removeUser()
- {
- var objlist=document.getElementById("SelectedUsers");
- for(i=objlist.length-1;i>=0;i--)
- {
- if(objlist.options[i].selected == true)
- {
- objlist.remove(i);
- }
- }
- }
- var x=null;
- var listObj=null;
- //鼠标按下不放时的操作
- function setTimeStart(type)
- {
- listObj=document.getElementById('SelectedUsers');
- //超过0.3秒启动连续的向上(下)的操作
- if(type=="up")
- {
- x=setTimeout(upListItem,300);
- }
- else
- {
- x=setTimeout(downListItem,300);
- }
- }
- //将选中item向上
- function upListItem()
- {
- var selIndex=listObj.selectedIndex;
- if(selIndex < 0)
- {
- if(x!=null)
- {
- clearTimeout(x);
- }
- return;
- }
- if(selIndex==0)
- {
- if(x!=null)
- {
- clearTimeout(x);
- }
- return;
- }
- var selValue=listObj.options[selIndex].value;
- var selText=listObj.options[selIndex].text;
- listObj.options[selIndex].value=listObj.options[selIndex-1].value;
- listObj.options[selIndex].text=listObj.options[selIndex-1].text;
- listObj.options[selIndex-1].value=selValue;
- listObj.options[selIndex-1].text=selText;
- listObj.selectedIndex=selIndex-1;
- if(selIndex+1>0)
- {
- x=setTimeout(upListItem,200)
- }
- }
- //将选中item向下
- function downListItem()
- {
- var selIndex=listObj.selectedIndex;
- if(selIndex<0)
- {
- if(x!=null)
- {
- clearTimeout(x);
- }
- return;
- }
- if(selIndex==listObj.options.length-1)
- {
- if(x!=null)
- {
- clearTimeout(x);
- }
- return;
- }
- var selValue=listObj.options[selIndex].value;
- var selText=listObj.options[selIndex].text;
- listObj.options[selIndex].value=listObj.options[selIndex+1].value;
- listObj.options[selIndex].text=listObj.options[selIndex+1].text;
- listObj.options[selIndex+1].value=selValue;
- listObj.options[selIndex+1].text=selText;
- listObj.selectedIndex=selIndex+1;
- if(selIndex+1<listObj.options.length-1)
- {
- x=setTimeout(downListItem,200)
- }
- }
- // 加载用户
- function loadUser()
- {
- // 检查是选择单值还是多值
- var mode = getQueryString("Mode");
- if(mode == null || mode == "" || mode.toLowerCase() == "single")
- {
- // 单值模式
- var curList=document.getElementById("UserListTable");
- curList.style.display = "none";
- var submitButton =document.getElementById("SubmitButton");
- submitButton.style.display = "none";
- }
- else
- {
- // 多值模式
- var parentListId = getQueryString("UserControl");
- if(parentListId == null || parentListId == "")
- {
- return;
- }
- var parentList=window.opener.document.getElementById(parentListId);
- if(parentList == null)
- {
- return;
- }
- var curList=document.getElementById("SelectedUsers");
- for(i=0;i<parentList.length;i++)
- {
- var itemValue = parentList.options[i].value;
- var itemText = parentList.options[i].text;
- node = document.createElement("<option value='" + itemValue + "'>");
- text = document.createTextNode(itemText);
- node.appendChild(text);
- curList.appendChild(node);
- }
- }
- }
- // 讲数据写回到对应的控件上
- function writeBackList()
- {
- var parentListId = getQueryString("UserControl");
- var parentList=window.opener.document.getElementById(parentListId);
- // 清空旧数据
- for(i=parentList.length-1;i>=0;i--)
- {
- parentList.remove(i);
- }
- var curList=document.getElementById("SelectedUsers");
- var listString = "";
- for(i=0;i<curList.length;i++)
- {
- var itemValue = curList.options[i].value;
- var itemText = curList.options[i].text;
- node = window.opener.document.createElement("<option value='" + itemValue + "'>");
- text = window.opener.document.createTextNode(itemText);
- node.appendChild(text);
- parentList.appendChild(node);
- listString = listString + itemValue + ";";
- }
- // 获得隐藏控件的ID
- var idControlName = getQueryString("UserIDControl");
- if(idControlName != null && idControlName != "")
- {
- var idControl = window.opener.document.getElementById(idControlName);
- if(idControl != null)
- {
- idControl.value = listString;
- }
- }
- window.close();
- }
- // 查找参数
- function getQueryString(name)
- {
- // 如果链接没有参数,或者链接中不存在我们要获取的参数,直接返回空
- if(location.href.indexOf("?")==-1 || location.href.indexOf(name+'=')==-1)
- {
- return '';
- }
- // 获取链接中参数部分
- var queryString = location.href.substring(location.href.indexOf("?")+1);
- // 分离参数对 ?key=value&key2=value2
- var parameters = queryString.split("&");
- var pos, paraName, paraValue;
- for(var i=0; i<parameters.length; i++)
- {
- // 获取等号位置
- pos = parameters[i].indexOf('=');
- if(pos == -1) { continue; }
- // 获取name 和 value
- paraName = parameters[i].substring(0, pos);
- paraValue = parameters[i].substring(pos + 1);
- // 如果查询的name等于当前name,就返回当前值,同时,将链接中的+号还原成空格
- if(paraName == name)
- {
- return unescape(paraValue.replace(/+/g, " "));
- }
- }
- return '';
- }
- </script>
- </head>
- <body leftmargin="0" topmargin="0" onload="javascript:loadUser();">
- <form id="form1" runat="server">
- <div>
- <INPUT type="button" value="确定" class="downBtn" onclick="javascript:writeBackList();" ID="SubmitButton" NAME="SubmitButton">
- <table height="100%" width="100%">
- <tr valign=top>
- <td width="50%">
- <asp:treeview ID="UserTree" runat="server" AutoGenerateDataBindings="false"
- ExpandDepth=0 OnTreeNodePopulate="UserTree_TreeNodePopulate" ShowLines="True">
- <SelectedNodeStyle BackColor="#B5B5B5"></SelectedNodeStyle>
- <NodeStyle VerticalPadding="2px" Font-Names="Tahoma" Font-Size="8pt" HorizontalPadding="2px" ForeColor="Black"></NodeStyle>
- <HoverNodeStyle Font-Underline="True" ForeColor="#6666AA"></HoverNodeStyle>
- </asp:treeview>
- </td>
- <td width="50%">
- <table id="UserListTable" width=100%>
- <tr>
- <td>
- <SELECT id="SelectedUsers" size="11" name="SelectedUsers" style="WIDTH:100%" ondblclick="javascript:removeUser();"></SELECT>
- </td>
- </tr>
- <tr>
- <td>
- <INPUT type="button" value="↑向上" class="upBtn" onmousedown="setTimeStart('up');" onmouseup="clearTimeout(x);" onclick="listObj=document.getElementById('SelectedUsers');upListItem();clearTimeout(x);" ID="Button3" NAME="Button1">
- <INPUT type="button" value="↓向下" class="downBtn" onmousedown="setTimeStart('down');" onmouseup="clearTimeout(x);" onclick="listObj=document.getElementById('SelectedUsers');downListItem();clearTimeout(x);" ID="Button4" NAME="Button2">
- <INPUT type="button" value="移出" class="btnRemove" onclick="javascript:removeUser();" ID="Button5" NAME="Button7">
- <br />
- 提示:双击列表项的选项可以删除成员</td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </div>
- </form>
- </body>
- </html>