<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserGroupSet.aspx.cs" Inherits="RM.Web.RMBase.SysUserGroup.UserGroupSet" %>

<!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>
        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserGroupSet")%></title>
    <link href="/Themes/Styles/Site.css" rel="stylesheet" type="text/css" />
    <script src="/Themes/Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/Validator/JValidator.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/artDialog/artDialog.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/artDialog/iframeTools.js" type="text/javascript"></script>
    <link href="/Themes/Scripts/TreeView/treeview.css" rel="stylesheet" type="text/css" />
    <script src="/Themes/Scripts/TreeView/treeview.pack.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/FunctionJS.js" type="text/javascript"></script>
    <script type="text/javascript">
        //初始化
         var PageUp=1;
         var PageDown=1;
         var oid="";
        $(function () {
        var Pageup
            UserGroupInfo();
            GetUserList("","");
                $("#Pup").click(function(){
            GetUserList(PageUp,oid);
            });
             $("#Pdown").click(function(){
            GetUserList(PageDown,oid);
            });
            treeAttrCss();
            GetClickValue();
          
        });

        //点击获取部门ID
        function GetClickValue() {
            $(".strTree li div").click(function () {
                var id = "";
                //子目录 
                $(this).parent().find("span").each(function () {
                    if ($(this).html() != "") {
                        id += "'" + $(this).html() + "',";
                    }
                });
                id = id.substr(0, id.length - 1);
                GetUserList("",id);
                Loading(true);
            })
        }
        //用户列表
        function GetUserList(page,id) {
        if (page=="") {
        page="1";
}
            var UserGroup_ID = '<%=_UserGroup_ID %>';
            var Searchwhere = $("#Searchwhere").val();
            var txt_Search = $("#txt_Search").val();
            
            var parm = 'action=UserList&Searchwhere=' + escape(Searchwhere) + '&orgid=' + escape(id)+'&txt_Search=' + escape(txt_Search) + '&UserGroup_ID=' + UserGroup_ID+"&PageIndex="+page;
            $("#htmlrp_Item").empty();
            getAjax('UserGroup.ashx', parm, function (rs) {
             var json = eval("(" + rs + ")");
             var userlist = eval("(" + json.obj + ")");
             var count=json.count;
             var Page=json.page;
             if (Page-1>=1) {
                PageUp=Page-1;
                }
                PageDown=parseInt(Page)+1;
                oid=id;
             var rowsum = userlist.length;
                if (rowsum > 0) {
                    for (var i = 0; i < rowsum; i++) {
                        $("#htmlrp_Item").append('<tr>');
                        $("#htmlrp_Item").append('<td style="width: 20px; text-align: left;"><input type="checkbox" value=' + userlist[i].User_ID + ' name="checkbox" /></td>');
                        $("#htmlrp_Item").append('<td style="width: 60px; text-align: center;">' + userlist[i].User_Code + '</td>');
                        $("#htmlrp_Item").append('<td style="width: 80px; text-align: center;">' + userlist[i].User_Name + '</td>');
                        $("#htmlrp_Item").append('<td style="width: 100px; border-right: 0px; text-align: center;">' + userlist[i].User_Account + '</td>');
                        $("#htmlrp_Item").append('</tr>');
                    }
                } else {
                    $("#htmlrp_Item").append("<tr><td colspan='4' style='color:red;text-align:center;border-right: 0px;'><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Null")%></td></tr>");
                }
  
            });
        }
        //用户组树
        function UserGroupInfo() {
            var UserGroup_ID = '<%=_UserGroup_ID %>';
            var parm = 'action=UserGroupInfo&UserGroup_ID=' + UserGroup_ID;
            $("#ulstrTree").empty();
            getAjax('UserGroup.ashx', parm, function (rs) {
                $("#ulstrTree").append(rs);
            });
            treeCss();
        }
        //添加成员到用户组
        function addMember() {
            var UserGroup_ID = '<%=_UserGroup_ID %>';
            var key = CheckboxValue();
            if (key != undefined || key != "") {
                var parm = 'action=UserGroupaddMember&UserGroup_ID=' + UserGroup_ID + '&User_ID=' + key;
                getAjax('UserGroup.ashx', parm, function (rs) {
                    if (parseInt(rs) > 0) {
                        showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserGroupSet_zjyh")%>', 2000, 4);
                        UserGroupInfo();
                        GetUserList("","");
                    }
                    else {
                        showTipsMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("SB")%>', 4000, 5);
                    }
                });
            } else {
                showWarningMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserGroupSet_xzyh")%>');
            }
        }
        //删除用户组里面成员
        function DeleteMember(id) {
            var delparm = 'action=Delete&tableName=Base_UserInfoUserGroup&pkName=UserInfoUserGroup_ID&pkVal=' + id;
            DeleteData('/Ajax/Common_Ajax.ashx', delparm)
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="UserInfolist" style="height: 470px;">
        <div style="float: left; width: 15%; border: 1px solid #ccc; margin-right: 10px;">
                <div class="btnbartitle">
        <div>
            <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Organization")%>
        </div>
    </div>
    <div class="div-body">
        <ul class="strTree">
            <%=strHtml.ToString()%>
        </ul>
    </div>
        </div>
        <div id="UserInfolistleft" style="float: left; width: 35%; border: 1px solid #ccc;">
            <div class="box-title" style="height: 27px;">
                <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserGroupSet_ulist")%>
            </div>
            <div style="padding-top: 5px;">
                <select id="Searchwhere" class="select" runat="server" style="float: left; margin-top: -2px;">
                </select>
                <input type="text" id="txt_Search" class="txtSearch SearchImg" onkeyup="GetUserList('','')" runat="server" style="width: 200px;" />
            </div>
            <div style="height: 30px; line-height: 30px;">
                <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserGroupSet_lb50")%>
            </div>
            <div class="div-overflow" id="allUserInfo" style="padding-bottom: 5px; height: 380px;">
                <table id="table1" class="grid">
                    <thead>
                        <tr>
                            <td style="width: 20px; text-align: left;">
                                <label id="checkAllOff" onclick="CheckAllLine()" title="<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Quanxuan")%>">
                                    &nbsp;</label>
                            </td>
                            <td style="width: 60px; text-align: center;">
                                <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserInfo_Form_no")%>
                            </td>
                            <td style="width: 80px; text-align: center;">
                                <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("User_Name")%>
                            </td>
                            <td style="width: 100px; border-right: 0px; text-align: center;">
                                <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("User_Accout")%>
                            </td>
                        </tr>
                    </thead>
                    <tbody id="htmlrp_Item">
                    </tbody>
                </table>
                <div>
                    <input type="button" id="Pup" value="上" />
                    <input type="button" id="Pdown" value="下" />
                </div>
            </div>
        </div>
        <div style="float: left; width: 8%; text-align: center; padding-top: 200px;">
            <a onclick="addMember()" class="button green" title="<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserGroupSet_zjyh")%>"><span class="icon-botton" style="background: url('/Themes/images/arrow_right.png') no-repeat scroll 5px 4px;"></span></a>
        </div>
        <div id="UserInfolistright" style="float: left; width: 40%; border: 1px solid #ccc;">
            <div class="box-title" style="height: 27px;">
                <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserGroupSet_yhzcy")%>;<span style="color: Red;"><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UserGroupSet_sjyc")%></span>
            </div>
            <div class="div-overflow" id="selectedUserInfo" style="padding-bottom: 5px; height: 440px;">
                <ul class="strTree">
                    <li>
                        <div class="node">
                            <%=_UserGroup_Name%></div>
                        <ul id="ulstrTree">
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
    </div>
    </form>
</body>
</html>
