增加订单复选搜索

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
@@ -391,7 +391,9 @@ async function loadLatestPriorVersionDraft() {
const res = await getPriceSet(props.priceSetId)
const data = res.data || {}
const versions = data.versions || []
const prior = pickLatestPriorVersion(versions, props.psvId || resolvedPsvId.value)
// Only exclude the draft being edited. Do NOT use resolvedPsvId — it may
// point at EFFECT after resolvePsvId() and wrongly skip the real prior.
const prior = pickLatestPriorVersion(versions, props.psvId)
if (!prior || prior.psvId == null) return false
const products = (prior.products || [])
.filter(p => p && p.productCode)
+17 -5
View File
@@ -377,19 +377,31 @@ function onPriceBuildModeUpdate(mode) {
}).catch(() => {})
})
} else if (mode === 'IMPORT') {
nextTick(() => {
nextTick(async () => {
// newVersion/copy: wait until loadExisting fills priceSetId
const qid = route.query.priceSetId
if (!form.priceSetId && qid) {
for (let i = 0; i < 50 && !form.priceSetId; i++) {
await new Promise(r => setTimeout(r, 100))
}
}
const loader = detailsRef.value && detailsRef.value.loadLatestPriorVersionDraft
if (!loader) {
proxy.$modal.msgSuccess("请导入 Excel 建价")
return
}
loader().then(ok => {
if (!form.priceSetId) {
proxy.$modal.msgSuccess("新建套餐无历史版本可带出,请直接导入 Excel 建价")
return
}
try {
const ok = await loader()
proxy.$modal.msgSuccess(ok
? "已带出上一版全部产品,导入 Excel 按产品+国家覆盖或新增"
: "暂无上一版产品,请导入 Excel 建价")
}).catch(() => {
: "未找到含产品的上一版,请导入 Excel 建价")
} catch (e) {
proxy.$modal.msgSuccess("请导入 Excel 建价")
})
}
})
}
}
@@ -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 */