This commit is contained in:
ll 2025-09-08 10:02:18 +08:00
commit dbd160ff31
15 changed files with 2195 additions and 158 deletions

View File

@ -43,7 +43,7 @@ export function delSperm(id) {
}) })
} }
// 根据耳号查询羊只信息 // 根据耳号查询羊只信息(带性别验证)
export function getSheepByManageTags(manageTags) { export function getSheepByManageTags(manageTags) {
return request({ return request({
url: '/Sperm/Sperm/getSheepByManageTags/' + manageTags, url: '/Sperm/Sperm/getSheepByManageTags/' + manageTags,
@ -51,11 +51,28 @@ export function getSheepByManageTags(manageTags) {
}) })
} }
// 查询羊只耳号列表(用于下拉选择) // 验证羊只是否为公羊
export function getSheepManageTagsList(query) { export function validateRam(manageTags) {
return request({ return request({
url: '/Sperm/Sperm/sheepManageTagsList', url: '/Sperm/Sperm/validateRam/' + manageTags,
method: 'get', method: 'get'
params: query })
}
// 根据耳号查询羊只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'
}) })
} }

View File

@ -61,3 +61,12 @@ export function addByEarTags(data) {
data data
}) })
} }
// 树形分组
export const listGroupTree = () =>
request({
url: '/sheep_grouping/sheep_grouping/group/tree',
method: 'get'
})

View File

@ -55,3 +55,11 @@ export function checkSheepfoldNoExist(ranchId, sheepfoldTypeId, sheepfoldNo) {
} }
}) })
} }
// 获取树形座位图(牧场 → 类型 → 羊舍 → 排栏)
export function getSeatMap() {
return request({
url: '/sheepfold_management/sheepfold_management/seatMap',
method: 'get'
})
}

View File

@ -50,3 +50,11 @@ export function getSheepInfo(manageTags) {
method: 'get' method: 'get'
}) })
} }
// 获取疾病树形列表
export function getDiseaseTree() {
return request({
url: '/sheep_death/death/disease/tree',
method: 'get'
})
}

View File

