From c53fbb2ee3cb2f5d69aa23b8a4b34c988fa0bc95 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期三, 04 二月 2026 14:57:41 +0800
Subject: [PATCH] #
---
src/main/webapp/components/MapCanvas.js | 80 +++++++++++++++++++++++++++++++++++----
1 files changed, 71 insertions(+), 9 deletions(-)
diff --git a/src/main/webapp/components/MapCanvas.js b/src/main/webapp/components/MapCanvas.js
index 5306b43..3147540 100644
--- a/src/main/webapp/components/MapCanvas.js
+++ b/src/main/webapp/components/MapCanvas.js
@@ -57,6 +57,9 @@
mapRowHeights: [],
mapColOffsets: [],
mapColWidths: [],
+ mapRowColOffsets: [],
+ mapRowColWidths: [],
+ mapRowShelfCells: [],
hoveredShelfCell: null,
hoverPointer: { x: 0, y: 0 },
hoverRaf: null,
@@ -1393,24 +1396,27 @@
if (!map || !Array.isArray(map)) { return; }
this.mapRowOffsets = Array.isArray(rowOffsets) ? rowOffsets.slice() : [];
this.mapRowHeights = Array.isArray(rowHeights) ? rowHeights.slice() : [];
+ const rowColOffsets = [];
+ const rowColWidths = [];
+ const rowShelfCells = new Array(map.length);
let maxCols = 0;
for (let r = 0; r < map.length; r++) {
const row = map[r];
if (row && row.length > maxCols) { maxCols = row.length; }
+ rowShelfCells[r] = [];
}
const colWidths = new Array(maxCols);
for (let c = 0; c < maxCols; c++) {
let w = null;
for (let r = 0; r < map.length; r++) {
const cell = map[r] && map[r][c];
- if (!cell || cell.type === 'merge' || cell.isMergedPart) { continue; }
- if (cell.width != null && cell.width > 0) {
- const span = cell.colSpan || 1;
- w = cell.width / span;
- break;
+ if (!cell) { continue; }
+ if (cell.cellWidth != null && cell.cellWidth !== '') {
+ const base = Number(cell.cellWidth);
+ if (isFinite(base) && base > 0) { w = base / 40; break; }
}
}
- colWidths[c] = w || 25;
+ colWidths[c] = (w && isFinite(w) && w > 0) ? w : 25;
}
const colOffsets = new Array(maxCols);
let xCursor = 0;
@@ -1418,8 +1424,54 @@
colOffsets[c] = xCursor;
xCursor += colWidths[c];
}
+ for (let r = 0; r < map.length; r++) {
+ const row = map[r];
+ if (!row || row.length === 0) {
+ rowColOffsets[r] = [];
+ rowColWidths[r] = [];
+ continue;
+ }
+ const widths = new Array(row.length);
+ for (let c = 0; c < row.length; c++) {
+ const cell = row[c];
+ let w = null;
+ if (cell && cell.cellWidth != null && cell.cellWidth !== '') {
+ const base = Number(cell.cellWidth);
+ if (isFinite(base) && base > 0) { w = base / 40; }
+ }
+ widths[c] = (w && isFinite(w) && w > 0) ? w : 25;
+ }
+ const offsets = new Array(row.length);
+ let x = 0;
+ for (let c = 0; c < row.length; c++) {
+ offsets[c] = x;
+ x += widths[c];
+ }
+ rowColOffsets[r] = offsets;
+ rowColWidths[r] = widths;
+ }
this.mapColWidths = colWidths;
this.mapColOffsets = colOffsets;
+ this.mapRowColOffsets = rowColOffsets;
+ this.mapRowColWidths = rowColWidths;
+ this.mapRowShelfCells = rowShelfCells;
+
+ for (let r = 0; r < map.length; r++) {
+ const row = map[r];
+ if (!row) { continue; }
+ for (let c = 0; c < row.length; c++) {
+ const cell = row[c];
+ if (!cell || cell.type !== 'shelf') { continue; }
+ const startRow = this.findIndexByOffsets(this.mapRowOffsets, this.mapRowHeights, cell.posY + 0.01);
+ const endRow = this.findIndexByOffsets(this.mapRowOffsets, this.mapRowHeights, cell.posY + cell.height - 0.01);
+ if (startRow < 0) { continue; }
+ const last = endRow >= 0 ? endRow : startRow;
+ for (let rr = startRow; rr <= last; rr++) {
+ if (!rowShelfCells[rr]) { rowShelfCells[rr] = []; }
+ rowShelfCells[rr].push(cell);
+ }
+ }
+ }
},
findIndexByOffsets(offsets, sizes, value) {
if (!offsets || !sizes || offsets.length === 0) { return -1; }
@@ -1436,9 +1488,19 @@
const local = this.mapRoot.toLocal(new PIXI.Point(globalPos.x, globalPos.y));
const rowIndex = this.findIndexByOffsets(this.mapRowOffsets, this.mapRowHeights, local.y);
if (rowIndex < 0) { if (this.hoveredShelfCell) { this.hoveredShelfCell = null; this.hideShelfTooltip(); } return; }
- const colIndex = this.findIndexByOffsets(this.mapColOffsets, this.mapColWidths, local.x);
- if (colIndex < 0) { if (this.hoveredShelfCell) { this.hoveredShelfCell = null; this.hideShelfTooltip(); } return; }
- const cell = this.resolveMergedCell(this.map, rowIndex, colIndex);
+ let cell = null;
+ if (this.mapRowShelfCells && this.mapRowShelfCells[rowIndex]) {
+ const list = this.mapRowShelfCells[rowIndex];
+ for (let i = 0; i < list.length; i++) {
+ const it = list[i];
+ if (!it) { continue; }
+ if (local.x >= it.posX && local.x < it.posX + it.width &&
+ local.y >= it.posY && local.y < it.posY + it.height) {
+ cell = it;
+ break;
+ }
+ }
+ }
if (!cell || cell.type !== 'shelf') { if (this.hoveredShelfCell) { this.hoveredShelfCell = null; this.hideShelfTooltip(); } return; }
if (this.hoveredShelfCell !== cell) {
this.hoveredShelfCell = cell;
--
Gitblit v1.9.1