bug修复

This commit is contained in:
zyh 2025-08-04 17:22:15 +08:00
parent 53b3efb432
commit 5df66f9b02

View File

@ -475,47 +475,54 @@ async function loadSheepByTypeOnly(typeId) {
//
async function loadSheepInfo() {
const tags = form.value.manageTags;
if (!tags || tags.length === 0) return;
const tags = form.value.manageTags;
if (!tags || tags.length === 0) return;
const tagDetails = {};
const validResults = [];
let firstSheepfoldId = null;
const tagDetails = {};
const validResults = [];
let firstSheepfoldId = null;
let firstRanchId = null;
for (const tag of tags) {
try {
const { data: sheepData } = await checkSheepByManageTags(tag.trim());
if (!sheepData) {
validResults.push(false);
proxy.$modal.msgError(`耳号 ${tag} 不存在或信息异常`);
} else {
validResults.push(true);
tagDetails[tag] = {
comment: sheepData.comment || '',
varietyId: sheepData.varietyId,
sheepId: sheepData.id,
sheepfoldId: sheepData.sheepfoldId,
};
if (!firstSheepfoldId) {
firstSheepfoldId = sheepData.sheepfoldId;
for (const tag of tags) {
try {
const { data: sheepData } = await checkSheepByManageTags(tag.trim());
if (!sheepData) {
validResults.push(false);
proxy.$modal.msgError(`耳号 ${tag} 不存在或信息异常`);
} else {
validResults.push(true);
tagDetails[tag] = {
comment: sheepData.comment || '',
varietyId: sheepData.varietyId,
sheepId: sheepData.id,
sheepfoldId: sheepData.sheepfoldId,
};
if (!firstSheepfoldId) {
firstSheepfoldId = sheepData.sheepfoldId;
firstRanchId = sheepData.ranchId;
}
}
} catch (error) {
console.error('获取耳号信息失败:', error);
proxy.$modal.msgError(`耳号 ${tag} 验证失败,请重试`);
validResults.push(false);
}
}
} catch (error) {
console.error('获取耳号信息失败:', error);
proxy.$modal.msgError(`耳号 ${tag} 验证失败,请重试`);
validResults.push(false);
}
}
if (validResults.includes(false)) {
form.value.manageTags = tags.filter((_, index) => validResults[index]);
proxy.$message.warning('部分耳号不合法,已自动过滤');
}
form.value.tagDetails = tagDetails;
if (validResults.includes(false)) {
form.value.manageTags = tags.filter((_, index) => validResults[index]);
proxy.$message.warning('部分耳号不合法,已自动过滤');
}
form.value.tagDetails = tagDetails;
if (firstSheepfoldId && isAdd.value) {
form.value.foldFrom = Number(firstSheepfoldId);
}
if (firstRanchId && isAdd.value) {
form.value.ranchId = firstRanchId;
handleRanchChange(firstRanchId);
}
if (firstSheepfoldId && isAdd.value) {
form.value.foldFrom = Number(firstSheepfoldId);
}
}
//