add test and outbound test
This commit is contained in:
1 parent
38ecbf82e5
commit
7f621dd553
23 files changed
+1301
-26
No files matched your search
@@ -16,6 +16,7 @@ import {
|
||||
actionRecord,
|
||||
confirmInboundLine,
|
||||
createRecord,
|
||||
getOutboundPickTasks,
|
||||
getRecordLines,
|
||||
pagedList,
|
||||
parseJsonObject,
|
||||
@@ -105,6 +106,13 @@ function lineFieldsForKind(kind: OrderKind): LineFieldDef[] {
|
||||
if (kind === 'transfer') return TRANSFER_LINE_FIELDS;
|
||||
if (kind === 'stocktake') return STOCKTAKE_LINE_FIELDS;
|
||||
if (kind === 'inbound') return INBOUND_LINE_FIELDS;
|
||||
if (kind === 'outbound') {
|
||||
return IN_OUT_LINE_FIELDS.map((field) =>
|
||||
field.key === 'locationCode'
|
||||
? { ...field, title: '指定库位(可选)', required: false, width: 128 }
|
||||
: field,
|
||||
);
|
||||
}
|
||||
return IN_OUT_LINE_FIELDS;
|
||||
}
|
||||
|
||||
@@ -169,6 +177,9 @@ function normalizeLinesForSubmit(lines: Record<string, any>[]) {
|
||||
attrs,
|
||||
inventoryKind: Number(line.inventoryKind ?? 1),
|
||||
};
|
||||
if ('locationCode' in next && !String(next.locationCode ?? '').trim()) {
|
||||
delete next.locationCode;
|
||||
}
|
||||
if ('qty' in next) next.qty = Number(next.qty);
|
||||
if ('countedQty' in next && next.countedQty !== undefined && next.countedQty !== '')
|
||||
next.countedQty = Number(next.countedQty);
|
||||
@@ -632,6 +643,7 @@ export default function OrderPage({ title, controller, kind }: OrderPageProps) {
|
||||
const [viewerOpen, setViewerOpen] = useState(false);
|
||||
const [viewerLoading, setViewerLoading] = useState(false);
|
||||
const [viewerLines, setViewerLines] = useState<Record<string, any>[]>([]);
|
||||
const [viewerPickTasks, setViewerPickTasks] = useState<Record<string, any>[]>([]);
|
||||
const [viewerTitle, setViewerTitle] = useState('');
|
||||
const [confirmOpen, setConfirmOpen] = useState(false);
|
||||
const [confirmLoading, setConfirmLoading] = useState(false);
|
||||
@@ -704,10 +716,14 @@ export default function OrderPage({ title, controller, kind }: OrderPageProps) {
|
||||
try {
|
||||
const lines = await getRecordLines<Record<string, any>>(controller, id);
|
||||
setViewerLines(Array.isArray(lines) ? lines : []);
|
||||
if (kind === 'outbound') {
|
||||
const tasks = await getOutboundPickTasks<Record<string, any>>(id);
|
||||
setViewerPickTasks(Array.isArray(tasks) ? tasks : []);
|
||||
}
|
||||
} catch {
|
||||
message.error('刷新明细失败');
|
||||
}
|
||||
}, [controller]);
|
||||
}, [controller, kind]);
|
||||
|
||||
const openConfirmInbound = useCallback(
|
||||
async (line: Record<string, any>) => {
|
||||
@@ -749,17 +765,23 @@ export default function OrderPage({ title, controller, kind }: OrderPageProps) {
|
||||
setViewerOpen(true);
|
||||
setViewerLoading(true);
|
||||
setViewerLines([]);
|
||||
setViewerPickTasks([]);
|
||||
try {
|
||||
const lines = await getRecordLines<Record<string, any>>(controller, record.id);
|
||||
setViewerLines(Array.isArray(lines) ? lines : []);
|
||||
if (kind === 'outbound') {
|
||||
const tasks = await getOutboundPickTasks<Record<string, any>>(record.id);
|
||||
setViewerPickTasks(Array.isArray(tasks) ? tasks : []);
|
||||
}
|
||||
} catch {
|
||||
setViewerLines([]);
|
||||
setViewerPickTasks([]);
|
||||
message.error('加载明细失败');
|
||||
} finally {
|
||||
setViewerLoading(false);
|
||||
}
|
||||
},
|
||||
[controller],
|
||||
[controller, kind],
|
||||
);
|
||||
|
||||
const viewerCols = useMemo(() => {
|
||||
@@ -796,6 +818,33 @@ export default function OrderPage({ title, controller, kind }: OrderPageProps) {
|
||||
];
|
||||
}, [kind, resolveLabel, openConfirmInbound]);
|
||||
|
||||
const pickTaskCols = useMemo(
|
||||
(): ProColumns<Record<string, any>>[] => [
|
||||
{ title: '任务号', dataIndex: 'taskNo', width: 180, ellipsis: true },
|
||||
{ title: '物料', dataIndex: 'materialCode', width: 120, ellipsis: true },
|
||||
{ title: '容器', dataIndex: 'containerCode', width: 110, ellipsis: true },
|
||||
{ title: '仓库', dataIndex: 'warehouseCode', width: 100, ellipsis: true },
|
||||
{ title: '库区', dataIndex: 'areaCode', width: 88, ellipsis: true },
|
||||
{ title: '分区', dataIndex: 'zoneCode', width: 88, ellipsis: true },
|
||||
{ title: '拣货库位', dataIndex: 'locationCode', width: 110, ellipsis: true },
|
||||
{ title: '应拣', dataIndex: 'qty', width: 88 },
|
||||
{ title: '已拣', dataIndex: 'pickedQty', width: 88 },
|
||||
{ title: '单位', dataIndex: 'unit', width: 72 },
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'taskStatus',
|
||||
width: 88,
|
||||
render: (_, row) => {
|
||||
const s = row.taskStatus;
|
||||
if (s === 'picked' || s === 'Picked' || s === 2) return '已拣';
|
||||
if (s === 'cancelled' || s === 'Cancelled' || s === 3) return '已取消';
|
||||
return '待拣';
|
||||
},
|
||||
},
|
||||
],
|
||||
[],
|
||||
);
|
||||
|
||||
const createInitialValues = useMemo(
|
||||
() =>
|
||||
kind === 'inbound'
|
||||
@@ -952,7 +1001,7 @@ export default function OrderPage({ title, controller, kind }: OrderPageProps) {
|
||||
<Modal
|
||||
title={`单据明细 — ${viewerTitle}`}
|
||||
open={viewerOpen}
|
||||
width={kind === 'inbound' ? 1280 : 1040}
|
||||
width={kind === 'inbound' || kind === 'outbound' ? 1280 : 1040}
|
||||
footer={null}
|
||||
destroyOnHidden
|
||||
onCancel={() => setViewerOpen(false)}
|
||||
@@ -967,6 +1016,24 @@ export default function OrderPage({ title, controller, kind }: OrderPageProps) {
|
||||
dataSource={viewerLines}
|
||||
scroll={{ x: 'max-content' }}
|
||||
/>
|
||||
{kind === 'outbound' && (
|
||||
<>
|
||||
<Typography.Title level={5} style={{ marginTop: 16, marginBottom: 8 }}>
|
||||
拣货任务
|
||||
</Typography.Title>
|
||||
<ProTable<Record<string, any>>
|
||||
loading={viewerLoading}
|
||||
rowKey={(row, i) => String(row.id ?? row.taskNo ?? i)}
|
||||
search={false}
|
||||
pagination={false}
|
||||
options={false}
|
||||
columns={pickTaskCols}
|
||||
dataSource={viewerPickTasks}
|
||||
scroll={{ x: 'max-content' }}
|
||||
locale={{ emptyText: '待出库单转待拣后生成拣货任务' }}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
|
||||
Reference in new issue
Block a user