feat:样品库管理

This commit is contained in:
houjunxiang
2025-11-21 17:56:33 +08:00
parent 7ee3df9ab9
commit 753766893b
24 changed files with 818 additions and 218 deletions

View File

@@ -52,6 +52,7 @@
import { computed, ref, toRefs, watch, reactive } from 'vue'
import nx from '@/nx'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { debounce } from 'lodash'
const takeOffType = ref('sample')
const takeOffTypeOptions = reactive([
@@ -75,11 +76,14 @@ const userInfo = computed(() => nx.$store('user').userInfo)
const { scanQRInfo } = toRefs(nx.$store('biz'))
watch(scanQRInfo, newVal => {
if (!newVal) return
debouncedHandleScan(newVal)
})
const debouncedHandleScan = debounce(val => {
if (!val) return
scanQRInfo.value = ''
if (nx.$router.getCurrentPage().route !== 'pages/sampleWarehouse/sampleTakeOff/index') return
try {
const isJson = nx.$helper.isJsonString(newVal)
const isJson = nx.$helper.isJsonString(val)
const isSample = takeOffType.value === 'sample'
if (isJson) {
if (isSample) {
@@ -88,11 +92,11 @@ watch(scanQRInfo, newVal => {
icon: 'none'
})
}
const codeObj = JSON.parse(newVal)
const codeObj = JSON.parse(val)
targetCode.value = codeObj.code
} else {
if (isSample) {
targetCode.value = newVal
targetCode.value = val
} else {
return uni.showToast({
title: '请扫描正确库位码',
@@ -107,7 +111,7 @@ watch(scanQRInfo, newVal => {
icon: 'none'
})
}
})
}, 300)
onShow(() => {
scanQRInfo.value = ''
})
@@ -138,7 +142,7 @@ async function handleSubmit() {
if (takeOffType.value === 'warehouseLocation') {
params.locationCode = targetCode.value
} else {
params.sampleCode = targetCode.value
params.sampleReturnCodes = sampleList.value.map(item => item.sampleReturnCode)
}
btnLoading.value = true
await nx.$api.sampleWarehouse.execTakeOff(params).finally(() => {