Compare commits
2 Commits
8be5607e82
...
adb8da9df6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
adb8da9df6 | ||
|
|
dc36abbb24 |
@ -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'
|
||||
})
|
||||
}
|
||||
@ -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>
|
||||
Loading…
x
Reference in New Issue
Block a user