新增模块
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
import { useMemo } from 'react';
|
||||
import { Package } from 'lucide-react';
|
||||
import { useTheme, type ThemeTokens } from '../../context/ThemeContext';
|
||||
import { salesOrders, type SalesOrder } from '../../data/ibp';
|
||||
import { ScrollList } from '../supply/PurchaseOrderList';
|
||||
import { money } from '../../lib/money';
|
||||
|
||||
/**
|
||||
* 销售订单页签内容:Excel「销售订单」全量卡片列表。
|
||||
* 列表口径交给纯函数,DemandPanel 用同一函数算页签徽标数,标题数字与条数不会各说各话。
|
||||
*/
|
||||
|
||||
/** 订单号 / 客户简称 / 客户编码 / 产品编码 四向模糊匹配 */
|
||||
export function filterSalesOrders(rows: SalesOrder[], query: string): SalesOrder[] {
|
||||
const q = query.trim().toLowerCase();
|
||||
if (!q) return rows;
|
||||
return rows.filter((s: SalesOrder) =>
|
||||
s.销售订单号.toLowerCase().includes(q)
|
||||
|| s.客户简称.toLowerCase().includes(q)
|
||||
|| s.客户编码.toLowerCase().includes(q)
|
||||
|| s.产品编码.toLowerCase().includes(q));
|
||||
}
|
||||
|
||||
const statusColor = (s: string, tk: ThemeTokens) =>
|
||||
s === '生效' || s === '已下达' ? { c: tk.success, bg: tk.successBg } : { c: tk.warning, bg: tk.warningBg };
|
||||
|
||||
interface Props {
|
||||
query: string;
|
||||
expanded: boolean;
|
||||
/** 当前选中的销售订单号(联动右侧采购单 / 生产工单 / 供应商与本页客户资料过滤) */
|
||||
selectedSO: string | null;
|
||||
onSelectSO: (so: string | null) => void;
|
||||
}
|
||||
|
||||
export default function SalesOrderList({ query, expanded, selectedSO, onSelectSO }: Props) {
|
||||
const { tokens } = useTheme();
|
||||
|
||||
const list = useMemo(() => filterSalesOrders(salesOrders, query), [query]);
|
||||
const total = useMemo(() => list.reduce((a, s) => a + s.含税金额, 0), [list]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* 汇总条 */}
|
||||
<div style={{
|
||||
display: 'flex', justifyContent: 'space-between', alignItems: 'center', flex: '0 0 auto',
|
||||
padding: '6px 10px', marginBottom: 10, borderRadius: 8, fontSize: 12,
|
||||
background: tokens.kpiCardBg, border: `1px solid ${tokens.border}`, color: tokens.textSub,
|
||||
}}>
|
||||
<span>{list.length} 张订单 · {new Set(list.map(s => s.客户编码)).size} 家客户</span>
|
||||
<span style={{ color: tokens.accent, fontWeight: 700, fontVariantNumeric: 'tabular-nums' }}>{money(total)}</span>
|
||||
</div>
|
||||
|
||||
<ScrollList>
|
||||
{list.length === 0 && (
|
||||
<div style={{ padding: '20px 0', textAlign: 'center', fontSize: 13, color: tokens.textMuted }}>无匹配订单</div>
|
||||
)}
|
||||
{list.map(s => {
|
||||
const active = selectedSO === s.销售订单号;
|
||||
const sc = statusColor(s.单据状态, tokens);
|
||||
return (
|
||||
<div
|
||||
key={s.销售订单号}
|
||||
onClick={() => onSelectSO(active ? null : s.销售订单号)}
|
||||
style={{
|
||||
position: 'relative', marginBottom: 8, padding: '9px 11px', borderRadius: 9, cursor: 'pointer',
|
||||
background: active ? tokens.accentBg : tokens.panelBgAlt,
|
||||
border: `1px solid ${active ? tokens.accent : tokens.border}`,
|
||||
transition: 'background .15s, border-color .15s',
|
||||
}}
|
||||
>
|
||||
{active && <span style={{ position: 'absolute', left: -1, top: 10, bottom: 10, width: 3, borderRadius: 2, background: tokens.accent }} />}
|
||||
{/* 行1:单号 + 状态 */}
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
|
||||
<span style={{ fontSize: 13.5, fontWeight: 700, color: active ? tokens.accent : tokens.text, fontVariantNumeric: 'tabular-nums', letterSpacing: '0.02em' }}>
|
||||
{s.销售订单号}
|
||||
</span>
|
||||
<span style={{ flex: 1 }} />
|
||||
<span style={{
|
||||
fontSize: 10.5, fontWeight: 600, padding: '1px 7px', borderRadius: 99,
|
||||
color: sc.c, background: sc.bg, border: `1px solid ${sc.c}44`, whiteSpace: 'nowrap',
|
||||
}}>{s.单据状态}</span>
|
||||
</div>
|
||||
{/* 行2:客户 */}
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 6, marginTop: 4 }}>
|
||||
<span style={{ fontSize: 12, color: tokens.textSub, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{s.客户简称}</span>
|
||||
<span style={{ fontSize: 10.5, color: tokens.textMuted, padding: '0 6px', borderRadius: 99, border: `1px solid ${tokens.border}`, whiteSpace: 'nowrap' }}>{s.客户分类}</span>
|
||||
</div>
|
||||
{/* 行3:产品 + 数量 */}
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 5, marginTop: 5 }}>
|
||||
<Package size={12} style={{ color: tokens.textMuted, flexShrink: 0 }} />
|
||||
<span style={{ fontSize: 12.5, color: tokens.text, fontFamily: 'ui-monospace, monospace', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{s.产品编码}</span>
|
||||
<span style={{ flex: 1 }} />
|
||||
<span style={{ fontSize: 12, color: tokens.textSub, fontVariantNumeric: 'tabular-nums' }}>{s.数量.toLocaleString()} PCS</span>
|
||||
</div>
|
||||
{/* 行4:金额 + 交期 */}
|
||||
<div style={{ display: 'flex', alignItems: 'baseline', gap: 6, marginTop: 5 }}>
|
||||
<span style={{ fontSize: 14.5, fontWeight: 800, color: tokens.accent, fontVariantNumeric: 'tabular-nums' }}>{money(s.含税金额)}</span>
|
||||
<span style={{ flex: 1 }} />
|
||||
<span style={{ fontSize: 11, color: tokens.textMuted }}>发货 {s.预计发货日期}</span>
|
||||
</div>
|
||||
{expanded && (
|
||||
<div style={{ fontSize: 10.5, color: tokens.textMuted, marginTop: 4 }}>{s.仓库名称} · {s.制单人} · 下单 {s.单据日期}</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</ScrollList>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user