786 lines
43 KiB
HTML
Executable File
786 lines
43 KiB
HTML
Executable File
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>MES 扫码物料追溯看板 - 设计方案 v3(基于真实表结构)</title>
|
||
<style>
|
||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||
body { font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif; background: #f0f2f5; color: #333; }
|
||
|
||
/* 顶栏 */
|
||
.header { background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%); color: #fff; padding: 16px 24px; display: flex; justify-content: space-between; align-items: center; }
|
||
.header h1 { font-size: 22px; font-weight: 600; }
|
||
.header-right { display: flex; align-items: center; gap: 16px; }
|
||
.header-right span { font-size: 14px; opacity: 0.8; }
|
||
.btn-refresh { background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.3); color: #fff; padding: 6px 16px; border-radius: 4px; cursor: pointer; font-size: 13px; }
|
||
.btn-refresh:hover { background: rgba(255,255,255,0.25); }
|
||
|
||
/* Tab栏 */
|
||
.tabs { display: flex; background: #fff; padding: 0 24px; border-bottom: 2px solid #e8e8e8; }
|
||
.tab { padding: 14px 28px; font-size: 15px; font-weight: 500; color: #666; cursor: pointer; border-bottom: 3px solid transparent; transition: all 0.2s; }
|
||
.tab:hover { color: #1890ff; }
|
||
.tab.active { color: #1890ff; border-bottom-color: #1890ff; }
|
||
.tab .badge { display: inline-block; background: #f0f0f0; color: #888; border-radius: 10px; padding: 1px 8px; font-size: 12px; margin-left: 6px; }
|
||
.tab.active .badge { background: #e6f7ff; color: #1890ff; }
|
||
|
||
.container { padding: 20px 24px; }
|
||
|
||
/* 全部机型对比 */
|
||
.machine-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
|
||
.machine-card { background: #fff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); overflow: hidden; transition: box-shadow 0.3s; }
|
||
.machine-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
|
||
.machine-card-header { padding: 14px 20px; font-size: 17px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
|
||
.machine-card-header.gss { background: linear-gradient(135deg, #e6f7ff, #bae7ff); color: #0050b3; }
|
||
.machine-card-header.gs50 { background: linear-gradient(135deg, #f6ffed, #d9f7be); color: #389e0d; }
|
||
.machine-card-header.gs40 { background: linear-gradient(135deg, #fff7e6, #ffe7ba); color: #d46b08; }
|
||
.machine-card-header.gssw { background: linear-gradient(135deg, #fff0f6, #ffd6e7); color: #c41d7f; }
|
||
.machine-card-header .product-count { font-size: 13px; font-weight: 400; opacity: 0.8; }
|
||
.machine-card-body { padding: 20px; }
|
||
|
||
/* 环形覆盖率 */
|
||
.coverage-ring { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
|
||
.ring-svg { width: 80px; height: 80px; flex-shrink: 0; }
|
||
.ring-info { flex: 1; }
|
||
.ring-info .rate { font-size: 28px; font-weight: 700; line-height: 1; }
|
||
.ring-info .label { font-size: 12px; color: #999; margin-top: 4px; }
|
||
.ring-info .detail { font-size: 13px; color: #666; margin-top: 2px; }
|
||
|
||
/* 状态分布 */
|
||
.status-row { display: flex; gap: 8px; margin-bottom: 16px; }
|
||
.status-item { flex: 1; text-align: center; padding: 8px 4px; border-radius: 6px; }
|
||
.status-item .num { font-size: 20px; font-weight: 700; }
|
||
.status-item .text { font-size: 11px; color: #999; margin-top: 2px; }
|
||
.status-item.completed { background: #f6ffed; }
|
||
.status-item.completed .num { color: #52c41a; }
|
||
.status-item.progress { background: #e6f7ff; }
|
||
.status-item.progress .num { color: #1890ff; }
|
||
.status-item.pending { background: #fafafa; }
|
||
.status-item.pending .num { color: #bfbfbf; }
|
||
.status-item.exception { background: #fff1f0; }
|
||
.status-item.exception .num { color: #f5222d; }
|
||
|
||
/* 工序覆盖率条形图 */
|
||
.process-bars { margin-top: 4px; }
|
||
.process-bar-item { margin-bottom: 8px; }
|
||
.process-bar-label { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 3px; }
|
||
.process-bar-label .name { color: #555; }
|
||
.process-bar-label .pct { font-weight: 600; }
|
||
.process-bar-track { height: 8px; background: #f0f0f0; border-radius: 4px; overflow: hidden; }
|
||
.process-bar-fill { height: 100%; border-radius: 4px; transition: width 0.6s ease; }
|
||
.process-bar-fill.high { background: linear-gradient(90deg, #52c41a, #73d13d); }
|
||
.process-bar-fill.mid { background: linear-gradient(90deg, #faad14, #ffc53d); }
|
||
.process-bar-fill.low { background: linear-gradient(90deg, #ff4d4f, #ff7875); }
|
||
.process-bar-fill.zero { background: #f0f0f0; }
|
||
|
||
.machine-card-footer { padding: 10px 20px; text-align: right; border-top: 1px solid #f0f0f0; }
|
||
.machine-card-footer a { color: #1890ff; font-size: 13px; text-decoration: none; cursor: pointer; }
|
||
.machine-card-footer a:hover { text-decoration: underline; }
|
||
|
||
/* 单机型深度视图 */
|
||
.detail-view { display: none; }
|
||
|
||
/* KPI卡片 */
|
||
.kpi-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 20px; }
|
||
.kpi-card { background: #fff; border-radius: 8px; padding: 16px; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
|
||
.kpi-card .value { font-size: 32px; font-weight: 700; line-height: 1.2; }
|
||
.kpi-card .label { font-size: 13px; color: #999; margin-top: 4px; }
|
||
.kpi-card .sub { font-size: 12px; color: #bbb; margin-top: 2px; }
|
||
.kpi-card.blue .value { color: #1890ff; }
|
||
.kpi-card.green .value { color: #52c41a; }
|
||
.kpi-card.orange .value { color: #fa8c16; }
|
||
.kpi-card.red .value { color: #f5222d; }
|
||
.kpi-card.gray .value { color: #bfbfbf; }
|
||
.kpi-card.purple .value { color: #722ed1; }
|
||
|
||
/* 图表区 */
|
||
.chart-row { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; margin-bottom: 20px; }
|
||
.chart-card { background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
|
||
.chart-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; color: #333; }
|
||
|
||
/* 环形图 */
|
||
.donut-container { display: flex; align-items: center; justify-content: center; gap: 20px; }
|
||
.donut-svg { width: 160px; height: 160px; }
|
||
.donut-legend { font-size: 13px; }
|
||
.donut-legend-item { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
|
||
.donut-legend-item .dot { width: 10px; height: 10px; border-radius: 50%; }
|
||
.donut-legend-item .pct { font-weight: 600; margin-left: auto; }
|
||
|
||
/* 趋势图 SVG */
|
||
.trend-chart { width: 100%; height: 200px; }
|
||
|
||
/* 异常列表 */
|
||
.chart-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
|
||
.exception-table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
||
.exception-table th { text-align: left; padding: 8px 12px; background: #fafafa; color: #666; font-weight: 500; border-bottom: 1px solid #e8e8e8; }
|
||
.exception-table td { padding: 8px 12px; border-bottom: 1px solid #f5f5f5; }
|
||
.exception-table tr:hover { background: #fafafa; }
|
||
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
|
||
.tag-red { background: #fff1f0; color: #f5222d; }
|
||
.tag-orange { background: #fff7e6; color: #fa8c16; }
|
||
.tag-green { background: #f6ffed; color: #52c41a; }
|
||
|
||
/* 产品明细表 */
|
||
.product-table-wrapper { background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
|
||
.product-table-wrapper h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
|
||
.product-table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
||
.product-table th { text-align: left; padding: 10px 12px; background: #fafafa; color: #666; font-weight: 500; border-bottom: 2px solid #e8e8e8; white-space: nowrap; }
|
||
.product-table td { padding: 10px 12px; border-bottom: 1px solid #f5f5f5; }
|
||
.product-table tr:hover { background: #fafafa; }
|
||
.progress-bar { display: inline-block; width: 120px; height: 8px; background: #f0f0f0; border-radius: 4px; overflow: hidden; vertical-align: middle; margin-right: 6px; }
|
||
.progress-bar-fill { height: 100%; border-radius: 4px; }
|
||
.status-badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; }
|
||
.status-badge.normal { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
|
||
.status-badge.abnormal { background: #fff1f0; color: #f5222d; border: 1px solid #ffa39e; }
|
||
.status-badge.notstart { background: #fafafa; color: #bfbfbf; border: 1px solid #d9d9d9; }
|
||
.btn-detail { color: #1890ff; cursor: pointer; font-size: 13px; }
|
||
.btn-detail:hover { text-decoration: underline; }
|
||
|
||
/* 搜索栏 */
|
||
.search-bar { display: flex; gap: 12px; margin-bottom: 16px; align-items: center; }
|
||
.search-bar input, .search-bar select { padding: 6px 12px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 13px; outline: none; }
|
||
.search-bar input:focus, .search-bar select:focus { border-color: #1890ff; }
|
||
.btn-search { padding: 6px 16px; background: #1890ff; color: #fff; border: none; border-radius: 4px; font-size: 13px; cursor: pointer; }
|
||
.btn-search:hover { background: #40a9ff; }
|
||
|
||
/* 分页 */
|
||
.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
|
||
.pagination button { padding: 4px 10px; border: 1px solid #d9d9d9; background: #fff; border-radius: 4px; font-size: 12px; cursor: pointer; color: #555; }
|
||
.pagination button:hover:not(:disabled) { border-color: #1890ff; color: #1890ff; }
|
||
.pagination button.active { background: #1890ff; color: #fff; border-color: #1890ff; }
|
||
.pagination button:disabled { opacity: 0.5; cursor: default; }
|
||
.pagination span { font-size: 12px; color: #999; margin: 0 4px; }
|
||
|
||
/* 弹窗 */
|
||
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 1000; justify-content: center; align-items: center; }
|
||
.modal-overlay.show { display: flex; }
|
||
.modal { background: #fff; border-radius: 8px; width: 800px; max-height: 80vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,0.2); }
|
||
.modal-header { padding: 16px 20px; border-bottom: 1px solid #e8e8e8; display: flex; justify-content: space-between; align-items: center; }
|
||
.modal-header h3 { font-size: 16px; font-weight: 600; }
|
||
.modal-close { font-size: 22px; color: #999; cursor: pointer; line-height: 1; }
|
||
.modal-close:hover { color: #333; }
|
||
.modal-body { padding: 20px; }
|
||
.trace-table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
||
.trace-table th { text-align: left; padding: 8px 12px; background: #fafafa; color: #666; font-weight: 500; border-bottom: 1px solid #e8e8e8; white-space: nowrap; }
|
||
.trace-table td { padding: 8px 12px; border-bottom: 1px solid #f5f5f5; }
|
||
.trace-table .scanned { color: #52c41a; }
|
||
.trace-table .missing { color: #f5222d; }
|
||
|
||
/* 方案说明区 */
|
||
.design-doc { background: #fff; border-radius: 8px; padding: 24px; margin-bottom: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
|
||
.design-doc h2 { font-size: 18px; font-weight: 600; margin-bottom: 16px; color: #333; border-left: 4px solid #1890ff; padding-left: 12px; }
|
||
.design-doc h3 { font-size: 15px; font-weight: 600; margin: 16px 0 8px; color: #555; }
|
||
.design-doc p { font-size: 13px; line-height: 1.8; color: #666; margin-bottom: 8px; }
|
||
.design-doc ul { padding-left: 20px; margin-bottom: 8px; }
|
||
.design-doc li { font-size: 13px; line-height: 1.8; color: #666; }
|
||
.design-doc table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13px; }
|
||
.design-doc th { text-align: left; padding: 8px 12px; background: #fafafa; border: 1px solid #e8e8e8; color: #333; }
|
||
.design-doc td { padding: 8px 12px; border: 1px solid #e8e8e8; color: #666; }
|
||
.design-doc .note { background: #e6f7ff; border: 1px solid #91d5ff; border-radius: 4px; padding: 8px 12px; font-size: 13px; color: #0050b3; margin: 8px 0; }
|
||
.design-doc .warn { background: #fff7e6; border: 1px solid #ffd591; border-radius: 4px; padding: 8px 12px; font-size: 13px; color: #d46b08; margin: 8px 0; }
|
||
</style>
|
||
</head>
|
||
<body>
|
||
|
||
<!-- 顶部标题栏 -->
|
||
<div class="header">
|
||
<h1>MES 扫码物料追溯看板</h1>
|
||
<div class="header-right">
|
||
<span id="curTime">2026-08-14 09:22:49</span>
|
||
<button class="btn-refresh" onclick="refreshData()">刷新数据</button>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 机型Tab栏 -->
|
||
<div class="tabs">
|
||
<div class="tab active" onclick="showCompareView()">全部机型 <span class="badge" id="badgeAll">43</span></div>
|
||
<div class="tab" onclick="showDetailView('gss')">GSS <span class="badge">18</span></div>
|
||
<div class="tab" onclick="showDetailView('gs50')">GS50 <span class="badge">12</span></div>
|
||
<div class="tab" onclick="showDetailView('gs40')">GS40 <span class="badge">8</span></div>
|
||
<div class="tab" onclick="showDetailView('gssw')">GSSW <span class="badge">5</span></div>
|
||
</div>
|
||
|
||
<div class="container">
|
||
|
||
<!-- ===== 场景一:全部机型对比模式 ===== -->
|
||
<div id="compareView" class="compare-view">
|
||
<div class="machine-grid" id="machineGrid"></div>
|
||
</div>
|
||
|
||
<!-- ===== 场景二:单机型深度视图 ===== -->
|
||
<div id="detailView" class="detail-view">
|
||
<!-- KPI 卡片 -->
|
||
<div class="kpi-row" id="kpiRow"></div>
|
||
|
||
<!-- 图表区 -->
|
||
<div class="chart-row">
|
||
<!-- 状态分布环形图 -->
|
||
<div class="chart-card">
|
||
<h3>产品扫码状态分布</h3>
|
||
<div class="donut-container" id="donutContainer"></div>
|
||
</div>
|
||
<!-- 工序覆盖率条形图 -->
|
||
<div class="chart-card">
|
||
<h3>各工序扫码覆盖率(实扫/应扫)</h3>
|
||
<div class="process-bars" id="detailProcessBars" style="display:grid; grid-template-columns:1fr 1fr; gap:8px 24px;"></div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 趋势图 + 异常列表 -->
|
||
<div class="chart-row-2">
|
||
<div class="chart-card">
|
||
<h3>扫码趋势(应扫 vs 实扫)</h3>
|
||
<svg class="trend-chart" viewBox="0 0 400 200" id="trendChart"></svg>
|
||
</div>
|
||
<div class="chart-card">
|
||
<h3>漏扫异常产品清单</h3>
|
||
<table class="exception-table" id="exceptionTable"></table>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 产品扫码明细表 -->
|
||
<div class="product-table-wrapper">
|
||
<h3>产品扫码明细</h3>
|
||
<div class="search-bar">
|
||
<input type="text" placeholder="搜索车号 / SN..." id="txtSearch">
|
||
<select id="selStatus">
|
||
<option value="">全部状态</option>
|
||
<option value="normal">正常完成</option>
|
||
<option value="abnormal">漏扫异常</option>
|
||
<option value="notstart">未开始</option>
|
||
</select>
|
||
<select id="selLine">
|
||
<option value="">全部产线</option>
|
||
<option value="517">517</option>
|
||
<option value="518">518</option>
|
||
</select>
|
||
<button class="btn-search" onclick="filterProducts()">查询</button>
|
||
</div>
|
||
<table class="product-table" id="productTable"></table>
|
||
<div class="pagination" id="pagination"></div>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<!-- 产品扫码详情弹窗 -->
|
||
<div class="modal-overlay" id="modalOverlay">
|
||
<div class="modal">
|
||
<div class="modal-header">
|
||
<h3 id="modalTitle">扫码追溯详情</h3>
|
||
<span class="modal-close" onclick="closeModal()">×</span>
|
||
</div>
|
||
<div class="modal-body" id="modalBody"></div>
|
||
</div>
|
||
</div>
|
||
|
||
<script>
|
||
/* ===================================================================
|
||
数据模型与计算逻辑(基于真实 MES 表结构)
|
||
===================================================================
|
||
|
||
一、数据来源表
|
||
───────────
|
||
1. ODK_ScanCodeIntercept(扫码拦截主表)
|
||
关键字段:
|
||
- FType : 机型
|
||
- FNO : 车号
|
||
- FSN : SN
|
||
- FNeedQty : 需要扫码数量(应扫数)
|
||
- FRealityQty : 实际扫码数量(实扫数)
|
||
- FInterID : 内码(关联子表)
|
||
|
||
2. ODK_ScanCodeInterceptEntry(扫码拦截子表)
|
||
关键字段:
|
||
- FInterID : 主表内码
|
||
- FProcessNumber : 工序编号
|
||
- FProcessName : 工序名称
|
||
- FQty : 扫码数据(该工序实扫数)
|
||
|
||
二、计算逻辑(后端 SQL 参考)
|
||
───────────────────────────────────────────────────────
|
||
|
||
1. 今日产量
|
||
= COUNT(DISTINCT FSN) WHERE 今日有记录
|
||
|
||
2. 整体扫码覆盖率
|
||
= SUM(FRealityQty) / SUM(FNeedQty) × 100%
|
||
|
||
3. 产品状态判定(逐产品)
|
||
┌─────────────────────────────────────────────────┐
|
||
│ FRealityQty >= FNeedQty → 正常完成 │
|
||
│ FRealityQty < FNeedQty → 漏扫异常 │
|
||
│ FRealityQty = 0 → 未开始 │
|
||
└─────────────────────────────────────────────────┘
|
||
|
||
4. 工序覆盖率
|
||
= SUM(子表.FQty) / SUM(FNeedQty) × 100%
|
||
(分母用主表应扫总数,因为每道工序的应扫基准相同)
|
||
|
||
5. 漏扫异常产品清单
|
||
= 状态为"漏扫异常"的产品,列出 FQty < FNeedQty 的工序
|
||
|
||
三、重要说明
|
||
───────────
|
||
- 不需要工艺路线表,应扫数直接来自主表 FNeedQty
|
||
- 状态由后端计算,前端直接展示
|
||
=================================================================== */
|
||
|
||
/* ===== 演示数据(模拟后端计算后的结果) ===== */
|
||
var machineData = {
|
||
gss: {
|
||
name:'GSS', count:18, color:'#1890ff',
|
||
coverage:86.5, scanned:522, total:604,
|
||
status:{normal:10, abnormal:6, notstart:0},
|
||
processes:[
|
||
{code:'02', name:'02 上盖组件', scanned:72, expected:72, pct:100},
|
||
{code:'03', name:'03 PCB组件', scanned:72, expected:72, pct:100},
|
||
{code:'04', name:'04 撞板组装', scanned:72, expected:72, pct:100},
|
||
{code:'12', name:'12 底盘+水箱', scanned:126, expected:126, pct:100},
|
||
{code:'01', name:'01 整机调试', scanned:54, expected:90, pct:60},
|
||
{code:'05', name:'05 包装', scanned:0, expected:90, pct:0}
|
||
],
|
||
products:[
|
||
{carNo:'517-GSS-16391-V1.3.0-3521', sn:'GS438-6260-ABR-L100', model:'GSS', line:'517', expected:29, actual:19, status:'abnormal', lastTime:'2026-08-11 10:50:21', missingProcs:'01,05'},
|
||
{carNo:'517-GSS-16401-V1.3.0-3521', sn:'GS438-6260-ABR-W100', model:'GSS', line:'517', expected:29, actual:19, status:'abnormal', lastTime:'2026-08-11 13:56:49', missingProcs:'01,05'},
|
||
{carNo:'517-GSS-22598-V1.3.0-3617', sn:'GS438-6260-G7S-H000', model:'GSS', line:'517', expected:29, actual:0, status:'notstart', lastTime:'2026-08-11 14:48:33', missingProcs:'全部'},
|
||
{carNo:'517-GSS-16395-V1.3.0-3521', sn:'GS438-6260-ABR-L102', model:'GSS', line:'517', expected:29, actual:29, status:'normal', lastTime:'2026-08-11 16:20:15', missingProcs:''},
|
||
{carNo:'517-GSS-16405-V1.3.0-3521', sn:'GS438-6260-ABR-W103', model:'GSS', line:'517', expected:29, actual:25, status:'abnormal', lastTime:'2026-08-11 17:05:33', missingProcs:'01,05'},
|
||
{carNo:'517-GSS-16388-V1.3.0-3521', sn:'GS438-6260-ABR-L097', model:'GSS', line:'517', expected:29, actual:29, status:'normal', lastTime:'2026-08-11 18:12:07', missingProcs:''},
|
||
{carNo:'518-GSS-16410-V1.3.0-3521', sn:'GS438-6260-ABR-W108', model:'GSS', line:'518', expected:29, actual:15, status:'abnormal', lastTime:'2026-08-11 09:33:41', missingProcs:'01,05'},
|
||
{carNo:'518-GSS-16415-V1.3.0-3521', sn:'GS438-6260-ABR-L111', model:'GSS', line:'518', expected:29, actual:29, status:'normal', lastTime:'2026-08-11 11:22:18', missingProcs:''},
|
||
{carNo:'518-GSS-16420-V1.3.0-3521', sn:'GS438-6260-ABR-W112', model:'GSS', line:'518', expected:29, actual:22, status:'abnormal', lastTime:'2026-08-11 14:10:55', missingProcs:'01,05'},
|
||
{carNo:'518-GSS-16425-V1.3.0-3521', sn:'GS438-6260-ABR-L115', model:'GSS', line:'518', expected:29, actual:29, status:'normal', lastTime:'2026-08-11 15:40:30', missingProcs:''}
|
||
],
|
||
exceptions:[
|
||
{carNo:'517-GSS-16391-V1.3.0-3521', missing:'01,05', missingCount:10},
|
||
{carNo:'517-GSS-16401-V1.3.0-3521', missing:'01,05', missingCount:10},
|
||
{carNo:'517-GSS-22598-V1.3.0-3617', missing:'全部', missingCount:29},
|
||
{carNo:'517-GSS-16405-V1.3.0-3521', missing:'01,05', missingCount:4},
|
||
{carNo:'518-GSS-16410-V1.3.0-3521', missing:'01,05', missingCount:14},
|
||
{carNo:'518-GSS-16420-V1.3.0-3521', missing:'01,05', missingCount:7}
|
||
],
|
||
trend:{labels:['08:00','10:00','12:00','14:00','16:00'], expected:[5,10,20,30,30], actual:[0,5,12,22,28]}
|
||
},
|
||
gs50: {
|
||
name:'GS50', count:12, color:'#52c41a',
|
||
coverage:72.3, scanned:348, total:481,
|
||
status:{normal:5, abnormal:5, notstart:1},
|
||
processes:[
|
||
{code:'02', name:'02 上盖组件', scanned:36, expected:48, pct:75},
|
||
{code:'03', name:'03 PCB组件', scanned:48, expected:48, pct:100},
|
||
{code:'04', name:'04 撞板组装', scanned:24, expected:48, pct:50},
|
||
{code:'12', name:'12 底盘+水箱', scanned:84, expected:84, pct:100},
|
||
{code:'01', name:'01 整机调试', scanned:0, expected:60, pct:0},
|
||
{code:'05', name:'05 包装', scanned:0, expected:60, pct:0}
|
||
],
|
||
products:[
|
||
{carNo:'517-GS50-32001-V2.1.0-3501', sn:'GS50-3201-ABR-L200', model:'GS50', line:'517', expected:24, actual:24, status:'normal', lastTime:'2026-08-11 15:30:00', missingProcs:''},
|
||
{carNo:'517-GS50-32002-V2.1.0-3501', sn:'GS50-3202-ABR-W200', model:'GS50', line:'517', expected:24, actual:18, status:'abnormal', lastTime:'2026-08-11 16:45:12', missingProcs:'01,05'},
|
||
{carNo:'517-GS50-32003-V2.1.0-3501', sn:'GS50-3203-ABR-L201', model:'GS50', line:'517', expected:24, actual:12, status:'abnormal', lastTime:'2026-08-11 14:20:33', missingProcs:'01,05'},
|
||
{carNo:'518-GS50-32004-V2.1.0-3501', sn:'GS50-3204-ABR-W201', model:'GS50', line:'518', expected:24, actual:0, status:'notstart', lastTime:'2026-08-11 08:00:00', missingProcs:'全部'},
|
||
{carNo:'518-GS50-32005-V2.1.0-3501', sn:'GS50-3205-ABR-L202', model:'GS50', line:'518', expected:24, actual:22, status:'abnormal', lastTime:'2026-08-11 17:10:45', missingProcs:'01,05'}
|
||
],
|
||
exceptions:[
|
||
{carNo:'518-GS50-32005-V2.1.0-3501', missing:'01,05', missingCount:6},
|
||
{carNo:'518-GS50-32004-V2.1.0-3501', missing:'全部', missingCount:24}
|
||
],
|
||
trend:{labels:['08:00','10:00','12:00','14:00','16:00'], expected:[3,8,12,18,24], actual:[0,3,8,12,16]}
|
||
},
|
||
gs40: {
|
||
name:'GS40', count:8, color:'#fa8c16',
|
||
coverage:95.0, scanned:218, total:229,
|
||
status:{normal:6, abnormal:2, notstart:0},
|
||
processes:[
|
||
{code:'02', name:'02 上盖组件', scanned:32, expected:32, pct:100},
|
||
{code:'03', name:'03 PCB组件', scanned:32, expected:32, pct:100},
|
||
{code:'04', name:'04 撞板组装', scanned:32, expected:32, pct:100},
|
||
{code:'12', name:'12 底盘+水箱', scanned:56, expected:56, pct:100},
|
||
{code:'01', name:'01 整机调试', scanned:16, expected:40, pct:40},
|
||
{code:'05', name:'05 包装', scanned:0, expected:40, pct:0}
|
||
],
|
||
products:[
|
||
{carNo:'517-GS40-41001-V1.0.0-3401', sn:'GS40-4101-ABR-L300', model:'GS40', line:'517', expected:29, actual:29, status:'normal', lastTime:'2026-08-11 14:00:00', missingProcs:''},
|
||
{carNo:'517-GS40-41002-V1.0.0-3401', sn:'GS40-4102-ABR-W300', model:'GS40', line:'517', expected:29, actual:29, status:'normal', lastTime:'2026-08-11 15:30:00', missingProcs:''},
|
||
{carNo:'517-GS40-41003-V1.0.0-3401', sn:'GS40-4103-ABR-L301', model:'GS40', line:'517', expected:29, actual:25, status:'abnormal', lastTime:'2026-08-11 17:00:00', missingProcs:'01,05'},
|
||
{carNo:'518-GS40-41004-V1.0.0-3401', sn:'GS40-4104-ABR-W301', model:'GS40', line:'518', expected:29, actual:29, status:'normal', lastTime:'2026-08-11 16:00:00', missingProcs:''}
|
||
],
|
||
exceptions:[
|
||
{carNo:'517-GS40-41003-V1.0.0-3401', missing:'01,05', missingCount:4}
|
||
],
|
||
trend:{labels:['08:00','10:00','12:00','14:00','16:00'], expected:[2,4,8,10,10], actual:[1,3,7,9,10]}
|
||
},
|
||
gssw: {
|
||
name:'GSSW', count:5, color:'#f5222d',
|
||
coverage:40.0, scanned:58, total:145,
|
||
status:{normal:0, abnormal:3, notstart:1},
|
||
processes:[
|
||
{code:'02', name:'02 上盖组件', scanned:0, expected:20, pct:0},
|
||
{code:'03', name:'03 PCB组件', scanned:0, expected:20, pct:0},
|
||
{code:'04', name:'04 撞板组装', scanned:0, expected:20, pct:0},
|
||
{code:'12', name:'12 底盘+水箱', scanned:35, expected:35, pct:100},
|
||
{code:'01', name:'01 整机调试', scanned:15, expected:25, pct:60},
|
||
{code:'05', name:'05 包装', scanned:0, expected:25, pct:0}
|
||
],
|
||
products:[
|
||
{carNo:'517-GSSW-55001-V1.0.0-3601', sn:'GSSW-5501-ABR-L400', model:'GSSW', line:'517', expected:29, actual:12, status:'abnormal', lastTime:'2026-08-11 16:00:00', missingProcs:'02,03,04,05'},
|
||
{carNo:'517-GSSW-55002-V1.0.0-3601', sn:'GSSW-5502-ABR-W400', model:'GSSW', line:'517', expected:29, actual:8, status:'abnormal', lastTime:'2026-08-11 15:30:00', missingProcs:'02,03,04,05'},
|
||
{carNo:'518-GSSW-55003-V1.0.0-3601', sn:'GSSW-5503-ABR-L401', model:'GSSW', line:'518', expected:29, actual:0, status:'notstart', lastTime:'2026-08-11 08:00:00', missingProcs:'全部'}
|
||
],
|
||
exceptions:[
|
||
{carNo:'517-GSSW-55002-V1.0.0-3601', missing:'02,03,04,05', missingCount:18},
|
||
{carNo:'518-GSSW-55003-V1.0.0-3601', missing:'全部', missingCount:29}
|
||
],
|
||
trend:{labels:['08:00','10:00','12:00','14:00','16:00'], expected:[1,3,5,7,10], actual:[0,1,2,4,5]}
|
||
}
|
||
};
|
||
|
||
var currentMachine = null;
|
||
var filteredProducts = [];
|
||
var currentPage = 1;
|
||
var pageSize = 10;
|
||
|
||
/* ===== 工具函数 ===== */
|
||
function barClass(pct) {
|
||
if (pct >= 80) return 'high';
|
||
if (pct >= 40) return 'mid';
|
||
if (pct > 0) return 'low';
|
||
return 'zero';
|
||
}
|
||
function barColor(pct) {
|
||
if (pct >= 80) return '#52c41a';
|
||
if (pct >= 40) return '#faad14';
|
||
if (pct > 0) return '#ff4d4f';
|
||
return '#bfbfbf';
|
||
}
|
||
function statusBadge(status) {
|
||
var map = {normal:'正常完成', abnormal:'漏扫异常', notstart:'未开始'};
|
||
var clsMap = {normal:'normal', abnormal:'abnormal', notstart:'notstart'};
|
||
return '<span class="status-badge ' + (clsMap[status]||'') + '">' + (map[status]||status) + '</span>';
|
||
}
|
||
|
||
/* ===== 渲染全部机型对比 ===== */
|
||
function renderCompareView() {
|
||
var grid = document.getElementById('machineGrid');
|
||
var html = '';
|
||
var keys = ['gss','gs50','gs40','gssw'];
|
||
keys.forEach(function(key) {
|
||
var d = machineData[key];
|
||
var circ = 2 * Math.PI * 32;
|
||
var dashLen = (d.coverage / 100) * circ;
|
||
html += '<div class="machine-card">'
|
||
+ '<div class="machine-card-header ' + key + '">'
|
||
+ '<span>' + d.name + '</span>'
|
||
+ '<span class="product-count">今日 ' + d.count + ' 台</span>'
|
||
+ '</div>'
|
||
+ '<div class="machine-card-body">'
|
||
+ '<div class="coverage-ring">'
|
||
+ '<svg class="ring-svg" viewBox="0 0 80 80">'
|
||
+ '<circle cx="40" cy="40" r="32" fill="none" stroke="#f0f0f0" stroke-width="8"/>'
|
||
+ '<circle cx="40" cy="40" r="32" fill="none" stroke="' + d.color + '" stroke-width="8" stroke-dasharray="' + dashLen.toFixed(1) + ' ' + circ.toFixed(1) + '" stroke-linecap="round" transform="rotate(-90 40 40)"/>'
|
||
+ '<text x="40" y="44" text-anchor="middle" font-size="16" font-weight="700" fill="' + d.color + '">' + d.coverage + '%</text>'
|
||
+ '</svg>'
|
||
+ '<div class="ring-info">'
|
||
+ '<div class="rate" style="color:' + d.color + '">' + d.coverage + '%</div>'
|
||
+ '<div class="label">整体扫码覆盖率</div>'
|
||
+ '<div class="detail">' + d.scanned + ' / ' + d.total + ' 次</div>'
|
||
+ '</div>'
|
||
+ '</div>'
|
||
+ '<div class="status-row">'
|
||
+ '<div class="status-item completed"><div class="num">' + d.status.normal + '</div><div class="text">正常完成</div></div>'
|
||
+ '<div class="status-item exception"><div class="num">' + d.status.abnormal + '</div><div class="text">漏扫异常</div></div>'
|
||
+ '<div class="status-item pending"><div class="num">' + d.status.notstart + '</div><div class="text">未开始</div></div>'
|
||
+ '</div>'
|
||
+ '<div class="process-bars">';
|
||
d.processes.forEach(function(p) {
|
||
html += '<div class="process-bar-item">'
|
||
+ '<div class="process-bar-label"><span class="name">' + p.name + '</span><span class="pct" style="color:' + barColor(p.pct) + '">' + p.scanned + '/' + p.expected + ' ' + p.pct + '%</span></div>'
|
||
+ '<div class="process-bar-track"><div class="process-bar-fill ' + barClass(p.pct) + '" style="width:' + p.pct + '%"></div></div>'
|
||
+ '</div>';
|
||
});
|
||
html += '</div></div>'
|
||
+ '<div class="machine-card-footer"><a onclick="showDetailView(\'' + key + '\')">查看详情 ></a></div>'
|
||
+ '</div>';
|
||
});
|
||
grid.innerHTML = html;
|
||
}
|
||
|
||
/* ===== 渲染单机型深度视图 ===== */
|
||
function renderDetailView(key) {
|
||
var d = machineData[key];
|
||
currentMachine = key;
|
||
|
||
// KPI
|
||
var kpiRow = document.getElementById('kpiRow');
|
||
var pctC = (d.status.normal / d.count * 100).toFixed(1);
|
||
var pctA = (d.status.abnormal / d.count * 100).toFixed(1);
|
||
var pctN = (d.status.notstart / d.count * 100).toFixed(1);
|
||
kpiRow.innerHTML = ''
|
||
+ '<div class="kpi-card blue"><div class="value">' + d.count + '</div><div class="label">今日产量</div><div class="sub">' + d.name + ' 机型</div></div>'
|
||
+ '<div class="kpi-card green"><div class="value">' + d.status.normal + '</div><div class="label">正常完成</div><div class="sub">' + pctC + '%</div></div>'
|
||
+ '<div class="kpi-card red"><div class="value">' + d.status.abnormal + '</div><div class="label">漏扫异常</div><div class="sub">' + pctA + '%</div></div>'
|
||
+ '<div class="kpi-card gray"><div class="value">' + d.status.notstart + '</div><div class="label">未开始</div><div class="sub">' + pctN + '%</div></div>'
|
||
+ '<div class="kpi-card orange"><div class="value">' + d.scanned + '</div><div class="label">实扫总数</div><div class="sub">' + d.total + ' 应扫</div></div>'
|
||
+ '<div class="kpi-card purple"><div class="value">' + d.coverage + '%</div><div class="label">整体覆盖率</div><div class="sub">实扫/应扫</div></div>';
|
||
|
||
// 环形图
|
||
var donutContainer = document.getElementById('donutContainer');
|
||
var circ = 2 * Math.PI * 60;
|
||
var total = d.count;
|
||
var s1 = d.status.normal, s2 = d.status.abnormal, s3 = d.status.notstart;
|
||
var d1 = (s1 / total) * circ, d2 = (s2 / total) * circ;
|
||
donutContainer.innerHTML = ''
|
||
+ '<svg class="donut-svg" viewBox="0 0 160 160">'
|
||
+ '<circle cx="80" cy="80" r="60" fill="none" stroke="#f0f0f0" stroke-width="20"/>'
|
||
+ '<circle cx="80" cy="80" r="60" fill="none" stroke="#52c41a" stroke-width="20" stroke-dasharray="' + d1.toFixed(1) + ' ' + circ.toFixed(1) + '" transform="rotate(-90 80 80)"/>'
|
||
+ '<circle cx="80" cy="80" r="60" fill="none" stroke="#f5222d" stroke-width="20" stroke-dasharray="' + d2.toFixed(1) + ' ' + circ.toFixed(1) + '" stroke-dashoffset="-' + d1.toFixed(1) + '" transform="rotate(-90 80 80)"/>'
|
||
+ '<text x="80" y="76" text-anchor="middle" font-size="28" font-weight="700" fill="#333">' + total + '</text>'
|
||
+ '<text x="80" y="96" text-anchor="middle" font-size="12" fill="#999">总产量</text>'
|
||
+ '</svg>'
|
||
+ '<div class="donut-legend">'
|
||
+ '<div class="donut-legend-item"><span class="dot" style="background:#52c41a"></span>正常完成 <span class="pct">' + s1 + ' (' + (s1/total*100).toFixed(1) + '%)</span></div>'
|
||
+ '<div class="donut-legend-item"><span class="dot" style="background:#f5222d"></span>漏扫异常 <span class="pct">' + s2 + ' (' + (s2/total*100).toFixed(1) + '%)</span></div>'
|
||
+ '<div class="donut-legend-item"><span class="dot" style="background:#f0f0f0;border:1px solid #d9d9d9"></span>未开始 <span class="pct">' + s3 + ' (' + (s3/total*100).toFixed(1) + '%)</span></div>'
|
||
+ '</div>';
|
||
|
||
// 工序覆盖率
|
||
var procEl = document.getElementById('detailProcessBars');
|
||
var procHtml = '';
|
||
d.processes.forEach(function(p) {
|
||
procHtml += '<div class="process-bar-item">'
|
||
+ '<div class="process-bar-label"><span class="name">' + p.name + '</span><span class="pct" style="color:' + barColor(p.pct) + '">' + p.scanned + '/' + p.expected + ' ' + p.pct + '%</span></div>'
|
||
+ '<div class="process-bar-track"><div class="process-bar-fill ' + barClass(p.pct) + '" style="width:' + p.pct + '%"></div></div>'
|
||
+ '</div>';
|
||
});
|
||
procEl.innerHTML = procHtml;
|
||
|
||
// 趋势图
|
||
renderTrendChart(d.trend);
|
||
|
||
// 异常列表
|
||
var exEl = document.getElementById('exceptionTable');
|
||
if (d.exceptions.length === 0) {
|
||
exEl.innerHTML = '<thead><tr><th>车号</th><th>缺失工序</th><th>缺扫码数</th><th>状态</th></tr></thead><tbody><tr><td colspan="4" style="text-align:center;color:#bbb;padding:24px">暂无异常</td></tr></tbody>';
|
||
} else {
|
||
var exHtml = '<thead><tr><th>车号</th><th>缺失工序</th><th>缺扫码数</th><th>状态</th></tr></thead><tbody>';
|
||
d.exceptions.forEach(function(e) {
|
||
var tagCls = e.missing === '全部' ? 'tag-red' : 'tag-orange';
|
||
exHtml += '<tr><td>' + e.carNo + '</td><td><span class="tag ' + tagCls + '">' + e.missing + '</span></td><td>' + e.missingCount + '</td><td><span class="tag tag-red">漏扫异常</span></td></tr>';
|
||
});
|
||
exHtml += '</tbody>';
|
||
exEl.innerHTML = exHtml;
|
||
}
|
||
|
||
// 产品明细
|
||
filteredProducts = d.products.slice();
|
||
currentPage = 1;
|
||
renderProductTable();
|
||
}
|
||
|
||
/* ===== 趋势图 ===== */
|
||
function renderTrendChart(trend) {
|
||
var svg = document.getElementById('trendChart');
|
||
var maxVal = Math.max.apply(null, trend.expected.concat(trend.actual));
|
||
if (maxVal < 5) maxVal = 5;
|
||
var w=400, h=200, padL=40, padR=20, padT=20, padB=30;
|
||
var chartW=w-padL-padR, chartH=h-padT-padB;
|
||
var stepX = chartW / (trend.labels.length - 1);
|
||
function yPos(v) { return padT + chartH - (v / maxVal) * chartH; }
|
||
function xPos(i) { return padL + i * stepX; }
|
||
|
||
var html = '';
|
||
html += '<line x1="' + padL + '" y1="' + padT + '" x2="' + padL + '" y2="' + (padT+chartH) + '" stroke="#e8e8e8"/>';
|
||
html += '<line x1="' + padL + '" y1="' + (padT+chartH) + '" x2="' + (w-padR) + '" y2="' + (padT+chartH) + '" stroke="#e8e8e8"/>';
|
||
for (var g=1; g<=3; g++) {
|
||
var gy = padT + (chartH/4)*g;
|
||
html += '<line x1="' + padL + '" y1="' + gy + '" x2="' + (w-padR) + '" y2="' + gy + '" stroke="#f5f5f5" stroke-dasharray="3,3"/>';
|
||
}
|
||
for (var g2=0; g2<=4; g2++) {
|
||
var gv = Math.round(maxVal - (maxVal/4)*g2);
|
||
var gy2 = padT + (chartH/4)*g2;
|
||
html += '<text x="' + (padL-5) + '" y="' + (gy2+4) + '" text-anchor="end" font-size="10" fill="#999">' + gv + '</text>';
|
||
}
|
||
trend.labels.forEach(function(lb, i) {
|
||
html += '<text x="' + xPos(i) + '" y="' + (h-8) + '" text-anchor="middle" font-size="10" fill="#999">' + lb + '</text>';
|
||
});
|
||
var expPts = trend.expected.map(function(v,i) { return xPos(i)+','+yPos(v); }).join(' ');
|
||
html += '<polyline points="' + expPts + '" fill="none" stroke="#bfbfbf" stroke-width="2" stroke-dasharray="5,3"/>';
|
||
var actPts = trend.actual.map(function(v,i) { return xPos(i)+','+yPos(v); }).join(' ');
|
||
html += '<polyline points="' + actPts + '" fill="none" stroke="#1890ff" stroke-width="2.5"/>';
|
||
trend.actual.forEach(function(v,i) {
|
||
html += '<circle cx="' + xPos(i) + '" cy="' + yPos(v) + '" r="3" fill="#1890ff"/>';
|
||
});
|
||
html += '<line x1="250" y1="30" x2="270" y2="30" stroke="#bfbfbf" stroke-width="2" stroke-dasharray="5,3"/>';
|
||
html += '<text x="275" y="34" font-size="11" fill="#999">应扫</text>';
|
||
html += '<line x1="310" y1="30" x2="330" y2="30" stroke="#1890ff" stroke-width="2.5"/>';
|
||
html += '<text x="335" y="34" font-size="11" fill="#1890ff">实扫</text>';
|
||
svg.innerHTML = html;
|
||
}
|
||
|
||
/* ===== 产品明细表 ===== */
|
||
function renderProductTable() {
|
||
var el = document.getElementById('productTable');
|
||
var start = (currentPage-1) * pageSize;
|
||
var pageData = filteredProducts.slice(start, start + pageSize);
|
||
if (pageData.length === 0) {
|
||
el.innerHTML = '<thead><tr><th>车号</th><th>SN</th><th>机型</th><th>应扫</th><th>实扫</th><th>进度</th><th>状态</th><th>缺失工序</th><th>最后扫码时间</th><th>操作</th></tr></thead><tbody><tr><td colspan="10" style="text-align:center;color:#bbb;padding:24px">暂无数据</td></tr></tbody>';
|
||
document.getElementById('pagination').innerHTML = '';
|
||
return;
|
||
}
|
||
var html = '<thead><tr><th>车号</th><th>SN</th><th>机型</th><th>应扫</th><th>实扫</th><th>进度</th><th>状态</th><th>缺失工序</th><th>最后扫码时间</th><th>操作</th></tr></thead><tbody>';
|
||
pageData.forEach(function(p) {
|
||
var pct = p.expected > 0 ? (p.actual / p.expected * 100).toFixed(1) : 0;
|
||
var pctNum = parseFloat(pct);
|
||
var barBg = pctNum >= 100 ? '#52c41a' : pctNum > 0 ? '#1890ff' : '#bfbfbf';
|
||
html += '<tr>'
|
||
+ '<td>' + p.carNo + '</td>'
|
||
+ '<td>' + p.sn + '</td>'
|
||
+ '<td>' + p.model + '</td>'
|
||
+ '<td>' + p.expected + '</td>'
|
||
+ '<td>' + p.actual + '</td>'
|
||
+ '<td><span class="progress-bar"><span class="progress-bar-fill" style="width:' + pct + '%;background:' + barBg + '"></span></span>' + pct + '%</td>'
|
||
+ '<td>' + statusBadge(p.status) + '</td>'
|
||
+ '<td>' + (p.missingProcs || '--') + '</td>'
|
||
+ '<td>' + p.lastTime + '</td>'
|
||
+ '<td><span class="btn-detail" onclick="showProductDetail(\'' + p.carNo + '\')">详情</span></td>'
|
||
+ '</tr>';
|
||
});
|
||
html += '</tbody>';
|
||
el.innerHTML = html;
|
||
renderPagination();
|
||
}
|
||
|
||
function renderPagination() {
|
||
var total = filteredProducts.length;
|
||
var totalPages = Math.ceil(total / pageSize);
|
||
var el = document.getElementById('pagination');
|
||
if (totalPages <= 1) { el.innerHTML = '<span>共 ' + total + ' 条</span>'; return; }
|
||
var html = '<span>共 ' + total + ' 条</span>';
|
||
html += '<button onclick="goPage(1)" ' + (currentPage===1?'disabled':'') + '>首页</button>';
|
||
html += '<button onclick="goPage(' + (currentPage-1) + ')" ' + (currentPage===1?'disabled':'') + '>上一页</button>';
|
||
for (var i=1; i<=totalPages; i++) {
|
||
if (i===1 || i===totalPages || Math.abs(i-currentPage)<=2) {
|
||
html += '<button onclick="goPage(' + i + ')" class="' + (i===currentPage?'active':'') + '">' + i + '</button>';
|
||
} else if (Math.abs(i-currentPage)===3) {
|
||
html += '<span>...</span>';
|
||
}
|
||
}
|
||
html += '<button onclick="goPage(' + (currentPage+1) + ')" ' + (currentPage===totalPages?'disabled':'') + '>下一页</button>';
|
||
html += '<button onclick="goPage(' + totalPages + ')" ' + (currentPage===totalPages?'disabled':'') + '>末页</button>';
|
||
el.innerHTML = html;
|
||
}
|
||
|
||
function goPage(p) { currentPage = p; renderProductTable(); }
|
||
|
||
function filterProducts() {
|
||
if (!currentMachine) return;
|
||
var d = machineData[currentMachine];
|
||
var kw = document.getElementById('txtSearch').value.trim().toLowerCase();
|
||
var st = document.getElementById('selStatus').value;
|
||
var line = document.getElementById('selLine').value;
|
||
filteredProducts = d.products.filter(function(p) {
|
||
var matchKw = !kw || p.carNo.toLowerCase().indexOf(kw) >= 0 || p.sn.toLowerCase().indexOf(kw) >= 0;
|
||
var matchSt = !st || p.status === st;
|
||
var matchLine = !line || p.line === line;
|
||
return matchKw && matchSt && matchLine;
|
||
});
|
||
currentPage = 1;
|
||
renderProductTable();
|
||
}
|
||
|
||
/* ===== 产品扫码详情弹窗 ===== */
|
||
function showProductDetail(carNo) {
|
||
if (!currentMachine) return;
|
||
var d = machineData[currentMachine];
|
||
var p = d.products.find(function(x) { return x.carNo === carNo; });
|
||
if (!p) return;
|
||
|
||
var processNames = d.processes.map(function(pr) { return pr.name; });
|
||
var html = '<div style="margin-bottom:16px;display:flex;gap:24px;font-size:13px;">'
|
||
+ '<div><span style="color:#999">车号:</span><b>' + p.carNo + '</b></div>'
|
||
+ '<div><span style="color:#999">SN:</span><b>' + p.sn + '</b></div>'
|
||
+ '<div><span style="color:#999">状态:</span>' + statusBadge(p.status) + '</div>'
|
||
+ '</div>';
|
||
|
||
html += '<table class="trace-table"><thead><tr>'
|
||
+ '<th>序号</th><th>工序编号</th><th>工序名称</th><th>应扫码数</th><th>实扫码数</th><th>扫码状态</th><th>最后扫码时间</th>'
|
||
+ '</tr></thead><tbody>';
|
||
|
||
var perProcess = Math.ceil(p.expected / processNames.length);
|
||
processNames.forEach(function(pn, idx) {
|
||
var expected = perProcess;
|
||
var actual = 0;
|
||
if (p.status === 'normal') {
|
||
actual = expected;
|
||
} else if (p.status === 'abnormal') {
|
||
var completedUpTo = Math.floor(p.actual / perProcess);
|
||
actual = idx < completedUpTo ? expected : (idx === completedUpTo ? p.actual % perProcess : 0);
|
||
} else if (p.status === 'notstart') {
|
||
actual = 0;
|
||
}
|
||
var isComplete = actual >= expected;
|
||
html += '<tr>'
|
||
+ '<td>' + (idx+1) + '</td>'
|
||
+ '<td>' + d.processes[idx].code + '</td>'
|
||
+ '<td>' + pn + '</td>'
|
||
+ '<td>' + expected + '</td>'
|
||
+ '<td class="' + (isComplete?'scanned':'missing') + '">' + actual + '</td>'
|
||
+ '<td>' + (isComplete ? '<span class="status-badge normal">已扫</span>' : (actual>0 ? '<span class="status-badge abnormal">漏扫</span>' : '<span class="status-badge notstart">未扫</span>')) + '</td>'
|
||
+ '<td>' + (actual > 0 ? p.lastTime : '--') + '</td>'
|
||
+ '</tr>';
|
||
});
|
||
html += '</tbody></table>';
|
||
|
||
document.getElementById('modalTitle').textContent = '扫码追溯详情 - ' + carNo;
|
||
document.getElementById('modalBody').innerHTML = html;
|
||
document.getElementById('modalOverlay').classList.add('show');
|
||
}
|
||
|
||
function closeModal() {
|
||
document.getElementById('modalOverlay').classList.remove('show');
|
||
}
|
||
|
||
/* ===== 视图切换 ===== */
|
||
function showCompareView() {
|
||
document.querySelectorAll('.tab').forEach(function(t) { t.classList.remove('active'); });
|
||
document.querySelector('.tab:first-child').classList.add('active');
|
||
document.getElementById('compareView').style.display = '';
|
||
document.getElementById('detailView').style.display = 'none';
|
||
}
|
||
|
||
function showDetailView(key) {
|
||
document.querySelectorAll('.tab').forEach(function(t) { t.classList.remove('active'); });
|
||
var tabs = document.querySelectorAll('.tab');
|
||
var tabIdx = ['gss','gs50','gs40','gssw'].indexOf(key);
|
||
if (tabIdx >= 0 && tabs[tabIdx+1]) tabs[tabIdx+1].classList.add('active');
|
||
document.getElementById('compareView').style.display = 'none';
|
||
document.getElementById('detailView').style.display = '';
|
||
renderDetailView(key);
|
||
}
|
||
|
||
function refreshData() {
|
||
if (document.getElementById('detailView').style.display !== 'none' && currentMachine) {
|
||
renderDetailView(currentMachine);
|
||
} else {
|
||
renderCompareView();
|
||
}
|
||
}
|
||
|
||
/* ===== 初始化 ===== */
|
||
renderCompareView();
|
||
|
||
// 实时时间
|
||
function updateTime() {
|
||
var now = new Date();
|
||
var pad = function(n) { return n < 10 ? '0' + n : n; };
|
||
document.getElementById('curTime').textContent =
|
||
now.getFullYear() + '-' + pad(now.getMonth()+1) + '-' + pad(now.getDate()) + ' '
|
||
+ pad(now.getHours()) + ':' + pad(now.getMinutes()) + ':' + pad(now.getSeconds());
|
||
}
|
||
updateTime();
|
||
setInterval(updateTime, 1000);
|
||
</script>
|
||
|
||
</body>
|
||
</html>
|