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

<!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/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>
    <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 menu;
        var menucategory;
        var actionNode;
        var actionRow;
        var categorytree = null;
        var gridlist = null;

        function itemclick(item, i) {
            switch (i) {
                case 0:
                    AddCategory();
                    break;
                case 1:
                    ModifyCategory();
                    break;
                case 2:
                    DeleteCategory();
                    break;
                default:
                    break;
            }
        }
        $(function () {
//            $("#layout1").ligerLayout({
//                leftWidth: 500
//            });
            InitMenu();
            InitCategory();
        });


        function InitMenu() {
            menu = $.ligerMenu({ top: 100, left: 100, width: 120, items:
            [
            { text: '增加', click: itemclick, icon: 'add' },
            { text: '修改', click: itemclick, icon: 'modify' },
            { line: true },
            { text: '删除', click: itemclick, icon: 'delete' }
            ]
            });


            menucategory = $.ligerMenu({ top: 100, left: 100, width: 120, items:
            [
            { text: '增加', click: itemclick, icon: 'add' },
            { text: '修改', click: itemclick, icon: 'modify' },
            { line: true },
            { text: '删除', click: itemclick, icon: 'delete' }
            ]
            });
        }

        var categoryform;
        function InitCategory() {
            try {
                categorytree = $("#treecategory").ligerTree({
                    checkbox: false,
                    nodeWidth: 135,
                    url: 'ajax/deptcategory.ashx?action=gettreelist',
                    isExpand: 2,
                    onContextmenu: function (node, e) {
                        actionNode = node;
                        categorytree.selectNode(actionNode.data.id);
                        menucategory.show({ top: e.pageY, left: e.pageX });
                        return false;
                    },
                    onClick: function (node, e) {
                       // InitList();
                    }
                });
            }
            catch (e) {
                alert(e.Message);
            }
        }


        //---------小型添加

        function AddCategory() {
            //获取选择的分类
            var node = categorytree.getSelected();
            if (node) {
                categoryform = $.ligerDialog.open({ url: 'DeptlistAddandEdit.aspx?action=Add&categoryid=' + node.data.id, title: '添加[<font color="red">' + node.data.text + '</font>]部门', height: 250, width: 400, isResize: false
                });
            }
            else {
                categoryform = $.ligerDialog.open({ url: 'DeptlistAddandEdit.aspx?action=Add&categoryid=0', title: '添加部门', height: 250, width: 400, isResize: true
                });
            }
        }
        function ModifyCategory() {
            //获取选择的分类
            var node = categorytree.getSelected();
            if (node) {
                $.ligerDialog.open({ url: 'DeptlistAddandEdit.aspx?action=Modify&id=' + node.data.id, title: '修改[<font color="red">' + node.data.text + '</font>]部门', height: 250, width: 400, isResize: true
                });
            }
            else {
                $.ligerDialog.error('没有选择要修改的部门');
            }
        }
        function DeleteCategory() {
            //获取选择的分类
            var node = categorytree.getSelected();
            if (node) {
                $.ligerDialog.confirm('确定要删除【<font color="red">' + node.data.text + '</font>】吗？', function (yes) {
                    if (yes) {
                        //
                        $.post("ajax/deptcategory.ashx?action=delete&id=" + node.data.id, function (data) {
                            if (data == "success") {
                                $.ligerDialog.success('删除成功');
                                InitCategory();
                            }
                            else {
                                $.ligerDialog.error('删除失败');
                            }
                        });
                    }
                    else {
                    }
                });
            }
            else {
                $.ligerDialog.error('没有选择要删除的分类');
            }
        }

        function CloseCategory() {
            categoryform.close();
            InitCategory();
        }

    </script>



</head>
<body>
    <form id="form1" runat="server">


    <div class="tools_box">
        <div class="tools_bar">
            <a class="tools_btn" href="#" onclick="AddCategory();"><span><b class="add">添加</b></span>
            </a><a class="tools_btn" href="#" onclick="ModifyCategory();"><span><b class="modify">修改</b></span>
            </a><a class="tools_btn" href="#" onclick="DeleteCategory();"><span>
                    <b class="delete">删除</b></span> </a>
        </div>
            <div class="search_box">
        <%--<asp:TextBox ID='aa' runat="server" Text=""></asp:TextBox>--%></div>
    </div>
     <div id="layout1" >
            <table cellpadding="0" cellspacing="0" border="0" height="100%">
                <tr height="100%">
                    <td>
                        <ul id="treecategory">
                            <li><span>玉</span>
                                <ul>
                                    <li><span>南阳玉</span> </li>
                                    <li><span>和田玉</span></li>
                                </ul>
                            </li>
                        </ul>
                    </td>
                </tr>
            </table>
    </div>
    </form>
</body>
</html>

