电子标签优化

This commit is contained in:
bb_pan 2025-08-23 14:46:51 +08:00
parent c6fc20f751
commit 8f8a20ba4a
1 changed files with 26 additions and 7 deletions

View File

@ -12,7 +12,7 @@
<!-- <button @click="handleRecognition" class="recognition-btn">识别</button> -->
</div>
<div v-if="optionList.length > 0" class="select-container">
<div v-if="optionList.length > 1" class="select-container">
<uni-data-select
v-model="maId"
:localdata="optionList"
@ -283,12 +283,19 @@ const handQuery = () => {
})
getSelectionList({ maCode: code.value, maId: 0 }).then((response) => {
if (response.data && response.data.length !== 0) {
if (response.data.length === 1) {
const option = response.data[0]
maCodeTwo.value = code.value
maId.value = option.maId
getTagInfo(option.devType)
}
optionList.value = response.data.map((option) => ({
value: option.maId,
text: option.maCode,
devType: option.devType,
}))
} else {
isJj.value = null
uni.showToast({
title: '未查询到该编号信息',
icon: 'none',
@ -296,6 +303,7 @@ const handQuery = () => {
})
}
}).finally(() => {
isJj.value = null
uni.hideLoading()
})
}
@ -309,13 +317,16 @@ const changeTag = async (e) => {
maCodeTwo.value = option.text || ''
console.log('🚀 ~ changeTag ~ maCodeTwo:', maCodeTwo.value)
if (!maCodeTwo.value) return
getTagInfo(option.devType)
}
const getTagInfo = async (devType) => {
try {
uni.showLoading({
title: '加载中...',
mask: true,
})
const response = await getListTag({ maCode: maCodeTwo.value, maId: maId.value, devType: option.devType })
const response = await getListTag({ maCode: maCodeTwo.value, maId: maId.value, devType: devType })
if (response.data && response.data.length !== 0) {
tagInfo.value = response.data[0]
isJj.value = tagInfo.value.isJj
@ -338,11 +349,19 @@ const changeTag = async (e) => {
}
} catch (error) {
console.error('获取标签信息失败', error)
uni.showToast({
title: '获取信息失败',
icon: 'none',
duration: 2000,
})
if (error.data && error.data.msg && error.data.msg.includes('检验时间')) {
uni.showModal({
title: '提示',
content: '该工器具已临近下次检验时间,请及时退还至机具(物流)分公司!',
showCancel: false,
})
} else {
uni.showToast({
title: '获取信息失败',
icon: 'none',
duration: 2000,
})
}
} finally {
uni.hideLoading()
}