<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('选择服务类目')" />
    <th:block th:include="include :: ztree-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-tree">
        <div class="form-group">
            <label class="col-sm-3 control-label">服务类目：</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input class="form-control" type="text" id="treeName" readonly="true">
                    <input type="hidden" id="treeId">
                    <span class="input-group-addon"><i class="fa fa-search"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label"></label>
            <div class="col-sm-8">
                <div id="tree" class="ztree"></div>
            </div>
        </div>
        <!-- <div class="form-group">
            <div class="form-control-static col-sm-offset-9">
                <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
                <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭</button>
            </div>
        </div> -->
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: ztree-js" />
<script type="text/javascript">
    $(function() {
        var url = ctx + "goods/category/serviceTreeData";
        var options = {
            url: url,
            expandLevel: 2,
            onClick : zOnClick
        };
        $.tree.init(options);
    });

    function zOnClick(event, treeId, treeNode) {
        $("#treeId").val(treeNode.id);
        $("#treeName").val(treeNode.name);
    }

    function submitHandler() {
        var treeId = $("#treeId").val();
        var treeName = $("#treeName").val();
        if (treeId == "" || treeName == "") {
            $.modal.alertWarning("请选择服务类目");
            return;
        }
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }

    function closeItem() {
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }
</script>
</body>
</html> 