Commit 5ab52842 by wusiyi

fear: 快捷生产自动完成上一单勾选缓存

parent 8b9abeac
...@@ -553,17 +553,27 @@ const props = withDefaults( ...@@ -553,17 +553,27 @@ const props = withDefaults(
) )
const emit = defineEmits(['update:detailVisible', 'close', 'onSuccess']) const emit = defineEmits(['update:detailVisible', 'close', 'onSuccess'])
const AUTO_SURE_CACHE_KEYS: Record<string, string> = {
qualityScan: 'qualityScanAutoSure',
productionScan: 'productionScanAutoSure',
}
const getAutoSureCacheKey = () => AUTO_SURE_CACHE_KEYS[props.fastKey] || ''
// 获取自动完成上一单勾选缓存 // 获取自动完成上一单勾选缓存
const getCachedQualityAutoSure = (fallback: boolean) => { const getCachedAutoSure = (fallback: boolean) => {
const cached = localStorage.getItem('qualityScanAutoSure') const key = getAutoSureCacheKey()
if (!key) return fallback
const cached = localStorage.getItem(key)
if (cached === null) return fallback if (cached === null) return fallback
return cached === 'true' return cached === 'true'
} }
// 缓存自动完成上一单勾选 // 缓存自动完成上一单勾选
watch(isAutoSure, (val) => { watch(isAutoSure, (val) => {
if (props.fastKey === 'qualityScan') { const key = getAutoSureCacheKey()
localStorage.setItem('qualityScanAutoSure', String(val)) if (key) {
localStorage.setItem(key, String(val))
} }
}) })
...@@ -672,10 +682,7 @@ watch( ...@@ -672,10 +682,7 @@ watch(
trackingNumberRef.value && trackingNumberRef.value.focus() trackingNumberRef.value && trackingNumberRef.value.focus()
TrackingNumber.value = '' TrackingNumber.value = ''
isAutoSure.value = isAutoSure.value = getCachedAutoSure(props.defaultAutoSure)
props.fastKey === 'qualityScan'
? getCachedQualityAutoSure(props.defaultAutoSure)
: props.defaultAutoSure
sendNum.value = 0 sendNum.value = 0
if (props.fastKey === 'qualityScan') { if (props.fastKey === 'qualityScan') {
initPrintDevice() initPrintDevice()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment