diff --git a/src/views/biosafety/deworm/index.vue b/src/views/biosafety/deworm/index.vue index 28589db..07d08d9 100644 --- a/src/views/biosafety/deworm/index.vue +++ b/src/views/biosafety/deworm/index.vue @@ -146,9 +146,16 @@ - + - + +

+ 羊只总数:{{ selectedSheepList.length }} + + 清空全部 + +

{{ 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) } diff --git a/src/views/biosafety/health/index.vue b/src/views/biosafety/health/index.vue index 6dbdd1d..6cc49ec 100644 --- a/src/views/biosafety/health/index.vue +++ b/src/views/biosafety/health/index.vue @@ -152,8 +152,14 @@ - - + + +

+ 羊只总数:{{ selectedSheepList.length }} + + 清空全部 + +

{{ tag.sheepNo }} @@ -654,24 +660,57 @@ function handleBarnChange(barnIds) { }) } +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('查询失败,请稍后重试') }) } diff --git a/src/views/biosafety/immunity/index.vue b/src/views/biosafety/immunity/index.vue index d8fd619..e53e9c6 100644 --- a/src/views/biosafety/immunity/index.vue +++ b/src/views/biosafety/immunity/index.vue @@ -149,8 +149,14 @@ - - + + +

+ 羊只总数:{{ selectedSheepList.length }} + + 清空全部 + +

{{ tag.sheepNo }} @@ -651,27 +657,59 @@ function handleBarnChange(barnIds) { }) } +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) } diff --git a/src/views/biosafety/quarantine/index.vue b/src/views/biosafety/quarantine/index.vue index ef475ec..45884f8 100644 --- a/src/views/biosafety/quarantine/index.vue +++ b/src/views/biosafety/quarantine/index.vue @@ -2,68 +2,8 @@
- -
- - - - - - - - - - - - - - 已选: {{ queryParams.allEarNumbers.length }} 个 - - - - - - 清空全部 - - -
- - - -
- - - {{ tag }} - - - - - - {{ isExpanded ? '收起' : `展开剩余 ${queryParams.allEarNumbers.length - defaultShowCount} 个` }} - - - - - - -
- -
- @@ -71,6 +11,77 @@ + +
+ + + + + + + + + + + + + + + + 已选: {{ queryParams.allEarNumbers.length }} 个 + + + + + + 清空全部 + + +
+ + + +
+ + + {{ tag }} + + + + + + {{ isExpanded ? '收起' : `展开剩余 ${queryParams.allEarNumbers.length - defaultShowCount} 个` }} + + + + + + +
+ +
+ + + + + + + + + + + @@ -97,18 +108,6 @@ - - - - - - - - - - - - 搜索 重置 @@ -134,6 +133,9 @@ + + - +

+ 羊只总数:{{ addForm.sheepList.length }} + + 清空全部 + +

+ style="margin: 0px 5px 0 0"> {{ item.ear }}
@@ -291,6 +298,11 @@ {{ editForm.sheepNo }} + + + {{ editForm.variety }} + + @@ -718,6 +730,17 @@ function handleBarnChange(selectedBarnIds) { } }) } +function clearAllSheep() { + proxy.$modal.confirm('确认清空所有已选羊只?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + addForm.value.sheepList = [] + validSheepId.value = false + proxy.$modal.msgSuccess('已清空全部羊只') + }).catch(() => { }) +} function validateSheepId() { const ear = addForm.value.sheepIdInput.trim() @@ -727,6 +750,7 @@ function validateSheepId() { validSheepId.value = false alreadySelected.value = false + // 检查是否已选择 if (addForm.value.sheepList.some(s => s.ear === ear)) { alreadySelected.value = true addForm.value.sheepIdInput = '' @@ -734,17 +758,42 @@ function validateSheepId() { } request.get(`/sheep/sheep/byManageTags/${ear}`).then(res => { - if (res.data) { - addForm.value.sheepList.push({ id: res.data.id, ear }) - validSheepId.value = true - } else { - invalidSheepId.value = true + // 有未查询到的耳号,弹窗显示 + if (res.data?.notInHerd?.length > 0) { + const notFoundEars = res.data.notInHerd.join(' ') + proxy.$modal.msgWarning(`以下耳号未查询到:${notFoundEars} 请检查后重新输入` ) } - addForm.value.sheepIdInput = '' + + // 处理查询到的耳号 + if (res.data?.inHerd?.length > 0) { + res.data.inHerd.forEach(earNum => { + // 检查是否已存在 + if (!addForm.value.sheepList.some(s => s.ear === earNum)) { + const sheep = res.data.sheepDetails.find(s => s.manageTags === earNum) + if (sheep) { + addForm.value.sheepList.push({ + id: sheep.id, + ear: sheep.manageTags + }) + } + } + }) + validSheepId.value = true + } + + // 只要 inHerd 有数据就清空输入框 + if (res.data?.inHerd?.length > 0) { + addForm.value.sheepIdInput = '' + } + }).catch(err => { + proxy.$modal.msgError('查询失败,请稍后重试') }) } function submitAddForm() { + if (addForm.value.sheepList.length === 0) { + return proxy.$modal.msgError('请至少添加一个耳号') + } addForm.value.ids = addForm.value.sheepList.map(s => s.id) addQuarantine(addForm.value).then(() => { proxy.$modal.msgSuccess('新增成功') @@ -832,7 +881,7 @@ getItems() getSample() getBarns() getSheepType() -getTechnicalList() +fetchTechnicalList()