添加库位监控
库存 库位 添加zone权限管控
This commit is contained in:
1 parent
b005422b01
commit
e90e0db019
43 files changed
+536
-479
No files matched your search
@@ -260,7 +260,7 @@ namespace HHWMS.Web.Controllers
|
||||
locationList.Add(new Location
|
||||
{
|
||||
Code = $"{vm.Entity.Type}{vm.Entity.RoadWay.ToString().PadLeft(2, '0')}-{row.ToString().PadLeft(2, '0')}-{line.ToString().PadLeft(2, '0')}-{layer.ToString().PadLeft(2, '0')}",
|
||||
LocationZoneId = vm.Entity.LocationZoneId,
|
||||
ZoneId = vm.Entity.ZoneId,
|
||||
Type = vm.Entity.Type,
|
||||
RoadWay = vm.Entity.RoadWay,
|
||||
Row = row,
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Mvc;
|
||||
|
||||
namespace HHWMS.Web.Controllers
|
||||
{
|
||||
[Area("configs")]
|
||||
[ActionDescription("库位监控")]
|
||||
public partial class LocationMonitorController : BaseController
|
||||
{
|
||||
[ActionDescription("二维监控")]
|
||||
public IActionResult Index()
|
||||
{
|
||||
var vm = Wtm.CreateVM<LocationMonitor2DVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult GetAreas()
|
||||
{
|
||||
var vm = Wtm.CreateVM<LocationMonitor2DVM>();
|
||||
return Json(vm.GetAreas());
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult GetRows([FromQuery]int area)
|
||||
{
|
||||
var vm = Wtm.CreateVM<LocationMonitor2DVM>();
|
||||
return Json(vm.GetRows(area));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult GetLocationsByAreaAndRow([FromQuery]int area, short row)
|
||||
{
|
||||
var vm = Wtm.CreateVM<LocationMonitor2DVM>();
|
||||
return Json(vm.GetLocationsByAreaAndRow(area, row));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using HHWMS.Web.Models;
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
public class LocationMonitor2DVM : BaseVM
|
||||
{
|
||||
public string Area { get; set; }
|
||||
public string Row { get; set; }
|
||||
|
||||
public class LocationGridItem
|
||||
{
|
||||
public string Code { get; set; }
|
||||
public short Row { get; set; }
|
||||
public short Line { get; set; }
|
||||
public short Layer { get; set; }
|
||||
public LocationStatusEnum Status { get; set; }
|
||||
public string ContainerCode { get; set; }
|
||||
}
|
||||
|
||||
public IEnumerable<int> GetAreas()
|
||||
{
|
||||
return DC.Set<Location>()
|
||||
.Select(x => x.ZoneId)
|
||||
.Distinct()
|
||||
.OrderBy(x => x)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public IEnumerable<short> GetRows(int area)
|
||||
{
|
||||
return DC.Set<Location>()
|
||||
.Where(x => x.ZoneId == area)
|
||||
.Select(x => x.Row)
|
||||
.Distinct()
|
||||
.OrderBy(x => x)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public IEnumerable<dynamic> GetLocationsByAreaAndRow(int area, short row)
|
||||
{
|
||||
var result = DC.Set<Location>()
|
||||
.Where(x => x.ZoneId == area && x.Row == row)
|
||||
.OrderBy(x => x.Line)
|
||||
.Select(x => new
|
||||
{
|
||||
Code = x.Code,
|
||||
Row = x.Row,
|
||||
Line = x.Line,
|
||||
Layer = x.Layer,
|
||||
x.Status,
|
||||
Status1 = x.Status.GetEnumDisplayName(),
|
||||
ContainerCode = x.ContainerCode
|
||||
}).ToList();
|
||||
return result;
|
||||
}
|
||||
|
||||
private string GetEnumDisplayName(Enum enumValue)
|
||||
{
|
||||
var fieldInfo = enumValue.GetType().GetField(enumValue.ToString());
|
||||
var displayAttribute = fieldInfo.GetCustomAttributes(typeof(DisplayAttribute), false).FirstOrDefault() as DisplayAttribute;
|
||||
|
||||
return displayAttribute?.Name ?? enumValue.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ namespace HHWMS.Web
|
||||
{
|
||||
public partial class LocationTemplateVM : BaseTemplateVM
|
||||
{
|
||||
public ExcelPropety LocationZone_Excel = ExcelPropety.CreateProperty<Location>(x => x.LocationZoneId);
|
||||
public ExcelPropety LocationZone_Excel = ExcelPropety.CreateProperty<Location>(x => x.ZoneId);
|
||||
[Display(Name = "Location.Code")]
|
||||
public ExcelPropety Code_Excel = ExcelPropety.CreateProperty<Location>(x => x.Code);
|
||||
[Display(Name = "Location.Type")]
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace HHWMS.Web
|
||||
public override IOrderedQueryable<Location_View> GetSearchQuery()
|
||||
{
|
||||
var query = DC.Set<Location>()
|
||||
.CheckEqual(Searcher.LocationZoneId, x=>x.LocationZoneId)
|
||||
.CheckEqual(Searcher.LocationZoneId, x=>x.ZoneId)
|
||||
.CheckContain(Searcher.Code, x=>x.Code)
|
||||
.CheckEqual(Searcher.Type, x=>x.Type)
|
||||
.CheckEqual(Searcher.Status, x=>x.Status)
|
||||
@@ -68,7 +68,7 @@ namespace HHWMS.Web
|
||||
.Select(x => new Location_View
|
||||
{
|
||||
ID = x.ID,
|
||||
Name_view = x.LocationZone.Name,
|
||||
Name_view = x.Zone.Name,
|
||||
Code = x.Code,
|
||||
Type = x.Type,
|
||||
Status = x.Status,
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace HHWMS.Web
|
||||
|
||||
public LocationVM()
|
||||
{
|
||||
SetInclude(x => x.LocationZone);
|
||||
SetInclude(x => x.Zone);
|
||||
}
|
||||
|
||||
protected override void InitVM()
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:combobox field="Entity.LocationZoneId" items="AllLocationZones" empty-text="@Localizer["Sys.All"]"/>
|
||||
<wt:combobox field="Entity.ZoneId" items="AllLocationZones" empty-text="@Localizer["Sys.All"]"/>
|
||||
|
||||
<wt:combobox field="RoadwayType" items="RoadwayTypes" empty-text="@Localizer["Sys.All"]"/>
|
||||
<wt:combobox field="Entity.Type" empty-text="@Localizer["Sys.All"]"/>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:combobox field="Entity.LocationZoneId" items="AllLocationZones"/>
|
||||
<wt:combobox field="Entity.ZoneId" items="AllLocationZones"/>
|
||||
<wt:textbox field="Entity.Code" />
|
||||
<wt:combobox field="Entity.Type" />
|
||||
<wt:combobox field="Entity.Status" />
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<wt:form vm="@Model">
|
||||
<wt:quote>@Localizer["Sys.DeleteConfirm"]</wt:quote>
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:display field="Entity.LocationZone.Name" />
|
||||
<wt:display field="Entity.Zone.Name" />
|
||||
<wt:display field="Entity.Code" />
|
||||
<wt:display field="Entity.Type" />
|
||||
<wt:display field="Entity.Status" />
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:display field="Entity.LocationZone.Name" />
|
||||
<wt:display field="Entity.Zone.Name" />
|
||||
<wt:display field="Entity.Code" />
|
||||
<wt:display field="Entity.Type" />
|
||||
<wt:display field="Entity.Status" />
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<wt:form vm="@Model">
|
||||
<wt:row items-per-row="ItemsPerRowEnum.Two">
|
||||
<wt:combobox field="Entity.LocationZoneId" items="AllLocationZones"/>
|
||||
<wt:combobox field="Entity.ZoneId" items="AllLocationZones"/>
|
||||
<wt:textbox field="Entity.Code" />
|
||||
<wt:combobox field="Entity.Type" />
|
||||
<wt:combobox field="Entity.Status" />
|
||||
|
||||
@@ -0,0 +1,266 @@
|
||||
@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>
|
||||
Reference in new issue
Block a user