diff --git a/src/views/breed/lambing_records/index.vue b/src/views/breed/lambing_records/index.vue index 2aa7c68..c0cba8c 100644 --- a/src/views/breed/lambing_records/index.vue +++ b/src/views/breed/lambing_records/index.vue @@ -107,7 +107,7 @@ @keyup.enter="handleQuery" /> - + + + + + + + + + + + + + + @@ -267,6 +305,30 @@ + + + + + + + + + + + + + + + + + + @@ -279,13 +341,47 @@ + + - + - - - - - - @@ -370,7 +455,7 @@ + @input="handleLambEarNumberInput(index)"/> @@ -452,6 +537,13 @@ {{ detailData.maleEarNumber }} {{ detailData.maleBreed }} {{ parseTime(detailData.breedingDate, '{y}-{m}-{d}') }} + {{ detailData.lambsBorn }} {{ detailData.survival }} {{ detailData.technician }} @@ -539,6 +631,11 @@ const detailData = ref({}) const lambDetailList = ref([]) const varietyList = ref([]) // 品种列表 +// 是否胚胎移植(有供体母羊或供体公羊信息时为true) +const isEmbryoTransfer = computed(() => { + return !!(form.value.donorEwe || form.value.donorRam) +}) + const data = reactive({ form: {}, queryParams: { @@ -813,6 +910,19 @@ function getGenderDisplay(gender) { return { label: '未知', type: 'info' } } +/** 配种类型标签映射 */ +function getBreedTypeLabel(breedType) { + const map = { + '1': '供体母羊配种', + '2': '同期发情人工授精', + '3': '本交', + '4': '自然发情人工授精', + '5': '胚胎移植' + } + if (breedType == null || breedType === '') return '-' + return map[String(breedType)] || String(breedType) +} + /** 母羊耳号输入处理 */ function handleEarNumberInput() { // 清空相关联动字段 @@ -822,6 +932,12 @@ function handleEarNumberInput() { form.value.breedingDate = null form.value.pregnancyDays = null form.value.technician = null + form.value.donorEwe = null + form.value.donorEweBreed = null + form.value.donorRam = null + form.value.donorRamBreed = null + form.value.embryoCount = null + form.value.breedType = null } /** 母羊耳号失焦处理 - 自动查询配种信息 */ @@ -840,6 +956,13 @@ function handleEarNumberBlur() { form.value.breedingDate = breedingData.breeding_date form.value.pregnancyDays = breedingData.pregnancy_days form.value.technician = breedingData.technician || '' + // 供体信息(胚胎移植时有值) + form.value.donorEwe = breedingData.donor_ewe || null + form.value.donorEweBreed = breedingData.donor_ewe_breed || null + form.value.donorRam = breedingData.donor_ram || null + form.value.donorRamBreed = breedingData.donor_ram_breed || null + form.value.embryoCount = breedingData.embryo_count || null + form.value.breedType = breedingData.breed_type || null const mVariety = varietyList.value.find(v => v.variety === breedingData.male_breed); const fVariety = varietyList.value.find(v => v.variety === breedingData.female_breed); @@ -874,10 +997,19 @@ function handleEarNumberBlur() { function getList() { loading.value = true listLambing_records(queryParams.value).then(response => { - lambing_recordsList.value = response.rows + const rows = response.rows || [] total.value = response.total - loading.value = false - }) + // 批量加载每行的羔羊详情 + const promises = rows.map(row => + getLambDetail(row.id).then(res => { + row.lambDetails = res.data || [] + }).catch(() => { row.lambDetails = [] }) + ) + Promise.all(promises).then(() => { + lambing_recordsList.value = rows + loading.value = false + }) + }).catch(() => { loading.value = false }) } // 取消按钮 @@ -903,7 +1035,13 @@ function reset() { score: null, comment: null, createBy: null, - createTime: null + createTime: null, + donorEwe: null, + donorEweBreed: null, + donorRam: null, + donorRamBreed: null, + embryoCount: null, + breedType: null } showLambForms.value = false lambForms.value = [] @@ -936,6 +1074,8 @@ function handleSelectionChange(selection) { /** 新增按钮操作 */ function handleAdd() { reset() + // 默认产羔日期为今天 + form.value.createTime = new Date().toISOString().split('T')[0] open.value = true title.value = "添加产羔记录" } diff --git a/src/views/produce/bodyManage/body_measure/index.vue b/src/views/produce/bodyManage/body_measure/index.vue index d4e3688..738b59a 100644 --- a/src/views/produce/bodyManage/body_measure/index.vue +++ b/src/views/produce/bodyManage/body_measure/index.vue @@ -605,12 +605,27 @@ function loadSheepTypeList() { }); } -function searchEarNumber(query) { - if (!query) { earOptions.value = []; return } +const searchEarNumber = async (query) => { + if (!query || query.trim() === '') { + earOptions.value = [] + return + } + earLoading.value = true - searchEarNumbers(query.trim()).then(res => { - earOptions.value = res.data || [] - }).finally(() => earLoading.value = false) + try { + const res = await searchEarNumbers(query.trim()) + if (res.code === 200 && Array.isArray(res.data)) { + earOptions.value = res.data + } else { + earOptions.value = [] + } + } catch (error) { + console.error('搜索耳号失败:', error) + earOptions.value = [] + proxy.$modal.msgError('搜索耳号失败') + } finally { + earLoading.value = false + } } function handlePaste() { nextTick(() => handlePasteSubmit()) diff --git a/src/views/produce/bodyManage/body_score/index.vue b/src/views/produce/bodyManage/body_score/index.vue index 8769afa..09075da 100644 --- a/src/views/produce/bodyManage/body_score/index.vue +++ b/src/views/produce/bodyManage/body_score/index.vue @@ -522,12 +522,27 @@ function loadVarietyOptions() { }) } -function searchEarNumber(query) { - if (!query) { earOptions.value = []; return } +const searchEarNumber = async (query) => { + if (!query || query.trim() === '') { + earOptions.value = [] + return + } + earLoading.value = true - searchEarNumbers(query.trim()).then(res => { - earOptions.value = res.data || [] - }).finally(() => earLoading.value = false) + try { + const res = await searchEarNumbers(query.trim()) + if (res.code === 200 && Array.isArray(res.data)) { + earOptions.value = res.data + } else { + earOptions.value = [] + } + } catch (error) { + console.error('搜索耳号失败:', error) + earOptions.value = [] + proxy.$modal.msgError('搜索耳号失败') + } finally { + earLoading.value = false + } } function clearEarNumbers() { diff --git a/src/views/produce/bodyManage/breast_rating/index.vue b/src/views/produce/bodyManage/breast_rating/index.vue index 5da79c5..ac671d6 100644 --- a/src/views/produce/bodyManage/breast_rating/index.vue +++ b/src/views/produce/bodyManage/breast_rating/index.vue @@ -540,12 +540,27 @@ function loadVarietyOptions() { varietyOptions.value = res.rows; }) } -function searchEarNumber(query) { - if (!query) { earOptions.value = []; return } +const searchEarNumber = async (query) => { + if (!query || query.trim() === '') { + earOptions.value = [] + return + } + earLoading.value = true - searchEarNumbers(query.trim()).then(res => { - earOptions.value = res.data || [] - }).finally(() => earLoading.value = false) + try { + const res = await searchEarNumbers(query.trim()) + if (res.code === 200 && Array.isArray(res.data)) { + earOptions.value = res.data + } else { + earOptions.value = [] + } + } catch (error) { + console.error('搜索耳号失败:', error) + earOptions.value = [] + proxy.$modal.msgError('搜索耳号失败') + } finally { + earLoading.value = false + } } function clearEarNumbers() { queryParams.value.manageTagsList = [] diff --git a/src/views/produce/manage_sheep/changeComment/index.vue b/src/views/produce/manage_sheep/changeComment/index.vue index 9d219c9..81b14ce 100644 --- a/src/views/produce/manage_sheep/changeComment/index.vue +++ b/src/views/produce/manage_sheep/changeComment/index.vue @@ -454,13 +454,27 @@ function getSheepfoldOptions() { sheepfoldOptions.value = res.rows }) } -/* 远程搜耳号 */ -function searchEarNumber(query) { - if (!query) { earOptions.value = []; return } +const searchEarNumber = async (query) => { + if (!query || query.trim() === '') { + earOptions.value = [] + return + } + earLoading.value = true - searchEarNumbers(query.trim()).then(res => { - earOptions.value = res.data || [] - }).finally(() => earLoading.value = false) + try { + const res = await searchEarNumbers(query.trim()) + if (res.code === 200 && Array.isArray(res.data)) { + earOptions.value = res.data + } else { + earOptions.value = [] + } + } catch (error) { + console.error('搜索耳号失败:', error) + earOptions.value = [] + proxy.$modal.msgError('搜索耳号失败') + } finally { + earLoading.value = false + } } /* 清空所有耳号 */ diff --git a/src/views/produce/manage_sheep/changeEar/index.vue b/src/views/produce/manage_sheep/changeEar/index.vue index 4479d40..fad47fd 100644 --- a/src/views/produce/manage_sheep/changeEar/index.vue +++ b/src/views/produce/manage_sheep/changeEar/index.vue @@ -497,12 +497,29 @@ function getSheepfoldOptions() { sheepfoldOptions.value = res.rows }) } -function searchEarNumber(query) { - if (!query) { earOptions.value = []; return } +// 搜索耳号的方法(用于下拉框远程搜索) +const searchEarNumber = async (query) => { + if (!query || query.trim() === '') { + earOptions.value = [] + return + } + earLoading.value = true - searchEarNumbers(query.trim()).then(res => { - earOptions.value = res.data || [] - }).finally(() => earLoading.value = false) + try { + // 调用API搜索耳号 + const res = await searchEarNumbers(query.trim()) + if (res.code === 200 && Array.isArray(res.data)) { + earOptions.value = res.data + } else { + earOptions.value = [] + } + } catch (error) { + console.error('搜索耳号失败:', error) + earOptions.value = [] + proxy.$modal.msgError('搜索耳号失败') + } finally { + earLoading.value = false + } } /* 粘贴事件 */ function handlePaste() { diff --git a/src/views/produce/manage_sheep/changeVariety/index.vue b/src/views/produce/manage_sheep/changeVariety/index.vue index ee4e5e2..7a27815 100644 --- a/src/views/produce/manage_sheep/changeVariety/index.vue +++ b/src/views/produce/manage_sheep/changeVariety/index.vue @@ -467,12 +467,29 @@ function getSheepfoldOptions() { sheepfoldOptions.value = res.rows }) } -function searchEarNumber(query) { - if (!query) { earOptions.value = []; return } +// 搜索耳号的方法(用于下拉框远程搜索) +const searchEarNumber = async (query) => { + if (!query || query.trim() === '') { + earOptions.value = [] + return + } + earLoading.value = true - searchEarNumbers(query.trim()).then(res => { - earOptions.value = res.data || [] - }).finally(() => earLoading.value = false) + try { + // 调用API搜索耳号 + const res = await searchEarNumbers(query.trim()) + if (res.code === 200 && Array.isArray(res.data)) { + earOptions.value = res.data + } else { + earOptions.value = [] + } + } catch (error) { + console.error('搜索耳号失败:', error) + earOptions.value = [] + proxy.$modal.msgError('搜索耳号失败') + } finally { + earLoading.value = false + } } /* 粘贴事件 */ function handlePaste() { diff --git a/src/views/produce/manage_sheep/trans_group/index.vue b/src/views/produce/manage_sheep/trans_group/index.vue index 3c61176..42742f0 100644 --- a/src/views/produce/manage_sheep/trans_group/index.vue +++ b/src/views/produce/manage_sheep/trans_group/index.vue @@ -629,7 +629,29 @@ function handleQuery() { queryParams.value.pageNum = 1; getList(); } - +// 搜索耳号的方法(用于下拉框远程搜索) +const searchEarNumber = async (query) => { + if (!query || query.trim() === '') { + earOptions.value = [] + return + } + + earLoading.value = true + try { + // 调用API搜索耳号 + const res = await searchEarNumbers(query.trim()) + if (res.code === 200 && Array.isArray(res.data)) { + earOptions.value = res.data + } else { + earOptions.value = [] + } + } catch (error) { + console.error('搜索耳号失败:', error) + earOptions.value = [] + } finally { + earLoading.value = false + } +} //重置搜索框 function resetQuery() { daterangeTransDate.value = []; diff --git a/src/views/produce/manage_sheep/transition_info/index.vue b/src/views/produce/manage_sheep/transition_info/index.vue index bedb059..cde1230 100644 --- a/src/views/produce/manage_sheep/transition_info/index.vue +++ b/src/views/produce/manage_sheep/transition_info/index.vue @@ -769,12 +769,29 @@ function handleDelete(row) { }) } -function searchEarNumber(query) { - if (!query) { earOptions.value = []; return } +// 搜索耳号的方法(用于下拉框远程搜索) +const searchEarNumber = async (query) => { + if (!query || query.trim() === '') { + earOptions.value = [] + return + } + earLoading.value = true - searchEarNumbers(query.trim()).then(res => { - earOptions.value = res.data || [] - }).finally(() => earLoading.value = false) + try { + // 调用API搜索耳号 + const res = await searchEarNumbers(query.trim()) + if (res.code === 200 && Array.isArray(res.data)) { + earOptions.value = res.data + } else { + earOptions.value = [] + } + } catch (error) { + console.error('搜索耳号失败:', error) + earOptions.value = [] + proxy.$modal.msgError('搜索耳号失败') + } finally { + earLoading.value = false + } } async function handleRanchChange(ranchName) { if (!ranchName) { diff --git a/src/views/produce/other/castrate/index.vue b/src/views/produce/other/castrate/index.vue index 5f42173..41cfc47 100644 --- a/src/views/produce/other/castrate/index.vue +++ b/src/views/produce/other/castrate/index.vue @@ -559,12 +559,27 @@ function filterSheepfold(query) { fold.sheepfoldName.includes(query) ) } -function searchEarNumber(query) { - if (!query) { earOptions.value = []; return } +const searchEarNumber = async (query) => { + if (!query || query.trim() === '') { + earOptions.value = [] + return + } + earLoading.value = true - searchEarNumbers(query.trim()).then(res => { - earOptions.value = res.data || [] - }).finally(() => earLoading.value = false) + try { + const res = await searchEarNumbers(query.trim()) + if (res.code === 200 && Array.isArray(res.data)) { + earOptions.value = res.data + } else { + earOptions.value = [] + } + } catch (error) { + console.error('搜索耳号失败:', error) + earOptions.value = [] + proxy.$modal.msgError('搜索耳号失败') + } finally { + earLoading.value = false + } } function clearEarNumbers() { queryParams.value.manageTagsList = [] diff --git a/src/views/produce/other/fixHoof/index.vue b/src/views/produce/other/fixHoof/index.vue index 02733a8..acc912b 100644 --- a/src/views/produce/other/fixHoof/index.vue +++ b/src/views/produce/other/fixHoof/index.vue @@ -508,12 +508,27 @@ const fetchTechnicalList = () => { technicalOptions.value = [] }) } -function searchEarNumber(query) { - if (!query) { earOptions.value = []; return } +const searchEarNumber = async (query) => { + if (!query || query.trim() === '') { + earOptions.value = [] + return + } + earLoading.value = true - searchEarNumbers(query.trim()).then(res => { - earOptions.value = res.data || [] - }).finally(() => earLoading.value = false) + try { + const res = await searchEarNumbers(query.trim()) + if (res.code === 200 && Array.isArray(res.data)) { + earOptions.value = res.data + } else { + earOptions.value = [] + } + } catch (error) { + console.error('搜索耳号失败:', error) + earOptions.value = [] + proxy.$modal.msgError('搜索耳号失败') + } finally { + earLoading.value = false + } } function clearEarNumbers() { queryParams.value.manageTagsList = []