<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="userlist.aspx.cs" Inherits="HySoft.BaseCallCenter.Web.sysmanage.userlist" %>

<!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 id="Head1" runat="server">
    <title>用户管理</title>
    <link href="../scripts/ui/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <script src="../scripts/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="../scripts/ui/json2.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/core/base.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/ligerui.min.js" type="text/javascript"></script>
    <link href="../scripts/ui/skins/Tab/css/tab.css" rel="stylesheet" type="text/css" />
    <link href="../scripts/ui/skins/Tab/css/grid.css" rel="stylesheet" type="text/css" />
    <script src="../scripts/ui/js/plugins/ligerGrid.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/plugins/ligerLayout.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/plugins/ligerTree.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/plugins/ligerMenu.js" type="text/javascript"></script>
    <script src="../scripts/CustomersData.js" type="text/javascript"></script>
    <link href="../scripts/ui/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
    <link href="../images/style.css" rel="stylesheet" type="text/css" />
</head>
<script type="text/javascript">
        var menu;
        var actionNodeID;
        var singleClick;
        var taotleCount = "";
        var manager = null;
        var a;
        function itemclick(item, i) {
            alert(actionNodeID + " | " + item.text);
        }
        var gridlist;
        $(function () {

            try {
                var vheight = document.body.clientHeight;
                document.getElementById("tableMessage").style.height = vheight - 130;
                document.getElementById("divTree").style.height = vheight - 130;
            }
            catch (e)
            { }
            $("#tree1").ligerTree({
                nodeWidth: 135,
                checkbox: false,
                isExpand: false,
                url: 'ajax/deptcategory.ashx?action=gettreelist',
                onClick: function (node, e) {
                    actionNodeID = node.data.id;
                    LoadList(node.data.id);
                }
            });

            LoadList("");
        });

        function getWhereStr() {
            var keyWords = "";
            if (document.getElementById("txtKeywords").value != "") {
                keyWords += document.getElementById("txtKeywords").value;
            }
            return keyWords;
        }

        function GetSql() {
            var sql = "";
            if (document.getElementById("txtKeywords").value != "") {
                sql += "&key=" + encodeURIComponent(document.getElementById("txtKeywords").value);
            }
            return sql;
        }

        function LoadList(id) {
            var sql = GetSql();
            if (actionNodeID == undefined) {
                actionNodeID = "";
            }
            gridlist = $("#divDataList").ligerGrid({
                height: '95%',
                columns: [
                { display: 'ID', name: '_f_userid', align: 'left', width: 1, hide: true },
                { display: '用户编号', name: '_f_usercode', width: 80 },
                { display: '坐席工号', name: '_f_worknumber', width: 80 },
                { display: '用户名称', name: '_f_username', width: 80 },
                { display: '用户电话', name: '_f_telephone', width: 100 },
                { display: '用户手机', name: '_f_mobile', width: 100 },
                { display: '用户角色', name: '_f_rolename', width: 90 },
                { display: '用户部门', name: '_f_deptname', width: 90 },
                { display: '坐席组', name: '_f_groupname', width: 90 },
                { display: '用户状态', name: '_f_deleteflag', width: 100, render: function (rowdata, rowindex) {
                    if (rowdata._f_deleteflag == 1) { return '注销'; }
                    else { return '正常'; }
                }
                },
                { display: '最后登录时间', name: '_f_lastactivetime', type: 'date', width: 130, format: 'yyyy-MM-dd hh:mm:ss' }
                ], url: '../sysmanage/ajax/UserAjaxList.ashx?action=getUserList' + sql + '&id=' + id, pageSize: 10, rownumbers: true,
                onSelectRow: function (data, rowindex, rowobj) {
                    singleClick = data._f_userid;
                },
                onDblClickRow: function (data, rowindex, rowobj) {
                    Edit('edit');
                },
                onAfterShowData: function (data) {
                    //var vheight = document.body.clientHeight;
                    var vheight = $("#divDataList").height();
                    document.getElementById("divTree").style.height = vheight;
                }
            });
            gridlist.changePage('first');
            $("#pageloading").hide();
        }

        function Add(param) {
            $.ligerDialog.open({ url: 'useredit.aspx?actionFlag=' + param, title: '添加用户信息', height: 600, width: 800, isResize: true
            });
        }

        function Edit(params) {
            if (singleClick == "" || singleClick == undefined) {
                alert("请选择修改行！");
            } else {
                $.ligerDialog.open({ url: 'usermodify.aspx?actionFlag=' + params + '&singleFlage=' + singleClick, title: '修改用户信息', height: 600, width: 800, isResize: true
                });
            }
        }

        function DeleteUser(type) {
            var row = gridlist.getSelectedRows();
            var idStr = "";
            jQuery.each(row, function (i, val) {
                idStr += val._f_userid + ",";
            });
            idStr = idStr.substring(0, idStr.length - 1);
            if (idStr == "") {
                alert("请选择行！");
            } else {
                if (type == "0") {
                    $.ligerDialog.confirm('确定要启用吗?', function (yes) {
                        if (yes) {
                            gridlist = $("#divDataList").ligerGrid({
                                url: '../sysmanage/ajax/UserAjaxList.ashx?action=delete&type=' + type + '&taolCount=' + idStr, pageSize: 10, rownumbers: true
                            });
                        }
                        LoadList("");
                    });
                }
                if (type == "1") {
                    $.ligerDialog.confirm('确定要禁用吗?', function (yes) {
                        if (yes) {
                            gridlist = $("#divDataList").ligerGrid({
                                url: '../sysmanage/ajax/UserAjaxList.ashx?action=delete&type=' + type + '&taolCount=' + idStr, pageSize: 10, rownumbers: true
                            });
                        }
                        LoadList("");
                    });
                }
            }
        }

        function ResetPass() {
            if (singleClick == "" || singleClick == undefined) {
                alert("请选择要重设密码的用户！");
            } else {
                $.ligerDialog.open({ url: 'ResetPassword.aspx?ResetPass=' + singleClick, title: '重设用户密码', height: 400, width: 430, isResize: true });
            }
        }


        function AllocationRole() {
            if (singleClick == "" || singleClick == undefined) {
                alert("请选择要分配用户的角色！");
            } else {
                $.ligerDialog.open({ url: 'userAllocationRole.aspx?ResetRole=' + singleClick, title: '分配用户角色', height: 300, width: 430, isResize: true });
            }
        }
        document.onkeydown = function (event) {
            var e = event || window.event || arguments.callee.caller.arguments[0];
            if (e && e.keyCode == 13) {
                LoadList();
            }
        };
