1
This commit is contained in:
parent
323aa323fb
commit
5480033c3c
@ -546,10 +546,22 @@ function saveSnapshot() {
|
|||||||
}, getScopedCacheKey())
|
}, getScopedCacheKey())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 仅保存 UI 草稿(表单值),不覆盖上次查询的 activeCondition */
|
||||||
|
function saveDraftSnapshot() {
|
||||||
|
const routePath = getRouteCacheKey()
|
||||||
|
if (!routePath) return
|
||||||
|
const existing = scanBoxCacheStore.getSnapshot(routePath, getScopedCacheKey())
|
||||||
|
scanBoxCacheStore.setSnapshot(routePath, {
|
||||||
|
activeTab: activeTab.value,
|
||||||
|
activeCondition: existing?.activeCondition ?? null,
|
||||||
|
customConditions: cloneSnapshotValue(customConditions)
|
||||||
|
}, getScopedCacheKey())
|
||||||
|
}
|
||||||
|
|
||||||
function scheduleSaveSnapshot() {
|
function scheduleSaveSnapshot() {
|
||||||
clearTimeout(cacheTimer)
|
clearTimeout(cacheTimer)
|
||||||
cacheTimer = setTimeout(() => {
|
cacheTimer = setTimeout(() => {
|
||||||
saveSnapshot()
|
saveDraftSnapshot()
|
||||||
}, 120)
|
}, 120)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -995,6 +1007,7 @@ function buildAndEmitCustomCondition() {
|
|||||||
|
|
||||||
if (hasCondition) {
|
if (hasCondition) {
|
||||||
activeCondition.value = conditions
|
activeCondition.value = conditions
|
||||||
|
saveSnapshot()
|
||||||
emit('condition-change', activeCondition.value)
|
emit('condition-change', activeCondition.value)
|
||||||
} else if (activeCondition.value && activeCondition.value.type === 'custom') {
|
} else if (activeCondition.value && activeCondition.value.type === 'custom') {
|
||||||
clearActiveCondition()
|
clearActiveCondition()
|
||||||
@ -1029,6 +1042,9 @@ function handleReset() {
|
|||||||
function handleSubmit() {
|
function handleSubmit() {
|
||||||
submitting.value = true
|
submitting.value = true
|
||||||
|
|
||||||
|
// 查询前立即持久化当前条件,供刷新恢复和导出使用
|
||||||
|
saveSnapshot()
|
||||||
|
|
||||||
// 对于自定义筛选,先构建当前条件但不依赖 buildAndEmitCustomCondition 的内部 emit
|
// 对于自定义筛选,先构建当前条件但不依赖 buildAndEmitCustomCondition 的内部 emit
|
||||||
if (activeTab.value === 'custom') {
|
if (activeTab.value === 'custom') {
|
||||||
const currentConditions = buildConditionsObject()
|
const currentConditions = buildConditionsObject()
|
||||||
@ -1215,7 +1231,14 @@ function setFieldCondition(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({ getConditions, reset, clear, getFieldDraft, setFieldCondition, submit: handleSubmit })
|
/** 获取上次查询时存储的条件,供导出等场景复用 */
|
||||||
|
function getStoredConditions() {
|
||||||
|
const routePath = getRouteCacheKey()
|
||||||
|
if (!routePath) return null
|
||||||
|
return scanBoxCacheStore.getSnapshot(routePath, getScopedCacheKey())
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({ getConditions, reset, clear, getFieldDraft, setFieldCondition, submit: handleSubmit, getStoredConditions })
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user