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


<%@ 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>
    <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" />--%>
    <%=ImportScriptStr %>
    <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>

    <script type="text/javascript">
		<!--
    var setting = {
        check: {
            enable: true,
            chkboxType : { "Y" : "", "N" : "" }
        },
        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);
            // alert(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 s1 = idlist + "#" + namelist;
        
            //var info = "确实要使用您选中的内容吗？";
            //art.dialog.confirm(info, function () {
            //    //alert("1=" + sPath);
            //    art.dialog.data("retndata", s1);
            //    art.dialog.close();
            //    parent.art.dialog.close();
            //    return false;
            //});

            SaveTreeValue1(s1);
            return false;


            //art.dialog.data("retndata", idlist);
            //art.dialog.data("retwdata", namelist);
        
            //art.dialog.close();
            //window.close();
            return true;
        }

        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: 300px">
                                <ul id="treeDemo" class="ztree"></ul>


                            </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>
