1
xiazhengtongxue
3 天以前 c906272c0905b1309503de92affbdb06ec9d4268
1
已添加2个文件
已修改5个文件
1831 ■■■■ 文件已修改
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/InboundTaskFlowService.cs 304 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code/WMS/WIDESEA_WMSClient/src/extension/stock/hcstockInfo.jsx 163 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code/WMS/WIDESEA_WMSClient/src/router/viewGird.js 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code/WMS/WIDESEA_WMSClient/src/views/Home.vue 821 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code/WMS/WIDESEA_WMSClient/src/views/stock/hcstockInfo.vue 505 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code/WMS/WIDESEA_WMSClient/src/views/stock/stockInfo.vue 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Dashboard/DashboardController.cs 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/InboundTaskFlowService.cs
@@ -1,153 +1,153 @@
using Serilog;
using System.Diagnostics.CodeAnalysis;
using WIDESEA_Core;
using WIDESEAWCS_Common.HttpEnum;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Enums;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.Service;
using WIDESEAWCS_Tasks;
namespace WIDESEAWCS_TaskInfoService.Flows
{
    /// <summary>
    /// å…¥åº“任务流程服务。
    /// è´Ÿè´£å…¥åº“任务接收初始化、状态推进及堆垛机完成处理。
    /// </summary>
    public class InboundTaskFlowService : IInboundTaskFlowService
    {
using Serilog;
using System.Diagnostics.CodeAnalysis;
using WIDESEA_Core;
using WIDESEAWCS_Common.HttpEnum;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Enums;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.Service;
using WIDESEAWCS_Tasks;
namespace WIDESEAWCS_TaskInfoService.Flows
{
    /// <summary>
    /// å…¥åº“任务流程服务。
    /// è´Ÿè´£å…¥åº“任务接收初始化、状态推进及堆垛机完成处理。
    /// </summary>
    public class InboundTaskFlowService : IInboundTaskFlowService
    {
        private readonly IRouterService _routerService;
        private readonly ITaskRepository _taskRepository;
        private readonly HttpClientHelper _httpClientHelper;
        private readonly ILogger _logger;
        /// <summary>
        /// åˆå§‹åŒ–入库任务流程服务。
        /// </summary>
        /// <param name="routerService">路由服务。</param>
        /// <param name="httpClientHelper">WMS接口调用帮助类。</param>
        public InboundTaskFlowService(IRouterService routerService, ITaskRepository taskRepository, HttpClientHelper httpClientHelper, ILogger logger)
        {
            _routerService = routerService;
            _taskRepository = taskRepository;
            _httpClientHelper = httpClientHelper;
            _logger = logger;
        }
        /// <summary>
        /// æŽ¥æ”¶WMS任务时初始化入库任务。
        /// </summary>
        /// <param name="task">任务实体。</param>
        /// <param name="source">WMS任务原始数据。</param>
        public WebResponseContent InitializeOnReceive([NotNull] Dt_Task task, [NotNull] WMSTaskDTO source)
        {
            WebResponseContent content = new WebResponseContent();
            Dt_Router routers = _routerService.QueryNextRoute(source.SourceAddress);
            if (routers.IsNullOrEmpty())
            {
                return content.Error("未找到路由信息");
            }
            task.TaskStatus = (int)TaskInStatusEnum.InNew;
            task.CurrentAddress = source.SourceAddress;
            task.NextAddress = routers.ChildPosi;
            return content.OK();
        }
        /// <summary>
        /// æŽ¨è¿›å…¥åº“任务状态,并在关键状态调用WMS接口。
        /// </summary>
        /// <param name="task">任务实体。</param>
        /// <returns>推进结果。</returns>
        public WebResponseContent MoveToNextStatus([NotNull] Dt_Task task)
        {
            if (task.TaskStatus >= (int)TaskInStatusEnum.InFinish)
                return WebResponseContent.Instance.Error($"该任务状态不可跳转到下一步,任务号:【{task.TaskNum}】,任务状态:【{task.TaskStatus}】");
            task.TaskStatus = task.TaskStatus.GetNextNotCompletedStatus<TaskInStatusEnum>();
            if (task.TaskStatus <= 0)
                return WebResponseContent.Instance.Error($"该任务状态不可跳转到下一步,任务号:【{task.TaskNum}】,任务状态:【{task.TaskStatus}】");
            if (task.TaskStatus == (int)TaskInStatusEnum.Line_InFinish)
            {
                return GetWMSInboundLocation(task);
            }
            return UpdateWMSTaskStatus(task);
        }
        /// <summary>
        /// å¤„理堆垛机入库完成动作。
        /// </summary>
        /// <param name="task">任务实体。</param>
        /// <returns>处理结果。</returns>
        public WebResponseContent CompleteStackerTask([NotNull] Dt_Task task)
        {
            WebResponseContent content = new WebResponseContent();
            if (task.TaskStatus != (int)TaskInStatusEnum.SC_InExecuting)
            {
                return WebResponseContent.Instance.OK();
            }
            int nextStatus = task.TaskStatus.GetNextNotCompletedStatus<TaskInStatusEnum>();
            task.TaskStatus = nextStatus;
            task.ModifyDate = DateTime.Now;
            task.Modifier = "System";
            var result = _httpClientHelper.Post<WebResponseContent>(
                nameof(ConfigKey.InboundFinishTaskAsync),
                (new CreateTaskDto { PalletCode = task.PalletCode }).ToJson());
            if (!result.IsSuccess || !result.Data.Status)
            {
                QuartzLogHelper.LogError(_logger, $"调用WMS接口失败,接口:【InboundFinishTaskAsync】,请求参数:【{task.PalletCode}】,错误信息:【{result.Data?.Message}】", "InboundTaskFlowService");
                return content.Error($"通知WMS系统堆垛机入库完成失败,任务号:【{task.TaskNum}】,托盘号:【{task.PalletCode}】,错误信息:【{result.Data?.Message}】");
            }
            QuartzLogHelper.LogInfo(_logger, $"调用WMS接口成功,接口:【InboundFinishTaskAsync】,响应数据:【{result.Data?.Data}】,耗时:0ms", "InboundTaskFlowService");
            return content.OK($"通知WMS系统堆垛机入库完成成功,任务号:【{task.TaskNum}】,托盘号:【{task.PalletCode}】");
        }
        /// <summary>
        /// ä»ŽWMS获取入库目标地址并回写任务。
        /// </summary>
        /// <param name="task">任务实体。</param>
        /// <returns>调用结果。</returns>
        private WebResponseContent GetWMSInboundLocation(Dt_Task task)
        {
            string configKey = nameof(ConfigKey.GetTasksLocation);
            string requestParam = new CreateTaskDto { PalletCode = task.PalletCode }.ToJson();
            DateTime startTime = DateTime.Now;
            var result = _httpClientHelper.Post<WebResponseContent>(
                configKey,
                requestParam);
            if (!result.IsSuccess || !result.Data.Status)
            {
                QuartzLogHelper.LogError(_logger, $"调用WMS接口失败,接口:【{configKey}】,请求参数:【{requestParam}】,错误信息:【{result.Data?.Message}】", "InboundTaskFlowService");
                return WebResponseContent.Instance.Error($"调用WMS接口获取任务目标地址失败,任务号:【{task.TaskNum}】,错误信息:【{result.Data?.Message}】");
            }
            QuartzLogHelper.LogInfo(_logger, $"调用WMS接口成功,接口:【{configKey}】,响应数据:【{result.Data?.Data}】,耗时:{(DateTime.Now - startTime).TotalMilliseconds}ms", "InboundTaskFlowService");
            string? nextAddress = result.Data.Data?.ToString();
            if (string.IsNullOrEmpty(nextAddress))
                return WebResponseContent.Instance.Error($"调用WMS接口获取任务目标地址失败,任务号:【{task.TaskNum}】,错误信息:【未获取到有效的目标地址】");
            task.CurrentAddress = task.NextAddress;
            task.NextAddress = nextAddress;
            task.TargetAddress = nextAddress;
            return WebResponseContent.Instance.OK();
        private readonly ITaskRepository _taskRepository;
        private readonly HttpClientHelper _httpClientHelper;
        private readonly ILogger _logger;
        /// <summary>
        /// åˆå§‹åŒ–入库任务流程服务。
        /// </summary>
        /// <param name="routerService">路由服务。</param>
        /// <param name="httpClientHelper">WMS接口调用帮助类。</param>
        public InboundTaskFlowService(IRouterService routerService, ITaskRepository taskRepository, HttpClientHelper httpClientHelper, ILogger logger)
        {
            _routerService = routerService;
            _taskRepository = taskRepository;
            _httpClientHelper = httpClientHelper;
            _logger = logger;
        }
        /// <summary>
        /// æŽ¥æ”¶WMS任务时初始化入库任务。
        /// </summary>
        /// <param name="task">任务实体。</param>
        /// <param name="source">WMS任务原始数据。</param>
        public WebResponseContent InitializeOnReceive([NotNull] Dt_Task task, [NotNull] WMSTaskDTO source)
        {
            WebResponseContent content = new WebResponseContent();
            Dt_Router routers = _routerService.QueryNextRoute(source.SourceAddress);
            if (routers.IsNullOrEmpty())
            {
                return content.Error("未找到路由信息");
            }
            task.TaskStatus = (int)TaskInStatusEnum.InNew;
            task.CurrentAddress = source.SourceAddress;
            task.NextAddress = routers.ChildPosi;
            return content.OK();
        }
        /// <summary>
        /// æŽ¨è¿›å…¥åº“任务状态,并在关键状态调用WMS接口。
        /// </summary>
        /// <param name="task">任务实体。</param>
        /// <returns>推进结果。</returns>
        public WebResponseContent MoveToNextStatus([NotNull] Dt_Task task)
        {
            if (task.TaskStatus >= (int)TaskInStatusEnum.InFinish)
                return WebResponseContent.Instance.Error($"该任务状态不可跳转到下一步,任务号:【{task.TaskNum}】,任务状态:【{task.TaskStatus}】");
            task.TaskStatus = task.TaskStatus.GetNextNotCompletedStatus<TaskInStatusEnum>();
            if (task.TaskStatus <= 0)
                return WebResponseContent.Instance.Error($"该任务状态不可跳转到下一步,任务号:【{task.TaskNum}】,任务状态:【{task.TaskStatus}】");
            if (task.TaskStatus == (int)TaskInStatusEnum.Line_InFinish)
            {
                return GetWMSInboundLocation(task);
            }
            return UpdateWMSTaskStatus(task);
        }
        /// <summary>
        /// å¤„理堆垛机入库完成动作。
        /// </summary>
        /// <param name="task">任务实体。</param>
        /// <returns>处理结果。</returns>
        public WebResponseContent CompleteStackerTask([NotNull] Dt_Task task)
        {
            WebResponseContent content = new WebResponseContent();
            if (task.TaskStatus != (int)TaskInStatusEnum.SC_InExecuting)
            {
                return WebResponseContent.Instance.OK();
            }
            int nextStatus = task.TaskStatus.GetNextNotCompletedStatus<TaskInStatusEnum>();
            task.TaskStatus = nextStatus;
            task.ModifyDate = DateTime.Now;
            task.Modifier = "System";
            var result = _httpClientHelper.Post<WebResponseContent>(
                nameof(ConfigKey.InboundFinishTaskAsync),
                (new CreateTaskDto { PalletCode = task.PalletCode }).ToJson());
            if (!result.IsSuccess || !result.Data.Status)
            {
                QuartzLogHelper.LogError(_logger, $"调用WMS接口失败,接口:【InboundFinishTaskAsync】,请求参数:【{task.PalletCode}】,错误信息:【{result.Data?.Message}】", "InboundTaskFlowService");
                return content.Error($"通知WMS系统堆垛机入库完成失败,任务号:【{task.TaskNum}】,托盘号:【{task.PalletCode}】,错误信息:【{result.Data?.Message}】");
            }
            QuartzLogHelper.LogInfo(_logger, $"调用WMS接口成功,接口:【InboundFinishTaskAsync】,响应数据:【{result.Data?.Data}】,耗时:0ms", "InboundTaskFlowService");
            return content.OK($"通知WMS系统堆垛机入库完成成功,任务号:【{task.TaskNum}】,托盘号:【{task.PalletCode}】");
        }
        /// <summary>
        /// ä»ŽWMS获取入库目标地址并回写任务。
        /// </summary>
        /// <param name="task">任务实体。</param>
        /// <returns>调用结果。</returns>
        private WebResponseContent GetWMSInboundLocation(Dt_Task task)
        {
            string configKey = nameof(ConfigKey.GetTasksLocation);
            string requestParam = new CreateTaskDto { PalletCode = task.PalletCode }.ToJson();
            DateTime startTime = DateTime.Now;
            var result = _httpClientHelper.Post<WebResponseContent>(
                configKey,
                requestParam);
            if (!result.IsSuccess || !result.Data.Status)
            {
                QuartzLogHelper.LogError(_logger, $"调用WMS接口失败,接口:【{configKey}】,请求参数:【{requestParam}】,错误信息:【{result.Data?.Message}】", "InboundTaskFlowService");
                return WebResponseContent.Instance.Error($"调用WMS接口获取任务目标地址失败,任务号:【{task.TaskNum}】,错误信息:【{result.Data?.Message}】");
            }
            QuartzLogHelper.LogInfo(_logger, $"调用WMS接口成功,接口:【{configKey}】,响应数据:【{result.Data?.Data}】,耗时:{(DateTime.Now - startTime).TotalMilliseconds}ms", "InboundTaskFlowService");
            string? nextAddress = result.Data.Data?.ToString();
            if (string.IsNullOrEmpty(nextAddress))
                return WebResponseContent.Instance.Error($"调用WMS接口获取任务目标地址失败,任务号:【{task.TaskNum}】,错误信息:【未获取到有效的目标地址】");
            task.CurrentAddress = task.NextAddress;
            task.NextAddress = nextAddress;
            task.TargetAddress = nextAddress;
            return WebResponseContent.Instance.OK();
        }
        /// <summary>
@@ -200,6 +200,6 @@
            QuartzLogHelper.LogInfo(_logger, $"调用WMS接口成功,接口:【{configKey}】,响应数据:【{result.Data?.Data}】,耗时:{(DateTime.Now - startTime).TotalMilliseconds}ms", "InboundTaskFlowService");
            return WebResponseContent.Instance.OK();
        }
    }
}
        }
    }
}
Code/WMS/WIDESEA_WMSClient/src/extension/stock/hcstockInfo.jsx
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,163 @@
//此js文件是用来自定义扩展业务代码,可以扩展一些自定义页面或者重新配置生成的代码
let extension = {
  components: {
    //查询界面扩展组件
    gridHeader: "",
    gridBody: "",
    gridFooter: "",
    //新建、编辑弹出框扩展组件
    modelHeader: "",
    modelBody: "",
    modelFooter: "",
  },
  tableAction: "",
  buttons: { view: [], box: [], detail: [] },
  methods: {
    onInit() {
      // æ·»åŠ MES操作列
      this.columns.push({
        title: "操作",
        field: "操作",
        align: "center",
        width: 200,
        fixed: "right",
        render: (h, { row, column, index }) => {
          return (
            <div>
              <el-button
                type="primary"
                size="small"
                onClick={($e) => {
                  this.handleInbound(row);
                }}
              >
                è¿›ç«™
              </el-button>
              <el-button
                type="success"
                size="small"
                style="margin-left: 8px"
                onClick={($e) => {
                  this.handleOutbound(row);
                }}
              >
                å‡ºç«™
              </el-button>
            </div>
          );
        },
      });
    },
    // æ‰˜ç›˜è¿›ç«™æ“ä½œ
    async handleInbound(row) {
      try {
        await this.$confirm(
          `确认执行托盘进站操作?\n托盘编号:${row.palletCode}`,
          "进站确认",
          {
            confirmButtonText: "确认",
            cancelButtonText: "取消",
            type: "warning",
          },
        );
        const result = await this.http.post(
          "/api/StockInfo/inboundInContainer",
          {
            palletCode: row.palletCode,
            stockId: row.id,
          },
          "正在调用MES接口...",
        );
        if (result.status) {
          this.$Message.success(result.message || "托盘进站成功");
          this.$refs.table.load();
        } else {
          this.$error(result.message || "托盘进站失败");
        }
      } catch (error) {
        if (error !== "cancel") {
          this.$error(error.message || "网络错误,请稍后重试");
        }
      }
    },
    // æ‰˜ç›˜å‡ºç«™æ“ä½œ
    async handleOutbound(row) {
      try {
        await this.$confirm(
          `确认执行托盘出站操作?\n托盘编号:${row.palletCode}`,
          "出站确认",
          {
            confirmButtonText: "确认",
            cancelButtonText: "取消",
            type: "warning",
          },
        );
        const result = await this.http.post(
          "/api/StockInfo/outboundInContainer",
          {
            palletCode: row.palletCode,
            stockId: row.id,
          },
          "正在调用MES接口...",
        );
        if (result.status) {
          this.$Message.success(result.message || "托盘出站成功");
          this.$refs.table.load();
        } else {
          this.$error(result.message || "托盘出站失败");
        }
      } catch (error) {
        if (error !== "cancel") {
          this.$error(error.message || "网络错误,请稍后重试");
        }
      }
    },
    onInited() {
      // æ¡†æž¶åˆå§‹åŒ–配置后
    },
    searchBefore(param) {
      const stockStatusFilter1 = {
        name: "stockStatus",
        value: "6",
        displayType: "int"
      };
      const warehouseIdFilter1 = {
        name: "warehouseId",
        value: "3",
        displayType: "int"
      };
      if (!param.wheres) {
        param.wheres = [];
      }
      // å°†è¿‡æ»¤æ¡ä»¶æ·»åŠ åˆ°æŸ¥è¯¢å‚æ•°ä¸­
      param.wheres.push(stockStatusFilter1);
      param.wheres.push(warehouseIdFilter1);
      return true;
    },
    searchAfter(result) {
      return result;
    },
    addBefore(formData) {
      return true;
    },
    updateBefore(formData) {
      return true;
    },
    rowClick({ row, column, event }) {
      this.$refs.table.$refs.table.toggleRowSelection(row);
    },
    modelOpenAfter(row) {
      // ç‚¹å‡»ç¼–辑、新建按钮弹出框后
    },
  },
};
export default extension;
Code/WMS/WIDESEA_WMSClient/src/router/viewGird.js
@@ -78,11 +78,18 @@
    path: '/outboundOrderDetail',
    name: 'outboundOrderDetail',
    component: () => import('@/views/outbound/outboundOrderDetail.vue')
  }, {
  },
  {
    path: '/stockInfo',
    name: 'stockInfo',
    component: () => import('@/views/stock/stockInfo.vue')
  }, {
  },
  {
    path: '/hcstockInfo',
    name: 'hcstockInfo',
    component: () => import('@/views/stock/hcstockInfo.vue')
  },
  {
    path: '/stockInfoDetail',
    name: 'stockInfoDetail',
    component: () => import('@/views/stock/stockInfoDetail.vue')
Code/WMS/WIDESEA_WMSClient/src/views/Home.vue
@@ -1,10 +1,95 @@
<template>
  <div class="dashboard-container">
    <!-- å„仓库月度出入库对比图 -->
    <!-- é¡¶éƒ¨KPI卡片:显示仓库总数和总库存量 -->
    <div class="kpi-cards">
      <div class="kpi-card">
        <div class="kpi-icon">🏚️</div>
        <div class="kpi-info">
          <div class="kpi-label">仓库总数</div>
          <div class="kpi-value">{{ totalWarehouses }}</div>
        </div>
      </div>
      <div class="kpi-card">
        <div class="kpi-icon">📦</div>
        <div class="kpi-info">
          <div class="kpi-label">总库存量</div>
          <div class="kpi-value">{{ totalStock.toLocaleString() }}</div>
        </div>
      </div>
      <div class="kpi-card">
        <div class="kpi-icon">📊</div>
        <div class="kpi-info">
          <div class="kpi-label">本月总入库</div>
          <div class="kpi-value">{{ monthlyInboundTotal.toLocaleString() }}</div>
        </div>
      </div>
      <div class="kpi-card">
        <div class="kpi-icon">📤</div>
        <div class="kpi-info">
          <div class="kpi-label">本月总出库</div>
          <div class="kpi-value">{{ monthlyOutboundTotal.toLocaleString() }}</div>
        </div>
      </div>
    </div>
    <!-- é¡¶éƒ¨ï¼šæœ¬æœˆå‡ºå…¥åº“趋势 - ä¸Š3下2布局,每个卡片直接显示仓库数字 -->
    <div class="chart-row top-three">
      <div v-for="warehouse in topWarehouses" :key="warehouse.code" class="chart-card">
        <div class="card-title">{{ warehouse.name }}</div>
        <!-- ä»“库数字显示区域 -->
        <div class="warehouse-numbers">
          <div class="number-item inbound">
            <span class="number-label">入库</span>
            <span class="number-value">{{ getMonthlyInbound(warehouse.code) }}</span>
          </div>
          <div class="number-item outbound">
            <span class="number-label">出库</span>
            <span class="number-value">{{ getMonthlyOutbound(warehouse.code) }}</span>
          </div>
          <div class="number-item stock">
            <span class="number-label">库存</span>
            <span class="number-value">{{ getWarehouseStock(warehouse.code) }}</span>
          </div>
        </div>
        <div :id="`chart-${warehouse.code}`" class="chart-content"></div>
      </div>
    </div>
    <div class="chart-row bottom-two">
      <div v-for="warehouse in bottomWarehouses" :key="warehouse.code" class="chart-card">
        <div class="card-title">{{ warehouse.name }}</div>
        <!-- ä»“库数字显示区域 -->
        <div class="warehouse-numbers">
          <div class="number-item inbound">
            <span class="number-label">入库</span>
            <span class="number-value">{{ getMonthlyInbound(warehouse.code) }}</span>
          </div>
          <div class="number-item outbound">
            <span class="number-label">出库</span>
            <span class="number-value">{{ getMonthlyOutbound(warehouse.code) }}</span>
          </div>
          <div class="number-item stock">
            <span class="number-label">库存</span>
            <span class="number-value">{{ getWarehouseStock(warehouse.code) }}</span>
          </div>
        </div>
        <div :id="`chart-${warehouse.code}`" class="chart-content"></div>
      </div>
    </div>
    <!-- æ¯æ—¥å‡ºå…¥åº“趋势 (全宽) -->
    <div class="chart-row full-width">
      <div class="chart-card">
        <div class="card-title">各仓库月度出入库对比</div>
        <div id="chart-warehouse-monthly" class="chart-content"></div>
        <div class="card-title">每日出入库趋势</div>
        <div id="chart-daily" class="chart-content"></div>
      </div>
    </div>
    <!-- ä»“库分布 -->
    <div class="chart-row">
      <div class="chart-card">
        <div class="card-title">各仓库库存分布</div>
        <div id="chart-warehouse" class="chart-content"></div>
      </div>
    </div>
  </div>
@@ -18,8 +103,40 @@
  data() {
    return {
      charts: {},
      monthlyData: [],
      warehouseNames: ['FJSC1', 'ZJSC1', 'GWSC1', 'CWSC1', 'HCSC1']
      // äº”个仓库定义 - ä¸Š3个
      topWarehouses: [
        { code: "GWSC1", name: "高温1号仓库" },
        { code: "CWSC1", name: "常温1号仓库" },
        { code: "HCSC1", name: "分容1号仓库" }
      ],
      // ä¸‹2个
      bottomWarehouses: [
        { code: "FJSC1", name: "负极卷1号仓库" },
        { code: "ZJSC1", name: "正极卷1号仓库" }
      ],
      dailyData: [],
      // å­˜å‚¨æ¯ä¸ªä»“库的月度数据
      monthlyData: {
        GWSC1: [],
        CWSC1: [],
        HCSC1: [],
        FJSC1: [],
        ZJSC1: []
      },
      // å­˜å‚¨æ¯ä¸ªä»“库的当前库存
      warehouseStocks: {
        GWSC1: 0,
        CWSC1: 0,
        HCSC1: 0,
        FJSC1: 0,
        ZJSC1: 0
      },
      warehouseData: [],
      // KPI æ±‡æ€»æ•°æ®
      totalWarehouses: 5,
      totalStock: 0,
      monthlyInboundTotal: 0,
      monthlyOutboundTotal: 0
    };
  },
  mounted() {
@@ -29,198 +146,412 @@
  },
  beforeUnmount() {
    window.removeEventListener("resize", this.handleResize);
    Object.values(this.charts).forEach(chart => chart.dispose());
    Object.values(this.charts).forEach(chart => chart && chart.dispose());
  },
  methods: {
    handleResize() {
      Object.values(this.charts).forEach(chart => chart.resize());
      Object.values(this.charts).forEach(chart => chart && chart.resize());
    },
    initCharts() {
      this.charts.warehouseMonthly = echarts.init(document.getElementById("chart-warehouse-monthly"));
      // åˆå§‹åŒ–所有仓库图表
      const allWarehouses = [...this.topWarehouses, ...this.bottomWarehouses];
      allWarehouses.forEach(warehouse => {
        const chartId = `chart-${warehouse.code}`;
        const el = document.getElementById(chartId);
        if (el) {
          this.charts[warehouse.code] = echarts.init(el);
        }
      });
      // åˆå§‹åŒ–每日图表和仓库分布图表
      this.charts.daily = echarts.init(document.getElementById("chart-daily"));
      this.charts.warehouse = echarts.init(document.getElementById("chart-warehouse"));
    },
    async loadData() {
      await this.loadMonthlyStats();
      // å¹¶è¡ŒåŠ è½½æ‰€æœ‰ä»“åº“çš„æœˆåº¦æ•°æ®ï¼ˆåˆ†åˆ«ä¼ å…¥ä¸åŒçš„Roadway参数)
      const allWarehouses = [...this.topWarehouses, ...this.bottomWarehouses];
      const monthlyPromises = allWarehouses.map(warehouse =>
        this.loadMonthlyStatsForWarehouse(warehouse.code)
      );
      await Promise.all(monthlyPromises);
      // æ›´æ–°æ‰€æœ‰ä»“库的月度图表
      this.updateAllMonthlyTrendCharts();
      await this.loadDailyStats();
      await this.loadStockByWarehouse();
      await this.loadWarehouseStocks();
      this.calculateKPIs();
    },
    async loadMonthlyStats() {
    async loadMonthlyStatsForWarehouse(roadway) {
      console.log(`正在加载${roadway}的每月统计数据...`);
      try {
        const promises = this.warehouseNames.map(warehouse =>
          this.http.get("/api/Dashboard/MonthlyStats", {
            months: 6,
            Roadway: warehouse
          })
        );
        const results = await Promise.all(promises);
        this.monthlyData = results.map((res, index) => ({
          warehouse: this.warehouseNames[index],
          warehouseName: this.getWarehouseName(this.warehouseNames[index]),
          data: res.data || []
        }));
        this.updateWarehouseMonthlyChart();
        // å…³é”®ä¿®å¤ï¼šåˆ†åˆ«ä¼ å…¥ä¸åŒçš„Roadway参数
        const res = await this.http.get("/api/Dashboard/MonthlyStats?monthly=12&roadway=" + roadway);
        if (res.status && res.data) {
          console.log(`${roadway} æ¯æœˆç»Ÿè®¡æ•°æ®:`, res.data);
          this.monthlyData[roadway] = res.data;
        } else {
          this.monthlyData[roadway] = [];
        }
      } catch (e) {
        console.error("加载每月统计失败", e);
        console.error(`加载${roadway}每月统计失败`, e);
        this.monthlyData[roadway] = [];
      }
    },
    getWarehouseName(code) {
      const nameMap = {
        'FJSC1': '负极卷1号仓库',
        'ZJSC1': '正极卷1号仓库',
        'GWSC1': '高温1号仓库',
        'CWSC1': '常温1号仓库',
        'HCSC1': '分容1号仓库'
      };
      return nameMap[code] || code;
    async loadDailyStats() {
      try {
        const res = await this.http.get("/api/Dashboard/DailyStats", { days: 30 });
        if (res.status && res.data) {
          console.log("每日统计数据:", res.data);
          this.dailyData = res.data;
          this.updateDailyChart();
        }
      } catch (e) {
        console.error("加载每日统计失败", e);
      }
    },
    updateWarehouseMonthlyChart() {
      // èŽ·å–æ‰€æœ‰æœˆä»½
      const months = this.monthlyData[0]?.data.map(d => `${d.month}月`) || [];
      // ä¸ºæ¯ä¸ªä»“库生成系列数据
      const series = [];
      this.monthlyData.forEach((warehouseData, index) => {
        const data = warehouseData.data;
        series.push({
          name: warehouseData.warehouseName,
          type: 'bar',
          data: data.map(d => ({
            value: (d.inbound || 0) + (d.outbound || 0),
            inbound: d.inbound || 0,
            outbound: d.outbound || 0,
            label: {
              show: true,
              position: 'top',
              formatter: function(params) {
                return `入:${params.data.inbound}\n出:${params.data.outbound}`;
              },
              fontSize: 10,
              color: '#fff',
              lineHeight: 15
    async loadStockByWarehouse() {
      try {
        const res = await this.http.get("/api/Dashboard/StockByWarehouse");
        if (res.status && res.data) {
          console.log("仓库分布数据:", res.data);
          this.warehouseData = res.data.data || res.data;
          this.updateWarehouseChart();
        }
      } catch (e) {
        console.error("加载仓库分布失败", e);
      }
    },
    async loadWarehouseStocks() {
      // æ¨¡æ‹ŸåŠ è½½æ¯ä¸ªä»“åº“çš„å½“å‰åº“å­˜é‡
      // å¦‚果后端有接口,可以替换为真实API调用
      try {
        // å°è¯•加载库存数据,如果接口不存在则使用模拟数据
        const allWarehouses = [...this.topWarehouses, ...this.bottomWarehouses];
        for (const warehouse of allWarehouses) {
          try {
            const res = await this.http.get(`/api/Dashboard/WarehouseStock?warehouse=${warehouse.code}`);
            if (res.status && res.data) {
              this.warehouseStocks[warehouse.code] = res.data.stock || 0;
            } else {
              // ä»Žæœˆåº¦æ•°æ®ä¸­è®¡ç®—模拟库存(最近月份累计入库-出库)
              const monthlyData = this.monthlyData[warehouse.code] || [];
              let totalInbound = 0;
              let totalOutbound = 0;
              monthlyData.forEach(m => {
                totalInbound += (m.inbound ?? m.Inbound) || 0;
                totalOutbound += (m.outbound ?? m.Outbound) || 0;
              });
              this.warehouseStocks[warehouse.code] = Math.max(0, totalInbound - totalOutbound);
            }
          })),
          barWidth: '15%',
          barGap: '10%',
          itemStyle: {
            color: this.getBarColor(index),
            borderRadius: [3, 3, 0, 0]
          } catch (e) {
            // ä½¿ç”¨æ¨¡æ‹Ÿæ•°æ®
            const mockStocks = {
              GWSC1: 12580,
              CWSC1: 8920,
              HCSC1: 15600,
              FJSC1: 4300,
              ZJSC1: 7200
            };
            this.warehouseStocks[warehouse.code] = mockStocks[warehouse.code] || 0;
          }
        });
        }
      } catch (e) {
        console.error("加载仓库库存失败", e);
      }
    },
    getMonthlyInbound(warehouseCode) {
      const data = this.monthlyData[warehouseCode] || [];
      if (data.length === 0) return 0;
      // èŽ·å–æœ€è¿‘ä¸€ä¸ªæœˆï¼ˆæœ€åŽä¸€æ¡ï¼‰çš„å…¥åº“æ•°
      const latest = data[data.length - 1];
      return (latest.inbound ?? latest.Inbound) || 0;
    },
    getMonthlyOutbound(warehouseCode) {
      const data = this.monthlyData[warehouseCode] || [];
      if (data.length === 0) return 0;
      // èŽ·å–æœ€è¿‘ä¸€ä¸ªæœˆï¼ˆæœ€åŽä¸€æ¡ï¼‰çš„å‡ºåº“æ•°
      const latest = data[data.length - 1];
      return (latest.outbound ?? latest.Outbound) || 0;
    },
    getWarehouseStock(warehouseCode) {
      return this.warehouseStocks[warehouseCode] || 0;
    },
    calculateKPIs() {
      // è®¡ç®—总库存
      let totalStock = 0;
      for (const code in this.warehouseStocks) {
        totalStock += this.warehouseStocks[code];
      }
      this.totalStock = totalStock;
      // è®¡ç®—本月总入库和总出库(所有仓库最近一个月的合计)
      let totalInbound = 0;
      let totalOutbound = 0;
      const allWarehouses = [...this.topWarehouses, ...this.bottomWarehouses];
      allWarehouses.forEach(warehouse => {
        totalInbound += this.getMonthlyInbound(warehouse.code);
        totalOutbound += this.getMonthlyOutbound(warehouse.code);
      });
      this.monthlyInboundTotal = totalInbound;
      this.monthlyOutboundTotal = totalOutbound;
    },
    // æ›´æ–°æ‰€æœ‰ä»“库的月度趋势图表
    updateAllMonthlyTrendCharts() {
      const allWarehouses = [...this.topWarehouses, ...this.bottomWarehouses];
      allWarehouses.forEach(warehouse => {
        this.updateMonthlyTrendChartForWarehouse(warehouse.code);
      });
    },
    updateMonthlyTrendChartForWarehouse(roadway) {
      const chart = this.charts[roadway];
      if (!chart) return;
      const data = this.monthlyData[roadway] || [];
      // å…¼å®¹å¤§å°å†™å­—段名
      const monthLabels = data.map(m => m.month || m.Month || "");
      const inboundData = data.map(m => {
        const val = m.inbound ?? m.Inbound;
        return val !== undefined && val !== null ? Number(val) : 0;
      });
      const outboundData = data.map(m => {
        const val = m.outbound ?? m.Outbound;
        return val !== undefined && val !== null ? Number(val) : 0;
      });
      const option = {
        title: {
          text: '各仓库月度出入库对比',
          textStyle: {
            color: '#00ffff',
            fontSize: 16
          },
          left: 'center',
          top: 10
        tooltip: {
          trigger: "axis",
          formatter: function(params) {
            let result = params[0].axisValue + "<br/>";
            params.forEach(p => {
              result += `${p.marker}${p.seriesName}: ${p.value}<br/>`;
            });
            return result;
          }
        },
        legend: {
          data: ["入库", "出库"],
          textStyle: { color: "#fff" },
          top: 0,
          right: 10,
          itemWidth: 20,
          itemHeight: 12
        },
        grid: {
          left: "8%",
          right: "8%",
          top: "18%",
          bottom: "12%",
          containLabel: true
        },
        xAxis: {
          type: "category",
          data: monthLabels,
          axisLabel: {
            color: "#ccc",
            rotate: 45,
            fontSize: 10,
            interval: 0,
            margin: 8
          },
          axisLine: { lineStyle: { color: "#4a5b6e" } }
        },
        yAxis: {
          type: "value",
          name: "任务数量",
          nameTextStyle: { color: "#ccc", fontSize: 11 },
          axisLabel: { color: "#ccc" },
          splitLine: { lineStyle: { color: "#2a3a4a", type: "dashed" } }
        },
        series: [
          {
            name: "入库",
            type: "bar",
            data: inboundData,
            itemStyle: {
              color: "#5470c6",
              borderRadius: [4, 4, 0, 0]
            },
            barWidth: "35%",
            label: {
              show: inboundData.length <= 8,
              position: "top",
              color: "#5470c6",
              fontSize: 10
            }
          },
          {
            name: "出库",
            type: "line",
            data: outboundData,
            symbol: "circle",
            symbolSize: 6,
            itemStyle: { color: "#91cc75" },
            lineStyle: { width: 2, type: "solid" },
            smooth: false,
            label: {
              show: outboundData.length <= 8,
              position: "top",
              color: "#91cc75",
              fontSize: 10
            }
          }
        ]
      };
      chart.setOption(option, true);
    },
    updateDailyChart() {
      if (!this.charts.daily) return;
      const option = {
        tooltip: { trigger: "axis" },
        legend: { data: ["入库", "出库"], textStyle: { color: "#fff" } },
        xAxis: {
          type: "category",
          data: this.dailyData.map(d => d.date),
          axisLabel: {
            color: "#fff",
            interval: 0,
            rotate: 45,
            fontSize: 12,
            margin: 10
          },
          axisTick: {
            alignWithLabel: true
          }
        },
        yAxis: {
          type: "value",
          axisLabel: { color: "#fff" }
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "15%",
          top: "10%",
          containLabel: true
        },
        series: [
          {
            name: "入库",
            type: "bar",
            data: this.dailyData.map(d => d.inbound),
            itemStyle: { color: "#5470c6" }
          },
          {
            name: "出库",
            type: "bar",
            data: this.dailyData.map(d => d.outbound),
            itemStyle: { color: "#91cc75" }
          }
        ]
      };
      this.charts.daily.setOption(option, true);
    },
    updateWarehouseChart() {
      if (!this.charts.warehouse) return;
      const warehouseNames = this.warehouseData.map(w => w.warehouse);
      const hasStocks = this.warehouseData.map(w => w.hasStock);
      const noStocks = this.warehouseData.map(w => w.noStock);
      const hasStockPercentages = this.warehouseData.map(w => w.hasStockPercentage);
      const noStockPercentages = this.warehouseData.map(w => w.noStockPercentage);
      const option = {
        tooltip: {
          trigger: 'axis',
          trigger: "axis",
          axisPointer: {
            type: 'shadow'
            type: "shadow"
          },
          formatter: function(params) {
            let tip = `<strong>${params[0].axisValue}</strong><br/>`;
            let tip = params[0].name + "<br/>";
            params.forEach(param => {
              tip += `<span style="display:inline-block;width:10px;height:10px;border-radius:50%;background:${param.color};margin-right:5px;"></span>`;
              tip += `${param.seriesName}: `;
              tip += `入库:${param.data.inbound} | å‡ºåº“:${param.data.outbound} | æ€»è®¡:${param.value}<br/>`;
              const dataIndex = param.dataIndex;
              const warehouse = window.homeComponent?.warehouseData[dataIndex];
              if (warehouse) {
                if (param.seriesName === "已用容量") {
                  tip += `${param.marker}${param.seriesName}: ${param.value} (${warehouse.hasStockPercentage})<br/>`;
                  tip += `有库存: ${warehouse.hasStock}<br/>`;
                  tip += `无库存: ${warehouse.noStock}<br/>`;
                  tip += `总容量: ${warehouse.total}`;
                } else if (param.seriesName === "剩余容量") {
                  tip += `${param.marker}${param.seriesName}: ${param.value} (${warehouse.noStockPercentage})<br/>`;
                }
              } else {
                tip += `${param.marker}${param.seriesName}: ${param.value}<br/>`;
              }
            });
            return tip;
          }
        },
        legend: {
          data: this.monthlyData.map(d => d.warehouseName),
          textStyle: { color: '#fff', fontSize: 11 },
          top: 45,
          left: 'center',
          type: 'scroll'
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '10%',
          top: '20%',
          containLabel: true
          data: ["已用容量", "剩余容量"],
          textStyle: { color: "#fff" }
        },
        xAxis: {
          type: 'category',
          data: months,
          axisLabel: {
            color: '#fff',
            fontSize: 11
          },
          axisLine: {
            lineStyle: { color: 'rgba(255,255,255,0.3)' }
          },
          splitLine: {
            show: true,
            lineStyle: {
              color: 'rgba(255,255,255,0.1)',
              type: 'dashed'
            }
          }
          type: "category",
          data: warehouseNames,
          axisLabel: { color: "#fff", rotate: 30, interval: 0 }
        },
        yAxis: {
          type: 'value',
          name: '数量',
          nameTextStyle: { color: '#fff' },
          axisLabel: { color: '#fff' },
          splitLine: {
            lineStyle: {
              color: 'rgba(255,255,255,0.1)',
              type: 'dashed'
            }
          }
          type: "value",
          name: "容量",
          axisLabel: { color: "#fff" }
        },
        dataZoom: [
        series: [
          {
            type: 'inside',
            start: 0,
            end: 100
            name: "已用容量",
            type: "bar",
            data: hasStocks.map((value, index) => ({
              value: value,
              label: {
                show: true,
                position: "top",
                formatter: (params) => {
                  const pct = hasStockPercentages[params.dataIndex];
                  return `${params.value} (${pct})`;
                },
                color: "#91cc75",
                fontSize: 11
              }
            })),
            itemStyle: { color: "#91cc75" }
          },
          {
            start: 0,
            end: 100,
            height: 20,
            bottom: 0,
            borderColor: 'rgba(255,255,255,0.3)',
            fillerColor: 'rgba(0,255,255,0.1)',
            handleStyle: {
              color: '#00ffff',
              borderColor: '#00ffff'
            },
            textStyle: {
              color: '#fff'
            }
            name: "剩余容量",
            type: "bar",
            data: noStocks.map((value, index) => ({
              value: value,
              label: {
                show: true,
                position: "top",
                formatter: (params) => {
                  const pct = noStockPercentages[params.dataIndex];
                  return `${params.value} (${pct})`;
                },
                color: "#fac858",
                fontSize: 11
              }
            })),
            itemStyle: { color: "#fac858" }
          }
        ],
        series: series
        ]
      };
      this.charts.warehouseMonthly.setOption(option, true);
    },
    getBarColor(index) {
      const colors = [
        '#5470c6', // è“
        '#fac858', // é»„
        '#73c0de', // å¤©è“
        '#fc8452', // æ©™
        '#ea7ccc'  // ç²‰
      ];
      return colors[index] || '#5470c6';
      window.homeComponent = this;
      this.charts.warehouse.setOption(option, true);
    }
  }
};
@@ -235,36 +566,93 @@
  background-attachment: fixed;
}
.chart-row {
/* KPI å¡ç‰‡æ ·å¼ */
.kpi-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}
.kpi-card {
  background: rgba(10, 16, 35, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(64, 224, 208, 0.3);
  border-radius: 16px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.3s ease;
  box-shadow: 0 0 15px rgba(0, 255, 255, 0.1);
}
.kpi-card:hover {
  transform: translateY(-3px);
  border-color: rgba(64, 224, 208, 0.6);
  box-shadow: 0 0 25px rgba(0, 255, 255, 0.2);
}
.kpi-icon {
  font-size: 32px;
  opacity: 0.9;
}
.kpi-info {
  flex: 1;
}
.kpi-label {
  font-size: 13px;
  color: #8ba0b5;
  margin-bottom: 6px;
  letter-spacing: 1px;
}
.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: #00ffff;
  text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
  line-height: 1.2;
}
/* ä¸Š3个图表布局 */
.chart-row.top-three {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}
/* ä¸‹2个图表布局 */
.chart-row.bottom-two {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}
.chart-row.full-width {
  width: 100%;
  margin-bottom: 20px;
}
.chart-card {
  flex: 1;
  background: rgba(10, 16, 35, 0.6);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(64, 224, 208, 0.3);
  border-radius: 12px;
  padding: 15px;
  position: relative;
  box-shadow:
    0 0 15px rgba(0, 255, 255, 0.1),
    inset 0 0 10px rgba(64, 224, 208, 0.1);
  box-shadow: 0 0 15px rgba(0, 255, 255, 0.1), inset 0 0 10px rgba(64, 224, 208, 0.1);
  transition: all 0.3s ease;
  overflow: hidden;
}
.chart-card:hover {
  transform: translateY(-5px);
  box-shadow:
    0 0 25px rgba(0, 255, 255, 0.3),
    inset 0 0 15px rgba(64, 224, 208, 0.2);
  box-shadow: 0 0 25px rgba(0, 255, 255, 0.3), inset 0 0 15px rgba(64, 224, 208, 0.2);
  border: 1px solid rgba(64, 224, 208, 0.6);
}
@@ -292,29 +680,129 @@
  box-shadow: 2px -2px 10px #00ffff, 0 0 10px rgba(0, 255, 255, 0.7);
}
.chart-card::before,
.chart-card::after {
  animation: neon-flicker 2s infinite alternate;
}
@keyframes neon-flicker {
  0%,
  100% {
    opacity: 1;
    box-shadow: -2px -2px 10px #00ffff, 0 0 10px rgba(0, 255, 255, 0.7);
  }
  50% {
    opacity: 0.8;
    box-shadow: -2px -2px 5px #00ffff, 0 0 5px rgba(0, 255, 255, 0.5);
  }
}
.card-title {
  color: #00ffff;
  font-size: 16px;
  font-size: 15px;
  text-align: center;
  margin-bottom: 10px;
  margin-bottom: 12px;
  text-shadow: 0 0 10px rgba(0, 255, 255, 0.7);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* ä»“库数字显示区域 */
.warehouse-numbers {
  display: flex;
  justify-content: space-around;
  margin-bottom: 12px;
  padding: 8px 0;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
}
.number-item {
  text-align: center;
  flex: 1;
}
.number-label {
  display: block;
  font-size: 11px;
  color: #8ba0b5;
  margin-bottom: 4px;
}
.number-value {
  display: block;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
}
.number-item.inbound .number-value {
  color: #5470c6;
}
.number-item.outbound .number-value {
  color: #91cc75;
}
.number-item.stock .number-value {
  color: #fac858;
}
.chart-content {
  height: 500px;
  height: 240px;
  width: 100%;
}
/* å…¨å®½å›¾è¡¨ */
.full-width .chart-card {
  flex: none;
  width: 100%;
}
.full-width .chart-content {
  height: 500px;
  height: 350px;
}
/* å“åº”式调整 */
@media (max-width: 1024px) {
  .kpi-cards {
    grid-template-columns: repeat(2, 1fr);
  }
  .chart-row.top-three {
    grid-template-columns: repeat(2, 1fr);
  }
  .chart-row.bottom-two {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 768px) {
  .kpi-cards {
    grid-template-columns: 1fr;
  }
  .chart-row.top-three {
    grid-template-columns: 1fr;
  }
  .chart-row.bottom-two {
    grid-template-columns: 1fr;
  }
  .chart-content {
    height: 220px;
  }
  .full-width .chart-content {
    height: 280px;
  }
  .card-title {
    font-size: 13px;
    white-space: normal;
  }
  .number-value {
    font-size: 16px;
  }
}
/* æ·»åŠ ç½‘æ ¼çº¿æ•ˆæžœ */
.dashboard-container::before {
  content: "";
  position: fixed;
@@ -322,8 +810,7 @@
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    linear-gradient(rgba(64, 224, 208, 0.05) 1px, transparent 1px),
  background-image: linear-gradient(rgba(64, 224, 208, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(64, 224, 208, 0.05) 1px, transparent 1px);
  background-size: 30px 30px;
  pointer-events: none;
Code/WMS/WIDESEA_WMSClient/src/views/stock/hcstockInfo.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,505 @@
<template>
  <view-grid ref="grid" :columns="columns" :detail="detail" :editFormFields="editFormFields"
    :editFormOptions="editFormOptions" :searchFormFields="searchFormFields" :searchFormOptions="searchFormOptions"
    :table="table" :tableExpand="tableExpand" :extend="extend">
  </view-grid>
</template>
<script>
import extend from "@/extension/stock/hcstockInfo.jsx";
import {
  defineComponent,
  getCurrentInstance,
  h,
  reactive,
  ref,
  resolveComponent,
} from "vue";
const TEXT = {
  pageName: "库存信息",
  palletCode: "托盘编号",
  stockStatus: "库存状态",
  locationCode: "货位编号",
  outboundDate: "出库时间",
  warehouse: "仓库",
  creator: "创建人",
  createDate: "创建时间",
  modifier: "修改人",
  modifyDate: "修改时间",
  detailName: "库存明细",
  materielName: "物料名称",
  serialNumber: "电芯码",
  stockQuantity: "库存数量",
  status: "状态",
  inboundOrderRowNo: "通道号",
  detailLoading: "库存明细加载中...",
  detailLoadFailed: "库存明细加载失败",
  detailEmpty: "当前库存头暂无明细数据",
  expandPrefix: "托盘:",
  expandMiddle: " / ",
  expandLocation: "货位:",
};
export default defineComponent({
  setup() {
    const { proxy } = getCurrentInstance();
    const ElTable = resolveComponent("el-table");
    const ElTableColumn = resolveComponent("el-table-column");
    const table = ref({
      key: "id",
      footer: "Foots",
      cnName: TEXT.pageName,
      name: "stockInfo",
      url: "/StockInfo/",
      sortName: "id",
    });
    const editFormFields = ref({
      palletCode: "",
      palletType: 0,
      warehouseId: 0,
      mesUploadStatus: "",
      stockStatus: "",
      locationCode: "",
      locationDetails: ""
    });
    const editFormOptions = ref([
      [
        { field: "palletCode", title: TEXT.palletCode, type: "string" },
        { field: "stockStatus", title: TEXT.stockStatus, type: "select", dataKey: "stockStatusEmun", data: [] },
        { field: "locationCode", title: TEXT.locationCode, type: "string" },
      ],
    ]);
    const searchFormFields = ref({
      palletCode: "",
      warehouseId: "",
      stockStatus: "",
      locationCode: "",
    });
    const searchFormOptions = ref([
      [
        { title: TEXT.palletCode, field: "palletCode", type: "like" },
        { title: TEXT.warehouse, field: "warehouseId", type: "selectList", dataKey: "warehouseEnum", data: []  },
        { title: TEXT.stockStatus, field: "stockStatus", type: "selectList", dataKey: "stockStatusEmun", data: [] },
        { title: TEXT.locationCode, field: "locationCode", type: "like" },
      ],
    ]);
    const columns = ref([
      {
        field: "id",
        title: "Id",
        type: "int",
        width: 90,
        hidden: true,
        readonly: true,
        require: true,
        align: "left",
      },
      {
        field: "palletCode",
        title: TEXT.palletCode,
        type: "string",
        width: 150,
        align: "left",
      },
      {
        field: "stockStatus",
        title: TEXT.stockStatus,
        type: "int",
        width: 120,
        align: "left",
        bind: { key: "stockStatusEmun", data: [] },
      },
      {
        field: "mesUploadStatus",
        title: "MES状态",
        type: "int",
        width: 120,
        align: "left",
        bind: { key: "mesUploadStatusEnum", data: [] },
      },
      {
        field: "outboundDate",
        title: TEXT.outboundDate,
        type: "string",
        width: 150,
        align: "left",
      },
      {
        field: "locationCode",
        title: TEXT.locationCode,
        type: "string",
        width: 120,
        align: "left",
      },
      {
        field: "warehouseId",
        title: TEXT.warehouse,
        type: "select",
        width: 100,
        align: "left",
        bind: { key: "warehouseEnum", data: [] },
      },
      {
        field: "creater",
        title: TEXT.creator,
        type: "string",
        width: 90,
        align: "left",
      },
      {
        field: "createDate",
        title: TEXT.createDate,
        type: "datetime",
        width: 160,
        align: "left",
      },
      {
        field: "modifier",
        title: TEXT.modifier,
        type: "string",
        width: 100,
        align: "left",
        hidden: true,
      },
      {
        field: "modifyDate",
        title: TEXT.modifyDate,
        type: "datetime",
        width: 160,
        align: "left",
        hidden: true,
      },
    ]);
    const detail = ref({
      cnName: "#detailCnName",
      table: "",
      columns: [],
      sortName: "",
    });
    const detailState = reactive({
      rowsMap: {},
      loadingMap: {},
      errorMap: {},
    });
    const stockStatusOptions = ref([]);
    const detailColumns = [
      { field: "materielName", title: TEXT.materielName, minWidth: 160 },
      { field: "serialNumber", title: TEXT.serialNumber, minWidth: 160 },
      { field: "stockQuantity", title: TEXT.stockQuantity, minWidth: 120 },
      { field: "status", title: TEXT.status, minWidth: 120 },
      { field: "inboundOrderRowNo", title: TEXT.inboundOrderRowNo, minWidth: 120 },
    ];
    const normalizeValue = (value) => {
      return value === null || value === undefined || value === "" ? "--" : value;
    };
    const formatStatusText = (value) => {
      const matched = stockStatusOptions.value.find((item) => `${item.key}` === `${value}`);
      return matched ? matched.value || matched.label : normalizeValue(value);
    };
    const getDetailRows = (stockId) => {
      return detailState.rowsMap[stockId] || [];
    };
    const loadDetailRows = async (row) => {
      if (!row || !row.id || detailState.loadingMap[row.id]) {
        return;
      }
      if (detailState.rowsMap[row.id]) {
        return;
      }
      detailState.loadingMap[row.id] = true;
      detailState.errorMap[row.id] = "";
      try {
        const result = await proxy.http.post("/api/StockInfoDetail/getPageData", {
          page: 1,
          rows: 200,
          sort: "id",
          order: "asc",
          wheres: JSON.stringify([
            {
              name: "stockId",
              value: String(row.id),
              displayType: "int",
            },
          ]),
        });
        detailState.rowsMap[row.id] = (result && result.rows) || [];
      } catch (error) {
        detailState.rowsMap[row.id] = null;
        detailState.errorMap[row.id] = error?.message || TEXT.detailLoadFailed;
      } finally {
        detailState.loadingMap[row.id] = false;
      }
    };
    const loadStockStatusOptions = async () => {
      try {
        const result = await proxy.http.post("/api/Sys_Dictionary/GetVueDictionary", ["stockStatusEmun", "mesUploadStatusEnum"]);
        const matched = (result || []).find((item) => item.dicNo === "stockStatusEmun");
        stockStatusOptions.value = matched ? matched.data || [] : [];
      } catch (error) {
        stockStatusOptions.value = [];
      }
    };
    loadStockStatusOptions();
    const renderStatus = (row) => {
      if (detailState.loadingMap[row.id]) {
        return h("div", { class: "stock-detail-status" }, TEXT.detailLoading);
      }
      if (detailState.errorMap[row.id]) {
        return h(
          "div",
          { class: "stock-detail-status stock-detail-status--error" },
          detailState.errorMap[row.id]
        );
      }
      return null;
    };
    const renderDetailTable = (row) => {
      const statusNode = renderStatus(row);
      if (statusNode) {
        return statusNode;
      }
      const rows = getDetailRows(row.id);
      if (!rows.length) {
        return h("div", { class: "stock-detail-status" }, TEXT.detailEmpty);
      }
      return h("div", { class: "stock-detail-table-wrapper" }, [
        h("div", { class: "stock-detail-toolbar" }, [
          h("div", { class: "stock-detail-toolbar__left" }, TEXT.detailName),
          h("div", { class: "stock-detail-toolbar__right" }, [
            h("span", { class: "stock-detail-count" }, `${rows.length} æ¡`),
          ]),
        ]),
        h(
          ElTable,
          {
            data: rows,
            border: true,
            stripe: true,
            size: "small",
            class: "stock-detail-el-table",
            maxHeight: 420,
            emptyText: TEXT.detailEmpty,
          },
          () =>
            detailColumns.map((column) =>
              h(ElTableColumn, {
                key: column.field,
                prop: column.field,
                label: column.title,
                minWidth: column.minWidth,
                showOverflowTooltip: true,
                formatter: (detailRow) =>
                  column.field === "status"
                    ? formatStatusText(detailRow[column.field])
                    : normalizeValue(detailRow[column.field]),
              })
            )
        ),
      ]);
    };
    const tableExpand = ref({
      width: 55,
      onChange(row, expandedRows) {
        const isExpanded = expandedRows.some((item) => item.id === row.id);
        if (isExpanded) {
          loadDetailRows(row);
        }
      },
      render(render, { row }) {
        return render("div", { class: "stock-detail-panel" }, [
          render("div", { class: "stock-detail-header" }, [
            render("div", { class: "stock-detail-header__main" }, [
              render("div", { class: "stock-detail-title" }, TEXT.detailName),
              render(
                "div",
                { class: "stock-detail-subtitle" },
                `${TEXT.expandPrefix}${normalizeValue(row.palletCode)}${TEXT.expandMiddle}${TEXT.expandLocation}${normalizeValue(row.locationCode)}`
              ),
            ]),
            // render("div", { class: "stock-detail-tags" }, [
            //   render("span", { class: "stock-detail-tag" }, normalizeValue(row.palletCode)),
            //   render(
            //     "span",
            //     { class: "stock-detail-tag stock-detail-tag--muted" },
            //     normalizeValue(row.locationCode)
            //   ),
            // ]),
          ]),
          renderDetailTable(row),
        ]);
      },
    });
    return {
      table,
      extend,
      editFormFields,
      editFormOptions,
      searchFormFields,
      searchFormOptions,
      columns,
      detail,
      tableExpand,
    };
  },
});
</script>
<style scoped>
.stock-detail-panel {
  margin: 4px 8px 12px;
  padding: 14px 16px 16px;
  background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
  border: 1px solid #e8edf3;
  border-radius: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.stock-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #edf1f5;
}
.stock-detail-header__main {
  min-width: 0;
}
.stock-detail-title {
  margin-bottom: 4px;
  font-size: 15px;
  font-weight: 700;
  color: #303133;
}
.stock-detail-subtitle {
  font-size: 13px;
  color: #606266;
  line-height: 1.6;
}
.stock-detail-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.stock-detail-tag {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  color: #1f5eff;
  background: #edf4ff;
  border: 1px solid #d8e6ff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.stock-detail-tag--muted {
  color: #4e5969;
  background: #f4f6f8;
  border-color: #e5e9ef;
}
.stock-detail-status {
  padding: 14px 12px;
  color: #606266;
  background: #f8fafc;
  border: 1px dashed #d9e2ec;
  border-radius: 8px;
}
.stock-detail-status--error {
  color: #f56c6c;
  background: #fef0f0;
  border-color: #fde2e2;
}
.stock-detail-table-wrapper {
  overflow-x: auto;
  border: 1px solid #ebeef5;
  border-radius: 8px;
  background: #fff;
}
.stock-detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #edf1f5;
}
.stock-detail-toolbar__left {
  font-size: 13px;
  font-weight: 600;
  color: #303133;
}
.stock-detail-count {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  color: #606266;
  background: #fff;
  border: 1px solid #e5e9ef;
  border-radius: 999px;
  font-size: 12px;
}
:deep(.stock-detail-el-table) {
  border-top: none;
}
:deep(.stock-detail-el-table .el-table__inner-wrapper::before) {
  display: none;
}
:deep(.stock-detail-el-table th.el-table__cell) {
  background: #f5f7fa;
  color: #303133;
  font-weight: 600;
}
:deep(.stock-detail-el-table td.el-table__cell) {
  color: #606266;
}
:deep(.stock-detail-el-table .el-table__body tr:hover > td.el-table__cell) {
  background: #f0f7ff;
}
</style>
Code/WMS/WIDESEA_WMSClient/src/views/stock/stockInfo.vue
@@ -77,6 +77,7 @@
    const searchFormFields = ref({
      palletCode: "",
      warehouseId: "",
      stockStatus: "",
      locationCode: "",
    });
@@ -84,6 +85,7 @@
    const searchFormOptions = ref([
      [
        { title: TEXT.palletCode, field: "palletCode", type: "like" },
        { title: TEXT.warehouse, field: "warehouseId", type: "selectList", dataKey: "warehouseEnum", data: []  },
        { title: TEXT.stockStatus, field: "stockStatus", type: "selectList", dataKey: "stockStatusEmun", data: [] },
        { title: TEXT.locationCode, field: "locationCode", type: "like" },
      ],
Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Dashboard/DashboardController.cs
@@ -218,7 +218,7 @@
        /// æŒ‰å¹´æœˆç»Ÿè®¡å…¥ç«™å’Œå‡ºç«™ä»»åŠ¡æ•°é‡
        /// </remarks>
        [HttpGet("MonthlyStats"), AllowAnonymous]
        public async Task<WebResponseContent> MonthlyStats([FromQuery] int months = 12, string Roadway = null)
        public async Task<WebResponseContent> MonthlyStats(int months, string roadway)
        {
            try
            {
@@ -230,11 +230,12 @@
                // ä»“库名称映射
                var roadwayNames = new Dictionary<string, string>
        {
            { "FJSC1", "负极卷1号仓库" },
            { "ZJSC1", "正极卷1号仓库" },
            { "GWSC1", "高温1号仓库" },
            { "CWSC1", "常温1号仓库" },
            { "HCSC1", "分容1号仓库" }
            { "HCSC1", "分容1号仓库" },
            { "FJSC1", "负极卷1号仓库" },
            { "ZJSC1", "正极卷1号仓库" },
        };
                // æž„建查询
@@ -242,9 +243,9 @@
                    .Where(t => t.InsertTime >= startDate);
                // å¦‚果指定了道路,添加道路过滤条件
                if (!string.IsNullOrEmpty(Roadway))
                if (!string.IsNullOrEmpty(roadway))
                {
                    query = query.Where(t => t.Roadway == Roadway);
                    query = query.Where(t => t.Roadway == roadway);
                }
                var monthlyStats = await query
@@ -294,9 +295,9 @@
                            Month = monthKey,
                            Inbound = stat.Inbound,
                            Outbound = stat.Outbound,
                            Roadway = Roadway,
                            RoadwayName = !string.IsNullOrEmpty(Roadway) && roadwayNames.ContainsKey(Roadway)
                                ? roadwayNames[Roadway]
                            Roadway = roadway,
                            RoadwayName = !string.IsNullOrEmpty(roadway) && roadwayNames.ContainsKey(roadway)
                                ? roadwayNames[roadway]
                                : null
                        });
                    }
@@ -307,9 +308,9 @@
                            Month = monthKey,
                            Inbound = 0,
                            Outbound = 0,
                            Roadway = Roadway,
                            RoadwayName = !string.IsNullOrEmpty(Roadway) && roadwayNames.ContainsKey(Roadway)
                                ? roadwayNames[Roadway]
                            Roadway = roadway,
                            RoadwayName = !string.IsNullOrEmpty(roadway) && roadwayNames.ContainsKey(roadway)
                                ? roadwayNames[roadway]
                                : null
                        });
                    }