| | |
| | | function handleBindPallet() { |
| | | const records = getSelectedRecords(); |
| | | if (!records) return; |
| | | if (records.some((record) => !record.batchId)) { |
| | | message.warning("请先录入生产批次,再绑定托盘"); |
| | | return; |
| | | } |
| | | const batchIds = new Set(records.map((record) => record.batchId)); |
| | | if (batchIds.size > 1) { |
| | | message.warning("请选择同一批次下的袋码进行绑定"); |
| | | return; |
| | | } |
| | | if (records.some((record) => record.palletId)) { |
| | | message.warning("所选袋码中存在已绑定托盘的记录,请先解绑"); |
| | | return; |
| | |
| | | message.warning("已作废的袋码不允许绑定托盘"); |
| | | return; |
| | | } |
| | | const withBatch = records.filter((record) => record.batchId); |
| | | // 已录批次与未录批次混选时可选托盘范围不一致,要求分开操作 |
| | | if (withBatch.length > 0 && withBatch.length < records.length) { |
| | | message.warning("所选袋码部分已录入批次,请分开选择后再绑定托盘"); |
| | | return; |
| | | } |
| | | const first = records[0]!; |
| | | if (withBatch.length > 0) { |
| | | const batchIds = new Set(records.map((record) => record.batchId)); |
| | | if (batchIds.size > 1) { |
| | | message.warning("请选择同一批次下的袋码进行绑定"); |
| | | return; |
| | | } |
| | | } else { |
| | | const itemIds = new Set(records.map((record) => record.itemId)); |
| | | if (itemIds.size > 1) { |
| | | message.warning("请选择同一品种下的袋码进行绑定"); |
| | | return; |
| | | } |
| | | } |
| | | bindPalletFormModalApi |
| | | .setData({ |
| | | batchId: first.batchId, |
| | | batchCode: first.batchCode, |
| | | itemId: first.itemId, |
| | | ids: records.map((record) => record.id!), |
| | | }) |
| | | .open(); |