Commit 5ab52842 by wusiyi

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

parent 8b9abeac
......@@ -553,17 +553,27 @@ const props = withDefaults(
)
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 cached = localStorage.getItem('qualityScanAutoSure')
const getCachedAutoSure = (fallback: boolean) => {
const key = getAutoSureCacheKey()
if (!key) return fallback
const cached = localStorage.getItem(key)
if (cached === null) return fallback
return cached === 'true'
}
// 缓存自动完成上一单勾选
watch(isAutoSure, (val) => {
if (props.fastKey === 'qualityScan') {
localStorage.setItem('qualityScanAutoSure', String(val))
const key = getAutoSureCacheKey()
if (key) {
localStorage.setItem(key, String(val))
}
})
......@@ -672,10 +682,7 @@ watch(
trackingNumberRef.value && trackingNumberRef.value.focus()
TrackingNumber.value = ''
isAutoSure.value =
props.fastKey === 'qualityScan'
? getCachedQualityAutoSure(props.defaultAutoSure)
: props.defaultAutoSure
isAutoSure.value = getCachedAutoSure(props.defaultAutoSure)
sendNum.value = 0
if (props.fastKey === 'qualityScan') {
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