/*全局自适应高度*/
function autoFlashHeight(){
    var headerHeight = $(".header").height();
    var bottomContentHeight = $(".bottom-content").height();
    var toolsBar = $(".tools-bar").height();
    $(".content").height($(window).height()-headerHeight);
    $(".main-side").height($(window).height()-headerHeight-2);
    $(".fluid-content").height($(window).height()-headerHeight-1);
    $(".side-content").height($(window).height()-headerHeight );
    $(".poj-list").height($(window).height()-headerHeight);
    $(".form-list").height($(window).height()-headerHeight-50 );
    $(".main-data-top").height($(window).height()-headerHeight-toolsBar-bottomContentHeight-2);
    $(".main-data-top-fluid").height($(window).height()-headerHeight-bottomContentHeight-2);
    $(".main-data").height($(window).height()-headerHeight);
    $(".main-side .tab-content").height($(window).height()-headerHeight-29);
    $('#partialBody').height($(window).height()-headerHeight-toolsBar - 60);
    let partialWidth = $('#tablePartial').width();
    $('#tablePartial').find('th:eq(0)').width(partialWidth * 0.06);
    $('#tablePartial').find('th:eq(1)').width(partialWidth * 0.3);
    $('#tablePartial').find('th:eq(2)').width(partialWidth * 0.64);
    $('#partialBody').find('tr').find('td:eq(0)').width(partialWidth * 0.06);
    $('#partialBody').find('tr').find('td:eq(1)').width(partialWidth * 0.3);
    $('#partialBody').find('tr').find('td:eq(2)').width(partialWidth * 0.64);
//说明
    $('#explanationShow').height($(window).height()-headerHeight-toolsBar-100);
//计算规则
    $('#ruleTextShow').height($(window).height()-headerHeight-toolsBar-100);
    typeof loadRationSubSize !== 'undefined' ? loadRationSubSize() : '';
    typeof loadZmhsAdjSize !== 'undefined' ? loadZmhsAdjSize() : '';
    typeof sectionTreeObj !== 'undefined' ? sectionTreeObj.loadRateWidth() : '';
};
$(window).resize(autoFlashHeight);
/*全局自适应高度结束*/
$(function(){
    //拖动头部
    $('body').on("show.bs.modal", ".modal", function(){
        if (typeof  $(this).find('.modal-content').draggable === 'function') {
            $(this).find('.modal-content').draggable({handle: '.modal-header', cancel: 'a, button'});
        }
    });
    /*侧滑*/
    $(".open-sidebar").click(function(){
        $(".slide-sidebar").animate({width:"800"}).addClass("open");
    });
    $("body").click(function(event){
        var e = event || window.event; //浏览器兼容性
        if(!$(event.target).is('a')) {
            var elem = event.target || e.srcElement;
            while (elem) { //循环判断至跟节点，防止点击的是div子元素
                if (elem.className == "open-sidebar" || elem.className == 'slide-sidebar open') {
                    return false;
                }
                elem = elem.parentNode;
            }
            $(".slide-sidebar").animate({width:"0"}).removeClass("open")// 关闭处理
        }

    });
    /*侧滑*/
    /*工具提示*/
    $('*[data-toggle=tooltip]').mouseover(function() {
        $(this).tooltip('show');
    });
    /*工具提示*/
});
/**
 * 设置本地缓存
 *
 * @param {String} key
 * @param {String|Number} value
 * @return {void}
 */
function setLocalCache(key, value) {
    const storage = window.localStorage;
    if (!storage || key === '' || value === '') {
        return;
    }
    try {
        storage.setItem(key, value);
    } catch (err) {
        storage.clear();
        storage.setItem(key, value);
    }
}

/**
 * 获取本地缓存
 *
 * @param {String} key
 * @return {String}
 */
function getLocalCache(key) {
    const storage = window.localStorage;
    if (!storage || key === '') {
        return null;
    }

    return storage.getItem(key);
}

function removeLocalCache(key) {
    const storage = window.localStorage;
    if (!storage || key === '') {
        return null;
    }
    return storage.removeItem(key);
}