diff --git a/src/api/Sperm/Sperm.js b/src/api/Sperm/Sperm.js index f19d0d9..26caaa0 100644 --- a/src/api/Sperm/Sperm.js +++ b/src/api/Sperm/Sperm.js @@ -43,7 +43,7 @@ export function delSperm(id) { }) } -// 根据耳号查询羊只信息 +// 根据耳号查询羊只信息(带性别验证) export function getSheepByManageTags(manageTags) { return request({ url: '/Sperm/Sperm/getSheepByManageTags/' + manageTags, @@ -51,11 +51,28 @@ export function getSheepByManageTags(manageTags) { }) } -// 查询羊只耳号列表(用于下拉选择) -export function getSheepManageTagsList(query) { +// 验证羊只是否为公羊 +export function validateRam(manageTags) { return request({ - url: '/Sperm/Sperm/sheepManageTagsList', - method: 'get', - params: query + url: '/Sperm/Sperm/validateRam/' + manageTags, + method: 'get' + }) +} + +// 根据耳号查询羊只ID(兼容原有接口) +export function getSheepIdByManageTags(manageTags) { + return request({ + url: '/Sperm/Sperm/getSheepIdByManageTags/' + manageTags, + method: 'get' + }) +} + +// 导出采精记录 +export function exportSperm(query) { + return request({ + url: '/Sperm/Sperm/export', + method: 'post', + data: query, + responseType: 'blob' }) } \ No newline at end of file diff --git a/src/api/sheep_death/death.js b/src/api/sheep_death/death.js index 6f85df7..93f93b2 100644 --- a/src/api/sheep_death/death.js +++ b/src/api/sheep_death/death.js @@ -49,4 +49,12 @@ export function getSheepInfo(manageTags) { url: '/sheep_death/death/sheepInfo/' + manageTags, method: 'get' }) +} + +// 获取疾病树形列表 +export function getDiseaseTree() { + return request({ + url: '/sheep_death/death/disease/tree', + method: 'get' + }) } \ No newline at end of file diff --git a/src/views/Pregnancy_Test/Pregnancy_Test/index.vue b/src/views/Pregnancy_Test/Pregnancy_Test/index.vue index 61148e8..6750e41 100644 --- a/src/views/Pregnancy_Test/Pregnancy_Test/index.vue +++ b/src/views/Pregnancy_Test/Pregnancy_Test/index.vue @@ -7,6 +7,7 @@ placeholder="请输入耳号,多个耳号用逗号分隔" clearable @keyup.enter="handleQuery" + @clear="handleQuery" /> @@ -84,6 +85,14 @@ v-hasPermi="['Pregnancy_Test:Pregnancy_Test:export']" >导出 + + 调试测试 + @@ -372,9 +381,26 @@ function onResultChange(value) { /** 查询孕检记录列表 */ function getList() { loading.value = true + console.log("发送查询请求,参数:", queryParams.value) + listPregnancy_Test(queryParams.value).then(response => { - Pregnancy_TestList.value = response.rows - total.value = response.total + console.log("查询响应:", response) + Pregnancy_TestList.value = response.rows || [] + total.value = response.total || 0 + loading.value = false + + console.log("查询结果:", Pregnancy_TestList.value.length, "条记录") + + // 打印前3条记录的耳号 + if (Pregnancy_TestList.value.length > 0) { + for (let i = 0; i < Math.min(3, Pregnancy_TestList.value.length); i++) { + console.log(`记录${i+1}:ID=${Pregnancy_TestList.value[i].id}, 耳号=${Pregnancy_TestList.value[i].manageTags}`) + } + } + }).catch(error => { + console.error("查询失败:", error) + Pregnancy_TestList.value = [] + total.value = 0 loading.value = false }) } @@ -382,27 +408,35 @@ function getList() { /** 根据耳号获取羊只信息和配种信息 */ function getSheepAndBreedInfo() { if (form.value.manageTags) { + const cleanTag = form.value.manageTags.trim() + console.log("查询羊只信息,耳号:", cleanTag) + // 获取羊只基本信息 - getSheepByManageTags(form.value.manageTags).then(response => { + getSheepByManageTags(cleanTag).then(response => { + console.log("羊只信息响应:", response) if (response.data) { form.value.sheepId = response.data.id + console.log("找到羊只,ID:", response.data.id) } else { proxy.$modal.msgError("未找到该耳号的羊只信息") form.value.sheepId = null } - }).catch(() => { + }).catch(error => { + console.error("查询羊只信息失败:", error) proxy.$modal.msgError("查询羊只信息失败") form.value.sheepId = null }) // 获取配种信息 - getBreedInfoByManageTags(form.value.manageTags).then(response => { + getBreedInfoByManageTags(cleanTag).then(response => { + console.log("配种信息响应:", response) if (response.data) { breedInfo.value = response.data } else { breedInfo.value = {} } - }).catch(() => { + }).catch(error => { + console.error("查询配种信息失败:", error) breedInfo.value = {} }) } @@ -435,13 +469,30 @@ function reset() { /** 搜索按钮操作 */ function handleQuery() { + console.log("执行搜索,原始参数:", queryParams.value) + + // 清理搜索参数 + if (queryParams.value.manageTags) { + queryParams.value.manageTags = queryParams.value.manageTags.trim() + console.log("清理后的耳号参数:", queryParams.value.manageTags) + } + if (queryParams.value.technician) { + queryParams.value.technician = queryParams.value.technician.trim() + } + queryParams.value.pageNum = 1 getList() } /** 重置按钮操作 */ function resetQuery() { + console.log("重置搜索条件") proxy.resetForm("queryRef") + queryParams.value.manageTags = null + queryParams.value.datetime = null + queryParams.value.result = null + queryParams.value.technician = null + queryParams.value.way = null handleQuery() } @@ -479,6 +530,19 @@ function handleUpdate(row) { function submitForm() { proxy.$refs["Pregnancy_TestRef"].validate(valid => { if (valid) { + // 清理表单数据 + if (form.value.manageTags) { + form.value.manageTags = form.value.manageTags.trim() + } + if (form.value.technician) { + form.value.technician = form.value.technician.trim() + } + if (form.value.remark) { + form.value.remark = form.value.remark.trim() + } + + console.log("提交表单数据:", form.value) + if (form.value.id != null) { updatePregnancy_Test(form.value).then(response => { console.log("修改成功响应", response) @@ -494,7 +558,7 @@ function submitForm() { }) } else { addPregnancy_Test(form.value).then(response => { - console.log("新增成功响应", response) // 查看这个日志 + console.log("新增成功响应", response) if (response && response.code === 200) { proxy.$modal.msgSuccess("新增成功") open.value = false @@ -533,7 +597,26 @@ function handleExport() { }, `Pregnancy_Test_${new Date().getTime()}.xlsx`) } -getList() +/** 调试测试按钮 */ +function handleDebugTest() { + console.log("执行调试测试") + proxy.$http({ + url: '/Pregnancy_Test/Pregnancy_Test/debug/test', + method: 'get' + }).then(response => { + console.log("调试测试响应:", response) + proxy.$modal.msgSuccess(response.msg || "调试测试完成") + }).catch(error => { + console.error("调试测试失败:", error) + proxy.$modal.msgError("调试测试失败") + }) +} + +// 页面初始化 +onMounted(() => { + console.log("页面初始化,开始加载数据") + getList() +}) \ No newline at end of file diff --git a/src/views/Sperm/Sperm/index.vue b/src/views/Sperm/Sperm/index.vue index 21bfb45..2441cda 100644 --- a/src/views/Sperm/Sperm/index.vue +++ b/src/views/Sperm/Sperm/index.vue @@ -161,12 +161,22 @@ /> - - + + - + +
+ + {{ sheepValidation.message }} +
@@ -175,15 +185,37 @@ v-model="form.pickDate" type="date" value-format="YYYY-MM-DD" - placeholder="请选择采精日期"> + placeholder="请选择采精日期" + style="width: 100%">
+ + + + + + + + + + + + + + + - - + + @@ -200,7 +232,7 @@ - + @@ -210,7 +242,11 @@ - + + + + + @@ -222,13 +258,19 @@ - - + + - + @@ -238,15 +280,15 @@ - + - + @@ -255,7 +297,7 @@ \ No newline at end of file + + + \ No newline at end of file diff --git a/src/views/Weaning/weaning_record/index.vue b/src/views/Weaning/weaning_record/index.vue index 8f668e7..20d1dd1 100644 --- a/src/views/Weaning/weaning_record/index.vue +++ b/src/views/Weaning/weaning_record/index.vue @@ -70,12 +70,14 @@ @keyup.enter="handleQuery" /> - - - - + + + + + + - + diff --git a/src/views/miscarriage/miscarriage/index.vue b/src/views/miscarriage/miscarriage/index.vue index 2e6d70c..ddd6a1b 100644 --- a/src/views/miscarriage/miscarriage/index.vue +++ b/src/views/miscarriage/miscarriage/index.vue @@ -165,9 +165,12 @@ +
+ 注意:只能录入母羊的流产记录 +
@@ -182,6 +185,36 @@
+ + + +
+

