feat: 大屏多订单改为同屏并列展示,物料申请新增跨工位借料来源并移除工单完成日期

This commit is contained in:
SunYF
2026-11-02 19:17:05 +08:00
parent 0c03d32682
commit fd2f0e2767
77 changed files with 1773 additions and 664 deletions
@@ -1,4 +1,4 @@
import { useEffect, useMemo, useState } from 'react';
import { useMemo } from 'react';
import type { EChartsOption } from 'echarts';
import type { DashboardData, ProductionProgress } from '../types';
import { EChart } from '../components/EChart';
@@ -12,10 +12,10 @@ const C = {
dim: '#64748b',
};
/** 轮播间隔(毫秒):多订单时逐单展示 */
const ROTATE_MS = 10000;
/** 同屏最多展示的订单数(多订单混生产:并列展示,不再轮播;超出部分折叠为 +N) */
const MAX_VISIBLE = 4;
/** 单张订单卡(左块):合同/工期/完成度 */
/** 单张订单卡(单订单时占满左块):合同/工期/完成度 */
function OrderCard({ order }: { order: ProductionProgress }) {
return (
<div style={{ flex: '1 1 46%', minWidth: 0, display: 'flex', flexDirection: 'column', gap: 'clamp(4px, 0.7vh, 9px)' }}>
@@ -63,28 +63,67 @@ function OrderCard({ order }: { order: ProductionProgress }) {
);
}
/** 底部左块 · 当前订单(多订单自动轮播)+ 近 7 日产量趋势 */
/** 紧凑订单行(多订单并列展示):一行一单,共享左块高度 */
function MiniOrderCard({ order }: { order: ProductionProgress }) {
return (
<div
style={{
flex: 1,
minHeight: 0,
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
gap: 2,
padding: 'clamp(2px, 0.5vh, 8px) clamp(6px, 0.6vw, 14px)',
background: 'rgba(22, 35, 58, 0.45)',
borderRadius: 8,
border: '1px solid rgba(56, 189, 248, 0.12)',
}}
>
<div style={{ display: 'flex', alignItems: 'baseline', gap: 'clamp(6px, 0.6vw, 18px)', minWidth: 0 }}>
<span style={{ fontSize: 'clamp(12px, 0.95vw, 36px)', fontWeight: 600, color: '#eaf6ff', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>
{order.contractNo || order.orderNo || '—'}
</span>
<span style={{ fontSize: 'clamp(9px, 0.72vw, 26px)', color: C.sub, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>
{order.productName || '—'}
</span>
<span style={{ marginLeft: 'auto', fontSize: 'clamp(9px, 0.72vw, 26px)', color: order.remainDays >= 0 ? C.green : '#fbbf24', whiteSpace: 'nowrap' }}>
剩余 {order.planEnd ? Math.max(order.remainDays, 0) : '—'} 天
</span>
</div>
<div style={{ display: 'flex', alignItems: 'center', gap: 'clamp(6px, 0.6vw, 16px)', minWidth: 0 }}>
<span style={{ fontSize: 'clamp(9px, 0.72vw, 26px)', color: C.sub, whiteSpace: 'nowrap', fontVariantNumeric: 'tabular-nums' }}>
{dash0(order.doneQty)}/{dash0(order.totalQty)} 台
</span>
<div style={{ flex: 1, height: 'clamp(4px, 0.6vh, 8px)', background: '#0f1b30', borderRadius: 4, overflow: 'hidden' }}>
<div
style={{
width: `${Math.max(0, Math.min(100, order.progress))}%`,
height: '100%',
background: 'linear-gradient(90deg, #0ea5e9, #22d3ee)',
transition: 'width 0.6s ease',
}}
/>
</div>
<span style={{ fontSize: 'clamp(9px, 0.72vw, 26px)', color: C.cyan, whiteSpace: 'nowrap' }}>{Math.round(order.progress)}%</span>
</div>
</div>
);
}
/** 底部左块 · 当前订单(多订单同屏并列展示)+ 近 7 日产量趋势 */
export function ProductionBoard({ data }: { data: DashboardData }) {
const { trends } = data;
// 多订单轮播:progressList 优先(后端下发,进行中排前),未升级时退回单条 progress
// 多订单同屏:progressList 优先(后端下发,进行中排前),未升级时退回单条 progress
const orders = useMemo<ProductionProgress[]>(() => {
const list = (data.progressList || []).filter((o) => o && (o.orderNo || o.contractNo));
if (list.length > 0) return list;
return data.progress ? [data.progress] : [];
}, [data.progressList, data.progress]);
const [idx, setIdx] = useState(0);
useEffect(() => {
setIdx(0);
}, [orders.length]);
useEffect(() => {
if (orders.length <= 1) return;
const t = setInterval(() => setIdx((i) => (i + 1) % orders.length), ROTATE_MS);
return () => clearInterval(t);
}, [orders.length]);
const current = orders[Math.min(idx, orders.length - 1)];
const visible = useMemo(() => orders.slice(0, MAX_VISIBLE), [orders]);
const hiddenCount = orders.length - visible.length;
const trendOption: EChartsOption = {
grid: { left: 8, right: 12, top: 14, bottom: 4, containLabel: true },
@@ -120,16 +159,20 @@ export function ProductionBoard({ data }: { data: DashboardData }) {
<div className="panel">
<div className="panel-head">
当前订单
<span className="note">合同 · 工期 · 完成度</span>
{orders.length > 1 && (
<span style={{ marginLeft: 'auto', fontSize: 'clamp(9px, 0.7vw, 26px)', color: C.dim }}>
{idx + 1}/{orders.length}
</span>
<span className="note">{orders.length > 1 ? '多单并行 · 合同 · 工期 · 完成度' : '合同 · 工期 · 完成度'}</span>
{hiddenCount > 0 && (
<span style={{ marginLeft: 'auto', fontSize: 'clamp(9px, 0.7vw, 26px)', color: C.dim }}>+{hiddenCount} 单未展示</span>
)}
</div>
<div className="panel-body" style={{ flexDirection: 'row', gap: 'clamp(8px, 0.9vw, 40px)' }}>
{/* 左:订单信息(多订单轮播,无鼠标大屏 10s 自动切换) */}
{current && <OrderCard key={current.orderNo} order={current} />}
{/* 左:订单信息(多订单同屏并列,进行中排前;单订单保持原大卡) */}
<div style={{ flex: '1 1 46%', minWidth: 0, display: 'flex', flexDirection: 'column', gap: 'clamp(4px, 0.7vh, 9px)' }}>
{visible.length === 1 && visible[0] ? (
<OrderCard order={visible[0]} />
) : (
visible.map((o) => <MiniOrderCard key={o.orderNo || o.contractNo} order={o} />)
)}
</div>
{/* 右:近 7 日产量趋势(height:100% 跟随容器) */}
<div style={{ flex: '1 1 54%', minWidth: 0, display: 'flex', flexDirection: 'column' }}>