<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="departmentztreeselectbd.aspx.cs" Inherits="Us.Web.admin.basic.departmentztreeselectbd" %>


<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

<!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>部门选择</title>
    <%=ImportScriptStr %>
    <link href="../style/default/style.css" rel="stylesheet" type="text/css" />
    <script language="javascript" src="/admin/js/System.js" type="text/javascript"></script>
    <%--<link rel="StyleSheet" href="/admin/js/tree/dtree.css" type="text/css" />--%>

    <asp:Literal ID="litScript" runat="server"></asp:Literal>
    <style type="text/css">
        input[type="checkbox"] {
            width: 12px;
            height: 12px;
            margin: 0px;
            padding: 0px;
            border: 0px none #009999;
        }
    </style>

    <link rel="stylesheet" href="../mtree/css/zTreeStyle/zTreeStyle.css" type="text/css">

    <script type="text/javascript" src="../mtree/js/jquery.ztree.core-3.5.js"></script>
    <script type="text/javascript" src="../mtree/js/jquery.ztree.excheck-3.5.js"></script>
    <script type="text/javascript" src="../mtree/js/jquery.ztree.exedit-3.5.js"></script>
    <style type="text/css">
        .ztree li span.button.switch.level0 {
            visibility: hidden;
            width: 1px;
        }

        .ztree li ul.level0 {
            padding: 0;
            background: none;
        }
    </style>
    <script type="text/javascript">
		<!--
    var setting = {
        check: {
            enable: true,
            chkboxType : { "Y" : "s", "N" : "s" }
        },
        view: {
            dblClickExpand: false,
            showLine: true,
            fontCss: getFontCss
        },
        data: {
            simpleData: {
                enable: true
            }
        }
    ,
        callback: {
            onClick: onClick,
            onCheck: zTreeOnCheck

        }
    };

   <% =TreeHTML %>

        function onClick(e, treeId, treeNode) {
            if (treeNode.id != "0") {
                var zTree = $.fn.zTree.getZTreeObj("treeDemo");
                zTree.expandNode(treeNode);
            }
            
        }
        function zTreeOnCheck(event, treeId, treeNode) {
            //alert(treeNode.tId + ", " + treeNode.name + "," + treeNode.checked);
            if(checkType==1||checkType==3)
            {
                var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
                treeObj.checkAllNodes(false);
                //var checked = treeObj.getNodes()[0].checked;
                treeNode.checked=true;
            }

        };
        $(document).ready(function () {
            $.fn.zTree.init($("#treeDemo"), setting, zNodes);
            ztreeinitsearch("treeDemo","txtUserName");
            //$("#callbackTrigger").bind("change", {}, setTrigger);
        });
        //-->
    </script>

    <script language="javascript" type="text/javascript">
        //1 单选  2 多选 3 单选
        var checkType = <% =Para%>;
        function SaveTreeValue1(info)
        {
            //alert(info);
            art.dialog.data("retndata", info);
            art.dialog.close();
            return false;
        }
        function SaveTreeValue()
        {
            var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
            var nodes = treeObj.getCheckedNodes(true);
            var idlist = "", namelist = "";
            var iCount = 0;
            for (var i = 0; i < nodes.length; i++) {
                idlist += nodes[i].id + ",";
                namelist += nodes[i].name + ",";
                iCount++;
            }
            //alert(idlist + namelist);
            if (idlist == "")
            {
                //alert("对不起，您必须至少选择一项才可以提交！");
                //return false;
            }
            if (checkType == 1||checkType == 3)
            {
                if (iCount != 1)
                {
                    alert("对不起，您只能选择一项才可以提交！");
                    return false;
                }
            }
            idlist = idlist.substr(0, idlist.length - 1);
            namelist = namelist.substr(0, namelist.length - 1);

            var json = '{"deptid":"' + idlist + '","deptname":"' + namelist+'"}';

            returnValue = json;
            SaveTreeValue1(returnValue);
            return false;
        }

        var bState= true;
        function skySelectCheckList()
        {
            var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
            var nodes = treeObj.getNodes();
            treeObj.checkAllNodes(bState);
            bState=!bState;
        
        }
    </script>



</head>
<body>
    <form id="Form1" method="post" runat="server">
        <table width="100%" border="0" cellpadding="0" cellspacing="0" height="100%">
            <tr>
                <td width="100%" valign="top">
                    <div class="divTbg">
                        <div class="divTbgL"></div>
                        <div class="divTbgInfo">
                            <div class="divTbgTitle">部门选择</div>
                        </div>
                    </div>
                    <div class="divTbgF"></div>
                    <div class="divSearchBoth">
                        <div class="divInfo">
                            <div class="divSearch">
                                <div id="searchBox" class="clearsearch">
                                    <p>
                                        &nbsp;<input type="text" id="txtUserName" placeholder="搜索的部门名称" />
                                    </p>
                                </div>
                            </div>
                        </div>
                        <div class="divInfo">
                            <div class="divAutoHeight" id="ScroLeft" style="height: 460px">
                                <ul id="treeDemo" class="ztree"></ul>
                                <%--  <%=TreeHTML %>--%>
                                <%-- <%=SelectHTML %>--%>
                            </div>

                        </div>


                    </div>
                    <%=SelectHTML %>
                    <%--<div style="padding-left:10px;"><input type="checkbox" name="chkselect" id="chkselect" onclick="skySelectCheckList();"/><label for="chkselect">[全选/全不选]</label></div>--%>
                    <div class="divSave">

                        <asp:Button ID="btnSubmit" runat="server" Text="保存(S)" CssClass="SkyButtonFocus" />
                    </div>
                </td>


            </tr>
        </table>
    </form>

</body>
</html>