+ 羊只信息 - {{ getSexTypeName(sheepInfo.gender) }} +

+ + + 品种: {{ sheepInfo.variety || '-' }} + + + 胎次: {{ sheepInfo.parity || '-' }} + + + 月龄: {{ sheepInfo.month_age || '-' }} + + + + + 羊舍: {{ sheepInfo.sheepfold_name || '-' }} + + + 牧场: {{ sheepInfo.dr_ranch || '-' }} + + +
+
+
+ @@ -267,6 +300,8 @@ const multiple = ref(true) const total = ref(0) const title = ref("") const reasonOptions = ref([]) +const sheepInfo = ref({}) +const sheepInfoVisible = ref(false) const data = reactive({ form: {}, @@ -304,6 +339,39 @@ const data = reactive({ const {queryParams, form, rules} = toRefs(data) +/** 获取羊只信息卡片样式 */ +const sheepInfoCardStyle = computed(() => { + const gender = sheepInfo.value.gender + if (gender === 1) { + // 母羊 - 绿色背景 + return { + background: '#f0f9f0', + padding: '12px', + borderRadius: '6px', + marginBottom: '15px', + border: '1px solid #b3e0b3' + } + } else if (gender === 2) { + // 公羊 - 红色背景 + return { + background: '#fef0f0', + padding: '12px', + borderRadius: '6px', + marginBottom: '15px', + border: '1px solid #fbc4c4' + } + } else { + // 未知 - 默认背景 + return { + background: '#f5f7fa', + padding: '12px', + borderRadius: '6px', + marginBottom: '15px', + border: '1px solid #dcdfe6' + } + } +}) + /** 查询流产记录列表 */ function getList() { loading.value = true @@ -341,6 +409,8 @@ function reset() { status: null, miscaLamb: null } + sheepInfo.value = {} + sheepInfoVisible.value = false proxy.resetForm("miscarriageRef") } @@ -379,22 +449,81 @@ function handleUpdate(row) { form.value.manageTags = response.data.bsManageTags open.value = true title.value = "修改流产记录" + + // 修改时也显示羊只信息 + if (form.value.manageTags) { + handleEarTagChange() + } }) } -/** 耳号输入框失焦事件 */ +/** 耳号输入框失焦事件 - 使用正确的gender字段 */ function handleEarTagChange() { if (form.value.manageTags) { getSheepInfo(form.value.manageTags).then(response => { if (response.data) { - // 这里可以显示羊只相关信息或做验证 - proxy.$modal.msgSuccess("羊只信息验证成功") + sheepInfo.value = response.data + sheepInfoVisible.value = true + + // 检查性别 - gender字段:1=母羊,2=公羊 + const gender = response.data.gender + + if (gender === 2 || gender === '2') { + proxy.$modal.msgError("流产记录只能录入母羊,该耳号【" + form.value.manageTags + "】对应的是公羊!") + // 清空耳号输入框和羊只信息 + setTimeout(() => { + form.value.manageTags = null + sheepInfo.value = {} + sheepInfoVisible.value = false + }, 1500) // 1.5秒后清空,让用户看到错误信息 + return + } else if (gender === 1 || gender === '1') { + proxy.$modal.msgSuccess(`羊只信息验证成功 - 母羊(${response.data.variety || '未知品种'})`) + } else { + proxy.$modal.msgWarning("该羊只性别信息不明确,请谨慎确认是否为母羊") + } + } else { proxy.$modal.msgError("未找到该耳号对应的羊只信息") + form.value.manageTags = null + sheepInfo.value = {} + sheepInfoVisible.value = false } }).catch(() => { - proxy.$modal.msgError("羊只信息查询失败") + proxy.$modal.msgError("羊只信息查询失败,请检查网络连接") + form.value.manageTags = null + sheepInfo.value = {} + sheepInfoVisible.value = false }) + } else { + sheepInfo.value = {} + sheepInfoVisible.value = false + } +} + +/** 获取性别名称 */ +function getSexTypeName(gender) { + switch(gender) { + case 1: + case '1': + return '母羊' + case 2: + case '2': + return '公羊' + default: + return '未知性别' + } +} + +/** 获取羊只信息颜色 */ +function getSheepInfoColor() { + const gender = sheepInfo.value.gender + if (gender === 1) { + return '#67c23a' // 绿色 - 母羊 + } else if (gender === 2) { + return '#f56c6c' // 红色 - 公羊 + } else { + return '#909399' // 灰色 - 未知 } } diff --git a/src/views/sheep_death/death/index.vue b/src/views/sheep_death/death/index.vue index e212dd4..38266b1 100644 --- a/src/views/sheep_death/death/index.vue +++ b/src/views/sheep_death/death/index.vue @@ -26,6 +26,18 @@ placeholder="请选择死亡日期"> + + + @@ -128,8 +140,8 @@ - - + + @@ -167,7 +179,7 @@ /> - + @@ -194,13 +206,32 @@ - - + + - - + + @@ -208,7 +239,7 @@ - + @@ -253,7 +284,7 @@