From 9245059bbd1202e8e59486e5f124d7819760818a Mon Sep 17 00:00:00 2001
From: cl <1442464845@qq.com>
Date: 星期一, 23 三月 2026 18:59:22 +0800
Subject: [PATCH] 热力图
---
src/main/webapp/static/js/report/locMap.js | 202 ++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 176 insertions(+), 26 deletions(-)
diff --git a/src/main/webapp/static/js/report/locMap.js b/src/main/webapp/static/js/report/locMap.js
index e8f5ac8..c9498f0 100644
--- a/src/main/webapp/static/js/report/locMap.js
+++ b/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());
}
--
Gitblit v1.9.1