干奶录入问题,干奶查询问题,断奶录入问题,断奶查询问题,死亡录入问题,死亡查询问题
This commit is contained in:
@@ -1,31 +1,60 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="100px">
|
||||
<el-form-item label="管理耳号" prop="manageTags">
|
||||
<el-input
|
||||
v-model="queryParams.manageTags"
|
||||
placeholder="请输入管理耳号"
|
||||
|
||||
<el-form-item label="管理耳号" prop="manageTagsList">
|
||||
<el-select
|
||||
v-model="queryParams.manageTagsList"
|
||||
multiple
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
placeholder="请输入耳号"
|
||||
:remote-method="remoteSearchEarNo"
|
||||
:loading="loadingSearch"
|
||||
allow-create
|
||||
default-first-option
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
@blur="validateManageTagsInQuery"
|
||||
/>
|
||||
style="width: 240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in earNoOptions"
|
||||
:key="item"
|
||||
:label="item"
|
||||
:value="item"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="事件类型" prop="eventType">
|
||||
<el-input
|
||||
v-model="queryParams.eventType"
|
||||
placeholder="请输入事件类型"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
|
||||
<el-form-item label="死亡日期" prop="deathDateRange">
|
||||
<el-date-picker
|
||||
v-model="queryParams.deathDateRange"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
value-format="YYYY-MM-DD"
|
||||
style="width: 240px"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="死亡日期" prop="deathDate">
|
||||
<el-date-picker clearable
|
||||
v-model="queryParams.deathDate"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="请选择死亡日期">
|
||||
</el-date-picker>
|
||||
|
||||
<el-form-item label="羊只类型" prop="sheepTypeList">
|
||||
<el-select
|
||||
v-model="queryParams.sheepTypeList"
|
||||
placeholder="请选择羊只类型"
|
||||
multiple
|
||||
clearable
|
||||
collapse-tags
|
||||
style="width: 200px">
|
||||
<el-option
|
||||
v-for="dict in sys_sheep_type"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.label"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="疾病类型" prop="diseaseTypeId">
|
||||
<el-tree-select
|
||||
v-model="queryParams.diseaseTypeId"
|
||||
@@ -38,36 +67,76 @@
|
||||
style="width: 200px;"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="死淘去向" prop="disposalDirection">
|
||||
<el-select v-model="queryParams.disposalDirection" placeholder="请选择死淘去向" clearable>
|
||||
<el-select v-model="queryParams.disposalDirection" placeholder="请选择死淘去向" clearable style="width: 200px;">
|
||||
<el-option label="深埋" value="深埋" />
|
||||
<el-option label="无害化" value="无害化" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="技术员" prop="technician">
|
||||
<el-input
|
||||
v-model="queryParams.technician"
|
||||
|
||||
<el-form-item label="技术员" prop="technicianList">
|
||||
<el-select
|
||||
v-model="queryParams.technicianList"
|
||||
multiple
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
placeholder="请输入技术员"
|
||||
:remote-method="remoteSearchTechnician"
|
||||
:loading="loadingSearch"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
style="width: 200px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in technicianOptions"
|
||||
:key="item"
|
||||
:label="item"
|
||||
:value="item"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="处理人" prop="handler">
|
||||
<el-input
|
||||
v-model="queryParams.handler"
|
||||
|
||||
<el-form-item label="处理人" prop="handlerList">
|
||||
<el-select
|
||||
v-model="queryParams.handlerList"
|
||||
multiple
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
placeholder="请输入处理人"
|
||||
:remote-method="remoteSearchHandler"
|
||||
:loading="loadingSearch"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
style="width: 200px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in handlerOptions"
|
||||
:key="item"
|
||||
:label="item"
|
||||
:value="item"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="班组" prop="workGroup">
|
||||
|
||||
<el-form-item label="班组" prop="workGroupList">
|
||||
<el-select v-model="queryParams.workGroupList" placeholder="请选择班组" multiple clearable style="width: 200px">
|
||||
<el-option label="一组" value="一组" />
|
||||
<el-option label="二组" value="二组" />
|
||||
<el-option label="三组" value="三组" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="羊只品种" prop="variety">
|
||||
<el-input
|
||||
v-model="queryParams.workGroup"
|
||||
placeholder="请输入班组"
|
||||
v-model="queryParams.variety"
|
||||
placeholder="请输入羊只品种"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
@@ -122,7 +191,6 @@
|
||||
|
||||
<el-table v-loading="loading" :data="deathList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center"/>
|
||||
<!-- 日期作为第一列 -->
|
||||
<el-table-column label="死亡日期" align="center" prop="deathDate" width="120" fixed="left">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.deathDate, '{y}-{m}-{d}') }}</span>
|
||||
@@ -132,7 +200,7 @@
|
||||
<el-table-column label="管理耳号" align="center" prop="manageTags" width="120"/>
|
||||
<el-table-column label="品种" align="center" prop="variety" width="100"/>
|
||||
<el-table-column label="事件类型" align="center" prop="eventType" width="100"/>
|
||||
<el-table-column label="死亡时羊只类别" align="center" prop="sheepType" width="130"/>
|
||||
<el-table-column label="羊只类型" align="center" prop="sheepType" width="130"/>
|
||||
<el-table-column label="性别" align="center" prop="gender" width="80">
|
||||
<template #default="scope">
|
||||
<span>{{ scope.row.gender === 1 ? '母' : scope.row.gender === 2 ? '公' : '' }}</span>
|
||||
@@ -178,7 +246,6 @@
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改羊只死淘记录对话框 -->
|
||||
<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>
|
||||
@@ -186,9 +253,7 @@
|
||||
<el-form-item label="管理耳号" prop="manageTags">
|
||||
<el-input
|
||||
v-model="form.manageTags"
|
||||
placeholder="请输入管理耳号"
|
||||
@blur="validateManageTagsInForm"
|
||||
:loading="validatingTags"
|
||||
placeholder="请输入管理耳号 (可多个空格隔开)"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -198,12 +263,13 @@
|
||||
v-model="form.deathDate"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="请选择死亡日期">
|
||||
placeholder="请选择死亡日期"
|
||||
style="width: 100%">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="疾病类型" prop="diseaseTypeId">
|
||||
@@ -284,9 +350,22 @@
|
||||
</template>
|
||||
|
||||
<script setup name="Death">
|
||||
import {listDeath, getDeath, delDeath, addDeath, updateDeath, getSheepInfo, getDiseaseTree} from "@/api/sheep_death/death"
|
||||
import {
|
||||
listDeath,
|
||||
getDeath,
|
||||
delDeath,
|
||||
addDeath,
|
||||
updateDeath,
|
||||
getSheepInfo,
|
||||
getDiseaseTree,
|
||||
searchEarNo,
|
||||
searchTechnician,
|
||||
searchHandler
|
||||
} from "@/api/sheep_death/death"
|
||||
|
||||
const {proxy} = getCurrentInstance()
|
||||
// 获取字典数据
|
||||
const { sys_sheep_type } = proxy.useDict("sys_sheep_type");
|
||||
|
||||
const deathList = ref([])
|
||||
const open = ref(false)
|
||||
@@ -297,26 +376,31 @@ const single = ref(true)
|
||||
const multiple = ref(true)
|
||||
const total = ref(0)
|
||||
const title = ref("")
|
||||
const validatingTags = ref(false) // 验证管理耳号的loading状态
|
||||
const diseaseOptions = ref([]) // 疾病类型选项
|
||||
const diseaseSubtypeOptions = ref([]) // 疾病子类型选项
|
||||
const diseaseOptions = ref([])
|
||||
const diseaseSubtypeOptions = ref([])
|
||||
|
||||
// 远程搜索相关变量
|
||||
const loadingSearch = ref(false)
|
||||
const earNoOptions = ref([])
|
||||
const technicianOptions = ref([])
|
||||
const handlerOptions = ref([])
|
||||
|
||||
const data = reactive({
|
||||
form: {},
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
manageTags: null,
|
||||
eventType: null,
|
||||
deathDate: null,
|
||||
manageTagsList: [], // 多选耳号
|
||||
deathDateRange: [], // 死亡日期范围
|
||||
sheepTypeList: [], // 多选羊只类型
|
||||
technicianList: [], // 多选技术员
|
||||
handlerList: [], // 多选处理人
|
||||
workGroupList: [], // 多选班组
|
||||
|
||||
variety: null,
|
||||
diseaseTypeId: null,
|
||||
diseaseSubtypeId: null,
|
||||
disposalDirection: null,
|
||||
technician: null,
|
||||
handler: null,
|
||||
workGroup: null,
|
||||
comment: null,
|
||||
isDelete: null
|
||||
disposalDirection: null
|
||||
},
|
||||
rules: {
|
||||
manageTags: [
|
||||
@@ -333,32 +417,80 @@ const {queryParams, form, rules} = toRefs(data)
|
||||
/** 查询羊只死淘记录列表 */
|
||||
function getList() {
|
||||
loading.value = true
|
||||
listDeath(queryParams.value).then(response => {
|
||||
|
||||
// 处理日期范围
|
||||
let params = { ...queryParams.value };
|
||||
|
||||
// 处理 params 对象 (BaseEntity 需要)
|
||||
params.params = {};
|
||||
if (queryParams.value.deathDateRange && queryParams.value.deathDateRange.length === 2) {
|
||||
params.params['beginDeathDate'] = queryParams.value.deathDateRange[0];
|
||||
params.params['endDeathDate'] = queryParams.value.deathDateRange[1];
|
||||
}
|
||||
|
||||
listDeath(params).then(response => {
|
||||
deathList.value = response.rows
|
||||
total.value = response.total
|
||||
loading.value = false
|
||||
}).catch(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
/** 远程搜索耳号 */
|
||||
function remoteSearchEarNo(query) {
|
||||
if (query) {
|
||||
loadingSearch.value = true
|
||||
searchEarNo(query).then(res => {
|
||||
earNoOptions.value = res.data || []
|
||||
loadingSearch.value = false
|
||||
})
|
||||
} else {
|
||||
earNoOptions.value = []
|
||||
}
|
||||
}
|
||||
|
||||
/** 远程搜索技术员 */
|
||||
function remoteSearchTechnician(query) {
|
||||
if (query) {
|
||||
loadingSearch.value = true
|
||||
searchTechnician(query).then(res => {
|
||||
technicianOptions.value = res.data || []
|
||||
loadingSearch.value = false
|
||||
})
|
||||
} else {
|
||||
technicianOptions.value = []
|
||||
}
|
||||
}
|
||||
|
||||
/** 远程搜索处理人 */
|
||||
function remoteSearchHandler(query) {
|
||||
if (query) {
|
||||
loadingSearch.value = true
|
||||
searchHandler(query).then(res => {
|
||||
handlerOptions.value = res.data || []
|
||||
loadingSearch.value = false
|
||||
})
|
||||
} else {
|
||||
handlerOptions.value = []
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取疾病树形列表 */
|
||||
function getDiseaseTreeData() {
|
||||
getDiseaseTree().then(response => {
|
||||
if (response.code === 200) {
|
||||
// 构建树形结构
|
||||
diseaseOptions.value = proxy.handleTree(response.data, "id", "pid")
|
||||
}
|
||||
}).catch(() => {
|
||||
proxy.$modal.msgError("获取疾病列表失败")
|
||||
})
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
/** 疾病类型改变时,更新子类型选项 */
|
||||
function onDiseaseTypeChange(value) {
|
||||
form.value.diseaseSubtypeId = null // 清空子类型选择
|
||||
form.value.diseaseSubtypeId = null
|
||||
diseaseSubtypeOptions.value = []
|
||||
|
||||
if (value) {
|
||||
// 查找选中疾病类型的子类型
|
||||
const findChildren = (nodes, targetId) => {
|
||||
for (const node of nodes) {
|
||||
if (node.id === targetId) {
|
||||
@@ -371,62 +503,10 @@ function onDiseaseTypeChange(value) {
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
diseaseSubtypeOptions.value = findChildren(diseaseOptions.value, value)
|
||||
}
|
||||
}
|
||||
|
||||
/** 验证查询条件中的管理耳号 */
|
||||
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
|
||||
@@ -439,8 +519,8 @@ function reset() {
|
||||
id: null,
|
||||
sheepId: null,
|
||||
manageTags: null,
|
||||
eventType: "死亡", // 默认事件类型
|
||||
deathDate: new Date().toISOString().split('T')[0], // 默认今日
|
||||
eventType: "死亡",
|
||||
deathDate: new Date().toISOString().split('T')[0],
|
||||
diseaseTypeId: null,
|
||||
diseaseSubtypeId: null,
|
||||
disposalDirection: null,
|
||||
@@ -454,7 +534,6 @@ function reset() {
|
||||
updateTime: null,
|
||||
isDelete: null
|
||||
}
|
||||
// 重置子类型选项
|
||||
diseaseSubtypeOptions.value = []
|
||||
proxy.resetForm("deathRef")
|
||||
}
|
||||
@@ -467,6 +546,14 @@ function handleQuery() {
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function resetQuery() {
|
||||
// 手动清空数组类型的查询条件
|
||||
queryParams.value.manageTagsList = []
|
||||
queryParams.value.sheepTypeList = []
|
||||
queryParams.value.technicianList = []
|
||||
queryParams.value.handlerList = []
|
||||
queryParams.value.workGroupList = []
|
||||
queryParams.value.deathDateRange = []
|
||||
|
||||
proxy.resetForm("queryRef")
|
||||
handleQuery()
|
||||
}
|
||||
@@ -481,7 +568,7 @@ function handleSelectionChange(selection) {
|
||||
/** 新增按钮操作 */
|
||||
function handleAdd() {
|
||||
reset()
|
||||
getDiseaseTreeData() // 获取疾病数据
|
||||
getDiseaseTreeData()
|
||||
open.value = true
|
||||
title.value = "添加羊只死淘记录"
|
||||
}
|
||||
@@ -489,11 +576,10 @@ function handleAdd() {
|
||||
/** 修改按钮操作 */
|
||||
function handleUpdate(row) {
|
||||
reset()
|
||||
getDiseaseTreeData() // 获取疾病数据
|
||||
getDiseaseTreeData()
|
||||
const _id = row.id || ids.value
|
||||
getDeath(_id).then(response => {
|
||||
form.value = response.data
|
||||
// 如果有疾病类型,需要设置子类型选项
|
||||
if (form.value.diseaseTypeId) {
|
||||
onDiseaseTypeChange(form.value.diseaseTypeId)
|
||||
}
|
||||
@@ -537,9 +623,15 @@ function handleDelete(row) {
|
||||
|
||||
/** 导出按钮操作 */
|
||||
function handleExport() {
|
||||
proxy.download('sheep_death/death/export', {
|
||||
...queryParams.value
|
||||
}, `death_${new Date().getTime()}.xlsx`)
|
||||
// 导出参数构造
|
||||
let params = { ...queryParams.value };
|
||||
params.params = {};
|
||||
if (queryParams.value.deathDateRange && queryParams.value.deathDateRange.length === 2) {
|
||||
params.params['beginDeathDate'] = queryParams.value.deathDateRange[0];
|
||||
params.params['endDeathDate'] = queryParams.value.deathDateRange[1];
|
||||
}
|
||||
|
||||
proxy.download('sheep_death/death/export', params, `death_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
|
||||
// 初始化
|
||||
|
||||
Reference in New Issue
Block a user