feat(energy): improve hydrogen drill workspace and verification cutoff
Co-authored-by: HiFox Agent <agents-noreply@hifox.com>
This commit is contained in:
+12
-14
@@ -1382,7 +1382,7 @@ export const EnergyBiBoardApp: React.FC = () => {
|
||||
const [customerId, setCustomerId] = useState<string | null>(null);
|
||||
const [customerLabel, setCustomerLabel] = useState<string | null>(null);
|
||||
const [liveOverview, setLiveOverview] = useState<any>(null);
|
||||
const [liveVerifiedOverview, setLiveVerifiedOverview] = useState<any>(null);
|
||||
const [livePendingOverview, setLivePendingOverview] = useState<any>(null);
|
||||
const [liveMeta, setLiveMeta] = useState<any>(null);
|
||||
const [liveError, setLiveError] = useState<string | null>(null);
|
||||
const [liveLoading, setLiveLoading] = useState(true);
|
||||
@@ -1417,25 +1417,23 @@ export const EnergyBiBoardApp: React.FC = () => {
|
||||
setLiveError(null);
|
||||
setLiveMeta(null);
|
||||
setLiveOverview(null);
|
||||
setLiveVerifiedOverview(null);
|
||||
setLivePendingOverview(null);
|
||||
const vehicleScope = fleetScope === 'own' ? 'lingniu' : fleetScope;
|
||||
Promise.all([
|
||||
fetchH2BiMeta(),
|
||||
fetchH2BiOverview({ year, vehicleScope, verifyScope, regionGranularity: 'city' }),
|
||||
verifyScope === 'all'
|
||||
? fetchH2BiOverview({ year, vehicleScope, verifyScope: 'verified', regionGranularity: 'city' })
|
||||
: Promise.resolve(null),
|
||||
]).then(([meta, overview, verifiedOverview]) => {
|
||||
fetchH2BiOverview({ year, vehicleScope, verifyScope: 'unverified', regionGranularity: 'city' }),
|
||||
]).then(([meta, overview, pendingOverview]) => {
|
||||
if (!active) return;
|
||||
setLiveMeta(meta);
|
||||
setLiveOverview(overview);
|
||||
setLiveVerifiedOverview(verifiedOverview);
|
||||
setLivePendingOverview(pendingOverview);
|
||||
setLiveLoading(false);
|
||||
}).catch((error) => {
|
||||
if (!active) return;
|
||||
setLiveMeta(null);
|
||||
setLiveOverview(null);
|
||||
setLiveVerifiedOverview(null);
|
||||
setLivePendingOverview(null);
|
||||
setLiveError(error instanceof Error ? error.message : String(error));
|
||||
setLiveLoading(false);
|
||||
});
|
||||
@@ -1577,12 +1575,12 @@ export const EnergyBiBoardApp: React.FC = () => {
|
||||
}, [stationRankOpen]);
|
||||
|
||||
const dims = useMemo(() => costDimCards(rows), [rows]);
|
||||
const risk = liveOverview && liveVerifiedOverview
|
||||
const risk = livePendingOverview
|
||||
? {
|
||||
count: Math.max(0, Number(liveOverview.kpis.recordCount || 0) - Number(liveVerifiedOverview.kpis.recordCount || 0)),
|
||||
amount: Math.max(0, Number(liveOverview.kpis.totalCost || 0) - Number(liveVerifiedOverview.kpis.totalCost || 0)),
|
||||
count: Number(livePendingOverview.kpis.recordCount || 0),
|
||||
amount: Number(livePendingOverview.kpis.totalCost || 0),
|
||||
}
|
||||
: unverified(rows);
|
||||
: { count: 0, amount: 0 };
|
||||
const unitProfitYuan = hostKpi.totalKgT > 0
|
||||
? ((hostKpi.profitWan * 10000) / (hostKpi.totalKgT * 1000)).toFixed(2)
|
||||
: '—';
|
||||
@@ -2218,7 +2216,7 @@ export const EnergyBiBoardApp: React.FC = () => {
|
||||
<button type="button" className="ehb-diagnosis__item is-action" onClick={() => setKpiDrillType('待核对订单')} title="查看待核对订单">
|
||||
<span>待核对订单</span>
|
||||
<strong className={risk.count > 0 ? 'is-warning' : ''}>{risk.count}笔 · ¥{unverifiedWan}万</strong>
|
||||
<small>查看待核对订单</small>
|
||||
<small>核对上线期初:2026-05-01(含)· 查看待核对订单</small>
|
||||
</button>
|
||||
</section>
|
||||
</div>
|
||||
@@ -2237,7 +2235,7 @@ export const EnergyBiBoardApp: React.FC = () => {
|
||||
<div><span>月度环比</span><strong className={liveMonthComparison && liveMonthComparison.value < 0 ? 'is-warning' : 'is-positive'}>{liveMonthComparison ? `${liveMonthComparison.value >= 0 ? '+' : ''}${liveMonthComparison.value.toFixed(1)}%` : '—'}</strong><small>{liveMonthComparison?.label ?? '暂无可比月份'}</small></div>
|
||||
<div><span>单公斤毛利</span><strong>¥{unitProfitYuan}<small>/kg</small></strong><small>按累计加氢量计算</small></div>
|
||||
<button type="button" className="ehb-mobile-diagnosis-action" onClick={() => setKpiDrillType('加氢站加氢量排名')}><span>头部站点占比</span><strong>{top5SharePct}%</strong><small>前5站占总量</small></button>
|
||||
<button type="button" className="ehb-mobile-diagnosis-action" onClick={() => setKpiDrillType('待核对订单')}><span>待核对订单</span><strong className={risk.count > 0 ? 'is-warning' : ''}>{risk.count}笔</strong><small>¥{unverifiedWan}万</small></button>
|
||||
<button type="button" className="ehb-mobile-diagnosis-action" onClick={() => setKpiDrillType('待核对订单')}><span>待核对订单</span><strong className={risk.count > 0 ? 'is-warning' : ''}>{risk.count}笔</strong><small>¥{unverifiedWan}万 · 上线期初 2026-05-01(含)</small></button>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
|
||||
+14
-29
@@ -88,18 +88,6 @@ function StationTrend({ vols }: { vols: StationDailyVolumeRow[] }) {
|
||||
);
|
||||
}
|
||||
|
||||
function StationFilter({ value, rows, onChange }: { value: string; rows: StationOverview[]; onChange: (value: string) => void }) {
|
||||
return (
|
||||
<select className="sd-station-filter-select" value={value} onChange={(e) => onChange(e.target.value)} aria-label="选择当前站点">
|
||||
{rows.map((row) => (
|
||||
<option key={row.id} value={row.id}>
|
||||
{row.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
);
|
||||
}
|
||||
|
||||
function localIsoDate(date: Date) {
|
||||
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
|
||||
}
|
||||
@@ -144,11 +132,10 @@ export const StationDailyApp: React.FC<StationDailyAppProps> = ({
|
||||
const [updatedAt, setUpdatedAt] = useState('2026-08-12 10:00');
|
||||
const [tick, setTick] = useState(0);
|
||||
const [kpiDrill, setKpiDrill] = useState<KpiDrill>(null);
|
||||
const [stationFilter, setStationFilter] = useState('');
|
||||
const [liveBoard, setLiveBoard] = useState<HydrogenStationBoardResponse | null>(null);
|
||||
const [liveError, setLiveError] = useState<string | null>(null);
|
||||
const [liveLoading, setLiveLoading] = useState(true);
|
||||
const [stationCashBoard, setStationCashBoard] = useState<HydrogenStationBoardResponse | null>(null);
|
||||
const [stationCashBoard, setStationCashBoard] = useState<HydrogenStationBoardResponse[] | null>(null);
|
||||
const [stationCashError, setStationCashError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -213,26 +200,21 @@ export const StationDailyApp: React.FC<StationDailyAppProps> = ({
|
||||
.sort((a, b) => b.rangeKg - a.rangeKg || a.name.localeCompare(b.name, 'zh-CN'));
|
||||
}, [liveBoard, endDate]);
|
||||
|
||||
// 单站入口只保留一条真实站点记录。首次拿到真实列表时按服务端排序后的首站默认选中。
|
||||
const selectedStationId = overviewRows.some((row) => row.id === stationFilter)
|
||||
? stationFilter
|
||||
: (overviewRows[0]?.id ?? '');
|
||||
const boardRows = selectedStationId ? overviewRows.filter((row) => row.id === selectedStationId) : [];
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedStationId && selectedStationId !== stationFilter) setStationFilter(selectedStationId);
|
||||
}, [selectedStationId, stationFilter]);
|
||||
// 自营站列表完整展示,点击其中一站再进入单站详情。
|
||||
const boardRows = overviewRows;
|
||||
const stationIdsKey = overviewRows.map((row) => row.id).sort().join(',');
|
||||
|
||||
// 总览请求的 summary.daily 是全站口径;单站现结日表必须另以真实 stationId 查询,不能按比例拆分。
|
||||
useEffect(() => {
|
||||
if (!selectedStationId) {
|
||||
if (!stationIdsKey) {
|
||||
setStationCashBoard(null);
|
||||
return;
|
||||
}
|
||||
let active = true;
|
||||
setStationCashBoard(null);
|
||||
setStationCashError(null);
|
||||
fetchHydrogenStationBoard({ startDate, endDate, stationId: Number(selectedStationId), force: tick > 0 })
|
||||
Promise.all(stationIdsKey.split(',').map((id) =>
|
||||
fetchHydrogenStationBoard({ startDate, endDate, stationId: Number(id), force: tick > 0 })))
|
||||
.then((result) => {
|
||||
if (active) setStationCashBoard(result);
|
||||
})
|
||||
@@ -240,7 +222,7 @@ export const StationDailyApp: React.FC<StationDailyAppProps> = ({
|
||||
if (active) setStationCashError(reason instanceof Error ? reason.message : '当前站点现结流水加载失败');
|
||||
});
|
||||
return () => { active = false; };
|
||||
}, [selectedStationId, startDate, endDate, tick]);
|
||||
}, [stationIdsKey, startDate, endDate, tick]);
|
||||
|
||||
const totals = useMemo(() => {
|
||||
return {
|
||||
@@ -266,8 +248,11 @@ export const StationDailyApp: React.FC<StationDailyAppProps> = ({
|
||||
|
||||
/** 当前选中站点的区间日现结;接口成功后才把无进账日期显式为 0。 */
|
||||
const cashDaily = useMemo(() => {
|
||||
if (!stationCashBoard?.selected) return null;
|
||||
const map = new Map(stationCashBoard.selected.daily.map((row) => [row.date, row.paymentAmount]));
|
||||
if (!stationCashBoard || stationCashBoard.some((board) => !board.selected)) return null;
|
||||
const map = new Map<string, number>();
|
||||
for (const board of stationCashBoard) {
|
||||
for (const row of board.selected!.daily) map.set(row.date, (map.get(row.date) ?? 0) + row.paymentAmount);
|
||||
}
|
||||
return calendarDays(startDate, endDate).map((date) => ({ date, amount: map.get(date) || 0 }));
|
||||
}, [stationCashBoard, startDate, endDate]);
|
||||
|
||||
@@ -413,7 +398,7 @@ export const StationDailyApp: React.FC<StationDailyAppProps> = ({
|
||||
<span className="sd-station-board__fullscreen">
|
||||
<MobileListFullscreenButton label="横屏全屏查看站点经营概况" />
|
||||
</span>
|
||||
<StationFilter value={stationFilter} rows={overviewRows} onChange={setStationFilter} />
|
||||
<span className="sd-panel__meta">全部自营站 · {boardRows.length} 站</span>
|
||||
</div>
|
||||
|
||||
<div className="sd-station-single-card">
|
||||
|
||||
Reference in New Issue
Block a user