| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 | /** * Created by Mai on 2017/3/10. */$(function () {    // 读取本地存储的高度(必须放在载入spread之前)    loadSize("main", function() {        refreshSubSpread();    });    $("#header-menu").removeAttr('style');    projectInfoObj.showProjectInfo();    projectObj.checkMainSpread();    projectObj.loadProjectData();    $('#tab_baobiao').on('shown.bs.tab', function (e) {        $(e.relatedTarget.hash).removeClass('active');        // do something    });    $('#tab_zaojiashu').on('shown.bs.tab', function (e) {        $(e.relatedTarget.hash).removeClass('active');        $("#subItems").addClass('active');        $(gljOprObj.activeTab).addClass('active');        // do something    });    slideResize($("#main"), function() {        projectObj.mainSpread.refresh();        refreshSubSpread();    });    const projectId = scUrlUtil.GetQueryString('project');    // 绑定点击事件    projectObj.mainSpread.bind(GC.Spread.Sheets.Events.CellClick, function(sender, info) {        if (info.row !== undefined && projectId !== undefined) {            setLocalCache('lastRow:' + projectId, info.row);            setLocalCache('lastCol:' + projectId, info.col);        }    });});/** * 拖动更改div大小 * * @param {Object} rootElement - 最顶层div * @param {function} callback - 成功后执行 * @return {void} */function slideResize(rootElement, callback) {    let startY = 0;    let drag = false;    const element = rootElement.find('.resize');    const topContentEle = rootElement.find(".top-content");    const bottomContentEle = rootElement.find(".bottom-content");    let topContentHeight = 0;    let bottomContentHeight = 0;    let navHeight = 0;    let topChangeHeight = 0;    let bottomChangeHeight = 0;    // 鼠标点下时    element.mousedown(function(e) {        drag = true;        startY = e.clientY;        // 获取上部分的高度        topContentHeight = topContentEle.height();        // 获取下部分的高度        bottomContentHeight = bottomContentEle.height();        // nav高度部分        navHeight = bottomContentEle.children('ul.nav').height() + 4;        element.tooltip('hide');    });    // 鼠标移动    $("body").mousemove(function(e) {        if (drag) {            let moveHeight = e.clientY - startY;            // 判断拖动范围不能超出            topChangeHeight = topContentHeight + moveHeight;            topChangeHeight = topChangeHeight < 170 ? 170 : topChangeHeight;            topChangeHeight = topChangeHeight > 700 ? 709 : topChangeHeight;            topContentEle.children(".main-data-top").height(topChangeHeight);            bottomChangeHeight = bottomContentHeight - moveHeight;            bottomChangeHeight = bottomChangeHeight < 170 ? 170 : bottomChangeHeight;            bottomChangeHeight = bottomChangeHeight > 700 ? 709 : bottomChangeHeight;            bottomContentEle.children().find(".main-data-bottom").height(bottomChangeHeight - navHeight);        }    });    // 鼠标弹起    $("body").mouseup(function(e) {        if (drag) {            callback();            drag = false;            // 存入本地缓存            const id = rootElement.attr('id');            topChangeHeight = topChangeHeight >= 700 ? 709 : topChangeHeight;            bottomChangeHeight = bottomChangeHeight >= 700 ? 709 : bottomChangeHeight;            setLocalCache('topHeight:' + id, topChangeHeight);            setLocalCache('bottomHeight:' + id, bottomChangeHeight);        }    });}/** * 读取设置的高度 * * @param {String} tag - 顶层div的id * @param {function} callback - 回调函数 * @return {void} */function loadSize(tag, callback) {    if (tag === '') {        return;    }    let topHeight = getLocalCache('topHeight:' + tag);    let bottomHeight = getLocalCache('bottomHeight:' + tag);    if (topHeight === null || bottomHeight === null) {        return;    }    const navHeight = $("#"+ tag +" .bottom-content").children('ul.nav').height() + 4;    topHeight = parseFloat(topHeight);    bottomHeight = parseFloat(bottomHeight);    $("#"+ tag +" .main-data-top").height(topHeight);    $("#"+ tag +" .main-data-bottom").height(bottomHeight - navHeight);    // $("#"+ tag +" .bottom-content").height(bottomHeight);    callback();}
 |