main.js 2.5 KB
layui.config({
    base: "/js/"
}).use(['form', 'I18nPage', 'vue', 'ztree', 'layer', 'jquery', 'table', 'droptree', 'hhweb', 'utils'], function () {
    var form = layui.form,
        layer = layui.layer,
        $ = layui.jquery,
        I18nPage = layui.I18nPage;

    var table = layui.table;
    var hhweb = layui.hhweb;
    var toplayer = (top == undefined || top.layer === undefined) ? layer : top.layer;  //顶层的LAYER
    //给按钮添加快捷键
    //Ctrl+I键添加,Ctrl+R键刷新,Ctrl+D键删除,Ctrl+E键编辑,Ctrl+F查询,Ctrl+S保存,Ctrl+A全选,Ctrl+Shift+A取消全选,左 上一页 右 下一页
    $(document).bind("keydown", function (e) {
        //禁用页面F5刷新
        if (e.which == 116) {
            e.preventDefault(); //Skip default behavior of the enter key
        }
    });

    $(document).ready(function () {
        $.ajax({
            url: "/Home/GetQuickFunc",
            type: "post",
            dataType: "json",
            success: function (data) {
                if (data.code === 200) {
                    var shtml = '';
                    for (var i = 0; i < data.count; i++) {
                        shtml += '<div class="col-md-2 col-sm-3 col-xs-6">';
                        shtml += '  <div class = "quickClick" data-url = "' + data.data[i].Url + '">';
                        shtml += '    <i class="layui-icon" data-icon="" style="font-size:60px;color:blue;background-color:rgb(84,167,152);border-radius:10px 10px;border:2px solid yellow;">' + data.data[i].IconName + '</i>';
                        shtml += '    <br />';
                        shtml += '    <span style="font-size:16px;font-weight: bold;color:white;">' + data.data[i].Name + '</span>';
                        shtml += '  </div>';
                        shtml += '</div>';

                    }
                    $('#QuickIcon').html(shtml);
                    $('.quickClick').on('click', function () {
                        var tab = '<a href="javascript:;" data-url="' + $(this).data('url') + '"><i class="layui-icon" data-icon="">' + $(this).find('i').html() + '</i><cite>' + $(this).find('span').html() + '</cite></a>';
                        parent.tab.tabAdd($(tab));
                    });
                } else {
                    layer.msg(data.msg);
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                layer.alert(errorThrown, { icon: 2, shadeClose: true, title: "错误信息" });
            }
        }); 
    })
});