矿车运营统计界面重构:作业时长与循环逻辑修正及多维度数据可视化

By 18561366332, 27 April, 2026
推理
The user wants me to redesign the mining truck operations statistics interface with corrected business logic:

1. **作业时长** = 卸载时长 + 装载时长 + 空车返回时间 + 重车运行时间
2. **一次循环** = 空车返回 + 装载 + 重车运行 + 卸载
3. Add **装载/行驶/卸载时间占比分析** (load/haul/dump time ratio analysis)

So I need to:
- Fix the data generation logic so that 作业时长 = 卸载 + 装载 + 空车返回 + 重车运行
- Make sure 循环次数 aligns with the cycle definition
- Add a new visualization for 装载/行驶/卸载 time ratio
- "行驶" here includes 空车返回 + 重车运行 (or could be split differently)

Let me think about the data model:
- 装载时长 (load time)
- 重车运行时间 (loaded haul time)
- 卸载时长 (dump/unload time)
- 空车返回时间 (empty return time)
- 作业时长 = 装载 + 重车运行 + 卸载 + 空车返回
- 怠速时长 (idle time)
- 运行时长 = 作业时长 + 怠速时长
- 循环次数: each cycle = 装载 + 重车运行 + 卸载 + 空车返回

For the ratio analysis:
- 装载占比 = 装载时长 / 作业时长
- 行驶占比 = (重车运行时间 + 空车返回时间) / 作业时长
- 卸载占比 = 卸载时长 / 作业时长

I'll create a fresh design with a white background, incorporating:
- The 8 metric cards (same as before but with corrected logic)
- A line chart for trends
- A bar/stacked bar chart for distribution
- A ratio pie/donut chart or stacked bar showing 装载/行驶/卸载 ratios
- The data table

Let me also add a section for the ratio analysis. I could use a donut chart or a horizontal stacked bar for this.

I'll go with a white background design. Let me design this thoughtfully.

The layout for 16:9:
- Header with controls
- 8 metric cards in one row
- Charts area: line chart (trends) on left, stacked bar (time composition) on right, and a ratio section
- Data table at bottom

Let me also add a dedicate ratio analysis panel or incorporate it into the charts area.

Actually, let me restructure the charts area to have:
- Left: Line chart for trends (运行时长, 作业时长, 循环次数 trends)
- Right top: Stacked bar for time composition (装载, 重车运行, 卸载, 空车返回, 怠速)
- Right bottom: Ratio donut/progress bars for 装载/行驶/卸载

Or I could do:
- Left: Line chart (trends)
- Middle: Stacked bar (distribution)
- Right: Ratio analysis (donut or horizontal bars)

For 16:9 ratio, I have space for 3 columns in the chart area.

Let me make a clean, modern white design with these features. I'll use a fresh color palette and typography.

Let me also keep the design system tool in mind - but I'll just go with a clean, professional white-background industrial analytics design.

Let me plan the layout:
- Header row
- 8 metric cards row
- Charts row (3 columns): Line chart | Stacked bar chart | Ratio analysis
- Table at bottom

For the ratio analysis, I'll use a donut chart showing 装载/行驶/卸载 proportions, plus maybe some progress bars.

Let me code this up. I'll use Canvas for all charts.

For the data generation, I need to fix the logic:
- 作业时长 = 卸载 + 装载 + 空车返回 + 重车运行
- 循环次数 is based on total cycles
- 运行时长 = 作业时长 + 怠速时长

Let me also think about the cycle count relationship. If each cycle takes a certain amount of time, then:
- 循环次数 = 作业时长 / (average cycle time) or just generated independently

Actually, the user says "空车+装载+重车运行+卸载记为一次循环", so the cycle count should relate to how many complete cycles happened. In the data, I'll generate cycle count and then derive the times from it.

Let me restructure:
- Generate 循环次数 first
- Per cycle times:
- 装载时长 per cycle
- 重车运行 per cycle
- 卸载时长 per cycle
- 空车返回 per cycle
- 怠速时长 per cycle (idle is NOT part of a cycle but part of total runtime)
- 作业时长 = 循环次数 × (装载 + 重车运行 + 卸载 + 空车返回) per cycle
- 运行时长 = 作业时长 + (循环次数 × 怠速 per cycle)

Let me code this now. I'll keep it white-background, clean and professional.

Actually for the ratio analysis, "行驶" = 空车返回 + 重车运行. So the three ratios are:
- 装载占比
- 行驶占比 (空车返回 + 重车运行)
- 卸载占比

These three sum to 100% of 作业时长.

Let me build this comprehensively.
角色
assistant
content

