优化了死亡模块,修改状态在群不在群

This commit is contained in:
zyk 2025-08-24 12:17:42 +08:00
parent 393e44442a
commit dc36abbb24
2 changed files with 76 additions and 5 deletions

View File

@ -41,4 +41,12 @@ export function delDeath(id) {
url: '/sheep_death/death/' + id,
method: 'delete'
})
}
// 根据管理耳号查询羊只信息
export function getSheepInfo(manageTags) {
return request({
url: '/sheep_death/death/sheepInfo/' + manageTags,
method: 'get'
})
}

View File

@ -7,6 +7,7 @@
placeholder="请输入管理耳号"
clearable
@keyup.enter="handleQuery"
@blur="validateManageTagsInQuery"
/>
</el-form-item>
<el-form-item label="事件类型" prop="eventType">
@ -156,13 +157,18 @@
@pagination="getList"
/>
<!-- 添加或修改羊只死淘记录对话框 - 简化版 -->
<!-- 添加或修改羊只死淘记录对话框 -->
<el-dialog :title="title" v-model="open" width="600px" append-to-body>
<el-form ref="deathRef" :model="form" :rules="rules" label-width="120px">
<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="validateManageTagsInForm"
:loading="validatingTags"
/>
</el-form-item>
</el-col>
<el-col :span="12">
@ -177,6 +183,8 @@
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="疾病类型ID" prop="diseaseTypeId">
@ -238,7 +246,7 @@
</template>
<script setup name="Death">
import {listDeath, getDeath, delDeath, addDeath, updateDeath} from "@/api/sheep_death/death"
import {listDeath, getDeath, delDeath, addDeath, updateDeath, getSheepInfo} from "@/api/sheep_death/death"
const {proxy} = getCurrentInstance()
@ -251,6 +259,7 @@ const single = ref(true)
const multiple = ref(true)
const total = ref(0)
const title = ref("")
const validatingTags = ref(false) // loading
const data = reactive({
form: {},
@ -291,13 +300,64 @@ function getList() {
})
}
/** 验证查询条件中的管理耳号 */
function validateManageTagsInQuery() {
const manageTags = queryParams.value.manageTags
if (manageTags && manageTags.trim()) {
validateManageTags(manageTags.trim(), 'query')
}
}
/** 验证表单中的管理耳号 */
function validateManageTagsInForm() {
const manageTags = form.value.manageTags
if (manageTags && manageTags.trim()) {
validateManageTags(manageTags.trim(), 'form')
}
}
/** 验证管理耳号是否存在 */
function validateManageTags(manageTags, source) {
if (validatingTags.value) return //
validatingTags.value = true
getSheepInfo(manageTags).then(response => {
if (response.code === 200 && response.data) {
if (source === 'form') {
proxy.$modal.msgSuccess("羊只验证成功")
} else {
proxy.$modal.msgSuccess("耳号验证成功")
}
} else {
//
if (source === 'form') {
form.value.manageTags = null
} else {
queryParams.value.manageTags = null
}
proxy.$modal.msgError("该耳号不存在")
}
}).catch(error => {
//
if (source === 'form') {
form.value.manageTags = null
} else {
queryParams.value.manageTags = null
}
proxy.$modal.msgError("该耳号不存在")
}).finally(() => {
validatingTags.value = false
})
}
//
function cancel() {
open.value = false
reset()
}
// -
//
function reset() {
form.value = {
id: null,
@ -399,4 +459,7 @@ function handleExport() {
}
getList()
</script>
</script>
<style scoped>
</style>