绝大部分页面修改完成
This commit is contained in:
parent
62b01a0825
commit
d8b2c36521
@ -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'
|
||||
})
|
||||
}
|
||||
@ -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'
|
||||
})
|
||||
}
|
||||
@ -7,6 +7,7 @@
|
||||
placeholder="请输入耳号,多个耳号用逗号分隔"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
@clear="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="孕检日期" prop="datetime">
|
||||
@ -84,6 +85,14 @@
|
||||
v-hasPermi="['Pregnancy_Test:Pregnancy_Test:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="info"
|
||||
plain
|
||||
icon="InfoFilled"
|
||||
@click="handleDebugTest"
|
||||
>调试测试</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
@ -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()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@ -544,4 +627,15 @@ getList()
|
||||
.el-table .cell {
|
||||
padding: 0 5px;
|
||||
}
|
||||
|
||||
/* 调试样式 */
|
||||
.debug-info {
|
||||
background-color: #f0f9ff;
|
||||
border: 1px solid #0ea5e9;
|
||||
border-radius: 4px;
|
||||
padding: 8px;
|
||||
margin: 8px 0;
|
||||
font-size: 12px;
|
||||
color: #0369a1;
|
||||
}
|
||||
</style>
|
||||
@ -161,12 +161,22 @@
|
||||
/>
|
||||
|
||||
<!-- 添加或修改采精记录对话框 -->
|
||||
<el-dialog :title="title" v-model="open" width="600px" append-to-body>
|
||||
<el-form ref="SpermRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-dialog :title="title" v-model="open" width="700px" append-to-body>
|
||||
<el-form ref="SpermRef" :model="form" :rules="rules" label-width="100px">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="耳号" prop="manageTags">
|
||||
<el-input v-model="form.manageTags" placeholder="请输入耳号" />
|
||||
<el-input
|
||||
v-model="form.manageTags"
|
||||
placeholder="请输入耳号"
|
||||
@blur="validateManageTags"
|
||||
:loading="sheepValidation.isValidating"
|
||||
/>
|
||||
<div v-if="sheepValidation.message"
|
||||
:class="['validation-message', sheepValidation.isValid ? 'success' : 'error']">
|
||||
<i :class="sheepValidation.isValid ? 'el-icon-success' : 'el-icon-error'"></i>
|
||||
{{ sheepValidation.message }}
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
@ -175,15 +185,37 @@
|
||||
v-model="form.pickDate"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="请选择采精日期">
|
||||
placeholder="请选择采精日期"
|
||||
style="width: 100%">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<!-- 自动填充的羊只信息 -->
|
||||
<el-row v-if="sheepValidation.sheepInfo">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="电子耳号">
|
||||
<el-input v-model="form.electronicTags" placeholder="自动填充" readonly />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="月龄">
|
||||
<el-input v-model="form.monthAge" placeholder="自动填充" readonly />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="采精量" prop="amount">
|
||||
<el-input v-model="form.amount" placeholder="请输入采精量(ml)" />
|
||||
<el-form-item label="采精量(ml)" prop="amount">
|
||||
<el-input-number
|
||||
v-model="form.amount"
|
||||
placeholder="请输入采精量"
|
||||
:min="0"
|
||||
:precision="1"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
@ -200,7 +232,7 @@
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="是否性控" prop="controlled">
|
||||
<el-select v-model="form.controlled" placeholder="请选择是否性控">
|
||||
<el-select v-model="form.controlled" placeholder="请选择是否性控" style="width: 100%">
|
||||
<el-option label="否" :value="0" />
|
||||
<el-option label="是" :value="1" />
|
||||
</el-select>
|
||||
@ -210,7 +242,11 @@
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="性欲情况" prop="sexualStatus">
|
||||
<el-input v-model="form.sexualStatus" placeholder="请输入性欲情况" />
|
||||
<el-select v-model="form.sexualStatus" placeholder="请选择性欲情况" style="width: 100%">
|
||||
<el-option label="良好" value="良好" />
|
||||
<el-option label="一般" value="一般" />
|
||||
<el-option label="较差" value="较差" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
@ -222,13 +258,19 @@
|
||||
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="阴囊周长" prop="scrotumCircumference">
|
||||
<el-input v-model="form.scrotumCircumference" placeholder="请输入阴囊周长(cm)" />
|
||||
<el-form-item label="阴囊周长(cm)" prop="scrotumCircumference">
|
||||
<el-input-number
|
||||
v-model="form.scrotumCircumference"
|
||||
placeholder="请输入阴囊周长"
|
||||
:min="0"
|
||||
:precision="1"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="精液品质" prop="semenQuality">
|
||||
<el-select v-model="form.semenQuality" placeholder="请选择精液品质">
|
||||
<el-select v-model="form.semenQuality" placeholder="请选择精液品质" style="width: 100%">
|
||||
<el-option label="A级" value="A" />
|
||||
<el-option label="B级" value="B" />
|
||||
<el-option label="C级" value="C" />
|
||||
@ -238,15 +280,15 @@
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="诊疗信息" prop="info">
|
||||
<el-input v-model="form.info" type="textarea" placeholder="请输入诊疗信息" />
|
||||
<el-input v-model="form.info" type="textarea" placeholder="请输入诊疗信息" :rows="2" />
|
||||
</el-form-item>
|
||||
<el-form-item label="采集备注" prop="comment">
|
||||
<el-input v-model="form.comment" type="textarea" placeholder="请输入采集备注" />
|
||||
<el-input v-model="form.comment" type="textarea" placeholder="请输入采集备注" :rows="2" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button type="primary" @click="submitForm" :loading="submitLoading">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
@ -255,7 +297,7 @@
|
||||
</template>
|
||||
|
||||
<script setup name="Sperm">
|
||||
import {listSperm, getSperm, delSperm, addSperm, updateSperm} from "@/api/Sperm/Sperm"
|
||||
import {listSperm, getSperm, delSperm, addSperm, updateSperm, getSheepByManageTags} from "@/api/Sperm/Sperm"
|
||||
|
||||
const {proxy} = getCurrentInstance()
|
||||
|
||||
@ -268,6 +310,15 @@ const single = ref(true)
|
||||
const multiple = ref(true)
|
||||
const total = ref(0)
|
||||
const title = ref("")
|
||||
const submitLoading = ref(false)
|
||||
|
||||
// 羊只验证相关状态
|
||||
const sheepValidation = ref({
|
||||
isValidating: false,
|
||||
isValid: false,
|
||||
message: '',
|
||||
sheepInfo: null
|
||||
})
|
||||
|
||||
const data = reactive({
|
||||
form: {},
|
||||
@ -309,6 +360,9 @@ function getList() {
|
||||
SpermList.value = response.rows
|
||||
total.value = response.total
|
||||
loading.value = false
|
||||
}).catch(error => {
|
||||
loading.value = false
|
||||
proxy.$modal.msgError("查询失败")
|
||||
})
|
||||
}
|
||||
|
||||
@ -323,6 +377,8 @@ function reset() {
|
||||
form.value = {
|
||||
id: null,
|
||||
manageTags: null,
|
||||
electronicTags: null,
|
||||
monthAge: null,
|
||||
pickDate: null,
|
||||
amount: null,
|
||||
density: null,
|
||||
@ -337,6 +393,15 @@ function reset() {
|
||||
createBy: null,
|
||||
createTime: null
|
||||
}
|
||||
|
||||
// 重置验证状态
|
||||
sheepValidation.value = {
|
||||
isValidating: false,
|
||||
isValid: false,
|
||||
message: '',
|
||||
sheepInfo: null
|
||||
}
|
||||
|
||||
proxy.resetForm("SpermRef")
|
||||
}
|
||||
|
||||
@ -372,26 +437,104 @@ function handleUpdate(row) {
|
||||
const _id = row.id || ids.value
|
||||
getSperm(_id).then(response => {
|
||||
form.value = response.data
|
||||
|
||||
// 如果有耳号,自动验证
|
||||
if (form.value.manageTags) {
|
||||
validateManageTags()
|
||||
}
|
||||
|
||||
open.value = true
|
||||
title.value = "修改采精记录"
|
||||
})
|
||||
}
|
||||
|
||||
/** 验证耳号 */
|
||||
const validateManageTags = async () => {
|
||||
if (!form.value.manageTags || form.value.manageTags.trim() === '') {
|
||||
sheepValidation.value = {
|
||||
isValidating: false,
|
||||
isValid: false,
|
||||
message: '',
|
||||
sheepInfo: null
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
sheepValidation.value.isValidating = true
|
||||
|
||||
try {
|
||||
const response = await getSheepByManageTags(form.value.manageTags.trim())
|
||||
if (response.code === 200) {
|
||||
const sheepInfo = response.data.sheepInfo || response.data
|
||||
sheepValidation.value = {
|
||||
isValidating: false,
|
||||
isValid: true,
|
||||
message: response.data.message || '验证通过,该羊只为公羊',
|
||||
sheepInfo: sheepInfo
|
||||
}
|
||||
|
||||
// 自动填充羊只信息
|
||||
if (sheepInfo) {
|
||||
form.value.electronicTags = sheepInfo.electronicTags || ''
|
||||
form.value.monthAge = sheepInfo.monthAge || null
|
||||
}
|
||||
} else {
|
||||
sheepValidation.value = {
|
||||
isValidating: false,
|
||||
isValid: false,
|
||||
message: response.msg || '验证失败',
|
||||
sheepInfo: null
|
||||
}
|
||||
|
||||
// 清空自动填充的信息
|
||||
form.value.electronicTags = ''
|
||||
form.value.monthAge = null
|
||||
}
|
||||
} catch (error) {
|
||||
sheepValidation.value = {
|
||||
isValidating: false,
|
||||
isValid: false,
|
||||
message: '验证失败,请检查网络连接',
|
||||
sheepInfo: null
|
||||
}
|
||||
|
||||
// 清空自动填充的信息
|
||||
form.value.electronicTags = ''
|
||||
form.value.monthAge = null
|
||||
}
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs["SpermRef"].validate(valid => {
|
||||
if (valid) {
|
||||
// 在提交前再次验证耳号
|
||||
if (!sheepValidation.value.isValid && form.value.manageTags) {
|
||||
proxy.$modal.msgError("请先验证耳号是否为公羊")
|
||||
return
|
||||
}
|
||||
|
||||
submitLoading.value = true
|
||||
|
||||
if (form.value.id != null) {
|
||||
updateSperm(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("修改成功")
|
||||
open.value = false
|
||||
getList()
|
||||
}).catch(error => {
|
||||
proxy.$modal.msgError(error.response?.data?.msg || "修改失败")
|
||||
}).finally(() => {
|
||||
submitLoading.value = false
|
||||
})
|
||||
} else {
|
||||
addSperm(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("新增成功")
|
||||
open.value = false
|
||||
getList()
|
||||
}).catch(error => {
|
||||
proxy.$modal.msgError(error.response?.data?.msg || "新增失败")
|
||||
}).finally(() => {
|
||||
submitLoading.value = false
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -417,5 +560,41 @@ function handleExport() {
|
||||
}, `Sperm_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
|
||||
// 页面加载时获取数据
|
||||
getList()
|
||||
</script>
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.validation-message {
|
||||
font-size: 12px;
|
||||
margin-top: 4px;
|
||||
padding: 2px 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.validation-message.success {
|
||||
color: #67c23a;
|
||||
}
|
||||
|
||||
.validation-message.error {
|
||||
color: #f56c6c;
|
||||
}
|
||||
|
||||
.el-input-number {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.app-container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.mb8 {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
</style>
|
||||
@ -70,12 +70,14 @@
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="繁育状态" prop="breedingStatus">
|
||||
<el-select v-model="queryParams.breedingStatus" placeholder="请选择繁育状态" clearable>
|
||||
<el-option label="未配种" value="未配种"></el-option>
|
||||
<el-option label="已配种" value="已配种"></el-option>
|
||||
<!-- 修改后的选项,与数据库实际值保持一致 -->
|
||||
<el-form-item label="繁殖状态" prop="breedingStatus">
|
||||
<el-select v-model="queryParams.breedingStatus" placeholder="请选择繁殖状态" clearable>
|
||||
<el-option label="后备" value="后备"></el-option>
|
||||
<el-option label="已配" value="已配"></el-option>
|
||||
<el-option label="可配" value="可配"></el-option>
|
||||
<el-option label="妊娠" value="妊娠"></el-option>
|
||||
<el-option label="产羔" value="产羔"></el-option>
|
||||
<el-option label="公羊" value="公羊"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
|
||||
@ -165,9 +165,12 @@
|
||||
<el-form-item label="耳号" prop="manageTags">
|
||||
<el-input
|
||||
v-model="form.manageTags"
|
||||
placeholder="请输入羊只耳号"
|
||||
placeholder="请输入母羊耳号"
|
||||
@blur="handleEarTagChange"
|
||||
/>
|
||||
<div style="font-size: 12px; color: #909399; margin-top: 4px;">
|
||||
注意:只能录入母羊的流产记录
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
@ -182,6 +185,36 @@
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<!-- 羊只信息显示区域 -->
|
||||
<el-row v-if="sheepInfoVisible">
|
||||
<el-col :span="24">
|
||||
<div class="sheep-info-card" :style="sheepInfoCardStyle">
|
||||
<h4 style="margin: 0 0 10px 0;" :style="{ color: getSheepInfoColor() }">
|
||||
羊只信息 - {{ getSexTypeName(sheepInfo.gender) }}
|
||||
</h4>
|
||||
<el-row :gutter="10">
|
||||
<el-col :span="8">
|
||||
<span><strong>品种:</strong> {{ sheepInfo.variety || '-' }}</span>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<span><strong>胎次:</strong> {{ sheepInfo.parity || '-' }}</span>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<span><strong>月龄:</strong> {{ sheepInfo.month_age || '-' }}</span>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="10" style="margin-top: 8px;">
|
||||
<el-col :span="12">
|
||||
<span><strong>羊舍:</strong> {{ sheepInfo.sheepfold_name || '-' }}</span>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<span><strong>牧场:</strong> {{ sheepInfo.dr_ranch || '-' }}</span>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="流产原因" prop="reason">
|
||||
@ -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' // 灰色 - 未知
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -26,6 +26,18 @@
|
||||
placeholder="请选择死亡日期">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="疾病类型" prop="diseaseTypeId">
|
||||
<el-tree-select
|
||||
v-model="queryParams.diseaseTypeId"
|
||||
:data="diseaseOptions"
|
||||
:props="{ value: 'id', label: 'name', children: 'children' }"
|
||||
value-key="id"
|
||||
placeholder="请选择疾病类型"
|
||||
check-strictly
|
||||
clearable
|
||||
style="width: 200px;"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="死淘去向" prop="disposalDirection">
|
||||
<el-select v-model="queryParams.disposalDirection" placeholder="请选择死淘去向" clearable>
|
||||
<el-option label="深埋" value="深埋" />
|
||||
@ -128,8 +140,8 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="日龄" align="center" prop="dayAge" width="80"/>
|
||||
<el-table-column label="胎次" align="center" prop="parity" width="80"/>
|
||||
<el-table-column label="疾病类型ID" align="center" prop="diseaseTypeId" width="120"/>
|
||||
<el-table-column label="疾病子类型ID" align="center" prop="diseaseSubtypeId" width="130"/>
|
||||
<el-table-column label="疾病类型" align="center" prop="diseaseTypeName" width="120"/>
|
||||
<el-table-column label="疾病子类型" align="center" prop="diseaseSubtypeName" width="130"/>
|
||||
<el-table-column label="死淘去向" align="center" prop="disposalDirection" width="100"/>
|
||||
<el-table-column label="技术员" align="center" prop="technician" width="100"/>
|
||||
<el-table-column label="处理人" align="center" prop="handler" width="100"/>
|
||||
@ -167,7 +179,7 @@
|
||||
/>
|
||||
|
||||
<!-- 添加或修改羊只死淘记录对话框 -->
|
||||
<el-dialog :title="title" v-model="open" width="600px" append-to-body>
|
||||
<el-dialog :title="title" v-model="open" width="700px" append-to-body>
|
||||
<el-form ref="deathRef" :model="form" :rules="rules" label-width="120px">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
@ -194,13 +206,32 @@
|
||||
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="疾病类型ID" prop="diseaseTypeId">
|
||||
<el-input-number v-model="form.diseaseTypeId" placeholder="请输入疾病类型ID" :min="0"/>
|
||||
<el-form-item label="疾病类型" prop="diseaseTypeId">
|
||||
<el-tree-select
|
||||
v-model="form.diseaseTypeId"
|
||||
:data="diseaseOptions"
|
||||
:props="{ value: 'id', label: 'name', children: 'children' }"
|
||||
value-key="id"
|
||||
placeholder="请选择疾病类型"
|
||||
check-strictly
|
||||
clearable
|
||||
@change="onDiseaseTypeChange"
|
||||
style="width: 100%;"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="疾病子类型ID" prop="diseaseSubtypeId">
|
||||
<el-input-number v-model="form.diseaseSubtypeId" placeholder="请输入疾病子类型ID" :min="0"/>
|
||||
<el-form-item label="疾病子类型" prop="diseaseSubtypeId">
|
||||
<el-tree-select
|
||||
v-model="form.diseaseSubtypeId"
|
||||
:data="diseaseSubtypeOptions"
|
||||
:props="{ value: 'id', label: 'name', children: 'children' }"
|
||||
value-key="id"
|
||||
placeholder="请选择疾病子类型"
|
||||
check-strictly
|
||||
clearable
|
||||
style="width: 100%;"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@ -208,7 +239,7 @@
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="死淘去向" prop="disposalDirection">
|
||||
<el-select v-model="form.disposalDirection" placeholder="请选择死淘去向">
|
||||
<el-select v-model="form.disposalDirection" placeholder="请选择死淘去向" style="width: 100%;">
|
||||
<el-option label="深埋" value="深埋"/>
|
||||
<el-option label="无害化" value="无害化"/>
|
||||
</el-select>
|
||||
@ -253,7 +284,7 @@
|
||||
</template>
|
||||
|
||||
<script setup name="Death">
|
||||
import {listDeath, getDeath, delDeath, addDeath, updateDeath, getSheepInfo} from "@/api/sheep_death/death"
|
||||
import {listDeath, getDeath, delDeath, addDeath, updateDeath, getSheepInfo, getDiseaseTree} from "@/api/sheep_death/death"
|
||||
|
||||
const {proxy} = getCurrentInstance()
|
||||
|
||||
@ -267,6 +298,8 @@ const multiple = ref(true)
|
||||
const total = ref(0)
|
||||
const title = ref("")
|
||||
const validatingTags = ref(false) // 验证管理耳号的loading状态
|
||||
const diseaseOptions = ref([]) // 疾病类型选项
|
||||
const diseaseSubtypeOptions = ref([]) // 疾病子类型选项
|
||||
|
||||
const data = reactive({
|
||||
form: {},
|
||||
@ -307,6 +340,42 @@ function getList() {
|
||||
})
|
||||
}
|
||||
|
||||
/** 获取疾病树形列表 */
|
||||
function getDiseaseTreeData() {
|
||||
getDiseaseTree().then(response => {
|
||||
if (response.code === 200) {
|
||||
// 构建树形结构
|
||||
diseaseOptions.value = proxy.handleTree(response.data, "id", "pid")
|
||||
}
|
||||
}).catch(() => {
|
||||
proxy.$modal.msgError("获取疾病列表失败")
|
||||
})
|
||||
}
|
||||
|
||||
/** 疾病类型改变时,更新子类型选项 */
|
||||
function onDiseaseTypeChange(value) {
|
||||
form.value.diseaseSubtypeId = null // 清空子类型选择
|
||||
diseaseSubtypeOptions.value = []
|
||||
|
||||
if (value) {
|
||||
// 查找选中疾病类型的子类型
|
||||
const findChildren = (nodes, targetId) => {
|
||||
for (const node of nodes) {
|
||||
if (node.id === targetId) {
|
||||
return node.children || []
|
||||
}
|
||||
if (node.children) {
|
||||
const result = findChildren(node.children, targetId)
|
||||
if (result.length > 0) return result
|
||||
}
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
diseaseSubtypeOptions.value = findChildren(diseaseOptions.value, value)
|
||||
}
|
||||
}
|
||||
|
||||
/** 验证查询条件中的管理耳号 */
|
||||
function validateManageTagsInQuery() {
|
||||
const manageTags = queryParams.value.manageTags
|
||||
@ -337,7 +406,7 @@ function validateManageTags(manageTags, source) {
|
||||
proxy.$modal.msgSuccess("耳号验证成功")
|
||||
}
|
||||
} else {
|
||||
// 耳号不存在时清除输入并提示
|
||||
// 耳号不存在时清空输入并提示
|
||||
if (source === 'form') {
|
||||
form.value.manageTags = null
|
||||
} else {
|
||||
@ -346,7 +415,7 @@ function validateManageTags(manageTags, source) {
|
||||
proxy.$modal.msgError("该耳号不存在")
|
||||
}
|
||||
}).catch(error => {
|
||||
// 验证失败时清除输入并提示
|
||||
// 验证失败时清空输入并提示
|
||||
if (source === 'form') {
|
||||
form.value.manageTags = null
|
||||
} else {
|
||||
@ -385,6 +454,8 @@ function reset() {
|
||||
updateTime: null,
|
||||
isDelete: null
|
||||
}
|
||||
// 重置子类型选项
|
||||
diseaseSubtypeOptions.value = []
|
||||
proxy.resetForm("deathRef")
|
||||
}
|
||||
|
||||
@ -410,6 +481,7 @@ function handleSelectionChange(selection) {
|
||||
/** 新增按钮操作 */
|
||||
function handleAdd() {
|
||||
reset()
|
||||
getDiseaseTreeData() // 获取疾病数据
|
||||
open.value = true
|
||||
title.value = "添加羊只死淘记录"
|
||||
}
|
||||
@ -417,9 +489,14 @@ function handleAdd() {
|
||||
/** 修改按钮操作 */
|
||||
function handleUpdate(row) {
|
||||
reset()
|
||||
getDiseaseTreeData() // 获取疾病数据
|
||||
const _id = row.id || ids.value
|
||||
getDeath(_id).then(response => {
|
||||
form.value = response.data
|
||||
// 如果有疾病类型,需要设置子类型选项
|
||||
if (form.value.diseaseTypeId) {
|
||||
onDiseaseTypeChange(form.value.diseaseTypeId)
|
||||
}
|
||||
open.value = true
|
||||
title.value = "修改羊只死淘记录"
|
||||
})
|
||||
@ -465,6 +542,8 @@ function handleExport() {
|
||||
}, `death_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
|
||||
// 初始化
|
||||
getDiseaseTreeData()
|
||||
getList()
|
||||
</script>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user