</script>
<body>
    <form id="form1" runat="server">
    <div class="tools_box">
        <div class="tools_bar">
            <a class="tools_btn" href="#" onclick="Add('add');"><span><b class="add">添加</b></span>
            </a><a class="tools_btn" href="#" onclick="Edit('edit');"><span><b class="modify">修改</b></span>
            </a><a class="tools_btn" href="#" onclick="ResetPass();"><span><b class="recharge">重设密码</b></span>
            </a><a class="tools_btn" href="#" onclick="DeleteUser('1');"><span><b class="delete">
                禁用用户</b></span> </a><a class="tools_btn" href="#" onclick="DeleteUser('0');"><span><b
                    class="delete">启用用户</b></span> </a>
            <%-- <a class="tools_btn" href="#" onclick="ResetPass();">
                <span><b class="modify">重设密码</b></span>
            </a>--%>
            <%-- <a class="tools_btn" href="#" onclick="AllocationRole();">
                <span><b class="modify">角色分配</b></span>
            </a>--%>
            <div class="search_box">
                关键字：<asp:TextBox ID="txtKeywords" runat="server" CssClass="txtInput"></asp:TextBox>&nbsp;&nbsp;
                <input id="btnSearch" type="button" value="搜 索" class="btnSearch" onclick="LoadList();" />
            </div>
        </div>
    </div>
    <table id="tableMessage" cellpadding="3" cellspacing="3" border="0" style="width: 100%;">
        <tr>
            <td valign="top" style="width: 230px; padding: 0px 2px 5px 2px;">
                <div class="tools_box" style="height: 30px;">
                    <div class="tools_bar">
                        <div style="float: left; padding-top: 6px; padding-left: 1px; font-weight: bold;
                            color: red;">
                            <img src="../images/icon_site.gif" />&nbsp;部门信息</div>
                    </div>
                </div>
                <table id="tableTree" cellpadding="0" cellspacing="0" style="width: 100%; border: 1px solid #D6D6D6;">
                    <tr>
                        <td valign="top">
                            <div id="divTree" style="overflow: auto;">
                                <ul id="tree1">
                                    <li isexpand="false" id="-1"><span>部门信息</span>
                                        <ul>
                                        </ul>
                                    </li>
                                </ul>
                            </div>
                        </td>
                    </tr>
                </table>
            </td>
            <td valign="top" style="padding: 0px 2px 5px 2px;">
                <div class="tools_box" style="height: 30px;">
                    <div class="tools_bar">
                        <div style="float: left; padding-top: 6px; padding-left: 1px; font-weight: bold;
                            color: red;">
                            <img src="../images/ico_16_2.gif" />&nbsp;用户列表</div>
                    </div>
                </div>
                <div id="divDataList">
                </div>
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
