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

<!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>
    <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" />
    <script type="text/javascript">
        var actionNodeID;
        var singleClick;
        var count = 1;
        var counts = 1;
        $(function () {
            $("#layout1").ligerLayout({
                leftWidth: 200,
                allowCenterBottomResize: false
            });
            $("#tree1").ligerTree({
                nodeWidth: 135,
                isExpand: false,
                checkbox: false,
                url: '../../sysmanage/ajax/deptcategory.ashx?action=gettreelist',
                onClick: function (node, e) {
                    count += 1;
                    counts = count;
                    actionNodeID = node.data.id;
                    LoadList(node.data.id);
                }
            });
            var deptid = $("#hfdeptID").val();
            LoadList(deptid);
        });
        function addSelRen(id, name) {
            if (count > 1) {
                count -= 1;
                return;
            } else {
                count = counts;
                var issel = false;
                $('.hrms>li').each(function (index) {
                    var aid = $(".hrms>li:eq(" + index + ") a").attr("rel");

                    if (aid == id) {
                        issel = true;
                        $.ligerDialog.success('人员【' + name + '】已经选择！');
                    }
                });
                if (!issel) {
                    var aa = "<li><a class=\"close\" href=\"javascript:void(0)\"  onclick=\"delSelRen(" + id + ")\" rel=\"" + id + "\">" + name + "</a></li>";
                    $(".hrms").append(aa);
                }
            }
        }
        function delSelRen(id, name) {
            $('.hrms>li').each(function (index) {
                var a = $(".hrms>li:eq(" + index + ") a").attr("rel");
                if (a == id) {
                    $(".hrms li:eq(" + index + ")").remove();
                }
            });
        }
        function Load() {
            count += 1;
            counts = count;
            LoadList("");
        }
        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: '30%' },
                { display: '用户名称', name: '_f_username', width: '30%' },
                { display: '部门信息', name: '_f_deptname', width: '30%' }
                ], url: '../../sysmanage/ajax/UserAjaxList.ashx?action=getUserListFinish' + '&id=' + id + sql, pageSize: 4, rownumbers: true,
                onSelectRow: function (data, rowindex, rowobj) {
                    singleClick = data._f_userid;
                    addSelRen(data._f_userid, '' + data._f_username + '');
                }

            });
            gridlist.changePage('first');
            $("#pageloading").hide();
        }
        function GetSql() {
            var sql = "";
            if (document.getElementById("txtName").value != "") {
                sql += "&name=" + escape(document.getElementById("txtName").value);
            }
            return sql;
        }
        function saveSel() {
            var id = "";
            var name = "";
            $('.hrms>li').each(function (index) {
                var aid = $(".hrms>li:eq(" + index + ") a").attr("rel");
                var aname = $(".hrms>li:eq(" + index + ") a").html();
                id += aid + ",";
                name += aname + ",";
            });
            var lastIndex = name.lastIndexOf(',');
            var lastIndexid = id.lastIndexOf(',');
            if (lastIndex > -1) {
                name = name.substring(0, lastIndex) + name.substring(lastIndex + 1, name.length);
                id = id.substring(0, lastIndexid) + id.substring(lastIndexid + 1, id.length);
            }

            if ((id == "") || (name == "")) {
                $.ligerDialog.success('人员选择为空，暂时无法保存！');
            } else {
                parent.GetValue(id);
                CloseThis();
            }
        }
        function CloseThis() {
            var dialog = frameElement.dialog;
            dialog.close();
        }
    </script>
    <style type="text/css">
        .hrms
        {
            margin: 0px;
            padding: 0px;
        }
        .hrms li
        {
            float: left;
            border: 1px solid #FFF;
            list-style-type: none;
        }
        #issel a.close
        {
            background: url('../../../images/dot0913.png.gif') no-repeat scroll right 3px transparent;
            border: 1px solid #E00102;
            color: #E00102;
            padding: 1px 20px 2px 5px;
            margin: 3px;
            float: left;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <asp:HiddenField ID="hfdeptID" runat="server" />
    <div data-options="region:'north',collapsible:false,border:false" style="height: 50px;"
        title="已经选择人员:">
        <table cellpadding="0" cellspacing="0" border="0" width="100%">
            <tr>
                <td>
                    <div id="issel" style="float: left; padding-left: 20px; height:40px; padding-top: 8px;">
                        <ul class="hrms">
                        </ul>
                    </div>
                </td>
                <td style="width:100px; text-align:right; vertical-align:top; padding-top:8px; padding-right:8px;">
                    <a href="javascript:void(0)" class="btnSearch" iconcls="icon-ok" onclick="saveSel()">
                        完成</a> <a href="javascript:void(0)" class="btnSearch" iconcls="icon-no" onclick="CloseThis()">
                            关闭</a>
                </td>
            </tr>
        </table>
    </div>
    <div class="tools_box">
        <div class="tools_bar">
            <div class="search_box">
                用户名称：<input id="txtName" type="text" style=" width:100px;" />&nbsp;&nbsp;
                <input id="btnSearch" type="button" value="搜 索" class="btnSearch" onclick="Load();" />&nbsp;&nbsp;
                <%--<input id="btnSearchGaoJi" type="button" value="高级搜索" class="btnSearch" />--%>
            </div>
        </div>
    </div>
    <div id="layout1" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px;
        padding-top: 0px">
        <div style="height: 99%; overflow: scroll;" position="left" title="部门信息">
            <ul id="tree1">
                <li isexpand="false" id="-1"><span>部门信息</span>
                    <ul>
                    </ul>
                </li>
            </ul>
        </div>
        <div position="center" title="用户列表">
            <div id="divDataList">
            </div>
        </div>
    </div>
    </form>
</body>
</html>
