fix(web-admin): allow same product with different packages on delivery stop
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
39161e43e4
commit
6548316644
1 file changed
+26
-5
@@ -426,6 +426,7 @@
|
||||
isPackageAllowedForContractProduct,
|
||||
normalizePackageSpec,
|
||||
packageSpecsForProduct,
|
||||
productPackageKey,
|
||||
type ContractProductRowLite
|
||||
} from '@/utils/pl-plan-contract-product'
|
||||
import { getPersonnelAffiliationLabel } from '@/utils/pl-personnel-cert'
|
||||
@@ -1379,17 +1380,37 @@
|
||||
const index = target.deliveryIndex
|
||||
const delivery = deliveryForms.value[index]
|
||||
if (!delivery) return
|
||||
const existingIds = new Set(
|
||||
(delivery.products || []).map((row) => String(row.productId || '').trim()).filter(Boolean)
|
||||
const cid = String(delivery?.contracts?.[0]?.contractId || '').trim()
|
||||
const contractRows = cid ? contractProductRowsCache.value[cid] || [] : []
|
||||
const existing = delivery.products || []
|
||||
const existingKeys = new Set(
|
||||
existing.map((row) => productPackageKey(row.productId, row.packageSpec)).filter(Boolean)
|
||||
)
|
||||
const countByPid = new Map<string, number>()
|
||||
for (const row of existing) {
|
||||
const pid = String(row.productId || '').trim()
|
||||
if (!pid) continue
|
||||
countByPid.set(pid, (countByPid.get(pid) || 0) + 1)
|
||||
}
|
||||
const added = (await buildRows()).filter((row) => {
|
||||
const pid = String(row.productId || '').trim()
|
||||
if (!pid || existingIds.has(pid)) return false
|
||||
existingIds.add(pid)
|
||||
if (!pid) return false
|
||||
const key = productPackageKey(row.productId, row.packageSpec)
|
||||
const specs = packageSpecsForProduct(contractRows, pid)
|
||||
// 同品多包装:可按包装份数追加空包装行,便于分别选包装
|
||||
if (!normalizePackageSpec(row.packageSpec) && specs.length > 1) {
|
||||
const count = countByPid.get(pid) || 0
|
||||
if (count >= specs.length) return false
|
||||
countByPid.set(pid, count + 1)
|
||||
return true
|
||||
}
|
||||
if (key && existingKeys.has(key)) return false
|
||||
if (key) existingKeys.add(key)
|
||||
countByPid.set(pid, (countByPid.get(pid) || 0) + 1)
|
||||
return true
|
||||
})
|
||||
if (!added.length) {
|
||||
ElMessage.info('所选产品已在送货段中')
|
||||
ElMessage.info('所选产品(含包装)已在送货段中')
|
||||
return
|
||||
}
|
||||
deliveryForms.value = deliveryForms.value.map((row, idx) =>
|
||||
|
||||
Reference in new issue
Block a user