list.vm 4.16 KB
#set($page_title="菜单列表")
#set($crumbs="首页:/home,菜单列表")
##查询地址
#set($url_list = "/menu/list.do")
#set($url_res_list = "/menu/listResource.do")
##详情
#set($url_show = "/menu/show.do")
##添加
#set($url_save = "/menu/preSave.do")
#set($url_res_save = "/resource/preSave.do")
##删除
#set($url_del = "/menu/del.do")
#set($url_res_del = "/resource/del.do")
##排序
#set($url_sort = "/menu/sort.do")
#set($url_move = "/menu/move.do")
##关联资源
#set($url_bind_resource = "/resource/bind.do")

<div class="row">
    <div class="col-xs-12">

        <div class="table-header">
            菜单列表
        </div>
        #if(${type} == "res")
            #parse("/menu/resList.vm")
        #else
            #parse("/menu/menuList.vm")
        #end
    </div>
</div>
<script type="text/javascript">


    jQuery(function ($) {

        $('table th input:checkbox').on('click', function () {
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                    .each(function () {
                        this.checked = that.checked;
                        $(this).closest('tr').toggleClass('selected');
                    });

        });
    })


    function cleanForm(id) {
        var form = $("#" + id);

        form.find("input[type=text]").each(function () {
            var obj = $(this);
            obj.val("");
        });

        form.find("select").each(function () {
            var obj = $(this);
            obj.val("20");
        });

    }

</script>


<link rel="stylesheet" href="/static/module/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="/static/module/ztree/js/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript" src="/static/module/ztree/js/jquery.ztree.excheck-3.5.js"></script>
<script type="text/javascript" src="/static/module/ztree/js/jquery.ztree.exedit-3.5.js"></script>


#macro(makeTree $tree)
    #foreach(${item} in ${tree})
        #if($velocityCount> 1),#end{
        id:$!{item.id}
        , name: "$!{item.label}"
        , tt:"$!{item.type}"
        #if(${item.type} != 1)
            ,open:true
            ,dropRoot:false
            ,isParent: true
            , children: [
                #makeTree(${item.children})
            ]
        #else
        ,dropInner:false
        #end
    }
    #end
#end
<script type="text/javascript">
    var znodes = [
        #makeTree($tree)
    ];
    var setting = {
        callback: {
            onClick: function (event, treeId, treeNode) {
                if (treeNode.tt != "1") {
                    window.location.href = "/menu/list.do?param[parentId]=" + treeNode.id
                }
                if (treeNode.tt == "1"){
                    window.location.href = "/menu/listResource.do?param[parentId]=" + treeNode.id
                }
            }
            ,onDrop:onDrop
        }
        ,edit: {
            enable: true
            ,showRemoveBtn: false
            ,showRenameBtn: false
            ,drag:{
                inner:dropInner
                ,prev:false
                ,next:false
            }
        }
    }

    $(function () {
        var tree = $.fn.zTree.init($("#menuTree"), setting, znodes);
        var node = tree.getNodeByParam("id",${parentId});//treeObj是tree对象
        tree.selectNode(node);
    })

    function redirect(id) {
        window.location.href = "/menu/list.do?parentId=" + id
    }


    /**
     * 移入
     * @param treeId
     * @param nodes
     * @param targetNode
     * @returns {boolean}
     */
    function dropInner(treeId, nodes, targetNode) {
        if (targetNode && targetNode.dropInner === false) {
            return false;
        }
        if(targetNode == null){
            return false;
        }
        return true;
    }

    function onDrop(event, treeId, treeNodes, targetNode, moveType) {
        var parent = targetNode.id;
        var id = treeNodes[0].id;
        window.location.href = "$url_move" + "?id=" + id + "&parentId=" + parent;
//        console.log(targetNode.id + "_" + treeNodes[0].id)
    }


</script>

<script src="$!{webUtils.getAssetsPath("/ace1.3/assets/js/diligrp.form.js")}"></script>