新增 ErrorListDialog 组件用于统一展示结构化校验错误信息,实现报错一次收全;新增工位报警语音播报功能,通过浏览器 SpeechSynthesis 播放本工位相关报警;调整物料类别及序列号字段文案,移除「其他」类别;新增工单实际开始字段及采集方式配置;优化 AGV 及 PlcSend 页签刷新逻辑;新增看板物料追溯及工位报警接口;删除 PLC 强制写 M 位及相关测试代码;同步数据库字段注释及补丁。
111 lines
3.4 KiB
TypeScript
111 lines
3.4 KiB
TypeScript
import { Card, Table, Tag, Typography } from '@douyinfe/semi-ui';
|
|
import type { DashboardData } from '../types';
|
|
|
|
interface MovementRow {
|
|
id: string;
|
|
time: string;
|
|
dir: string;
|
|
material: string;
|
|
qty: string;
|
|
operator: string;
|
|
batch: string;
|
|
}
|
|
|
|
export function WarehouseBoard({ data }: { data: DashboardData }) {
|
|
const { warehouse: w } = data;
|
|
const rows: MovementRow[] = w.movements.map((m) => ({
|
|
id: m.id,
|
|
time: m.time,
|
|
dir: m.type === 'in' ? '入库' : '出库',
|
|
material: m.material,
|
|
qty: `${m.qty}`,
|
|
operator: m.operator,
|
|
batch: m.batch || '—',
|
|
}));
|
|
|
|
const locationPct =
|
|
w.locationTotal > 0 ? `${Math.round((w.locationUsed / w.locationTotal) * 100)}%` : '—';
|
|
|
|
const columns = [
|
|
{ title: '时间', dataIndex: 'time' },
|
|
{
|
|
title: '方向',
|
|
dataIndex: 'dir',
|
|
render: (dir: string) => (
|
|
<Tag color={dir === '入库' ? 'green' : 'blue'}>{dir}</Tag>
|
|
),
|
|
},
|
|
{ title: '物料名称', dataIndex: 'material' },
|
|
{ title: '数量', dataIndex: 'qty' },
|
|
{ title: '批次', dataIndex: 'batch', width: 140 },
|
|
{ title: '操作人', dataIndex: 'operator' },
|
|
];
|
|
|
|
return (
|
|
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 16 }}>
|
|
<div style={{ gridColumn: 'span 4', display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 14 }}>
|
|
<Card title="库存总量">
|
|
<BigNumber value={w.totalStock} unit="件" color="#36a3f7" />
|
|
</Card>
|
|
<Card title="物料种类">
|
|
<BigNumber value={w.materialTypes} unit="种" color="#00d68f" />
|
|
</Card>
|
|
<Card title="当日出入库">
|
|
<div style={{ display: 'flex', gap: 24 }}>
|
|
<TextStat color="#00d68f" value={w.inboundToday} label="入库" />
|
|
<TextStat color="#36a3f7" value={w.outboundToday} label="出库" />
|
|
</div>
|
|
</Card>
|
|
<Card title="库位利用率">
|
|
<BigNumber value={locationPct} unit="" color="#fbbf24" />
|
|
<div style={{ color: '#8fa3bf', fontSize: 12, marginTop: 4 }}>
|
|
已用 {w.locationUsed} / 共 {w.locationTotal}
|
|
</div>
|
|
</Card>
|
|
</div>
|
|
|
|
<Card title="待处理出入库任务" style={{ gridColumn: 'span 4' }}>
|
|
<div style={{ display: 'flex', gap: 32 }}>
|
|
<TextStat color="#fbbf24" value={w.pendingInbound} label="入库待检(检未闭环)" />
|
|
<TextStat color="#36a3f7" value={w.pendingOutbound} label="出库待送(已出库)" />
|
|
</div>
|
|
</Card>
|
|
|
|
<Card title="出入库动态(实时)" style={{ gridColumn: 'span 4' }}>
|
|
<Table
|
|
columns={columns}
|
|
dataSource={rows}
|
|
pagination={false}
|
|
rowKey="id"
|
|
empty={<Typography.Text type="tertiary">暂无出入库记录</Typography.Text>}
|
|
/>
|
|
</Card>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function TextStat({ value, label, color }: { value: number; label: string; color: string }) {
|
|
return (
|
|
<div>
|
|
<div style={{ fontSize: 28, fontWeight: 600, color }}>{value}</div>
|
|
<div style={{ color: '#8fa3bf', fontSize: 13 }}>{label}</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function BigNumber({
|
|
value,
|
|
unit,
|
|
color,
|
|
}: {
|
|
value: number | string;
|
|
unit: string;
|
|
color: string;
|
|
}) {
|
|
return (
|
|
<div style={{ display: 'flex', alignItems: 'baseline', gap: 6 }}>
|
|
<span style={{ fontSize: 36, fontWeight: 700, color }}>{value}</span>
|
|
<span style={{ color: '#8fa3bf' }}>{unit}</span>
|
|
</div>
|
|
);
|
|
} |