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() { async function loadSheepInfo() {
const tags = form.value.manageTags; const tags = form.value.manageTags;
if (!tags || tags.length === 0) return; if (!tags || tags.length === 0) return;
const tagDetails = {}; const tagDetails = {};
const validResults = []; const validResults = [];
let firstSheepfoldId = null; let firstSheepfoldId = null;
let firstRanchId = null;
for (const tag of tags) { for (const tag of tags) {
try { try {
const { data: sheepData } = await checkSheepByManageTags(tag.trim()); const { data: sheepData } = await checkSheepByManageTags(tag.trim());
if (!sheepData) { if (!sheepData) {
validResults.push(false); validResults.push(false);
proxy.$modal.msgError(`耳号 ${tag} 不存在或信息异常`); proxy.$modal.msgError(`耳号 ${tag} 不存在或信息异常`);
} else { } else {
validResults.push(true); validResults.push(true);
tagDetails[tag] = { tagDetails[tag] = {
comment: sheepData.comment || '', comment: sheepData.comment || '',
varietyId: sheepData.varietyId, varietyId: sheepData.varietyId,
sheepId: sheepData.id, sheepId: sheepData.id,
sheepfoldId: sheepData.sheepfoldId, sheepfoldId: sheepData.sheepfoldId,
}; };
if (!firstSheepfoldId) { if (!firstSheepfoldId) {
firstSheepfoldId = sheepData.sheepfoldId; 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)) { if (validResults.includes(false)) {
form.value.manageTags = tags.filter((_, index) => validResults[index]); form.value.manageTags = tags.filter((_, index) => validResults[index]);
proxy.$message.warning('部分耳号不合法,已自动过滤'); proxy.$message.warning('部分耳号不合法,已自动过滤');
} }
form.value.tagDetails = tagDetails; form.value.tagDetails = tagDetails;
if (firstSheepfoldId && isAdd.value) { if (firstRanchId && isAdd.value) {
form.value.foldFrom = Number(firstSheepfoldId); form.value.ranchId = firstRanchId;
} handleRanchChange(firstRanchId);
}
if (firstSheepfoldId && isAdd.value) {
form.value.foldFrom = Number(firstSheepfoldId);
}
} }
// //