@ -7,6 +7,7 @@
placeholder="请输入耳号,多个耳号用逗号分隔" placeholder="请输入耳号,多个耳号用逗号分隔"
clearable clearable
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
@clear="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="孕检日期" prop="datetime"> <el-form-item label="孕检日期" prop="datetime">
@ -84,6 +85,14 @@
v-hasPermi="['Pregnancy_Test:Pregnancy_Test:export']" v-hasPermi="['Pregnancy_Test:Pregnancy_Test:export']"
>导出</el-button> >导出</el-button>
</el-col> </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> <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
@ -372,9 +381,26 @@ function onResultChange(value) {
/** 查询孕检记录列表 */ /** 查询孕检记录列表 */
function getList() { function getList() {
loading.value = true loading.value = true
console.log("发送查询请求,参数:", queryParams.value)
listPregnancy_Test(queryParams.value).then(response => { listPregnancy_Test(queryParams.value).then(response => {
Pregnancy_TestList.value = response.rows console.log("查询响应:", response)
total.value = response.total 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 loading.value = false
}) })
} }
@ -382,27 +408,35 @@ function getList() {
/** 根据耳号获取羊只信息和配种信息 */ /** 根据耳号获取羊只信息和配种信息 */
function getSheepAndBreedInfo() { function getSheepAndBreedInfo() {
if (form.value.manageTags) { 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) { if (response.data) {
form.value.sheepId = response.data.id form.value.sheepId = response.data.id
console.log("找到羊只ID", response.data.id)
} else { } else {
proxy.$modal.msgError("未找到该耳号的羊只信息") proxy.$modal.msgError("未找到该耳号的羊只信息")
form.value.sheepId = null form.value.sheepId = null
} }
}).catch(() => { }).catch(error => {
console.error("查询羊只信息失败:", error)
proxy.$modal.msgError("查询羊只信息失败") proxy.$modal.msgError("查询羊只信息失败")
form.value.sheepId = null form.value.sheepId = null
}) })
// //
getBreedInfoByManageTags(form.value.manageTags).then(response => { getBreedInfoByManageTags(cleanTag).then(response => {
console.log("配种信息响应:", response)
if (response.data) { if (response.data) {
breedInfo.value = response.data breedInfo.value = response.data
} else { } else {
breedInfo.value = {} breedInfo.value = {}
} }
}).catch(() => { }).catch(error => {
console.error("查询配种信息失败:", error)
breedInfo.value = {} breedInfo.value = {}
}) })
} }
@ -435,13 +469,30 @@ function reset() {
/** 搜索按钮操作 */ /** 搜索按钮操作 */
function handleQuery() { 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 queryParams.value.pageNum = 1
getList() getList()
} }
/** 重置按钮操作 */ /** 重置按钮操作 */
function resetQuery() { function resetQuery() {
console.log("重置搜索条件")
proxy.resetForm("queryRef") proxy.resetForm("queryRef")
queryParams.value.manageTags = null
queryParams.value.datetime = null
queryParams.value.result = null
queryParams.value.technician = null
queryParams.value.way = null
handleQuery() handleQuery()
} }
@ -479,6 +530,19 @@ function handleUpdate(row) {
function submitForm() { function submitForm() {
proxy.$refs["Pregnancy_TestRef"].validate(valid => { proxy.$refs["Pregnancy_TestRef"].validate(valid => {
if (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) { if (form.value.id != null) {
updatePregnancy_Test(form.value).then(response => { updatePregnancy_Test(form.value).then(response => {
console.log("修改成功响应", response) console.log("修改成功响应", response)
@ -494,7 +558,7 @@ function submitForm() {
}) })
} else { } else {
addPregnancy_Test(form.value).then(response => { addPregnancy_Test(form.value).then(response => {
console.log("新增成功响应", response) // console.log("新增成功响应", response)
if (response && response.code === 200) { if (response && response.code === 200) {
proxy.$modal.msgSuccess("新增成功") proxy.$modal.msgSuccess("新增成功")
open.value = false open.value = false
@ -533,7 +597,26 @@ function handleExport() {
}, `Pregnancy_Test_${new Date().getTime()}.xlsx`) }, `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> </script>
<style scoped> <style scoped>
@ -544,4 +627,15 @@ getList()
.el-table .cell { .el-table .cell {
padding: 0 5px; 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> </style>

View File

@ -161,12 +161,22 @@
/> />
<!-- 添加或修改采精记录对话框 --> <!-- 添加或修改采精记录对话框 -->
<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="SpermRef" :model="form" :rules="rules" label-width="80px"> <el-form ref="SpermRef" :model="form" :rules="rules" label-width="100px">
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="耳号" prop="manageTags"> <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-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
@ -175,15 +185,37 @@
v-model="form.pickDate" v-model="form.pickDate"
type="date" type="date"
value-format="YYYY-MM-DD" value-format="YYYY-MM-DD"
placeholder="请选择采精日期"> placeholder="请选择采精日期"
style="width: 100%">
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </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-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="采精量" prop="amount"> <el-form-item label="采精量(ml)" prop="amount">
<el-input v-model="form.amount" placeholder="请输入采精量(ml)" /> <el-input-number
v-model="form.amount"
placeholder="请输入采精量"
:min="0"
:precision="1"
style="width: 100%"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
@ -200,7 +232,7 @@
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="是否性控" prop="controlled"> <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="0" />
<el-option label="是" :value="1" /> <el-option label="是" :value="1" />
</el-select> </el-select>
@ -210,7 +242,11 @@
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="性欲情况" prop="sexualStatus"> <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-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
@ -222,13 +258,19 @@
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="阴囊周长" prop="scrotumCircumference"> <el-form-item label="阴囊周长(cm)" prop="scrotumCircumference">
<el-input v-model="form.scrotumCircumference" placeholder="请输入阴囊周长(cm)" /> <el-input-number
v-model="form.scrotumCircumference"
placeholder="请输入阴囊周长"
:min="0"
:precision="1"
style="width: 100%"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="精液品质" prop="semenQuality"> <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="A级" value="A" />
<el-option label="B级" value="B" /> <el-option label="B级" value="B" />
<el-option label="C级" value="C" /> <el-option label="C级" value="C" />
@ -238,15 +280,15 @@
</el-col> </el-col>
</el-row> </el-row>
<el-form-item label="诊疗信息" prop="info"> <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>
<el-form-item label="采集备注" prop="comment"> <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-item>
</el-form> </el-form>
<template #footer> <template #footer>
<div class="dialog-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> <el-button @click="cancel"> </el-button>
</div> </div>
</template> </template>
@ -255,7 +297,7 @@
</template> </template>
<script setup name="Sperm"> <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() const {proxy} = getCurrentInstance()
@ -268,6 +310,15 @@ const single = ref(true)
const multiple = ref(true) const multiple = ref(true)
const total = ref(0) const total = ref(0)
const title = ref("") const title = ref("")
const submitLoading = ref(false)
//
const sheepValidation = ref({
isValidating: false,
isValid: false,
message: '',
sheepInfo: null
})
const data = reactive({ const data = reactive({
form: {}, form: {},
@ -309,6 +360,9 @@ function getList() {
SpermList.value = response.rows SpermList.value = response.rows
total.value = response.total total.value = response.total
loading.value = false loading.value = false
}).catch(error => {
loading.value = false
proxy.$modal.msgError("查询失败")
}) })
} }
@ -323,6 +377,8 @@ function reset() {
form.value = { form.value = {
id: null, id: null,
manageTags: null, manageTags: null,
electronicTags: null,
monthAge: null,
pickDate: null, pickDate: null,
amount: null, amount: null,
density: null, density: null,
@ -337,6 +393,15 @@ function reset() {
createBy: null, createBy: null,
createTime: null createTime: null
} }
//
sheepValidation.value = {
isValidating: false,
isValid: false,
message: '',
sheepInfo: null
}
proxy.resetForm("SpermRef") proxy.resetForm("SpermRef")
} }
@ -372,26 +437,104 @@ function handleUpdate(row) {
const _id = row.id || ids.value const _id = row.id || ids.value
getSperm(_id).then(response => { getSperm(_id).then(response => {
form.value = response.data form.value = response.data
//
if (form.value.manageTags) {
validateManageTags()
}
open.value = true open.value = true
title.value = "修改采精记录" 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() { function submitForm() {
proxy.$refs["SpermRef"].validate(valid => { proxy.$refs["SpermRef"].validate(valid => {
if (valid) { if (valid) {
//
if (!sheepValidation.value.isValid && form.value.manageTags) {
proxy.$modal.msgError("请先验证耳号是否为公羊")
return
}
submitLoading.value = true
if (form.value.id != null) { if (form.value.id != null) {
updateSperm(form.value).then(response => { updateSperm(form.value).then(response => {
proxy.$modal.msgSuccess("修改成功") proxy.$modal.msgSuccess("修改成功")
open.value = false open.value = false
getList() getList()
}).catch(error => {
proxy.$modal.msgError(error.response?.data?.msg || "修改失败")
}).finally(() => {
submitLoading.value = false
}) })
} else { } else {
addSperm(form.value).then(response => { addSperm(form.value).then(response => {
proxy.$modal.msgSuccess("新增成功") proxy.$modal.msgSuccess("新增成功")
open.value = false open.value = false
getList() 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`) }, `Sperm_${new Date().getTime()}.xlsx`)
} }
//
getList() 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>

View File

@ -70,12 +70,14 @@
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="繁育状态" prop="breedingStatus"> <!-- 修改后的选项与数据库实际值保持一致 -->
<el-select v-model="queryParams.breedingStatus" placeholder="请选择繁育状态" clearable> <el-form-item label="繁殖状态" prop="breedingStatus">
<el-option label="未配种" value="未配种"></el-option> <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-option label="产羔" value="产羔"></el-option> <el-option label="公羊" value="公羊"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px"> <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px" @submit.prevent>
<el-form-item label="分组名称" prop="groupName"> <el-form-item label="分组名称" prop="groupName">
<el-input <el-input
v-model="queryParams.groupName" v-model="queryParams.groupName"
@ -20,7 +20,7 @@
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> <el-button type="primary" icon="Search" @click="handleQuery" native-type="button"> 搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button> <el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -256,38 +256,71 @@ async function handleUpdate(row) {
}) })
} }
/** 提交按钮 */
// function submitForm() {
// proxy.$refs["group_managementRef"].validate(valid => {
// if (valid) {
// //
// if (form.value.parentId === 0) {
// form.value.ancestors = "0"
// } else {
// const parentNode = findNode(group_managementOptions.value, form.value.parentId)
// if (parentNode) {
// form.value.ancestors = `${parentNode.ancestors},${parentNode.groupId}`
// } else {
// // 使
// form.value.ancestors = "0"
// }
// }
// if (form.value.groupId != null) {
// updateGroup_management(form.value).then(response => {
// proxy.$modal.msgSuccess("")
// open.value = false
// getList()
// })
// } else {
// addGroup_management(form.value).then(response => {
// proxy.$modal.msgSuccess("")
// open.value = false
// getList()
// })
// }
// }
// })
// }
/** 提交按钮 */ /** 提交按钮 */
function submitForm() { function submitForm() {
proxy.$refs["group_managementRef"].validate(valid => { proxy.$refs["group_managementRef"].validate(valid => {
if (valid) { if (!valid) return;
//
if (form.value.parentId === 0) {
form.value.ancestors = "0"
} else {
const parentNode = findNode(group_managementOptions.value, form.value.parentId)
if (parentNode) {
form.value.ancestors = `${parentNode.ancestors},${parentNode.groupId}`
} else {
// 使
form.value.ancestors = "0"
}
}
if (form.value.groupId != null) { //
updateGroup_management(form.value).then(response => { if (form.value.parentId === 0) {
proxy.$modal.msgSuccess("修改成功") form.value.ancestors = "0";
open.value = false } else {
getList() const parentNode = findNode(group_managementOptions.value, form.value.parentId);
}) form.value.ancestors = parentNode
} else { ? `${parentNode.ancestors},${parentNode.groupId}`
addGroup_management(form.value).then(response => { : "0";
proxy.$modal.msgSuccess("新增成功")
open.value = false
getList()
})
}
} }
})
const request = form.value.groupId != null
? updateGroup_management(form.value)
: addGroup_management(form.value);
request
.then(() => {
proxy.$modal.msgSuccess(form.value.groupId ? "修改成功" : "新增成功");
open.value = false;
getList();
})
.catch(error => {
//
const msg = error?.response?.data?.msg || "操作失败";
proxy.$modal.msgError(msg);
});
});
} }
/** 删除按钮操作 */ /** 删除按钮操作 */

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,18 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px"> <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="羊只id" prop="id"> <!-- <el-form-item label="羊只id" prop="id">
<el-input <el-input
v-model="queryParams.id" v-model="queryParams.id"
placeholder="请输入羊只id" placeholder="请输入羊只id"
clearable clearable
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
/> />
</el-form-item> </el-form-item> -->
<el-form-item label="管理耳号" prop="bsManageTags"> <el-form-item label="耳号" prop="bsManageTags">
<el-input <el-input
v-model="queryParams.bsManageTags" v-model="queryParams.bsManageTags"
placeholder="请输入管理耳号" placeholder="请输入耳号"
clearable clearable
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
/> />
@ -66,7 +66,7 @@
border border
> >
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column <!-- <el-table-column
v-if="columns['id'].visible" v-if="columns['id'].visible"
label="羊只id" label="羊只id"
align="center" align="center"
@ -78,10 +78,10 @@
<template #header> <template #header>
<span style="font-weight: bold; color: #333;">羊只id</span> <span style="font-weight: bold; color: #333;">羊只id</span>
</template> </template>
</el-table-column> </el-table-column> -->
<el-table-column <el-table-column
v-if="columns['bsManageTags'].visible" v-if="columns['bsManageTags'].visible"
label="管理耳号" label="耳号"
align="center" align="center"
prop="bsManageTags" prop="bsManageTags"
width="120" width="120"
@ -89,10 +89,10 @@
sortable sortable
> >
<template #header> <template #header>
<span style="font-weight: bold; color: #333;">管理耳号</span> <span style="font-weight: bold; color: #333;">耳号</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <!-- <el-table-column
v-if="columns['ranchId'].visible" v-if="columns['ranchId'].visible"
label="牧场id" label="牧场id"
align="center" align="center"
@ -103,7 +103,7 @@
<template #header> <template #header>
<span style="font-weight: bold; color: #333;">牧场id</span> <span style="font-weight: bold; color: #333;">牧场id</span>
</template> </template>
</el-table-column> </el-table-column> -->
<el-table-column <el-table-column
v-if="columns['drRanch'].visible" v-if="columns['drRanch'].visible"
label="牧场名称" label="牧场名称"
@ -116,7 +116,7 @@
<span style="font-weight: bold; color: #333;">牧场名称</span> <span style="font-weight: bold; color: #333;">牧场名称</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <!-- <el-table-column
v-if="columns['sheepfoldId'].visible" v-if="columns['sheepfoldId'].visible"
label="羊舍id" label="羊舍id"
align="center" align="center"
@ -127,7 +127,7 @@
<template #header> <template #header>
<span style="font-weight: bold; color: #333;">羊舍id</span> <span style="font-weight: bold; color: #333;">羊舍id</span>
</template> </template>
</el-table-column> </el-table-column> -->
<el-table-column <el-table-column
v-if="columns['sheepfoldName'].visible" v-if="columns['sheepfoldName'].visible"
label="羊舍名称" label="羊舍名称"
@ -166,7 +166,7 @@
</el-tooltip> </el-tooltip>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <!-- <el-table-column
v-if="columns['varietyId'].visible" v-if="columns['varietyId'].visible"
label="品种id" label="品种id"
align="center" align="center"
@ -177,7 +177,7 @@
<template #header> <template #header>
<span style="font-weight: bold; color: #333;">品种id</span> <span style="font-weight: bold; color: #333;">品种id</span>
</template> </template>
</el-table-column> </el-table-column> -->
<el-table-column <el-table-column
v-if="columns['variety'].visible" v-if="columns['variety'].visible"
label="品种" label="品种"
@ -346,7 +346,7 @@
<span style="font-weight: bold; color: #333;">当前体重</span> <span style="font-weight: bold; color: #333;">当前体重</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <!-- <el-table-column
v-if="columns['breedStatusId'].visible" v-if="columns['breedStatusId'].visible"
label="繁育状态id" label="繁育状态id"
align="center" align="center"
@ -357,7 +357,7 @@
<template #header> <template #header>
<span style="font-weight: bold; color: #333;">繁育状态id</span> <span style="font-weight: bold; color: #333;">繁育状态id</span>
</template> </template>
</el-table-column> </el-table-column> -->
<el-table-column <el-table-column
v-if="columns['breed'].visible" v-if="columns['breed'].visible"
label="繁殖状态" label="繁殖状态"
@ -370,7 +370,7 @@
<span style="font-weight: bold; color: #333;">繁殖状态</span> <span style="font-weight: bold; color: #333;">繁殖状态</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <!-- <el-table-column
v-if="columns['bsFatherId'].visible" v-if="columns['bsFatherId'].visible"
label="父号id" label="父号id"
align="center" align="center"
@ -381,20 +381,20 @@
<template #header> <template #header>
<span style="font-weight: bold; color: #333;">父号id</span> <span style="font-weight: bold; color: #333;">父号id</span>
</template> </template>
</el-table-column> </el-table-column> -->
<el-table-column <el-table-column
v-if="columns['fatherManageTags'].visible" v-if="columns['fatherManageTags'].visible"
label="父亲管理耳号" label="父亲耳号"
align="center" align="center"
prop="fatherManageTags" prop="fatherManageTags"
width="120" width="120"
sortable sortable
> >
<template #header> <template #header>
<span style="font-weight: bold; color: #333;">父亲管理耳号</span> <span style="font-weight: bold; color: #333;">父亲耳号</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <!-- <el-table-column
v-if="columns['bsMotherId'].visible" v-if="columns['bsMotherId'].visible"
label="母号id" label="母号id"
align="center" align="center"
@ -405,20 +405,20 @@
<template #header> <template #header>
<span style="font-weight: bold; color: #333;">母号id</span> <span style="font-weight: bold; color: #333;">母号id</span>
</template> </template>
</el-table-column> </el-table-column> -->
<el-table-column <el-table-column
v-if="columns['motherManageTags'].visible" v-if="columns['motherManageTags'].visible"
label="母亲管理耳号" label="母亲耳号"
align="center" align="center"
prop="motherManageTags" prop="motherManageTags"
width="120" width="120"
sortable sortable
> >
<template #header> <template #header>
<span style="font-weight: bold; color: #333;">母亲管理耳号</span> <span style="font-weight: bold; color: #333;">母亲耳号</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <!-- <el-table-column
v-if="columns['receptorId'].visible" v-if="columns['receptorId'].visible"
label="受体id" label="受体id"
align="center" align="center"
@ -429,20 +429,20 @@
<template #header> <template #header>
<span style="font-weight: bold; color: #333;">受体id</span> <span style="font-weight: bold; color: #333;">受体id</span>
</template> </template>
</el-table-column> </el-table-column> -->
<el-table-column <el-table-column
v-if="columns['receptorManageTags'].visible" v-if="columns['receptorManageTags'].visible"
label="受体管理耳号" label="受体耳号"
align="center" align="center"
prop="receptorManageTags" prop="receptorManageTags"
width="120" width="120"
sortable sortable
> >
<template #header> <template #header>
<span style="font-weight: bold; color: #333;">受体管理耳号</span> <span style="font-weight: bold; color: #333;">受体耳号</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <!-- <el-table-column
v-if="columns['fatherFatherId'].visible" v-if="columns['fatherFatherId'].visible"
label="祖父号id" label="祖父号id"
align="center" align="center"
@ -453,20 +453,20 @@
<template #header> <template #header>
<span style="font-weight: bold; color: #333;">祖父号id</span> <span style="font-weight: bold; color: #333;">祖父号id</span>
</template> </template>
</el-table-column> </el-table-column> -->
<el-table-column <el-table-column
v-if="columns['grandfatherManageTags'].visible" v-if="columns['grandfatherManageTags'].visible"
label="祖父管理耳号" label="祖父耳号"
align="center" align="center"
prop="grandfatherManageTags" prop="grandfatherManageTags"
width="120" width="120"
sortable sortable
> >
<template #header> <template #header>
<span style="font-weight: bold; color: #333;">祖父管理耳号</span> <span style="font-weight: bold; color: #333;">祖父耳号</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <!-- <el-table-column
v-if="columns['fatherMotherId'].visible" v-if="columns['fatherMotherId'].visible"
label="祖母号id" label="祖母号id"
align="center" align="center"
@ -477,20 +477,20 @@
<template #header> <template #header>
<span style="font-weight: bold; color: #333;">祖母号id</span> <span style="font-weight: bold; color: #333;">祖母号id</span>
</template> </template>
</el-table-column> </el-table-column> -->
<el-table-column <el-table-column
v-if="columns['grandmotherManageTags'].visible" v-if="columns['grandmotherManageTags'].visible"
label="祖母管理耳号" label="祖母耳号"
align="center" align="center"
prop="grandmotherManageTags" prop="grandmotherManageTags"
width="120" width="120"
sortable sortable
> >
<template #header> <template #header>
<span style="font-weight: bold; color: #333;">祖母管理耳号</span> <span style="font-weight: bold; color: #333;">祖母耳号</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <!-- <el-table-column
v-if="columns['fatherId'].visible" v-if="columns['fatherId'].visible"
label="外祖父号id" label="外祖父号id"
align="center" align="center"
@ -501,20 +501,20 @@
<template #header> <template #header>
<span style="font-weight: bold; color: #333;">外祖父号id</span> <span style="font-weight: bold; color: #333;">外祖父号id</span>
</template> </template>
</el-table-column> </el-table-column> -->
<el-table-column <el-table-column
v-if="columns['maternalGrandfatherManageTags'].visible" v-if="columns['maternalGrandfatherManageTags'].visible"
label="外祖父管理耳号" label="外祖父耳号"
align="center" align="center"
prop="maternalGrandfatherManageTags" prop="maternalGrandfatherManageTags"
width="120" width="120"
sortable sortable
> >
<template #header> <template #header>
<span style="font-weight: bold; color: #333;">外祖父管理耳号</span> <span style="font-weight: bold; color: #333;">外祖父耳号</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <!-- <el-table-column
v-if="columns['motherId'].visible" v-if="columns['motherId'].visible"
label="外祖母号id" label="外祖母号id"
align="center" align="center"
@ -525,17 +525,17 @@
<template #header> <template #header>
<span style="font-weight: bold; color: #333;">外祖母号id</span> <span style="font-weight: bold; color: #333;">外祖母号id</span>
</template> </template>
</el-table-column> </el-table-column> -->
<el-table-column <el-table-column
v-if="columns['maternalGrandmotherManageTags'].visible" v-if="columns['maternalGrandmotherManageTags'].visible"
label="外祖母管理耳号" label="外祖母耳号"
align="center" align="center"
prop="maternalGrandmotherManageTags" prop="maternalGrandmotherManageTags"
width="120" width="120"
sortable sortable
> >
<template #header> <template #header>
<span style="font-weight: bold; color: #333;">外祖母管理耳号</span> <span style="font-weight: bold; color: #333;">外祖母耳号</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
@ -809,7 +809,7 @@
<span>{{ parseTime(scope.row.sourceDate, '{y}-{m}-{d}') }}</span> <span>{{ parseTime(scope.row.sourceDate, '{y}-{m}-{d}') }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <!-- <el-table-column
v-if="columns['sourceRanchId'].visible" v-if="columns['sourceRanchId'].visible"
label="来源牧场id" label="来源牧场id"
align="center" align="center"
@ -820,7 +820,7 @@
<template #header> <template #header>
<span style="font-weight: bold; color: #333;">来源牧场id</span> <span style="font-weight: bold; color: #333;">来源牧场id</span>
</template> </template>
</el-table-column> </el-table-column> -->
<el-table-column <el-table-column
v-if="columns['sourceRanch'].visible" v-if="columns['sourceRanch'].visible"
label="来源牧场" label="来源牧场"
@ -915,14 +915,14 @@
<el-dialog v-model="columnDialogVisible" title="显示列设置" width="800px"> <el-dialog v-model="columnDialogVisible" title="显示列设置" width="800px">
<div style="max-height: 400px; overflow-y: auto; "> <div style="max-height: 400px; overflow-y: auto; ">
<el-checkbox-group v-model="selectedColumns" style="grid; grid-template-columns: repeat(3, 1fr); gap: 10px;" > <el-checkbox-group v-model="selectedColumns" style="grid; grid-template-columns: repeat(3, 1fr); gap: 10px;" >
<el-checkbox label="id">羊只id</el-checkbox> <!-- <el-checkbox label="id">羊只id</el-checkbox> -->
<el-checkbox label="bsManageTags">管理耳号</el-checkbox> <el-checkbox label="bsManageTags">耳号</el-checkbox>
<el-checkbox label="ranchId">牧场id</el-checkbox> <!-- <el-checkbox label="ranchId">牧场id</el-checkbox> -->
<el-checkbox label="drRanch">牧场名称</el-checkbox> <el-checkbox label="drRanch">牧场名称</el-checkbox>
<el-checkbox label="sheepfoldId">羊舍id</el-checkbox> <!-- <el-checkbox label="sheepfoldId">羊舍id</el-checkbox> -->
<el-checkbox label="sheepfoldName">羊舍名称</el-checkbox> <el-checkbox label="sheepfoldName">羊舍名称</el-checkbox>
<el-checkbox label="electronicTags">电子耳号</el-checkbox> <el-checkbox label="electronicTags">电子耳号</el-checkbox>
<el-checkbox label="varietyId">品种id</el-checkbox> <!-- <el-checkbox label="varietyId">品种id</el-checkbox> -->
<el-checkbox label="variety">品种</el-checkbox> <el-checkbox label="variety">品种</el-checkbox>
<el-checkbox label="family">家系</el-checkbox> <el-checkbox label="family">家系</el-checkbox>
<el-checkbox label="name">羊只类型</el-checkbox> <el-checkbox label="name">羊只类型</el-checkbox>
@ -936,22 +936,22 @@
<el-checkbox label="statusId">羊只状态</el-checkbox> <el-checkbox label="statusId">羊只状态</el-checkbox>
<el-checkbox label="weaningWeight">断奶体重</el-checkbox> <el-checkbox label="weaningWeight">断奶体重</el-checkbox>
<el-checkbox label="currentWeight">当前体重</el-checkbox> <el-checkbox label="currentWeight">当前体重</el-checkbox>
<el-checkbox label="breedStatusId">繁育状态id</el-checkbox> <!-- <el-checkbox label="breedStatusId">繁育状态id</el-checkbox> -->
<el-checkbox label="breed">繁殖状态</el-checkbox> <el-checkbox label="breed">繁殖状态</el-checkbox>
<el-checkbox label="bsFatherId">父号id</el-checkbox> <!-- <el-checkbox label="bsFatherId">父号id</el-checkbox> -->
<el-checkbox label="fatherManageTags">父亲管理耳号</el-checkbox> <el-checkbox label="fatherManageTags">父亲耳号</el-checkbox>
<el-checkbox label="bsMotherId">母号id</el-checkbox> <!-- <el-checkbox label="bsMotherId">母号id</el-checkbox> -->
<el-checkbox label="motherManageTags">母亲管理耳号</el-checkbox> <el-checkbox label="motherManageTags">母亲耳号</el-checkbox>
<el-checkbox label="receptorId">受体id</el-checkbox> <!-- <el-checkbox label="receptorId">受体id</el-checkbox> -->
<el-checkbox label="receptorManageTags">受体管理耳号</el-checkbox> <el-checkbox label="receptorManageTags">受体耳号</el-checkbox>
<el-checkbox label="fatherFatherId">祖父号id</el-checkbox> <!-- <el-checkbox label="fatherFatherId">祖父号id</el-checkbox> -->
<el-checkbox label="grandfatherManageTags">祖父管理耳号</el-checkbox> <el-checkbox label="grandfatherManageTags">祖父耳号</el-checkbox>
<el-checkbox label="fatherMotherId">祖母号id</el-checkbox> <!-- <el-checkbox label="fatherMotherId">祖母号id</el-checkbox> -->
<el-checkbox label="grandmotherManageTags">祖母管理耳号</el-checkbox> <el-checkbox label="grandmotherManageTags">祖母耳号</el-checkbox>
<el-checkbox label="fatherId">外祖父号id</el-checkbox> <!-- <el-checkbox label="fatherId">外祖父号id</el-checkbox> -->
<el-checkbox label="maternalGrandfatherManageTags">外祖父管理耳号</el-checkbox> <el-checkbox label="maternalGrandfatherManageTags">外祖父耳号</el-checkbox>
<el-checkbox label="motherId">外祖母号id</el-checkbox> <!-- <el-checkbox label="motherId">外祖母号id</el-checkbox> -->
<el-checkbox label="maternalGrandmotherManageTags">外祖母管理耳号</el-checkbox> <el-checkbox label="maternalGrandmotherManageTags">外祖母耳号</el-checkbox>
<el-checkbox label="matingDate">配种日期</el-checkbox> <el-checkbox label="matingDate">配种日期</el-checkbox>
<el-checkbox label="matingTypeId">配种类型</el-checkbox> <el-checkbox label="matingTypeId">配种类型</el-checkbox>
<el-checkbox label="pregDate">孕检日期</el-checkbox> <el-checkbox label="pregDate">孕检日期</el-checkbox>
@ -972,7 +972,7 @@
<el-checkbox label="breast">乳房评分</el-checkbox> <el-checkbox label="breast">乳房评分</el-checkbox>
<el-checkbox label="source">入群来源</el-checkbox> <el-checkbox label="source">入群来源</el-checkbox>
<el-checkbox label="sourceDate">入群日期</el-checkbox> <el-checkbox label="sourceDate">入群日期</el-checkbox>
<el-checkbox label="sourceRanchId">来源牧场id</el-checkbox> <!-- <el-checkbox label="sourceRanchId">来源牧场id</el-checkbox> -->
<el-checkbox label="sourceRanch">来源牧场</el-checkbox> <el-checkbox label="sourceRanch">来源牧场</el-checkbox>
<el-checkbox label="updateBy">修改人</el-checkbox> <el-checkbox label="updateBy">修改人</el-checkbox>
<el-checkbox label="updateTime">修改日期</el-checkbox> <el-checkbox label="updateTime">修改日期</el-checkbox>

View File

@ -18,7 +18,7 @@
/> />
</el-form-item> </el-form-item>
<el-form-item label="分组" prop="groupId"> <el-form-item label="分组" prop="groupId">
<el-select <!-- <el-select
v-model="queryParams.groupId" v-model="queryParams.groupId"
placeholder="请选择分组" placeholder="请选择分组"
clearable clearable
@ -30,8 +30,15 @@
:label="g.groupName" :label="g.groupName"
:value="g.groupId" :value="g.groupId"
/> />
</el-select> </el-select> -->
</el-form-item> <el-tree-select v-model="queryParams.groupId" :data="groupTree" style="width: 180px;"
:props="{ value: 'groupId', label: 'groupName', children: 'children' }"
value-key="groupId" placeholder="请选择"
check-strictly
clearable
/>
</el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button> <el-button icon="Refresh" @click="resetQuery">重置</el-button>
@ -134,14 +141,27 @@
<el-input type="textarea" :rows="4" v-model="form.earTags" :disabled="form.earTagsDisabled" placeholder="请输入耳号,多个耳号用逗号或换行分隔"/> <el-input type="textarea" :rows="4" v-model="form.earTags" :disabled="form.earTagsDisabled" placeholder="请输入耳号,多个耳号用逗号或换行分隔"/>
</el-form-item> </el-form-item>
<el-form-item label="分组" prop="groupId"> <el-form-item label="分组" prop="groupId">
<el-select v-model="form.groupId" placeholder="请选择分组" clearable> <!-- <el-select v-model="form.groupId" placeholder="请选择分组" clearable>
<el-option <el-option
v-for="g in leafGroupOptions" v-for="g in leafGroupOptions"
:key="g.groupId" :key="g.groupId"
:label="g.groupName" :label="g.groupName"
:value="g.groupId" :value="g.groupId"
/> />
</el-select> </el-select> -->
<el-tree-select
v-model="form.groupId"
:data="groupTree"
style="width: 180px"
:props="{ value: 'groupId', label: 'groupName', children: 'children' }"
value-key="groupId"
placeholder="请选择分组"
clearable
check-strictly
:select-leaf-only="true"
/>
</el-form-item> </el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>
@ -159,6 +179,7 @@ import { listSheep_grouping, getSheep_grouping, delSheep_grouping, addSheep_grou
import {listLeafGroup} from "@/api/fileManagement/group_management" import {listLeafGroup} from "@/api/fileManagement/group_management"
import {listSheep_grouping_join} from "@/api/fileManagement/sheep_grouping" import {listSheep_grouping_join} from "@/api/fileManagement/sheep_grouping"
import { addByEarTags } from '@/api/fileManagement/sheep_grouping' import { addByEarTags } from '@/api/fileManagement/sheep_grouping'
import { listGroupTree } from '@/api/fileManagement/sheep_grouping'
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
@ -173,6 +194,8 @@ const total = ref(0)
const title = ref("") const title = ref("")
const leafGroupOptions = ref([]) const leafGroupOptions = ref([])
const { sheep_gender } = proxy.useDict('sheep_gender') const { sheep_gender } = proxy.useDict('sheep_gender')
// data
const groupTree = ref([])
const data = reactive({ const data = reactive({
form: { form: {
@ -390,17 +413,33 @@ loadLeafGroups()
getList() getList()
// //
// function loadLeafGroups() {
// listLeafGroup().then(res => {
// leafGroupOptions.value = res.data
// })
// }
// //
function loadLeafGroups() { function loadLeafGroups() {
listLeafGroup().then(res => { listGroupTree().then(res => {
leafGroupOptions.value = res.data groupTree.value = res.data
console.log(groupTree.value)
}) })
} }
// groupId // groupId
// function getGroupName(id) {
// const group = leafGroupOptions.value.find(g => g.groupId === id)
// return group ? group.groupName : ''
// }
function getGroupName(id) { function getGroupName(id) {
const group = leafGroupOptions.value.find(g => g.groupId === id) const flatten = (arr) =>
return group ? group.groupName : '' arr.reduce((acc, cur) => acc.concat(cur, flatten(cur.children || [])), [])
const node = flatten(groupTree.value).find(n => n.groupId === id)
return node ? node.groupName : ''
} }
</script> </script>

View File

@ -103,6 +103,86 @@
@pagination="getList" @pagination="getList"
/> />
<!-- ===== 图形化展示区域 ===== -->
<el-divider>牧场羊舍示意图</el-divider>
<el-collapse
v-model="activeNames"
accordion
style="margin-top: 16px; max-width: 100%; overflow-x: auto"
>
<!-- 一级牧场 -->
<el-collapse-item
v-for="ranch in seatMapTree"
:key="ranch.ranchId"
:title="ranch.ranchName"
:name="ranch.ranchId"
>
<!-- 二级羊舍类型 -->
<el-collapse accordion>
<el-collapse-item
v-for="type in ranch.types"
:key="type.typeId"
:title="`${type.typeName} (${type.folds.length}个)`"
>
<!-- 三级羊舍卡片 -->
<el-row :gutter="16">
<el-col
v-for="fold in type.folds"
:key="fold.foldNo"
:xs="24"
:sm="12"
:md="8"
:lg="6"
:xl="4"
style="margin-bottom: 16px"
>
<el-card shadow="hover">
<template #header>
<span>{{ fold.foldNo }}{{type.typeName}}</span>
</template>
<!-- 四级 -->
<div
v-for="row in fold.rows"
:key="row.rowNo"
class="seat-block"
>
<div class="row-label">{{ row.rowNo }}</div>
<div class="seat-row">
<!-- 五级栏位 -->
<div
v-for="col in row.columns"
:key="col"
class="seat"
:class="{ occupied: isOccupied(fold.foldNo, row.rowNo, col) }"
@click="toggleSeat(fold.foldNo, row.rowNo, col)"
>
{{ col }}
</div>
</div>
</div>
</el-card>
</el-col>
</el-row>
</el-collapse-item>
</el-collapse>
</el-collapse-item>
</el-collapse>
<!-- 添加或修改羊舍管理对话框 --> <!-- 添加或修改羊舍管理对话框 -->
<el-dialog :title="title" v-model="open" width="500px" append-to-body> <el-dialog :title="title" v-model="open" width="500px" append-to-body>
<el-form ref="sheepfold_managementRef" :model="form" :rules="rules" label-width="80px"> <el-form ref="sheepfold_managementRef" :model="form" :rules="rules" label-width="80px">
@ -190,7 +270,7 @@
</template> </template>
<script setup name="Sheepfold_management"> <script setup name="Sheepfold_management">
import { listSheepfold_management, getSheepfold_management, delSheepfold_management, addSheepfold_management, updateSheepfold_management,checkSheepfoldNoExist } from "@/api/fileManagement/sheepfold_management" import { getSeatMap,listSheepfold_management, getSheepfold_management, delSheepfold_management, addSheepfold_management, updateSheepfold_management,checkSheepfoldNoExist } from "@/api/fileManagement/sheepfold_management"
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const { bas_sheepfold_type, da_ranch } = proxy.useDict('bas_sheepfold_type', 'da_ranch') const { bas_sheepfold_type, da_ranch } = proxy.useDict('bas_sheepfold_type', 'da_ranch')
@ -206,6 +286,7 @@ const total = ref(0)
const title = ref("") const title = ref("")
const sheepfoldNoExists = ref(false) // const sheepfoldNoExists = ref(false) //
const data = reactive({ const data = reactive({
form: { form: {
id: null, id: null,
@ -295,6 +376,7 @@ function reset() {
function handleQuery() { function handleQuery() {
queryParams.value.pageNum = 1 queryParams.value.pageNum = 1
getList() getList()
loadSeatMap()
} }
/** 重置按钮操作 */ /** 重置按钮操作 */
@ -388,6 +470,7 @@ function submitForm() {
proxy.$modal.msgSuccess("修改成功") proxy.$modal.msgSuccess("修改成功")
open.value = false open.value = false
getList() getList()
loadSeatMap()
}) })
} else { } else {
// - // -
@ -423,6 +506,7 @@ function submitForm() {
proxy.$modal.msgSuccess(`新增成功,共添加${requests.length}条记录`) proxy.$modal.msgSuccess(`新增成功,共添加${requests.length}条记录`)
open.value = false open.value = false
getList() getList()
loadSeatMap()
}) })
.catch(error => { .catch(error => {
proxy.$modal.msgError("部分记录添加失败:" + error.message) proxy.$modal.msgError("部分记录添加失败:" + error.message)
@ -439,6 +523,7 @@ function handleDelete(row) {
return delSheepfold_management(_ids) return delSheepfold_management(_ids)
}).then(() => { }).then(() => {
getList() getList()
loadSeatMap();
proxy.$modal.msgSuccess("删除成功") proxy.$modal.msgSuccess("删除成功")
}).catch(() => {}) }).catch(() => {})
} }
@ -450,7 +535,46 @@ function handleExport() {
}, `sheepfold_management_${new Date().getTime()}.xlsx`) }, `sheepfold_management_${new Date().getTime()}.xlsx`)
} }
/* ===== 图形化展示所需变量和方法 ===== */
const activeNames = ref([]) //
const seatMapTree = ref([]) //
const loadSeatMap = () => {
getSeatMap()
.then(res => (seatMapTree.value = res.data))
.catch(err => proxy.$modal.msgError('加载座位图失败:' + err.message))
}
/* 演示:点击栏位切换颜色 */
const occupied = ref(new Set())
const isOccupied = (foldNo, rowNo, col) =>
occupied.value.has(`${foldNo}-${rowNo}-${col}`)
const toggleSeat = (foldNo, rowNo, col) => {
const key = `${foldNo}-${rowNo}-${col}`
occupied.value.has(key)
? occupied.value.delete(key)
: occupied.value.add(key)
}
/* 页面加载时拉取数据 */
onMounted(() => {
getList()
loadSeatMap()
})
getList() getList()
loadSeatMap()
</script> </script>
@ -462,4 +586,34 @@ getList()
border-radius: 4px; border-radius: 4px;
background-color: #f5f7fa; background-color: #f5f7fa;
} }
/* ===== 图形化展示样式 ===== */
.seat-block {
margin-bottom: 8px;
}
.row-label {
font-weight: bold;
margin-bottom: 4px;
}
.seat-row {
display: flex;
flex-wrap: wrap;
gap: 4px;
}
.seat {
width: 32px;
height: 32px;
border: 1px solid #dcdfe6;
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
cursor: pointer;
background: #f2f6fc;
}
.seat.occupied {
background: #67c23a;
color: #fff;
}
</style> </style>

View File

@ -165,9 +165,12 @@
<el-form-item label="耳号" prop="manageTags"> <el-form-item label="耳号" prop="manageTags">
<el-input <el-input
v-model="form.manageTags" v-model="form.manageTags"
placeholder="请输入耳号" placeholder="请输入羊耳号"
@blur="handleEarTagChange" @blur="handleEarTagChange"
/> />
<div style="font-size: 12px; color: #909399; margin-top: 4px;">
注意只能录入母羊的流产记录
</div>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
@ -182,6 +185,36 @@
</el-col> </el-col>
</el-row> </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-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="流产原因" prop="reason"> <el-form-item label="流产原因" prop="reason">
@ -267,6 +300,8 @@ const multiple = ref(true)
const total = ref(0) const total = ref(0)
const title = ref("") const title = ref("")
const reasonOptions = ref([]) const reasonOptions = ref([])
const sheepInfo = ref({})
const sheepInfoVisible = ref(false)
const data = reactive({ const data = reactive({
form: {}, form: {},
@ -304,6 +339,39 @@ const data = reactive({
const {queryParams, form, rules} = toRefs(data) 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() { function getList() {
loading.value = true loading.value = true
@ -341,6 +409,8 @@ function reset() {
status: null, status: null,
miscaLamb: null miscaLamb: null
} }
sheepInfo.value = {}
sheepInfoVisible.value = false
proxy.resetForm("miscarriageRef") proxy.resetForm("miscarriageRef")
} }
@ -379,22 +449,81 @@ function handleUpdate(row) {
form.value.manageTags = response.data.bsManageTags form.value.manageTags = response.data.bsManageTags
open.value = true open.value = true
title.value = "修改流产记录" title.value = "修改流产记录"
//
if (form.value.manageTags) {
handleEarTagChange()
}
}) })
} }
/** 耳号输入框失焦事件 */ /** 耳号输入框失焦事件 - 使用正确的gender字段 */
function handleEarTagChange() { function handleEarTagChange() {
if (form.value.manageTags) { if (form.value.manageTags) {
getSheepInfo(form.value.manageTags).then(response => { getSheepInfo(form.value.manageTags).then(response => {
if (response.data) { if (response.data) {
// sheepInfo.value = response.data
proxy.$modal.msgSuccess("羊只信息验证成功") sheepInfoVisible.value = true
// - gender1=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 { } else {
proxy.$modal.msgError("未找到该耳号对应的羊只信息") proxy.$modal.msgError("未找到该耳号对应的羊只信息")
form.value.manageTags = null
sheepInfo.value = {}
sheepInfoVisible.value = false
} }
}).catch(() => { }).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' // -
} }
} }

View File

@ -26,6 +26,18 @@
placeholder="请选择死亡日期"> placeholder="请选择死亡日期">
</el-date-picker> </el-date-picker>
</el-form-item> </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-form-item label="死淘去向" prop="disposalDirection">
<el-select v-model="queryParams.disposalDirection" placeholder="请选择死淘去向" clearable> <el-select v-model="queryParams.disposalDirection" placeholder="请选择死淘去向" clearable>
<el-option label="深埋" value="深埋" /> <el-option label="深埋" value="深埋" />
@ -128,8 +140,8 @@
</el-table-column> </el-table-column>
<el-table-column label="日龄" align="center" prop="dayAge" width="80"/> <el-table-column label="日龄" align="center" prop="dayAge" width="80"/>
<el-table-column label="胎次" align="center" prop="parity" 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="疾病类型" align="center" prop="diseaseTypeName" width="120"/>
<el-table-column label="疾病子类型ID" align="center" prop="diseaseSubtypeId" width="130"/> <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="disposalDirection" width="100"/>
<el-table-column label="技术员" align="center" prop="technician" width="100"/> <el-table-column label="技术员" align="center" prop="technician" width="100"/>
<el-table-column label="处理人" align="center" prop="handler" 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-form ref="deathRef" :model="form" :rules="rules" label-width="120px">
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
@ -194,13 +206,32 @@
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="疾病类型ID" prop="diseaseTypeId"> <el-form-item label="疾病类型" prop="diseaseTypeId">
<el-input-number v-model="form.diseaseTypeId" placeholder="请输入疾病类型ID" :min="0"/> <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-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="疾病子类型ID" prop="diseaseSubtypeId"> <el-form-item label="疾病子类型" prop="diseaseSubtypeId">
<el-input-number v-model="form.diseaseSubtypeId" placeholder="请输入疾病子类型ID" :min="0"/> <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-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -208,7 +239,7 @@
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="死淘去向" prop="disposalDirection"> <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-option label="无害化" value="无害化"/> <el-option label="无害化" value="无害化"/>
</el-select> </el-select>
@ -253,7 +284,7 @@
</template> </template>
<script setup name="Death"> <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() const {proxy} = getCurrentInstance()
@ -267,6 +298,8 @@ const multiple = ref(true)
const total = ref(0) const total = ref(0)
const title = ref("") const title = ref("")
const validatingTags = ref(false) // loading const validatingTags = ref(false) // loading
const diseaseOptions = ref([]) //
const diseaseSubtypeOptions = ref([]) //
const data = reactive({ const data = reactive({
form: {}, 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() { function validateManageTagsInQuery() {
const manageTags = queryParams.value.manageTags const manageTags = queryParams.value.manageTags
@ -337,7 +406,7 @@ function validateManageTags(manageTags, source) {
proxy.$modal.msgSuccess("耳号验证成功") proxy.$modal.msgSuccess("耳号验证成功")
} }
} else { } else {
// //
if (source === 'form') { if (source === 'form') {
form.value.manageTags = null form.value.manageTags = null
} else { } else {
@ -346,7 +415,7 @@ function validateManageTags(manageTags, source) {
proxy.$modal.msgError("该耳号不存在") proxy.$modal.msgError("该耳号不存在")
} }
}).catch(error => { }).catch(error => {
// //
if (source === 'form') { if (source === 'form') {
form.value.manageTags = null form.value.manageTags = null
} else { } else {
@ -385,6 +454,8 @@ function reset() {
updateTime: null, updateTime: null,
isDelete: null isDelete: null
} }
//
diseaseSubtypeOptions.value = []
proxy.resetForm("deathRef") proxy.resetForm("deathRef")
} }
@ -410,6 +481,7 @@ function handleSelectionChange(selection) {
/** 新增按钮操作 */ /** 新增按钮操作 */
function handleAdd() { function handleAdd() {
reset() reset()
getDiseaseTreeData() //
open.value = true open.value = true
title.value = "添加羊只死淘记录" title.value = "添加羊只死淘记录"
} }
@ -417,9 +489,14 @@ function handleAdd() {
/** 修改按钮操作 */ /** 修改按钮操作 */
function handleUpdate(row) { function handleUpdate(row) {
reset() reset()
getDiseaseTreeData() //
const _id = row.id || ids.value const _id = row.id || ids.value
getDeath(_id).then(response => { getDeath(_id).then(response => {
form.value = response.data form.value = response.data
//
if (form.value.diseaseTypeId) {
onDiseaseTypeChange(form.value.diseaseTypeId)
}
open.value = true open.value = true
title.value = "修改羊只死淘记录" title.value = "修改羊只死淘记录"
}) })
@ -465,6 +542,8 @@ function handleExport() {
}, `death_${new Date().getTime()}.xlsx`) }, `death_${new Date().getTime()}.xlsx`)
} }
//
getDiseaseTreeData()
getList() getList()
</script> </script>

View File

@ -42,7 +42,7 @@ export default defineConfig(({ mode, command }) => {
}, },
// vite 相关配置 // vite 相关配置
server: { server: {
port: 80, port: 82,
host: true, host: true,
open: true, open: true,
proxy: { proxy: {