增加订单复选搜索

This commit is contained in:
wuweihua
2026-10-22 17:40:57 +08:00
parent 23236ec141
commit 4ec28de073
5 changed files with 144 additions and 19 deletions
@@ -108,9 +108,14 @@ export function nextVersionNo(versions) {
return 'V' + (max + 1)
}
function versionHasProducts(v) {
return !!(v && (v.products || []).some(p => p && p.productCode))
}
/**
* Latest prior version for Excel build-price preload (exclude current draft).
* Prefer EFFECT, then PENDING, then highest versionSeq.
* Prefer EFFECT / PENDING / highest versionSeq that actually has products,
* so an empty EFFECT does not hide an older version that still has data.
*/
export function pickLatestPriorVersion(versions, excludePsvId) {
const list = (versions || []).filter(v => {
@@ -119,11 +124,17 @@ export function pickLatestPriorVersion(versions, excludePsvId) {
return true
})
if (!list.length) return null
const ranked = []
const effect = list.find(v => String(v.status) === VER_STATUS.EFFECT)
if (effect) return effect
if (effect) ranked.push(effect)
const pending = list.find(v => String(v.status) === VER_STATUS.PENDING)
if (pending) return pending
return list.slice().sort((a, b) => (Number(b.versionSeq) || 0) - (Number(a.versionSeq) || 0))[0]
if (pending && (!effect || String(pending.psvId) !== String(effect.psvId))) ranked.push(pending)
const bySeq = list.slice().sort((a, b) => (Number(b.versionSeq) || 0) - (Number(a.versionSeq) || 0))
bySeq.forEach(v => {
if (!ranked.some(x => String(x.psvId) === String(v.psvId))) ranked.push(v)
})
const withProducts = ranked.find(versionHasProducts)
return withProducts || ranked[0] || null
}
/** Package status label */