自动化立体仓库 - WMS系统
cl
2026-03-23 9245059bbd1202e8e59486e5f124d7819760818a
src/main/webapp/static/js/report/locMap.js
@@ -2,9 +2,93 @@
    var $ = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;
    var locMapRefreshTimer = null;
    var locMapDocVisible = !document.hidden;
    var locMapFrameVisible = true;
    function locMapIframeUsable() {
        try {
            var fe = window.frameElement;
            if (!fe) {
                return true;
            }
            var doc = fe.ownerDocument;
            var win = doc.defaultView || window.parent;
            var el = fe;
            while (el) {
                var st = win.getComputedStyle(el);
                if (st.display === 'none' || st.visibility === 'hidden' || Number(st.opacity) === 0) {
                    return false;
                }
                el = el.parentElement;
            }
            var r = fe.getBoundingClientRect();
            return r.width >= 1 && r.height >= 1;
        } catch (e) {
            return true;
        }
    }
    function locMapHeatmapPageActive() {
        return locMapDocVisible && locMapFrameVisible && locMapIframeUsable();
    }
    function clearLocMapRefresh() {
        if (locMapRefreshTimer) {
            clearInterval(locMapRefreshTimer);
            locMapRefreshTimer = null;
        }
    }
    function updateLocMapRefreshTimer() {
        clearLocMapRefresh();
        var ms = parseInt($('#locMapRefreshSelect').val(), 10) || 0;
        if (ms <= 0 || !locMapHeatmapPageActive()) {
            return;
        }
        locMapRefreshTimer = setInterval(function () {
            if (!locMapHeatmapPageActive()) {
                return;
            }
            var row = $('#rowSelect').val();
            if (row) {
                getLocTable(row);
            }
        }, ms);
    }
    function resumeLocMapAutoRefresh() {
        var ms = parseInt($('#locMapRefreshSelect').val(), 10) || 0;
        var row = $('#rowSelect').val();
        if (ms > 0 && row && locMapHeatmapPageActive()) {
            getLocTable(row, true);
        }
        updateLocMapRefreshTimer();
    }
    getLocMapRows();
    getLocTable(1);
    getLocTable(1, true);
    updateLocMapRefreshTimer();
    if (typeof IntersectionObserver !== 'undefined') {
        var locMapIo = new IntersectionObserver(function (entries) {
            var e = entries[0];
            var next = !!(e && e.isIntersecting && e.intersectionRatio > 0);
            if (next === locMapFrameVisible) {
                return;
            }
            locMapFrameVisible = next;
            if (locMapFrameVisible) {
                resumeLocMapAutoRefresh();
            } else {
                updateLocMapRefreshTimer();
            }
        }, { threshold: [0, 0.01, 1] });
        var locMapHold = document.getElementById('locMapContain');
        if (locMapHold) {
            locMapIo.observe(locMapHold);
        }
    }
    function getLocMapRows() {
        $.ajax({
@@ -28,7 +112,10 @@
        });
    }
    function getLocTable(row){
    function getLocTable(row, force) {
        if (!force && !locMapHeatmapPageActive()) {
            return;
        }
        $.ajax({
            url: baseUrl+"/report/viewLocMapList.action",
            headers: {'token': localStorage.getItem('token')},
@@ -50,35 +137,98 @@
    }
    form.on('select(row)', function (data) {
        getLocTable(data.value);
        getLocTable(data.value, true);
    });
    form.on('select(locMapRefresh)', function () {
        updateLocMapRefreshTimer();
    });
    $(window).on('beforeunload', function () {
        clearLocMapRefresh();
    });
    document.addEventListener('visibilitychange', function () {
        locMapDocVisible = !document.hidden;
        if (locMapDocVisible) {
            resumeLocMapAutoRefresh();
        } else {
            updateLocMapRefreshTimer();
        }
    });
    function copyLocMapText(text) {
        if (!text) {
            return;
        }
        if (navigator.clipboard && navigator.clipboard.writeText) {
            navigator.clipboard.writeText(text).then(function () {
                layer.msg('已复制');
            }, function () {
                copyLocMapTextLegacy(text);
            });
        } else {
            copyLocMapTextLegacy(text);
        }
    }
    function copyLocMapTextLegacy(text) {
        var ta = document.createElement('textarea');
        ta.value = text;
        ta.style.position = 'fixed';
        ta.style.left = '-9999px';
        document.body.appendChild(ta);
        ta.select();
        try {
            document.execCommand('copy');
            layer.msg('已复制');
        } catch (e) {
            layer.msg('复制失败');
        }
        document.body.removeChild(ta);
    }
    $(document).on('click', '#locMapContain .loc-map-locno-badge', function (e) {
        e.stopPropagation();
        e.preventDefault();
        copyLocMapText($(this).attr('data-copy-loc'));
    });
    $(document).on('click', '#locMapContain .loc-map-bar', function (e) {
        e.stopPropagation();
        e.preventDefault();
        copyLocMapText($(this).attr('data-copy-bar'));
    });
    $(document).on('click', '#locMapContain .loc-map-maktx', function (e) {
        e.stopPropagation();
        e.preventDefault();
        var $td = $(this).closest('td.a-loc');
        var no = ($(this).attr('data-loc-no') || $td.attr('title') || '').trim();
        var sts = ($td.attr('data-loc-sts') || '').trim();
        locDetlOpen(no, sts);
    });
});
var locNo = '';
function locDetl(el) {
    var value = $(el).attr('title');
    var html = $(el).html();
    if (value===null
        ||value === undefined
        || value.trim()===''
        || html.trim()==='S'
        || html.trim()==='D'
        || html.trim()==='O'
        || html.trim()==='Z'
    ){
    } else {
        layer.open({
            type: 2,
            title: '库位物料',
            maxmin: true,
            area: [top.detailWidth, top.detailHeight],
            shadeClose: true,
            content: 'locDetl.html',
            success: function(layero, index){
                locNo = value;
            }
        });
function locDetlOpen(value, sts) {
    if (value === null || value === undefined || String(value).trim() === ''
        || sts === 'S' || sts === 'D' || sts === 'O' || sts === 'Z') {
        return;
    }
    layer.open({
        type: 2,
        title: '库位物料',
        maxmin: true,
        area: [top.detailWidth, top.detailHeight],
        shadeClose: true,
        content: 'locDetl.html',
        success: function (layero, index) {
            locNo = value;
        }
    });
}
function locDetl(el) {
    locDetlOpen($(el).attr('title'), ($(el).attr('data-loc-sts') || '').trim());
}