```json
{
"summary": "重新设计矿车运营统计界面,修正业务逻辑:作业时长=卸载+装载+空车返回+重车运行,循环=空车+装载+重车运行+卸载。新增装载/行驶/卸载时间占比环形图分析,白底企业级设计,8项指标卡片+折线趋势+堆叠柱状分布+占比环形图+数据明细表。",
"widget": {
"type": "full-html",
"html": "<!DOCTYPE html>\n<html lang=\"zh-CN\">\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>矿车生产运营数据统计</title>\n <link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">\n <link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>\n <link href=\"https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9…\" rel=\"stylesheet\">\n <link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.c…\">\n <style>\n :root {\n --bg-page: #f5f6f8;\n --bg-panel: #fdfdfd;\n --bg-card: #ffffff;\n --bg-elevated: #fafbfc;\n --bg-stripe: #f8f9fb;\n --border: #e5e8ed;\n --border-light: #eff1f5;\n --border-active: #c9ced7;\n --text-primary: #0f172a;\n --text-secondary: #475569;\n --text-muted: #94a3b8;\n --accent-amber: #d4891a;\n --accent-amber-bg: #fef9f0;\n --accent-amber-light: #fdf0db;\n --accent-cyan: #0d82b8;\n --accent-cyan-bg: #f0f9fd;\n --accent-teal: #0f766e;\n --accent-teal-bg: #f0fdf9;\n --accent-orange: #ea570c;\n --accent-orange-bg: #fff8f4;\n --accent-purple: #7c3aed;\n --accent-purple-bg: #faf8ff;\n --accent-blue: #2563eb;\n --accent-blue-bg: #f6f9fe;\n --accent-green: #16a34a;\n --accent-green-bg: #f6fdf8;\n --accent-red: #dc2626;\n --accent-red-bg: #fef7f7;\n --accent-slate: #64748b;\n --radius-sm: 4px;\n --radius: 8px;\n --radius-md: 10px;\n --radius-lg: 14px;\n --radius-xl: 18px;\n --shadow-xs: 0 1px 2px rgba(0,0,0,0.03);\n --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);\n --shadow-card: 0 2px 8px rgba(0,0,0,0.04), 0 0 0 1px rgba(0,0,0,0.02);\n --shadow-elevated: 0 8px 28px rgba(0,0,0,0.07), 0 2px 6px rgba(0,0,0,0.03);\n --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);\n --font-display: 'DM Sans', 'Noto Sans SC', sans-serif;\n --font-body: 'Noto Sans SC', 'DM Sans', sans-serif;\n --font-mono: 'DM Sans', monospace;\n }\n\n * { box-sizing: border-box; margin: 0; padding: 0; }\n\n body {\n background: var(--bg-page);\n color: var(--text-primary);\n font-family: var(--font-body);\n min-height: 100vh;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 12px;\n background-image:\n radial-gradient(ellipse at 18% 12%, rgba(212,137,26,0.035) 0%, transparent 60%),\n radial-gradient(ellipse at 82% 88%, rgba(13,130,184,0.025) 0%, transparent 60%);\n }\n\n .dashboard {\n width: 100%;\n max-width: 1600px;\n aspect-ratio: 16 / 9;\n max-height: calc(100vh - 24px);\n display: flex;\n flex-direction: column;\n gap: 9px;\n background: var(--bg-panel);\n border-radius: var(--radius-xl);\n padding: 16px 20px;\n box-shadow: var(--shadow-elevated);\n border: 1px solid var(--border);\n position: relative;\n overflow: hidden;\n }\n\n .dashboard::before {\n content: '';\n position: absolute;\n inset: 0;\n pointer-events: none;\n background:\n linear-gradient(180deg, rgba(212,137,26,0.018) 0%, transparent 25%),\n linear-gradient(0deg, rgba(13,130,184,0.012) 0%, transparent 35%);\n border-radius: var(--radius-xl);\n z-index: 0;\n }\n\n .dashboard > * { position: relative; z-index: 1; }\n\n /* ============ HEADER ============ */\n .header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 14px;\n flex-shrink: 0;\n padding-bottom: 8px;\n border-bottom: 1px solid var(--border-light);\n }\n\n .header-left {\n display: flex;\n align-items: center;\n gap: 10px;\n }\n\n .logo-mark {\n width: 34px;\n height: 34px;\n background: linear-gradient(135deg, #d4891a, #b07214);\n border-radius: var(--radius);\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 16px;\n color: #ffffff;\n font-weight: 700;\n flex-shrink: 0;\n box-shadow: 0 2px 10px rgba(212,137,26,0.22);\n }\n\n .header-title h1 {\n font-family: var(--font-display);\n font-size: clamp(15px, 1.3vw, 21px);\n font-weight: 700;\n letter-spacing: -0.01em;\n color: var(--text-primary);\n line-height: 1.1;\n }\n\n .header-title span {\n font-size: 10px;\n color: var(--text-muted);\n font-weight: 500;\n letter-spacing: 0.06em;\n text-transform: uppercase;\n }\n\n .header-right {\n display: flex;\n align-items: center;\n gap: 7px;\n flex-wrap: wrap;\n justify-content: flex-end;\n }\n\n .btn-group {\n display: flex;\n background: var(--bg-card);\n border-radius: var(--radius);\n border: 1px solid var(--border);\n overflow: hidden;\n box-shadow: var(--shadow-xs);\n }\n\n .btn-group button {\n background: transparent;\n border: none;\n color: var(--text-secondary);\n padding: 6px 13px;\n cursor: pointer;\n font-family: var(--font-display);\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0.01em;\n transition: all var(--transition-base);\n white-space: nowrap;\n position: relative;\n }\n\n .btn-group button:not(:last-child)::after {\n content: '';\n position: absolute;\n right: 0;\n top: 18%;\n height: 64%;\n width: 1px;\n background: var(--border);\n }\n\n .btn-group button:hover { color: var(--text-primary); background: var(--bg-elevated); }\n\n .btn-group button.active {\n color: #ffffff;\n background: #d4891a;\n box-shadow: 0 0 12px rgba(212,137,26,0.25);\n border-radius: 0;\n }\n .btn-group button.active::after { display: none; }\n .btn-group button:first-child.active { border-radius: var(--radius) 0 0 var(--radius); }\n .btn-group button:last-child.active { border-radius: 0 var(--radius) var(--radius) 0; }\n\n .date-input {\n background: var(--bg-card);\n border: 1px solid var(--border);\n color: var(--text-primary);\n padding: 6px 9px;\n border-radius: var(--radius);\n font-family: var(--font-display);\n font-size: 12px;\n outline: none;\n transition: all var(--transition-base);\n width: 124px;\n cursor: pointer;\n box-shadow: var(--shadow-xs);\n }\n\n .date-input:focus { border-color: #d4891a; box-shadow: 0 0 0 3px rgba(212,137,26,0.12); }\n\n .date-separator { color: var(--text-muted); font-size: 12px; font-weight: 500; }\n\n .btn-action {\n background: var(--bg-card);\n border: 1px solid var(--border);\n color: var(--text-secondary);\n width: 32px;\n height: 32px;\n border-radius: var(--radius);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all var(--transition-base);\n font-size: 13px;\n box-shadow: var(--shadow-xs);\n }\n\n .btn-action:hover { color: var(--text-primary); border-color: var(--border-active); background: var(--bg-elevated); }\n\n .btn-primary {\n background: linear-gradient(135deg, #d4891a, #b07214);\n border: none;\n color: #ffffff;\n padding: 6px 16px;\n border-radius: var(--radius);\n cursor: pointer;\n font-family: var(--font-display);\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0.01em;\n transition: all var(--transition-base);\n white-space: nowrap;\n box-shadow: 0 2px 8px rgba(212,137,26,0.22);\n }\n\n .btn-primary:hover { filter: brightness(1.07); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(212,137,26,0.28); }\n .btn-primary:active { transform: scale(0.97); }\n\n /* ============ METRICS ROW ============ */\n .metrics-row {\n display: grid;\n grid-template-columns: repeat(8, 1fr);\n gap: 7px;\n flex-shrink: 0;\n }\n\n .metric-card {\n background: var(--bg-card);\n border-radius: var(--radius-md);\n padding: 10px 12px;\n border: 1px solid var(--border-light);\n position: relative;\n overflow: hidden;\n transition: all var(--transition-base);\n cursor: default;\n display: flex;\n flex-direction: column;\n gap: 2px;\n box-shadow: var(--shadow-sm);\n }\n\n .metric-card:hover {\n border-color: var(--border-active);\n box-shadow: var(--shadow-elevated);\n transform: translateY(-2px);\n }\n\n .metric-card .card-accent {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 3px;\n }\n\n .metric-card:nth-child(1) .card-accent { background: #d4891a; }\n .metric-card:nth-child(2) .card-accent { background: #0d82b8; }\n .metric-card:nth-child(3) .card-accent { background: #0f766e; }\n .metric-card:nth-child(4) .card-accent { background: #ea570c; }\n .metric-card:nth-child(5) .card-accent { background: #7c3aed; }\n .metric-card:nth-child(6) .card-accent { background: #2563eb; }\n .metric-card:nth-child(7) .card-accent { background: #16a34a; }\n .metric-card:nth-child(8) .card-accent { background: #dc2626; }\n\n .metric-card .card-icon {\n font-size: 10px;\n color: var(--text-muted);\n }\n\n .metric-card .card-label {\n font-size: 9px;\n color: var(--text-muted);\n text-transform: uppercase;\n letter-spacing: 0.06em;\n font-weight: 600;\n }\n\n .metric-card .card-value {\n font-family: var(--font-display);\n font-size: clamp(15px, 1.7vw, 23px);\n font-weight: 700;\n color: var(--text-primary);\n letter-spacing: -0.02em;\n line-height: 1;\n }\n\n .metric-card .card-sub {\n font-size: 9px;\n color: var(--text-muted);\n font-weight: 500;\n }\n\n /* ============ CHARTS AREA ============ */\n .charts-area {\n display: grid;\n grid-template-columns: 1.25fr 0.85fr 0.9fr;\n gap: 9px;\n flex: 1;\n min-height: 0;\n }\n\n .chart-box {\n background: var(--bg-card);\n border-radius: var(--radius-md);\n border: 1px solid var(--border-light);\n padding: 12px 14px;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n box-shadow: var(--shadow-sm);\n }\n\n .chart-box-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n flex-shrink: 0;\n margin-bottom: 6px;\n gap: 8px;\n }\n\n .chart-box-title {\n font-family: var(--font-display);\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0.02em;\n color: var(--text-secondary);\n text-transform: uppercase;\n white-space: nowrap;\n }\n\n .chart-legend {\n display: flex;\n gap: 8px;\n font-size: 9px;\n color: var(--text-muted);\n flex-wrap: wrap;\n justify-content: flex-end;\n }\n\n .chart-legend span {\n display: flex;\n align-items: center;\n gap: 3px;\n white-space: nowrap;\n }\n\n .chart-legend .dot {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n display: inline-block;\n flex-shrink: 0;\n }\n\n .chart-canvas-wrap {\n flex: 1;\n min-height: 0;\n position: relative;\n width: 100%;\n }\n\n .chart-canvas-wrap canvas {\n width: 100%;\n height: 100%;\n display: block;\n }\n\n /* ============ RATIO PANEL ============ */\n .ratio-panel {\n background: var(--bg-card);\n border-radius: var(--radius-md);\n border: 1px solid var(--border-light);\n padding: 12px 14px;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n box-shadow: var(--shadow-sm);\n }\n\n .ratio-header {\n flex-shrink: 0;\n margin-bottom: 4px;\n }\n\n .ratio-body {\n flex: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n min-height: 0;\n }\n\n .ratio-donut-wrap {\n flex: 1;\n min-width: 0;\n height: 100%;\n position: relative;\n }\n\n .ratio-donut-wrap canvas {\n width: 100%;\n height: 100%;\n display: block;\n }\n\n .ratio-legend-vert {\n display: flex;\n flex-direction: column;\n gap: 10px;\n flex-shrink: 0;\n font-size: 10px;\n font-family: var(--font-display);\n }\n\n .ratio-legend-item {\n display: flex;\n align-items: center;\n gap: 6px;\n }\n\n .ratio-legend-dot {\n width: 9px;\n height: 9px;\n border-radius: 2px;\n flex-shrink: 0;\n }\n\n .ratio-legend-val {\n font-weight: 700;\n font-size: 14px;\n color: var(--text-primary);\n line-height: 1;\n }\n\n .ratio-legend-label {\n color: var(--text-muted);\n font-size: 9px;\n }\n\n /* ============ TABLE ============ */\n .table-section {\n flex-shrink: 0;\n background: var(--bg-card);\n border-radius: var(--radius-md);\n border: 1px solid var(--border-light);\n overflow: hidden;\n display: flex;\n flex-direction: column;\n max-height: 140px;\n box-shadow: var(--shadow-sm);\n }\n\n .table-section-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 7px 14px;\n border-bottom: 1px solid var(--border-light);\n flex-shrink: 0;\n }\n\n .table-section-title {\n font-family: var(--font-display);\n font-size: 11px;\n font-weight: 600;\n letter-spacing: 0.03em;\n color: var(--text-secondary);\n text-transform: uppercase;\n }\n\n .table-wrap {\n overflow-y: auto;\n flex: 1;\n }\n\n .table-wrap::-webkit-scrollbar { width: 4px; }\n .table-wrap::-webkit-scrollbar-track { background: transparent; }\n .table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }\n\n table {\n width: 100%;\n border-collapse: collapse;\n font-size: 10px;\n font-family: var(--font-display);\n }\n\n thead th {\n text-align: left;\n padding: 6px 9px;\n color: var(--text-muted);\n font-weight: 500;\n letter-spacing: 0.04em;\n text-transform: uppercase;\n font-size: 9px;\n position: sticky;\n top: 0;\n background: var(--bg-card);\n z-index: 2;\n border-bottom: 1px solid var(--border-light);\n }\n\n tbody td {\n padding: 5px 9px;\n border-bottom: 1px solid rgba(0,0,0,0.03);\n color: var(--text-primary);\n font-weight: 500;\n letter-spacing: 0.01em;\n }\n\n tbody tr:nth-child(even) { background: var(--bg-stripe); }\n tbody tr:hover { background: rgba(212,137,26,0.04); }\n tbody tr { transition: background var(--transition-base); }\n\n .cell-highlight { color: #d4891a; font-weight: 700; }\n .cell-cycles { font-weight: 700; color: #0f766e; }\n\n /* ============ TOAST ============ */\n .toast-container {\n position: fixed;\n top: 20px;\n right: 20px;\n z-index: 9999;\n display: flex;\n flex-direction: column;\n gap: 8px;\n pointer-events: none;\n }\n\n .toast {\n background: #ffffff;\n border: 1px solid var(--border);\n border-left: 3px solid #d4891a;\n color: var(--text-primary);\n padding: 10px 16px;\n border-radius: var(--radius);\n font-size: 12px;\n font-family: var(--font-body);\n box-shadow: 0 4px 20px rgba(0,0,0,0.1);\n opacity: 0;\n transform: translateX(30px);\n transition: all 280ms cubic-bezier(0.4, 0, 0.2, 1);\n pointer-events: auto;\n display: flex;\n align-items: center;\n gap: 8px;\n }\n\n .toast.show { opacity: 1; transform: translateX(0); }\n .toast i { color: #d4891a; font-size: 14px; }\n\n /* ============ RESPONSIVE ============ */\n @media (max-width: 1400px) {\n .metrics-row { grid-template-columns: repeat(4, 1fr); }\n .charts-area { grid-template-columns: 1fr 1fr; }\n .ratio-panel { grid-column: span 2; flex-direction: row; }\n .dashboard { aspect-ratio: auto; max-height: none; }\n .chart-box { min-height: 200px; }\n .ratio-panel { min-height: 180px; }\n }\n\n @media (max-width: 900px) {\n .metrics-row { grid-template-columns: repeat(3, 1fr); }\n .charts-area { grid-template-columns: 1fr; }\n .ratio-panel { grid-column: span 1; flex-direction: column; }\n .header { flex-direction: column; align-items: stretch; }\n .header-right { justify-content: flex-start; }\n .date-input { width: 95px; }\n .dashboard { padding: 10px; }\n .chart-box { min-height: 180px; }\n }\n\n @media (max-width: 600px) {\n .metrics-row { grid-template-columns: repeat(2, 1fr); }\n .btn-group button { padding: 5px 9px; font-size: 11px; }\n .date-input { width: 80px; font-size: 11px; }\n .header-right { gap: 4px; }\n table { font-size: 9px; }\n thead th, tbody td { padding: 4px 5px; }\n .ratio-body { flex-direction: column; }\n }\n\n @media print {\n body { background: #fff; padding: 0; }\n .dashboard { box-shadow: none; border: none; aspect-ratio: auto; max-height: none; }\n .btn-primary, .btn-action, .btn-group { display: none; }\n .toast-container { display: none; }\n }\n </style>\n</head>\n<body>\n\n<div class=\"dashboard\" id=\"dashboard\">\n\n <!-- HEADER -->\n <div class=\"header\">\n <div class=\"header-left\">\n <div class=\"logo-mark\"><i class=\"fa-solid fa-truck\"></i></div>\n <div class=\"header-title\">\n <h1>矿车运营数据统计</h1>\n <span>Mining Truck Operations</span>\n </div>\n </div>\n <div class=\"header-right\">\n <div class=\"btn-group\" id=\"granularityGroup\">\n <button data-gran=\"day\" class=\"active\">按日</button>\n <button data-gran=\"month\">按月</button>\n <button data-gran=\"year\">按年</button>\n </div>\n <input type=\"date\" class=\"date-input\" id=\"startDate\" value=\"2026-04-01\">\n <span class=\"date-separator\">至</span>\n <input type=\"date\" class=\"date-input\" id=\"endDate\" value=\"2026-04-27\">\n <button class=\"btn-primary\" onclick=\"refreshData()\"><i class=\"fa-solid fa-arrows-rotate\"></i>&nbsp;刷新</button>\n <button class=\"btn-action\" onclick=\"exportCSV()\" title=\"导出CSV\"><i class=\"fa-solid fa-file-csv\"></i></button>\n <button class=\"btn-action\" onclick=\"printDashboard()\" title=\"打印\"><i class=\"fa-solid fa-print\"></i></button>\n </div>\n </div>\n\n <!-- METRICS ROW -->\n <div class=\"metrics-row\" id=\"metricsRow\"></div>\n\n <!-- CHARTS AREA: 3 columns -->\n <div class=\"charts-area\">\n <!-- LINE CHART: 运行趋势 -->\n <div class=\"chart-box\" id=\"lineChartBox\">\n <div class=\"chart-box-header\">\n <span class=\"chart-box-title\"><i class=\"fa-solid fa-chart-line\"></i>&nbsp;运行趋势</span>\n <div class=\"chart-legend\">\n <span><span class=\"dot\" style=\"background:#d4891a\"></span>运行时长</span>\n <span><span class=\"dot\" style=\"background:#0d82b8\"></span>作业时长</span>\n <span><span class=\"dot\" style=\"background:#0f766e\"></span>循环次数</span>\n </div>\n </div>\n <div class=\"chart-canvas-wrap\"><canvas id=\"lineChart\"></canvas></div>\n </div>\n\n <!-- STACKED BAR: 时长构成 -->\n <div class=\"chart-box\" id=\"barChartBox\">\n <div class=\"chart-box-header\">\n <span class=\"chart-box-title\"><i class=\"fa-solid fa-chart-bar\"></i>&nbsp;时长构成</span>\n <div class=\"chart-legend\">\n <span><span class=\"dot\" style=\"background:#ea570c\"></span>装载</span>\n <span><span class=\"dot\" style=\"background:#2563eb\"></span>重车</span>\n <span><span class=\"dot\" style=\"background:#7c3aed\"></span>卸载</span>\n <span><span class=\"dot\" style=\"background:#16a34a\"></span>空返</span>\n <span><span class=\"dot\" style=\"background:#dc2626\"></span>怠速</span>\n </div>\n </div>\n <div class=\"chart-canvas-wrap\"><canvas id=\"barChart\"></canvas></div>\n </div>\n\n <!-- RATIO DONUT: 装载/行驶/卸载占比 -->\n <div class=\"ratio-panel\" id=\"ratioPanel\">\n <div class=\"ratio-header\">\n <span class=\"chart-box-title\"><i class=\"fa-solid fa-chart-pie\"></i>&nbsp;装载 / 行驶 / 卸载占比</span>\n </div>\n <div class=\"ratio-body\">\n <div class=\"ratio-donut-wrap\"><canvas id=\"donutChart\"></canvas></div>\n <div class=\"ratio-legend-vert\" id=\"ratioLegend\"></div>\n </div>\n </div>\n </div>\n\n <!-- TABLE -->\n <div class=\"table-section\">\n <div class=\"table-section-header\">\n <span class=\"table-section-title\"><i class=\"fa-solid fa-table-list\"></i>&nbsp;数据明细</span>\n <span style=\"font-size:9px;color:var(--text-muted)\" id=\"tableInfo\">共 0 条记录</span>\n </div>\n <div class=\"table-wrap\">\n <table>\n <thead>\n <tr>\n <th>周期</th>\n <th>运行(h)</th>\n <th>作业(h)</th>\n <th>循环(次)</th>\n <th>怠速(h)</th>\n <th>装载(h)</th>\n <th>卸载(h)</th>\n <th>空返(h)</th>\n <th>重车(h)</th>\n </tr>\n </thead>\n <tbody id=\"tableBody\"></tbody>\n </table>\n </div>\n </div>\n</div>\n\n<div class=\"toast-container\" id=\"toastContainer\"></div>\n\n<script>\n(function() {\n 'use strict';\n\n // ==================== STATE ====================\n const state = {\n granularity: 'day',\n startDate: '2026-04-01',\n endDate: '2026-04-27',\n };\n\n const $ = (sel) => document.querySelector(sel);\n\n const dom = {\n granularityGroup: $('#granularityGroup'),\n startDate: $('#startDate'),\n endDate: $('#endDate'),\n metricsRow: $('#metricsRow'),\n lineChart: $('#lineChart'),\n barChart: $('#barChart'),\n donutChart: $('#donutChart'),\n tableBody: $('#tableBody'),\n tableInfo: $('#tableInfo'),\n toastContainer: $('#toastContainer'),\n ratioLegend: $('#ratioLegend'),\n };\n\n // ==================== TOAST ====================\n function showToast(msg, icon) {\n const el = document.createElement('div');\n el.className = 'toast';\n el.innerHTML = `<i class=\"fa-solid ${icon || 'fa-circle-check'}\"></i>${msg}`;\n dom.toastContainer.appendChild(el);\n requestAnimationFrame(() => el.classList.add('show'));\n setTimeout(() => {\n el.classList.remove('show');\n setTimeout(() => el.remove(), 350);\n }, 2200);\n }\n\n // ==================== DATA GENERATION (CORRECTED LOGIC) ====================\n // 作业时长 = 卸载时长 + 装载时长 + 空车返回时间 + 重车运行时间\n // 一次循环 = 空车返回 + 装载 + 重车运行 + 卸载\n // 运行时长 = 作业时长 + 怠速时长\n\n function seedRandom(seed) {\n let s = seed;\n return function() {\n s = (s * 16807 + 0) % 2147483647;\n return (s - 1) / 2147483646;\n };\n }\n\n function generateRecords(granularity, start, end) {\n const records = [];\n const startD = new Date(start);\n const endD = new Date(end);\n\n if (isNaN(startD.getTime()) || isNaN(endD.getTime()) || startD > endD) return records;\n\n let labels = [];\n let current = new Date(startD);\n\n if (granularity === 'day') {\n while (current <= endD) {\n labels.push(new Date(current));\n current.setDate(current.getDate() + 1);\n }\n } else if (granularity === 'month') {\n current = new Date(startD.getFullYear(), startD.getMonth(), 1);\n const endMonth = new Date(endD.getFullYear(), endD.getMonth(), 1);\n while (current <= endMonth) {\n labels.push(new Date(current));\n current.setMonth(current.getMonth() + 1);\n }\n } else {\n current = new Date(startD.getFullYear(), 0, 1);\n const endYear = new Date(endD.getFullYear(), 0, 1);\n while (current <= endYear) {\n labels.push(new Date(current));\n current.setFullYear(current.getFullYear() + 1);\n }\n }\n\n if (labels.length > 120) {\n const step = Math.ceil(labels.length / 100);\n labels = labels.filter((_, i) => i % step === 0);\n }\n\n labels.forEach((d, i) => {\n const rng = seedRandom(d.getTime() % 100000 + i * 73);\n\n // 循环次数\n const cyclesBase = granularity === 'year'\n ? 4200 + rng() * 2800\n : granularity === 'month'\n ? 350 + rng() * 240\n : 13 + rng() * 11;\n const cycles = Math.round(cyclesBase);\n\n // 每次循环的各阶段时长(小时)\n const loadPerCycle = 0.09 + rng() * 0.07; // 装载\n const loadedRunPerCycle = 0.16 + rng() * 0.12; // 重车运行\n const unloadPerCycle = 0.03 + rng() * 0.03; // 卸载\n const emptyReturnPerCycle = 0.10 + rng() * 0.08; // 空车返回\n const idlePerCycle = 0.06 + rng() * 0.10; // 怠速(不属于作业)\n\n // 各阶段总时长\n const loadTime = Math.round(cycles * loadPerCycle * 10) / 10;\n const loadedRunTime = Math.round(cycles * loadedRunPerCycle * 10) / 10;\n const unloadTime = Math.round(cycles * unloadPerCycle * 10) / 10;\n const emptyReturnTime = Math.round(cycles * emptyReturnPerCycle * 10) / 10;\n const idleTime = Math.round(cycles * idlePerCycle * 10) / 10;\n\n // 作业时长 = 装载 + 重车运行 + 卸载 + 空车返回\n const workTime = Math.round((loadTime + loadedRunTime + unloadTime + emptyReturnTime) * 10) / 10;\n // 运行时长 = 作业时长 + 怠速时长\n const totalTime = Math.round((workTime + idleTime) * 10) / 10;\n\n records.push({\n label: d,\n totalTime,\n workTime,\n cycles,\n idleTime,\n loadTime,\n unloadTime,\n emptyReturnTime,\n loadedRunTime,\n });\n });\n\n return records;\n }\n\n function formatLabel(d, granularity) {\n if (granularity === 'day') return `${d.getMonth() + 1}/${d.getDate()}`;\n if (granularity === 'month') return `${d.getFullYear()}/${String(d.getMonth() + 1).padStart(2, '0')}`;\n return `${d.getFullYear()}`;\n }\n\n function formatFullLabel(d, granularity) {\n if (granularity === 'day') return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;\n if (granularity === 'month') return `${d.getFullYear()}年${d.getMonth() + 1}月`;\n return `${d.getFullYear()}年`;\n }\n\n // ==================== METRICS ====================\n function renderMetrics(records) {\n if (records.length === 0) {\n dom.metricsRow.innerHTML = Array.from({ length: 8 }, () => `\n <div class=\"metric-card\"><div class=\"card-accent\"></div><div class=\"card-label\">--</div><div class=\"card-value\">0</div></div>`).join('');\n return;\n }\n\n const sums = records.reduce((acc, r) => {\n Object.keys(acc).forEach(k => { acc[k] += r[k] || 0; });\n return acc;\n }, { totalTime: 0, workTime: 0, cycles: 0, idleTime: 0, loadTime: 0, unloadTime: 0, emptyReturnTime: 0, loadedRunTime: 0 });\n\n const cfg = [\n { icon: 'fa-clock', label: '运行时长', value: sums.totalTime.toFixed(1), unit: 'h', color: '#d4891a' },\n { icon: 'fa-gears', label: '作业时长', value: sums.workTime.toFixed(1), unit: 'h', color: '#0d82b8' },\n { icon: 'fa-rotate', label: '循环次数', value: sums.cycles.toString(), unit: '次', color: '#0f766e' },\n { icon: 'fa-pause', label: '怠速时长', value: sums.idleTime.toFixed(1), unit: 'h', color: '#ea570c' },\n { icon: 'fa-arrow-down', label: '装载时长', value: sums.loadTime.toFixed(1), unit: 'h', color: '#7c3aed' },\n { icon: 'fa-arrow-up', label: '卸载时长', value: sums.unloadTime.toFixed(1), unit: 'h', color: '#2563eb' },\n { icon: 'fa-truck-fast', label: '空车返回', value: sums.emptyReturnTime.toFixed(1), unit: 'h', color: '#16a34a' },\n { icon: 'fa-weight-hanging', label: '重车运行', value: sums.loadedRunTime.toFixed(1), unit: 'h', color: '#dc2626' },\n ];\n\n dom.metricsRow.innerHTML = cfg.map(c => `\n <div class=\"metric-card\">\n <div class=\"card-accent\"></div>\n <div class=\"card-icon\"><i class=\"fa-solid ${c.icon}\"></i></div>\n <div class=\"card-label\">${c.label}</div>\n <div class=\"card-value\" style=\"color:${c.color}\">${c.value}</div>\n <div class=\"card-sub\">${c.unit}</div>\n </div>\n `).join('');\n }\n\n // ==================== LINE CHART ====================\n function renderLineChart(canvas, records, granularity) {\n if (!canvas || records.length === 0) return;\n const dpr = window.devicePixelRatio || 1;\n const rect = canvas.parentElement.getBoundingClientRect();\n const w = rect.width;\n const h = rect.height;\n canvas.width = w * dpr;\n canvas.height = h * dpr;\n canvas.style.width = w + 'px';\n canvas.style.height = h + 'px';\n const ctx = canvas.getContext('2d');\n ctx.scale(dpr, dpr);\n ctx.clearRect(0, 0, w, h);\n\n const pad = { top: 10, right: 18, bottom: 28, left: 46 };\n const cw = w - pad.left - pad.right;\n const ch = h - pad.top - pad.bottom;\n\n // 运行时长 and 作业时长 on left Y, 循环次数 on right Y\n let maxTime = 0, maxCycles = 0;\n records.forEach(r => {\n if (r.totalTime > maxTime) maxTime = r.totalTime;\n if (r.workTime > maxTime) maxTime = r.workTime;\n if (r.cycles > maxCycles) maxCycles = r.cycles;\n });\n maxTime = Math.ceil(maxTime * 1.15) || 10;\n maxCycles = Math.ceil(maxCycles * 1.2) || 10;\n\n // Grid - left axis\n const gridLines = 5;\n ctx.strokeStyle = '#eef0f4';\n ctx.lineWidth = 1;\n for (let i = 0; i <= gridLines; i++) {\n const y = pad.top + (ch / gridLines) * i;\n ctx.beginPath();\n ctx.moveTo(pad.left, y);\n ctx.lineTo(w - pad.right, y);\n ctx.stroke();\n ctx.fillStyle = '#94a3b8';\n ctx.font = '9px DM Sans, sans-serif';\n ctx.textAlign = 'right';\n ctx.fillText(Math.round(maxTime - (maxTime / gridLines) * i), pad.left - 6, y + 3);\n }\n\n // Right axis labels\n for (let i = 0; i <= gridLines; i++) {\n const y = pad.top + (ch / gridLines) * i;\n ctx.fillStyle = '#94a3b8';\n ctx.textAlign = 'left';\n ctx.fillText(Math.round(maxCycles - (maxCycles / gridLines) * i), w - pad.right + 6, y + 3);\n }\n\n // X labels\n const xStep = cw / Math.max(records.length - 1, 1);\n const maxLabels = Math.min(records.length, 12);\n const labelStep = Math.max(1, Math.floor(records.length / maxLabels));\n ctx.fillStyle = '#94a3b8';\n ctx.font = '9px DM Sans, sans-serif';\n ctx.textAlign = 'center';\n records.forEach((r, i) => {\n if (i % labelStep === 0 || i === records.length - 1) {\n ctx.fillText(formatLabel(r.label, granularity), pad.left + xStep * i, pad.top + ch + 15);\n }\n });\n\n // Lines\n const lineDefs = [\n { key: 'totalTime', color: '#d4891a', max: maxTime, dash: false },\n { key: 'workTime', color: '#0d82b8', max: maxTime, dash: false },\n ];\n\n lineDefs.forEach(def => {\n ctx.strokeStyle = def.color;\n ctx.lineWidth = 2;\n ctx.lineJoin = 'round';\n ctx.lineCap = 'round';\n if (def.dash) ctx.setLineDash([5, 3]);\n else ctx.setLineDash([]);\n ctx.beginPath();\n records.forEach((r, i) => {\n const x = pad.left + xStep * i;\n const y = pad.top + ch - (r[def.key] / def.max) * ch;\n if (i === 0) ctx.moveTo(x, y);\n else ctx.lineTo(x, y);\n });\n ctx.stroke();\n ctx.setLineDash([]);\n });\n\n // Cycles line (right axis)\n ctx.strokeStyle = '#0f766e';\n ctx.lineWidth = 2;\n ctx.lineJoin = 'round';\n ctx.lineCap = 'round';\n ctx.setLineDash([4, 3]);\n ctx.beginPath();\n records.forEach((r, i) => {\n const x = pad.left + xStep * i;\n const y = pad.top + ch - (r.cycles / maxCycles) * ch;\n if (i === 0) ctx.moveTo(x, y);\n else ctx.lineTo(x, y);\n });\n ctx.stroke();\n ctx.setLineDash([]);\n\n // Dots for time lines only\n [0, 1].forEach(di => {\n const def = lineDefs[di];\n records.forEach((r, i) => {\n const x = pad.left + xStep * i;\n const y = pad.top + ch - (r[def.key] / def.max) * ch;\n ctx.fillStyle = '#ffffff';\n ctx.beginPath();\n ctx.arc(x, y, 3.5, 0, Math.PI * 2);\n ctx.fill();\n ctx.fillStyle = def.color;\n ctx.beginPath();\n ctx.arc(x, y, 2.2, 0, Math.PI * 2);\n ctx.fill();\n });\n });\n }\n\n // ==================== STACKED BAR CHART ====================\n function renderBarChart(canvas, records, granularity) {\n if (!canvas || records.length === 0) return;\n const dpr = window.devicePixelRatio || 1;\n const rect = canvas.parentElement.getBoundingClientRect();\n const w = rect.width;\n const h = rect.height;\n canvas.width = w * dpr;\n canvas.height = h * dpr;\n canvas.style.width = w + 'px';\n canvas.style.height = h + 'px';\n const ctx = canvas.getContext('2d');\n ctx.scale(dpr, dpr);\n ctx.clearRect(0, 0, w, h);\n\n const pad = { top: 10, right: 16, bottom: 28, left: 44 };\n const cw = w - pad.left - pad.right;\n const ch = h - pad.top - pad.bottom;\n\n // Stack order: bottom=装载, then 重车, then 卸载, then 空返, top=怠速\n const datasets = [\n { key: 'loadTime', color: '#ea570c', label: '装载' },\n { key: 'loadedRunTime', color: '#2563eb', label: '重车' },\n { key: 'unloadTime', color: '#7c3aed', label: '卸载' },\n { key: 'emptyReturnTime', color: '#16a34a', label: '空返' },\n { key: 'idleTime', color: '#dc2626', label: '怠速' },\n ];\n\n let maxStack = 0;\n records.forEach(r => {\n const s = datasets.reduce((a, ds) => a + r[ds.key], 0);\n if (s > maxStack) maxStack = s;\n });\n maxStack = Math.ceil(maxStack * 1.18) || 10;\n\n // Grid\n const gridLines = 4;\n ctx.strokeStyle = '#eef0f4';\n ctx.lineWidth = 1;\n for (let i = 0; i <= gridLines; i++) {\n const y = pad.top + (ch / gridLines) * i;\n ctx.beginPath();\n ctx.moveTo(pad.left, y);\n ctx.lineTo(w - pad.right, y);\n ctx.stroke();\n ctx.fillStyle = '#94a3b8';\n ctx.font = '9px DM Sans, sans-serif';\n ctx.textAlign = 'right';\n ctx.fillText(Math.round(maxStack - (maxStack / gridLines) * i), pad.left - 6, y + 3);\n }\n\n const maxBars = Math.min(records.length, 22);\n const step = Math.max(1, Math.floor(records.length / maxBars));\n const displayRecords = records.filter((_, i) => i % step === 0 || i === records.length - 1);\n const barGap = 3;\n const barW = (cw / displayRecords.length) - barGap;\n if (barW <= 0) return;\n\n displayRecords.forEach((r, di) => {\n const x = pad.left + (cw / displayRecords.length) * di + barGap / 2;\n let stackY = pad.top + ch;\n datasets.forEach((ds, dsi) => {\n const val = r[ds.key];\n const barH = (val / maxStack) * ch;\n const y = stackY - barH;\n ctx.fillStyle = ds.color;\n ctx.fillRect(x, y, barW, barH);\n if (dsi > 0 && barH > 2) {\n ctx.fillStyle = 'rgba(255,255,255,0.22)';\n ctx.fillRect(x, y, barW, 0.6);\n }\n stackY = y;\n });\n\n const labelStep2 = Math.max(1, Math.floor(displayRecords.length / 8));\n if (di % labelStep2 === 0 || di === displayRecords.length - 1) {\n ctx.fillStyle = '#94a3b8';\n ctx.font = '9px DM Sans, sans-serif';\n ctx.textAlign = 'center';\n ctx.fillText(formatLabel(r.label, granularity), x + barW / 2, pad.top + ch + 15);\n }\n });\n }\n\n // ==================== DONUT CHART (装载/行驶/卸载 占比) ====================\n function renderDonutChart(canvas, records) {\n if (!canvas || records.length === 0) return;\n const dpr = window.devicePixelRatio || 1;\n const rect = canvas.parentElement.getBoundingClientRect();\n const w = rect.width;\n const h = rect.height;\n canvas.width = w * dpr;\n canvas.height = h * dpr;\n canvas.style.width = w + 'px';\n canvas.style.height = h + 'px';\n const ctx = canvas.getContext('2d');\n ctx.scale(dpr, dpr);\n ctx.clearRect(0, 0, w, h);\n\n // Aggregate\n const sums = { loadTime: 0, haulTime: 0, unloadTime: 0 };\n records.forEach(r => {\n sums.loadTime += r.loadTime;\n sums.haulTime += (r.loadedRunTime + r.emptyReturnTime);\n sums.unloadTime += r.unloadTime;\n });\n const total = sums.loadTime + sums.haulTime + sums.unloadTime;\n\n const segments = [\n { label: '装载', value: sums.loadTime, pct: total > 0 ? (sums.loadTime / total * 100) : 0, color: '#ea570c' },\n { label: '行驶', value: sums.haulTime, pct: total > 0 ? (sums.haulTime / total * 100) : 0, color: '#2563eb' },\n { label: '卸载', value: sums.unloadTime, pct: total > 0 ? (sums.unloadTime / total * 100) : 0, color: '#7c3aed' },\n ];\n\n // Render legend\n dom.ratioLegend.innerHTML = segments.map(s => `\n <div class=\"ratio-legend-item\">\n <div class=\"ratio-legend-dot\" style=\"background:${s.color}\"></div>\n <div>\n <div class=\"ratio-legend-val\">${s.pct.toFixed(1)}%</div>\n <div class=\"ratio-legend-label\">${s.label} ${s.value.toFixed(1)}h</div>\n </div>\n </div>\n `).join('');\n\n // Draw donut\n const cx = w / 2;\n const cy = h / 2;\n const outerR = Math.min(cx, cy) - 6;\n const innerR = outerR * 0.58;\n\n if (total === 0) {\n ctx.fillStyle = '#94a3b8';\n ctx.font = '12px DM Sans, sans-serif';\n ctx.textAlign = 'center';\n ctx.fillText('暂无数据', cx, cy + 4);\n return;\n }\n\n let startAngle = -Math.PI / 2;\n segments.forEach(seg => {\n const sliceAngle = (seg.pct / 100) * Math.PI * 2;\n ctx.beginPath();\n ctx.arc(cx, cy, outerR, startAngle, startAngle + sliceAngle);\n ctx.arc(cx, cy, innerR, startAngle + sliceAngle, startAngle, true);\n ctx.closePath();\n ctx.fillStyle = seg.color;\n ctx.fill();\n startAngle += sliceAngle;\n });\n\n // Center text\n ctx.fillStyle = '#0f172a';\n ctx.font = 'bold 15px DM Sans, sans-serif';\n ctx.textAlign = 'center';\n ctx.fillText(total.toFixed(1) + 'h', cx, cy - 2);\n ctx.fillStyle = '#94a3b8';\n ctx.font = '9px DM Sans, sans-serif';\n ctx.fillText('作业总时长', cx, cy + 13);\n }\n\n // ==================== TABLE ====================\n function renderTable(records, granularity) {\n dom.tableInfo.textContent = `共 ${records.length} 条记录`;\n if (records.length === 0) {\n dom.tableBody.innerHTML = '<tr><td colspan=\"9\" style=\"text-align:center;color:var(--text-muted);padding:16px;\">暂无数据</td></tr>';\n return;\n }\n const display = records.slice(-25);\n dom.tableBody.innerHTML = display.map(r => `\n <tr>\n <td>${formatFullLabel(r.label, granularity)}</td>\n <td class=\"cell-highlight\">${r.totalTime.toFixed(1)}</td>\n <td>${r.workTime.toFixed(1)}</td>\n <td class=\"cell-cycles\">${r.cycles}</td>\n <td>${r.idleTime.toFixed(1)}</td>\n <td>${r.loadTime.toFixed(1)}</td>\n <td>${r.unloadTime.toFixed(1)}</td>\n <td>${r.emptyReturnTime.toFixed(1)}</td>\n <td>${r.loadedRunTime.toFixed(1)}</td>\n </tr>\n `).join('');\n }\n\n // ==================== MAIN ====================\n let currentRecords = [];\n\n function updateDashboard(silent) {\n const records = generateRecords(state.granularity, state.startDate, state.endDate);\n currentRecords = records;\n\n renderMetrics(records);\n renderLineChart(dom.lineChart, records, state.granularity);\n renderBarChart(dom.barChart, records, state.granularity);\n renderDonutChart(dom.donutChart, records);\n renderTable(records, state.granularity);\n\n if (!silent) {\n const granLabel = state.granularity === 'day' ? '日' : state.granularity === 'month' ? '月' : '年';\n showToast(`已加载 ${records.length} 条${granLabel}度统计数据`, 'fa-circle-check');\n }\n }\n\n // ==================== EVENTS ====================\n dom.granularityGroup.addEventListener('click', (e) => {\n const btn = e.target.closest('button');\n if (!btn || btn.classList.contains('active')) return;\n dom.granularityGroup.querySelectorAll('button').forEach(b => b.classList.remove('active'));\n btn.classList.add('active');\n state.granularity = btn.dataset.gran;\n\n const now = new Date();\n if (state.granularity === 'day') {\n state.startDate = new Date(now.getFullYear(), now.getMonth(), 1).toISOString().slice(0, 10);\n state.endDate = now.toISOString().slice(0, 10);\n } else if (state.granularity === 'month') {\n state.startDate = new Date(now.getFullYear() - 1, now.getMonth(), 1).toISOString().slice(0, 10);\n state.endDate = now.toISOString().slice(0, 10);\n } else {\n state.startDate = new Date(now.getFullYear() - 4, 0, 1).toISOString().slice(0, 10);\n state.endDate = now.toISOString().slice(0, 10);\n }\n dom.startDate.value = state.startDate;\n dom.endDate.value = state.endDate;\n updateDashboard();\n });\n\n dom.startDate.addEventListener('change', () => {\n state.startDate = dom.startDate.value;\n updateDashboard();\n });\n\n dom.endDate.addEventListener('change', () => {\n state.endDate = dom.endDate.value;\n updateDashboard();\n });\n\n // ==================== GLOBALS ====================\n window.refreshData = function() {\n state.startDate = dom.startDate.value;\n state.endDate = dom.endDate.value;\n updateDashboard();\n };\n\n window.exportCSV = function() {\n if (currentRecords.length === 0) {\n showToast('无数据可导出', 'fa-triangle-exclamation');\n return;\n }\n let csv = '周期,运行时长(h),作业时长(h),循环次数,怠速时长(h),装载时长(h),卸载时长(h),空车返回(h),重车运行(h),装载占比,行驶占比,卸载占比\\n';\n currentRecords.forEach(r => {\n const haulTime = r.loadedRunTime + r.emptyReturnTime;\n const workTime = r.workTime || 1;\n csv += [\n formatFullLabel(r.label, state.granularity),\n r.totalTime.toFixed(1), r.workTime.toFixed(1), r.cycles,\n r.idleTime.toFixed(1), r.loadTime.toFixed(1), r.unloadTime.toFixed(1),\n r.emptyReturnTime.toFixed(1), r.loadedRunTime.toFixed(1),\n (r.loadTime / workTime * 100).toFixed(1) + '%',\n (haulTime / workTime * 100).toFixed(1) + '%',\n (r.unloadTime / workTime * 100).toFixed(1) + '%',\n ].join(',') + '\\n';\n });\n const blob = new Blob(['\\uFEFF' + csv], { type: 'text/csv;charset=utf-8;' });\n const url = URL.createObjectURL(blob);\n const a = document.createElement('a');\n a.href = url;\n a.download = `矿车运营数据_${state.granularity}_${state.startDate}_${state.endDate}.csv`;\n a.click();\n URL.revokeObjectURL(url);\n showToast('CSV 已下载', 'fa-file-csv');\n };\n\n window.printDashboard = function() {\n showToast('正在准备打印...', 'fa-print');\n setTimeout(() => window.print(), 400);\n };\n\n // ==================== RESIZE ====================\n let resizeTid;\n window.addEventListener('resize', () => {\n clearTimeout(resizeTid);\n resizeTid = setTimeout(() => {\n if (currentRecords.length > 0) {\n renderLineChart(dom.lineChart, currentRecords, state.granularity);\n renderBarChart(dom.barChart, currentRecords, state.granularity);\n renderDonutChart(dom.donutChart, currentRecords);\n }\n }, 250);\n });\n\n // ==================== INIT ====================\n function init() {\n const now = new Date();\n state.startDate = new Date(now.getFullYear(), now.getMonth(), 1).toISOString().slice(0, 10);\n state.endDate = now.toISOString().slice(0, 10);\n dom.startDate.value = state.startDate;\n dom.endDate.value = state.endDate;\n updateDashboard(true);\n }\n\n init();\n})();\n</script>\n\n</body>\n</html>"
},
"next": ["按车辆编号分组统计", "添加设备稼动率指标", "对比多矿区运营效率", "设置异常偏差预警线", "导出PDF运营日报"],
"breakpoint": "none"
}
```

total_tokens
48779
summary
重新设计矿车运营统计界面,修正业务逻辑:作业时长=卸载+装载+空车返回+重车运行,循环=空车+装载+重车运行+卸载。新增装载/行驶/卸载时间占比环形图分析,白底企业级设计,8项指标卡片+折线趋势+堆叠柱状分布+占比环形图+数据明细表。
uiParsing
关闭