- 在Program.cs中注册LoginHub - 在HomeController中传递用户ID以支持SignalR连接 - 在Index.cshtml中实现SignalR连接和心跳机制,处理强制登出和注册成功事件 - 移除旧的登录状态检查逻辑,优化页面加载时的连接管理
267 lines
8.8 KiB
Plaintext
267 lines
8.8 KiB
Plaintext
@model HHWMS.Web.LocationMonitor2DVM
|
|
@inject IStringLocalizer<Program> Localizer;
|
|
<div class="layui-fluid">
|
|
<div class="layui-card">
|
|
<div class="layui-form layui-card-header">
|
|
<div class="layui-form-item">
|
|
<div class="layui-inline">
|
|
<label class="layui-form-label">库区</label>
|
|
<div class="layui-input-inline">
|
|
<select id="areaSelect" lay-filter="areaSelect">
|
|
<option value="">请选择库区</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="layui-inline">
|
|
<label class="layui-form-label">排号</label>
|
|
<div class="layui-input-inline">
|
|
<select id="rowSelect" lay-filter="rowSelect">
|
|
<option value="">请选择排号</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="layui-card-body">
|
|
<div id="locationGrid" class="location-grid">
|
|
<!-- 货架布局将通过JavaScript动态生成 -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
.location-grid {
|
|
display: flex;
|
|
flex-direction: column-reverse;
|
|
gap: 10px;
|
|
padding: 10px;
|
|
}
|
|
|
|
.layer-container {
|
|
display: flex;
|
|
flex-wrap: nowrap;
|
|
gap: 5px;
|
|
align-items: center;
|
|
}
|
|
|
|
.column-header {
|
|
min-width: 40px;
|
|
height: 40px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-weight: bold;
|
|
color: #666;
|
|
padding: 4px;
|
|
box-sizing: border-box;
|
|
width: 50px;
|
|
}
|
|
|
|
.layer-title {
|
|
min-width: 60px;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.location-cell {
|
|
border: none;
|
|
padding: 4px;
|
|
min-width: 40px;
|
|
height: 40px;
|
|
text-align: center;
|
|
cursor: pointer;
|
|
font-size: 12px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
background-size: contain;
|
|
background-repeat: no-repeat;
|
|
background-position: center;
|
|
box-sizing: border-box;
|
|
width: 50px;
|
|
}
|
|
|
|
.location-cell.some {
|
|
background-image: url('/images/container/Some.png');
|
|
}
|
|
|
|
.location-cell.full {
|
|
background-image: url('/images/container/Full.png');
|
|
}
|
|
|
|
.location-cell.emptycontainer {
|
|
background-image: url('/images/container/EmptyContainer.png');
|
|
}
|
|
|
|
.location-cell.empty {
|
|
background-image: url('/images/container/Empty.png');
|
|
}
|
|
|
|
.location-cell.locked {
|
|
background-image: url('/images/container/locked.svg');
|
|
}
|
|
.location-cell.none {
|
|
background-color: black;
|
|
}
|
|
|
|
|
|
.location-tooltip {
|
|
display: none;
|
|
position: absolute;
|
|
background: rgba(0, 0, 0, 0.8);
|
|
color: white;
|
|
padding: 8px;
|
|
border-radius: 4px;
|
|
font-size: 12px;
|
|
z-index: 1000;
|
|
max-width: 200px;
|
|
}
|
|
</style>
|
|
|
|
|
|
<script>
|
|
layui.use(['form', 'jquery'], function () {
|
|
var form = layui.form;
|
|
var $ = layui.jquery;
|
|
|
|
// 初始化加载库区数据
|
|
function loadAreas() {
|
|
$.get('/configs/LocationMonitor/GetAreas', function(data) {
|
|
var areaSelect = $('#areaSelect');
|
|
data.forEach(function(area) {
|
|
areaSelect.append(new Option(area, area));
|
|
});
|
|
form.render('select');
|
|
});
|
|
}
|
|
|
|
// 根据库区加载排号
|
|
function loadRows(area) {
|
|
//console.log(area);
|
|
if (!area) return;
|
|
$.get('/configs/LocationMonitor/GetRows', { area: area }, function(data) {
|
|
var rowSelect = $('#rowSelect');
|
|
rowSelect.empty();
|
|
rowSelect.append(new Option('请选择排号', ''));
|
|
data.forEach(function(row) {
|
|
rowSelect.append(new Option(row, row));
|
|
});
|
|
form.render('select');
|
|
});
|
|
}
|
|
|
|
// 加载库位数据并渲染网格
|
|
function loadLocationGrid(area, row) {
|
|
if (!area || !row) return;
|
|
$.get('/configs/LocationMonitor/GetLocationsByAreaAndRow', {
|
|
area: area,
|
|
row: row
|
|
}, function(data) {
|
|
renderLocationGrid(data);
|
|
});
|
|
}
|
|
|
|
// 渲染库位网格
|
|
function renderLocationGrid(locations) {
|
|
var grid = $('#locationGrid');
|
|
grid.empty();
|
|
|
|
// 获取所有唯一的Layer和Line值
|
|
var layers = [...new Set(locations.map(loc => loc.Layer || 1))].sort((a, b) => a - b);
|
|
var lines = [...new Set(locations.map(loc => loc.Line || 1))].sort((a, b) => a - b);
|
|
|
|
// 按层级和列号分组
|
|
var locationsByLayer = {};
|
|
locations.forEach(function(loc) {
|
|
var layer = loc.Layer || 1;
|
|
locationsByLayer[layer] = locationsByLayer[layer] || {};
|
|
var line = loc.Line || 1;
|
|
locationsByLayer[layer][line] = loc;
|
|
});
|
|
|
|
// 创建tooltip元素
|
|
var tooltip = $('<div>').addClass('location-tooltip').appendTo('body');
|
|
|
|
// 处理鼠标移动
|
|
$(document).on('mousemove', function(e) {
|
|
tooltip.css({
|
|
left: e.pageX + 10,
|
|
top: e.pageY + 10
|
|
});
|
|
});
|
|
|
|
// 当鼠标移出网格区域时隐藏提示框
|
|
grid.on('mouseleave', function() {
|
|
tooltip.hide();
|
|
});
|
|
|
|
// 如果有数据,先添加列标行
|
|
if (lines.length > 0) {
|
|
var headerContainer = $('<div>').addClass('layer-container');
|
|
headerContainer.append($('<div>').addClass('layer-title').text('')); // 空标题占位
|
|
|
|
// 使用实际的Line值生成列标
|
|
lines.forEach(function(line) {
|
|
headerContainer.append($('<div>').addClass('column-header').text(line.toString()));
|
|
});
|
|
grid.append(headerContainer);
|
|
}
|
|
|
|
// 按层级顺序创建容器(自动从下到上显示)
|
|
layers.forEach(function(layer) {
|
|
var layerContainer = $('<div>').addClass('layer-container');
|
|
|
|
// 添加层号标题
|
|
layerContainer.append($('<div>').addClass('layer-title').text('第' + layer + '层'));
|
|
|
|
// 按Line顺序创建单元格
|
|
lines.forEach(function(line) {
|
|
var loc = locationsByLayer[layer]?.[line];
|
|
var cell = $('<div>').addClass('location-cell');
|
|
|
|
if (loc) {
|
|
var status = (loc.Status).toString().toLowerCase();
|
|
cell.addClass(status)
|
|
.data('location', loc)
|
|
.hover(
|
|
function() {
|
|
var location = $(this).data('location');
|
|
var tooltipContent =
|
|
'编码: ' + location.Code + '<br>' +
|
|
'状态: ' + (location.Status1) + '<br>' +
|
|
(location.ContainerCode ? '容器: ' + location.ContainerCode + '<br>' : '');
|
|
tooltip.html(tooltipContent).show();
|
|
},
|
|
function() {
|
|
tooltip.hide();
|
|
}
|
|
);
|
|
} else {
|
|
cell.addClass('none');
|
|
}
|
|
|
|
layerContainer.append(cell);
|
|
});
|
|
|
|
grid.append(layerContainer);
|
|
});
|
|
}
|
|
|
|
// 事件绑定
|
|
form.on('select(areaSelect)', function(data) {
|
|
loadRows(data.value);
|
|
$('#rowSelect').val('');
|
|
form.render('select');
|
|
$('#locationGrid').empty();
|
|
});
|
|
|
|
form.on('select(rowSelect)', function(data) {
|
|
var area = $('#areaSelect').val();
|
|
loadLocationGrid(area, data.value);
|
|
});
|
|
|
|
// 初始化加载
|
|
loadAreas();
|
|
});
|
|
</script>
|