feat(testing): 增加质检报告独立编辑与详情页面,不再使用弹窗
这个提交包含在:
@@ -1,3 +1,4 @@
|
||||
import { fetchSiteData, showSiteDataState } from './site_data.js?v=20261028_demo3';
|
||||
import {
|
||||
calcScreenScale,
|
||||
normalizeGranaryList,
|
||||
@@ -17,7 +18,7 @@ import {
|
||||
getGranaryQualityReport,
|
||||
generateDepotAlerts,
|
||||
syncAlertMarqueeSpeed
|
||||
} from './grain_monitor_core.js?v=20261028_chart3';
|
||||
} from './grain_monitor_core.js?v=20261028_demo3';
|
||||
|
||||
// 全局状态
|
||||
const STATE = {
|
||||
@@ -86,37 +87,18 @@ function updateClock() {
|
||||
}
|
||||
|
||||
// 3. 加载习水子库标准数据集
|
||||
function loadGranaryData() {
|
||||
STATE.list = normalizeGranaryList(XISHUI_GRANARY_DATA);
|
||||
|
||||
// 尝试连接后台接口同步最新配置
|
||||
if (typeof fetch !== 'undefined') {
|
||||
const urls = [
|
||||
'/api/index/granaryList?site=xishui',
|
||||
'https://grain.gynhc.com/api/index/granaryList?site=xishui',
|
||||
'/api/granary/list?site=xishui'
|
||||
];
|
||||
(async () => {
|
||||
for (const u of urls) {
|
||||
try {
|
||||
const res = await fetch(u, { cache: 'no-cache', signal: AbortSignal.timeout(2000) });
|
||||
if (!res.ok) continue;
|
||||
const json = await res.json();
|
||||
if (json && json.data && Array.isArray(json.data.list) && json.data.list.length > 0) {
|
||||
STATE.list = normalizeGranaryList(json);
|
||||
if (json.data.coords) {
|
||||
STATE.customCoords = json.data.coords;
|
||||
}
|
||||
renderKPIs();
|
||||
renderHotspots();
|
||||
renderMiniGrid();
|
||||
renderDetailPanels();
|
||||
renderDepotAlerts();
|
||||
return;
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
})();
|
||||
async function loadGranaryData() {
|
||||
try {
|
||||
const data = await fetchSiteData('xishui');
|
||||
STATE.list = normalizeGranaryList({ data });
|
||||
STATE.customCoords = data.coords || {};
|
||||
STATE.activeId = STATE.list.some(item => item.id === STATE.activeId) ? STATE.activeId : (STATE.list[0]?.id || null);
|
||||
showSiteDataState('xishui', STATE.list.length ? 'live' : 'empty', STATE.list.length, STATE.list.some(item => item.isDemo));
|
||||
} catch (_) {
|
||||
STATE.list = [];
|
||||
STATE.customCoords = {};
|
||||
STATE.activeId = null;
|
||||
showSiteDataState('xishui', 'unavailable', 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -395,8 +377,8 @@ function renderLeftPanel(item, params) {
|
||||
document.getElementById('param-granary-type').textContent = b.warehouseType;
|
||||
document.getElementById('param-granary-variety').textContent = b.varieties;
|
||||
document.getElementById('param-granary-nature').textContent = b.natureName;
|
||||
document.getElementById('param-granary-addr').textContent = b.addr || '河南/湖北';
|
||||
document.getElementById('param-granary-year').textContent = b.harvestYear || '2023';
|
||||
document.getElementById('param-granary-addr').textContent = item.isOilTank ? b.productArea : b.addr;
|
||||
document.getElementById('param-granary-year').textContent = item.isOilTank ? b.machiningYear : b.harvestYear;
|
||||
document.getElementById('param-granary-enter').textContent = b.enterTime || '2023-08';
|
||||
document.getElementById('param-granary-custodian').textContent = b.custodian || '张卫国';
|
||||
document.getElementById('param-granary-mgmt').textContent = b.managementForm || '直接管理';
|
||||
@@ -500,20 +482,26 @@ function renderRightPanel(item, params) {
|
||||
// 标题与总体状态指示徽章 (短小精悍,杜绝截断)
|
||||
if (qualityTitle) {
|
||||
let statusBadge = '';
|
||||
if (report.summary.dangerCount > 0) {
|
||||
if (report.empty) {
|
||||
statusBadge = '<span class="quality-badge status-unknown" style="margin-left: 5px;">暂无数据</span>';
|
||||
} else if (report.summary.dangerCount > 0) {
|
||||
statusBadge = `<span class="quality-badge status-danger" style="margin-left: 5px;">⚠️ ${report.summary.dangerCount}项超标</span>`;
|
||||
} else if (report.summary.warnCount > 0) {
|
||||
statusBadge = `<span class="quality-badge status-warn" style="margin-left: 5px;">⚠️ ${report.summary.warnCount}项预警</span>`;
|
||||
} else {
|
||||
} else if (!report.summary.unknownCount) {
|
||||
statusBadge = `<span class="quality-badge status-normal" style="margin-left: 5px;">✓ 健康达标</span>`;
|
||||
}
|
||||
if (report.summary.unknownCount > 0) {
|
||||
statusBadge += `<span class="quality-badge status-unknown" style="margin-left: 5px;">${report.summary.unknownCount}项待核实</span>`;
|
||||
}
|
||||
qualityTitle.innerHTML = `<span>${report.variety}品质全参数舱</span>${statusBadge}`;
|
||||
}
|
||||
|
||||
// 标题栏右侧显示批次阶段与检验日期 (精炼格式)
|
||||
if (qualityExtra) {
|
||||
const stageShort = (report.inspectStage || '').split('/')[0].trim();
|
||||
qualityExtra.innerHTML = `<span style="font-size: 9px; color: var(--text-sub); white-space: nowrap;">${stageShort} · ${report.inspectDate}</span>`;
|
||||
if (report.empty) qualityExtra.textContent = stageShort;
|
||||
if (!report.empty) qualityExtra.innerHTML = `<span style="font-size: 9px; color: var(--text-sub); white-space: nowrap;">${stageShort} · ${report.inspectDate}</span>`;
|
||||
}
|
||||
|
||||
// 渲染方案A专属品质全参数舱 (全量水平条形卡片 + 分类Tab)
|
||||
@@ -560,6 +548,27 @@ async function initOrUpdateForecastCharts(granaryItem) {
|
||||
STATE.charts.forecastCompare = echarts.init(compareDom);
|
||||
}
|
||||
|
||||
const currentReport = getGranaryQualityReport(grainName, currentItem.rawContent || currentItem.content || {}, currentItem.qualityTest, { requireRecordedData: true });
|
||||
for (const id of ['btn-forecast-recalc', 'btn-forecast-reset']) {
|
||||
const button = document.getElementById(id);
|
||||
if (button) {
|
||||
button.disabled = currentReport.empty;
|
||||
button.title = currentReport.empty ? '请先录入本仓化验数据' : '';
|
||||
}
|
||||
}
|
||||
if (currentReport.empty) {
|
||||
const emptyOption = {
|
||||
title: { text: '暂无化验数据\n录入本仓实测数据后可查看质量预测', left: 'center', top: '40%',
|
||||
textStyle: { color: '#94a3b8', fontSize: 13, lineHeight: 24 } }
|
||||
};
|
||||
STATE.charts.forecastTrend.setOption(emptyOption, true);
|
||||
STATE.charts.forecastCompare.setOption(emptyOption, true);
|
||||
if (trendTitleEl) trendTitleEl.textContent = `${currentItem.name} · 暂无实测数据`;
|
||||
if (compareTitleEl) compareTitleEl.textContent = '待录入化验记录';
|
||||
delete STATE.forecastCache[currentItem.id];
|
||||
return;
|
||||
}
|
||||
|
||||
if (!grainType) {
|
||||
const emptyOption = {
|
||||
title: {
|
||||
@@ -607,7 +616,7 @@ async function initOrUpdateForecastCharts(granaryItem) {
|
||||
|
||||
setupForecastEnvControls();
|
||||
|
||||
const currentReport = getGranaryQualityReport(grainName, currentItem.rawContent || currentItem.content || {}, currentItem.qualityTest);
|
||||
|
||||
|
||||
// 1. 0 毫秒即时秒出基础图表 (杜绝任何白屏与残亮点)
|
||||
const baselineList = [
|
||||
@@ -648,6 +657,9 @@ async function initOrUpdateForecastCharts(granaryItem) {
|
||||
key: m.key,
|
||||
name: m.name,
|
||||
unit: m.unit,
|
||||
warn: m.warn,
|
||||
alert: m.alert,
|
||||
direction: m.direction,
|
||||
predictedValue: m.values[3] !== undefined ? m.values[3] : m.values[m.values.length - 1]
|
||||
}));
|
||||
const initialCompareOption = buildForecastCompareChartOption(grainType, currentReport?.items || [], initialFuture30);
|
||||
@@ -684,6 +696,9 @@ async function initOrUpdateForecastCharts(granaryItem) {
|
||||
key: m.key,
|
||||
name: m.name,
|
||||
unit: m.unit,
|
||||
warn: m.warn,
|
||||
alert: m.alert,
|
||||
direction: m.direction,
|
||||
predictedValue: m.values[3] !== undefined ? m.values[3] : m.values[m.values.length - 1]
|
||||
}));
|
||||
|
||||
@@ -847,7 +862,7 @@ function initOrUpdateGranaryBar() {
|
||||
|
||||
const names = STATE.list.map(i => i.name.replace('号浅圆仓', '#圆').replace('号仓房', '#平'));
|
||||
const storageData = STATE.list.map(i => i.storageNum);
|
||||
const capacityData = STATE.list.map(i => i.capacity);
|
||||
const capacityData = STATE.list.map(i => i.capacityNum);
|
||||
|
||||
const option = {
|
||||
tooltip: {
|
||||
@@ -992,14 +1007,14 @@ function toggleFullscreen() {
|
||||
}
|
||||
|
||||
// 初始化入口
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
window.addEventListener('DOMContentLoaded', async () => {
|
||||
resizeScreen();
|
||||
window.addEventListener('resize', resizeScreen);
|
||||
|
||||
updateClock();
|
||||
setInterval(updateClock, 1000);
|
||||
|
||||
loadGranaryData();
|
||||
await loadGranaryData();
|
||||
loadEnvData();
|
||||
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
@@ -1020,15 +1035,20 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||
renderDepotAlerts();
|
||||
|
||||
// 电视大屏 60 秒自动静默轮询同步最新台账与微气候
|
||||
setInterval(() => {
|
||||
setInterval(async () => {
|
||||
try {
|
||||
loadGranaryData();
|
||||
await loadGranaryData();
|
||||
loadEnvData();
|
||||
renderKPIs();
|
||||
renderHotspots();
|
||||
renderMiniGrid();
|
||||
renderDetailPanels();
|
||||
renderDepotAlerts();
|
||||
} catch (_) {}
|
||||
}, 60000);
|
||||
|
||||
setupAutoPlay();
|
||||
if (urlParams.get('view') === 'forecast') selectGranary(STATE.activeId, true);
|
||||
|
||||
const fsBtn = document.getElementById('btn-fullscreen');
|
||||
if (fsBtn) fsBtn.addEventListener('click', toggleFullscreen);
|
||||
@@ -1044,6 +1064,11 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
|
||||
window.addEventListener('keydown', (e) => {
|
||||
if (e.target?.closest?.('input, textarea, select, [contenteditable="true"]')) return;
|
||||
if (e.key === 'Escape' && STATE.isCenterChartOpen) {
|
||||
toggleCenterChartBoard(STATE.centerChartTab, false);
|
||||
return;
|
||||
}
|
||||
const curIdx = STATE.list.findIndex(w => w.id === STATE.activeId);
|
||||
if (e.key === 'ArrowLeft' || e.key === 'ArrowUp') {
|
||||
const nextIdx = (curIdx - 1 + STATE.list.length) % STATE.list.length;
|
||||
|
||||
在新工单中引用
屏蔽一个用户