生物安全模块批量新增修改
This commit is contained in:
@@ -146,9 +146,16 @@
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
|
||||
|
||||
<!-- 已选耳号 -->
|
||||
<el-form-item label="已选耳号">
|
||||
<el-form-item v-if="selectedSheepList.length > 0" label="">
|
||||
<p style="font-size: 12px; color: #999; margin: 5px 0 0 0; width: 100%; display: block;">
|
||||
羊只总数:{{ selectedSheepList.length }}
|
||||
<el-button link type="danger" size="small" @click="clearAllSheep"
|
||||
style="margin-left: 10px;">
|
||||
清空全部
|
||||
</el-button>
|
||||
</p>
|
||||
<el-tag v-for="(tag, idx) in selectedSheepList" :key="tag.sheepId" closable @close="removeSheep(idx)"
|
||||
style="margin-right: 6px">
|
||||
{{ tag.sheepNo }}
|
||||
@@ -621,27 +628,60 @@
|
||||
})
|
||||
}
|
||||
|
||||
function clearAllSheep() {
|
||||
proxy.$modal.confirm('确认清空所有已选羊只?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
selectedSheepList.value = []
|
||||
proxy.$modal.msgSuccess('已清空全部羊只')
|
||||
}).catch(() => { })
|
||||
}
|
||||
|
||||
function validateSheep() {
|
||||
const no = sheepInput.value.trim()
|
||||
if (!no) return
|
||||
|
||||
// 检查是否已选择
|
||||
if (selectedSheepList.value.some(s => s.sheepNo === no)) {
|
||||
proxy.$modal.msgWarning('该耳号已存在')
|
||||
sheepInput.value = ''
|
||||
return
|
||||
}
|
||||
request.get(`/sheep_file/sheep_file/byNo/${no}`).then(res => {
|
||||
if (!res.data) {
|
||||
proxy.$modal.msgError('羊只耳号不存在')
|
||||
} else {
|
||||
selectedSheepList.value.push({
|
||||
sheepNo: res.data.sheepNo || res.data.bsManageTags,
|
||||
sheepId: res.data.id
|
||||
|
||||
request.get(`/sheep/sheep/byManageTags/${no}`).then(res => {
|
||||
// 有未查询到的耳号,弹窗显示
|
||||
if (res.data?.notInHerd?.length > 0) {
|
||||
const notFoundEars = res.data.notInHerd.join(' ')
|
||||
proxy.$modal.msgWarning(`以下耳号未查询到:${notFoundEars} 请检查后重新输入`)
|
||||
}
|
||||
|
||||
// 处理查询到的耳号
|
||||
if (res.data?.inHerd?.length > 0) {
|
||||
res.data.inHerd.forEach(earNum => {
|
||||
// 检查是否已存在
|
||||
if (!selectedSheepList.value.some(s => s.sheepNo === earNum)) {
|
||||
const sheep = res.data.sheepDetails.find(s => s.manageTags === earNum)
|
||||
if (sheep) {
|
||||
selectedSheepList.value.push({
|
||||
sheepId: sheep.id,
|
||||
sheepNo: sheep.manageTags
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
sheepInput.value = ''
|
||||
|
||||
// 只要 inHerd 有数据就清空输入框
|
||||
if (res.data?.inHerd?.length > 0) {
|
||||
sheepInput.value = ''
|
||||
}
|
||||
}).catch(err => {
|
||||
proxy.$modal.msgError('查询失败,请稍后重试')
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function removeSheep(index) {
|
||||
selectedSheepList.value.splice(index, 1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user