<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('磁贴列表')" />
    <th:block th:include="include :: ztree-css" />

</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">

        <div class="form-group">
            <label class="col-sm-3 control-label">磁贴权限</label>
            <div class="col-sm-8">
                <div id="menuTrees" class="ztree"></div>
            </div>
        </div>
    </div>
</div>

<th:block th:include="include :: footer" />
<th:block th:include="include :: ztree-js" />
<script th:inline="javascript">
    var roleId = [[${roleId}]]
    var prefix = ctx + "wxportal/magnet";

    $(function() {
        var url = prefix + "/roleMagnetTreeData?roleId=" + roleId;
        var options = {
            id: "menuTrees",
            url: url,
            check: { enable: true },
            expandLevel: 0
        };
        $.tree.init(options);
    });

    function submitHandler() {
        var magnetIds = $.tree.getCheckedNodes();
        $.ajax({
            cache : true,
            type : "POST",
            url : prefix + "/upRoleMagnet",
            data : {
                "roleId":roleId,
                "magnetIds": magnetIds
            },
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                $.operate.successCallback(data);
            }
        });
    }
</script>
</body>
</html>