Merge remote-tracking branch 'origin/main'

This commit is contained in:
zyk 2025-08-26 10:30:10 +08:00
commit 62b01a0825
19 changed files with 2460 additions and 233 deletions

View File

@ -23,6 +23,7 @@
"clipboard": "2.0.11",
"date-fns": "^4.1.0",
"echarts": "5.5.1",
"element-china-area-data": "^6.1.0",
"element-plus": "^2.7.6",
"file-saver": "2.0.5",
"fuse.js": "6.6.2",

View File

@ -1,56 +1,44 @@
// import request from '@/utils/request'
// // 查询胎次校正列表
// export function listParityCorrection(query) {
// return request({
// url: '/parityCorrection/parityCorrection/list',
// method: 'get',
// params: query
// })
// }
// // 查询胎次校正详细
// export function getParityCorrection(id) {
// return request({
// url: '/parityCorrection/parityCorrection/' + id,
// method: 'get'
// })
// }
// // 新增胎次校正
// export function addParityCorrection(data) {
// return request({
// url: '/parityCorrection/parityCorrection',
// method: 'post',
// data: data
// })
// }
// // 修改胎次校正
// export function updateParityCorrection(data) {
// return request({
// url: '/parityCorrection/parityCorrection',
// method: 'put',
// data: data
// })
// }
// // 删除胎次校正
// export function delParityCorrection(id) {
// return request({
// url: '/parityCorrection/parityCorrection/' + id,
// method: 'delete'
// })
// }
// 可以保留空文件或删除此文件
// 因为前端不再需要调用后端API
import request from '@/utils/request'
// 查询胎次校正列表
export function listParityCorrection(query) {
return request({
url: '/parityCorrection/parityCorrection/listAll',
url: '/parityCorrection/parityCorrection/list',
method: 'get',
params: query
})
}
}
// 查询胎次校正详细
export function getParityCorrection(id) {
return request({
url: '/parityCorrection/parityCorrection/' + id,
method: 'get'
})
}
// 新增胎次校正
export function addParityCorrection(data) {
return request({
url: '/parityCorrection/parityCorrection',
method: 'post',
data: data
})
}
// 修改胎次校正
export function updateParityCorrection(data) {
return request({
url: '/parityCorrection/parityCorrection',
method: 'put',
data: data
})
}
// 删除胎次校正
export function delParityCorrection(id) {
return request({
url: '/parityCorrection/parityCorrection/' + id,
method: 'delete'
})
}

View File

@ -0,0 +1,53 @@
import request from '@/utils/request'
// 查询饲喂量统计列表
export function listFeedStatistic(query) {
return request({
url: '/feed/FeedStatistic/list',
method: 'get',
params: query
})
}
// 查询饲喂量统计详细
export function getFeedStatistic(id) {
return request({
url: '/feed/FeedStatistic/' + id,
method: 'get'
})
}
// 新增饲喂量统计
export function addFeedStatistic(data) {
return request({
url: '/feed/FeedStatistic',
method: 'post',
data: data
})
}
// 修改饲喂量统计
export function updateFeedStatistic(data) {
return request({
url: '/feed/FeedStatistic',
method: 'put',
data: data
})
}
// 删除饲喂量统计
export function delFeedStatistic(id) {
return request({
url: '/feed/FeedStatistic/' + id,
method: 'delete'
})
}
// 查询饲喂量统计列表
export function initFeedStatistic(query) {
return request({
url: '/feed/FeedStatistic/init',
method: 'get',
params: query
})
}

View File

@ -0,0 +1,39 @@
import request from '@/utils/request'
export function listCustomer(query) {
return request({
url: '/customer/customer/list',
method: 'get',
params: query
})
}
export function getCustomer(id) {
return request({
url: '/customer/customer/' + id,
method: 'get'
})
}
export function addCustomer(data) {
return request({
url: '/customer/customer',
method: 'post',
data: data
})
}
export function updateCustomer(data) {
return request({
url: '/customer/customer',
method: 'put',
data: data
})
}
export function delCustomer(id) {
return request({
url: '/customer/customer/' + id,
method: 'delete'
})
}

View File

@ -0,0 +1,62 @@
import request from '@/utils/request'
// 查询羊只销售记录列表
export function listSaleRecord(query) {
return request({
url: '/saleRecord/saleRecord/list',
method: 'get',
params: query
})
}
// 查询羊只销售记录详细
export function getSaleRecord(id) {
return request({
url: '/saleRecord/saleRecord/' + id,
method: 'get'
})
}
// 新增羊只销售记录
export function addSaleRecord(data) {
return request({
url: '/saleRecord/saleRecord',
method: 'post',
data: data
})
}
// 修改羊只销售记录
export function updateSaleRecord(data) {
return request({
url: '/saleRecord/saleRecord',
method: 'put',
data: data
})
}
// 删除羊只销售记录
export function delSaleRecord(ids) {
return request({
url: '/saleRecord/saleRecord/' + ids,
method: 'delete'
})
}
// 导出羊只销售记录
export function exportSaleRecord(query) {
return request({
url: '/saleRecord/saleRecord/export',
method: 'post',
data: query
})
}
// 根据耳号查询羊只信息
export function getSheepInfo(bsManageTags) {
return request({
url: '/saleRecord/saleRecord/getSheepInfo',
method: 'get',
params: { bsManageTags }
})
}

View File

@ -95,13 +95,13 @@
<el-col :span="12">
<el-form-item label="治疗结果" prop="result">
<el-select v-model="form.result" placeholder="请选择治疗结果" style="width: 100%;">
<el-option v-for="item in diag_status" :key="item.value" :label="item.label"
<el-option v-for="item in diag_result" :key="item.value" :label="item.label"
:value="item.value" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="转入羊舍" prop="sheepfoldId">
<el-form-item label="转入羊舍" >
<el-select v-model="form.sheepfoldId" placeholder="请选择转入羊舍" filterable
style="width: 100%;">
<el-option v-for="item in sheepfolds" :key="item.id" :label="item.name"
@ -139,7 +139,7 @@ import { listSheepfold_management } from "@/api/fileManagement/sheepfold_managem
import { addDiagnosis } from "@/api/biosafety/diagnosis"
const { proxy } = getCurrentInstance()
const { diag_status } = proxy.useDict( "diag_status")
const { diag_result } = proxy.useDict( "diag_result")

View File

@ -12,7 +12,7 @@
<el-option v-for="item in typeOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="使用方法" prop="medicType">
<el-form-item label="使用方法" prop="usageId">
<el-select v-model="queryParams.usageId" placeholder="请选择药品使用方法" clearable style="width: 180px">
<el-option v-for="item in usageOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
@ -25,8 +25,7 @@
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd"
v-hasPermi="['system:medicine:add']">新增</el-button>
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:medicine:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate"
@ -36,15 +35,15 @@
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete"
v-hasPermi="['system:medicine:remove']">删除</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" />
</el-row>
<el-table v-loading="loading" :data="medicineList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="药品编号" align="center" prop="medica" />
<el-table-column label="药品名称" align="center" prop="name" />
<el-table-column label="药品类型" align="center" prop="medicType" :formatter="formatType"></el-table-column>
<el-table-column label="使用方法" align="center" prop="usage" :formatter="formatUsage"></el-table-column>
<el-table-column label="药品类型" align="center" prop="medicType" :formatter="formatType" />
<el-table-column label="使用方法" align="center" prop="usageId" :formatter="formatUsage" />
<el-table-column label="备注" align="center" prop="comment" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
@ -57,7 +56,7 @@
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize" @pagination="getList" />
v-model:limit="queryParams.pageSize" @pagination="getList" />
<!-- 添加或修改药品对话框 -->
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
@ -73,13 +72,11 @@
<el-option v-for="item in typeOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="使用方法" prop="medicType">
<el-form-item label="使用方法" prop="usageId">
<el-select v-model="form.usageId" placeholder="请选择药品使用方法">
<el-option v-for="item in usageOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="备注" prop="comment">
<el-input v-model="form.comment" placeholder="请输入备注" :rows="3" type="textarea" />
</el-form-item>
@ -96,8 +93,9 @@
<script setup name="Medicine">
import { listMedicine, getMedicine, delMedicine, addMedicine, updateMedicine } from "@/api/biosafety/medicine"
import {listType} from "@/api/biosafety/type"
import {listUsage} from "@/api/biosafety/usage"
import { listType } from "@/api/biosafety/type"
import { listUsage } from "@/api/biosafety/usage"
import { ref, reactive, toRefs, getCurrentInstance } from 'vue'
const { proxy } = getCurrentInstance()
@ -121,59 +119,41 @@ const data = reactive({
medicType: null,
usageId: null,
},
rules: {
}
rules: {}
})
const { queryParams, form, rules } = toRefs(data)
//
const typeOptions = ref()
// 使
const usageOptions = ref()
// undefined
const typeOptions = ref([])
const usageOptions = ref([])
/* 查询药品类型 */
function getTypeOptions() {
listType().then(response => {
typeOptions.value = response.rows.map(item => ({
typeOptions.value = response.rows?.map(item => ({
value: item.id,
label: item.name
}))
})) || []
})
}
/* 查询药品使用方法 */
function getUsageOptions() {
listUsage().then(response => {
usageOptions.value = response.rows.map(item => ({
usageOptions.value = response.rows?.map(item => ({
value: item.id,
label: item.name
}))
})) || []
})
}
const formatType = (row) => {
let result = ''
for (const item of typeOptions.value) {
if (item.value === row.medicType) {
result = item.label
break
}
}
return result
}
const formatUsage = (row) => {
let result = ''
for (const item of usageOptions.value) {
if (item.value === row.usageId) {
result = item.label
break
}
}
return result
}
/* ✅ 安全的 formatter */
const formatType = (row) =>
(typeOptions.value || []).find(item => item.value === row.medicType)?.label ?? row.medicType
const formatUsage = (row) =>
(usageOptions.value || []).find(item => item.value === row.usageId)?.label ?? row.usageId
/** 查询药品列表 */
function getList() {
@ -184,52 +164,39 @@ function getList() {
loading.value = false
})
}
//
function cancel() {
open.value = false
reset()
}
//
function reset() {
form.value = {
id: null,
medica: null,
name: null,
medicType: null,
usage: null,
comment: null
}
form.value = { id: null, medica: null, name: null, medicType: null, usageId: null, comment: null }
proxy.resetForm("medicineRef")
}
/** 搜索按钮操作 */
function handleQuery() {
queryParams.value.pageNum = 1
getList()
}
/** 重置按钮操作 */
function resetQuery() {
proxy.resetForm("queryRef")
handleQuery()
}
//
function handleSelectionChange(selection) {
ids.value = selection.map(item => item.id)
single.value = selection.length != 1
single.value = selection.length !== 1
multiple.value = !selection.length
}
/** 新增按钮操作 */
function handleAdd() {
reset()
open.value = true
title.value = "添加药品"
}
/** 修改按钮操作 */
function handleUpdate(row) {
reset()
const _id = row.id || ids.value
@ -240,18 +207,17 @@ function handleUpdate(row) {
})
}
/** 提交按钮 */
function submitForm() {
proxy.$refs["medicineRef"].validate(valid => {
if (valid) {
if (form.value.id != null) {
updateMedicine(form.value).then(response => {
updateMedicine(form.value).then(() => {
proxy.$modal.msgSuccess("修改成功")
open.value = false
getList()
})
} else {
addMedicine(form.value).then(response => {
addMedicine(form.value).then(() => {
proxy.$modal.msgSuccess("新增成功")
open.value = false
getList()
@ -261,25 +227,21 @@ function submitForm() {
})
}
/** 删除按钮操作 */
function handleDelete(row) {
const _ids = row.id || ids.value
proxy.$modal.confirm('是否确认删除药品编号为"' + _ids + '"的数据项?').then(function () {
return delMedicine(_ids)
}).then(() => {
getList()
proxy.$modal.msgSuccess("删除成功")
}).catch(() => { })
proxy.$modal.confirm('是否确认删除药品编号为"' + _ids + '"的数据项?')
.then(() => delMedicine(_ids))
.then(() => {
getList()
proxy.$modal.msgSuccess("删除成功")
})
}
/** 导出按钮操作 */
function handleExport() {
proxy.download('system/medicine/export', {
...queryParams.value
}, `medicine_${new Date().getTime()}.xlsx`)
proxy.download('system/medicine/export', { ...queryParams.value }, `medicine_${new Date().getTime()}.xlsx`)
}
getList()
getTypeOptions()
getUsageOptions()
</script>
</script>

View File

@ -147,7 +147,17 @@
</el-select>
</template>
</el-table-column>
<el-table-column label="使用时间" >
<template #default="scope">
<el-date-picker
v-model="scope.row.usetime"
type="date"
placeholder="选择日期"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
style="width: 100%;"/>
</template>
</el-table-column>
<el-table-column label="生产厂家" prop="manufacturer">
<template #default="scope">
<el-input v-model="scope.row.manufacturer" placeholder="请输入生产厂家" style="width:100%" />
@ -175,6 +185,13 @@
<el-input v-model="form.veterinarian" placeholder="请输入兽医姓名" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="治疗状态">
<el-select v-model="form.status" placeholder="请选择治疗状态">
<el-option v-for="u in treat_status" :key="u.value" :label="u.label" :value="u.value" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="备注">
@ -209,6 +226,7 @@ import { ElMessage } from 'element-plus'
import { useRoute, useRouter } from 'vue-router'
const { proxy } = getCurrentInstance()
const { treat_status } = proxy.useDict("treat_status")
const route = useRoute()
const router = useRouter()
@ -346,11 +364,11 @@ const rules = {
}
const swPresDetailList = ref([
{ mediId: null, dosage: 0, unitId: null, usageId: null, manufacturer: '', batchNumber: '' }
{ mediId: null, dosage: 0, unitId: null, usageId: null, usetime: new Date(),manufacturer: '', batchNumber: '' }
])
const handleAddSwPresDetail = () => {
swPresDetailList.value.push({ mediId: null, dosage: 0, unitId: null, usageId: null, manufacturer: '', batchNumber: '' })
swPresDetailList.value.push({ mediId: null, dosage: 0, unitId: null, usageId: null,usetime: new Date(), manufacturer: '', batchNumber: '' })
}
const deletePresDetail = (row) => {
@ -380,6 +398,8 @@ function submitForm() {
dosage: item.dosage,
unit: item.unitId,
usageId: item.usageId,
usetime: item.usetime ? new Date(item.usetime).getTime() : null,
manufacturer: item.manufacturer,
batchNumber: item.batchNumber
}))

View File

@ -9,6 +9,11 @@
<el-form-item label="羊只耳号" prop="sheepNo">
<el-input v-model="queryParams.sheepNo" placeholder="请输入羊只耳号" clearable />
</el-form-item>
<el-form-item label="治疗状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择治疗状态" style="width: 120px;">
<el-option v-for="u in treat_status" :key="u.value" :label="u.label" :value="u.value" />
</el-select>
</el-form-item>
<el-form-item label="兽医" prop="veterinary">
<el-input v-model="queryParams.veterinary" placeholder="请输入兽医" clearable />
</el-form-item>
@ -59,12 +64,16 @@
<el-table-column label="泌乳天数" align="center" prop="lactDay" />
<el-table-column label="怀孕天数" align="center" prop="gestDay" />
<el-table-column label="疾病类型" align="center" prop="diseaseName" />
<el-table-column label="治疗状态" align="center" prop="treatmentPlan">
<template #default="scope"><dict-tag :options="treat_status" :value="scope.row.status" /></template>
</el-table-column>
<el-table-column label="兽医" align="center" prop="veterinary" />
<el-table-column label="备注" align="center" prop="comment" />
<el-table-column label="操作" align="center" width="200" fixed="right">
<template #default="scope">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)">修改</el-button>
<el-button link type="primary" @click="gotDiag(scope.row)">诊断</el-button>
<el-button link type="primary" @click="gotDiag(scope.row)"
v-if="scope.row.status == 0 || scope.row.status == 1">诊断</el-button>
<el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
@ -74,8 +83,8 @@
v-model:limit="queryParams.pageSize" @pagination="getList" />
<!-- 新增弹窗 -->
<el-dialog title="添加治疗记录" v-model="addDialog" width="65%" top="5vh" append-to-body destroy-on-close>
<el-form ref="addFormRef" :model="addForm" :rules="rules" label-width="140px" size="large">
<el-dialog title="添加治疗记录" v-model="addDialog" width="70%" top="5vh" append-to-body destroy-on-close>
<el-form ref="addFormRef" :model="addForm" :rules="rules" label-width="80px" size="large">
<el-row :gutter="20">
<el-col :span="24">
<el-form-item label="羊只耳号" required>
@ -137,16 +146,16 @@
<el-table-column label="序号" width="60">
<template #default="scope">{{ scope.$index + 1 }}</template>
</el-table-column>
<el-table-column label="药品">
<el-table-column label="药品" width="160px">
<template #default="scope">
<el-select v-model="scope.row.mediId" filterable placeholder="请选择药品">
<el-option v-for="m in medicines" :key="m.value" :label="m.label" :value="m.value" />
</el-select>
</template>
</el-table-column>
<el-table-column label="用量">
<el-table-column label="用量" width="160px">
<template #default="scope">
<el-input-number v-model="scope.row.dosage" :min="0" :precision="1" />
<el-input-number v-model="scope.row.dosage" :min="0" :precision="1" style="width: 120px;"/>
</template>
</el-table-column>
<el-table-column label="单位">
@ -163,23 +172,18 @@
</el-select>
</template>
</el-table-column>
<el-table-column label="使用时间" >
<template #default="scope">
<el-date-picker
v-model="scope.row.usetime"
type="date"
placeholder="选择日期"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
style="width: 100%;"/>
<el-table-column label="使用时间" width="160px">
<template #default="scope">
<el-date-picker v-model="scope.row.usetime" type="date" placeholder="选择日期" format="YYYY-MM-DD"
value-format="YYYY-MM-DD" style="width:100%;" />
</template>
</el-table-column>
<el-table-column label="生产厂家">
<el-table-column label="生产厂家" width="160px">
<template #default="scope">
<el-input v-model="scope.row.manufacturer" placeholder="生产厂家" />
</template>
</el-table-column>
<el-table-column label="生产批号">
<el-table-column label="生产批号" width="160px">
<template #default="scope">
<el-input v-model="scope.row.batchNumber" placeholder="批号" />
</template>
@ -197,6 +201,13 @@
<el-input v-model="addForm.veterinarian" placeholder="请输入兽医姓名" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="治疗状态">
<el-select v-model="addForm.status" placeholder="请选择治疗状态">
<el-option v-for="u in treat_status" :key="u.value" :label="u.label" :value="u.value" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="备注">
@ -214,7 +225,7 @@
<!-- 修改弹窗 -->
<el-dialog title="修改治疗记录" v-model="editDialog" width="70%" top="5vh" append-to-body destroy-on-close>
<el-form ref="editFormRef" :model="editForm" :rules="rules" label-width="140px" size="large">
<el-form ref="editFormRef" :model="editForm" :rules="rules" label-width="80px" size="large">
<!-- 羊只基本信息展示只读 -->
<el-row :gutter="20">
<el-col :span="6">
@ -328,35 +339,29 @@
<el-table-column label="单位">
<template #default="scope">
<el-select v-model="scope.row.unit" placeholder="单位">
<el-option v-for="u in units" :key="u.value" :label="u.label" :value="u.value+''" />
<el-option v-for="u in units" :key="u.value" :label="u.label" :value="u.value + ''" />
</el-select>
</template>
</el-table-column>
<el-table-column label="使用方法">
<template #default="scope">
<el-select v-model="scope.row.usageId" placeholder="用法">
<el-option v-for="u in usages" :key="u.value" :label="u.label" :value="u.value+''" />
<el-option v-for="u in usages" :key="u.value" :label="u.label" :value="u.value + ''" />
</el-select>
</template>
</el-table-column>
<el-table-column label="使用时间" >
<template #default="scope">
<el-date-picker
v-model="scope.row.usetime"
type="date"
placeholder="选择日期"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
style="width: 100%;"
/>
</template>
</el-table-column>
<el-table-column label="生产厂家">
<el-table-column label="使用时间" width="160px">
<template #default="scope">
<el-date-picker v-model="scope.row.usetime" type="date" placeholder="选择日期" format="YYYY-MM-DD"
value-format="YYYY-MM-DD" style="width: 100%;" />
</template>
</el-table-column>
<el-table-column label="生产厂家" width="160px">
<template #default="scope">
<el-input v-model="scope.row.manufacturer" placeholder="生产厂家" />
</template>
</el-table-column>
<el-table-column label="生产批号">
<el-table-column label="生产批号" width="160px">
<template #default="scope">
<el-input v-model="scope.row.batchNumber" placeholder="批号" />
</template>
@ -374,13 +379,20 @@
<el-input v-model="editForm.veterinarian" placeholder="请输入兽医姓名" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="治疗状态">
<el-select v-model="editForm.status" placeholder="请选择治疗状态">
<el-option v-for="u in treat_status" :key="u.value" :label="u.label" :value="u.value + ''" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="备注">
<el-input type="textarea" :rows="3" v-model="editForm.comment" placeholder="请输入备注" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
@ -390,30 +402,31 @@
</template>
</el-dialog>
<!-- 新增诊疗弹窗 -->
<el-dialog title="新增诊疗记录" v-model="diagnosisDialog" width="50%" append-to-body destroy-on-close>
<el-form label-width="120px">
<el-form-item label="选中羊只">
<el-tag v-for="no in selectedSheepNos" :key="no" style="margin-right: 5px">{{ no }}</el-tag>
</el-form-item>
<el-form-item label="诊疗结果" prop="result">
<el-select v-model="addDia.result" placeholder="请选择治疗结果" style="width: 100%;">
<el-option v-for="item in diag_result" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
<el-dialog title="新增诊疗记录" v-model="diagnosisDialog" width="50%" append-to-body destroy-on-close>
<el-form label-width="120px">
<el-form-item label="选中羊只">
<el-tag v-for="no in selectedSheepNos" :key="no" style="margin-right: 5px">{{ no }}</el-tag>
</el-form-item>
<el-form-item label="转入羊舍" prop="sheepfoldId">
<el-select v-model="addDia.sheepfoldId" filterable placeholder="请选择转入羊舍"
style="width: 100%;">
<el-option v-for="item in sheepfolds" :key="item.id" :label="item.name"
:value="item.id" />
</el-select>
<el-form-item label="治疗日期" prop="datetime">
<el-date-picker v-model="addDia.datetime" type="date" style="width: 100%" />
</el-form-item>
<el-form-item label="诊疗结果" prop="result">
<el-select v-model="addDia.result" placeholder="请选择治疗结果" style="width: 100%;">
<el-option v-for="item in diag_result" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="转入羊舍" prop="sheepfoldId">
<el-select v-model="addDia.sheepfoldId" filterable placeholder="请选择转入羊舍" style="width: 100%;">
<el-option v-for="item in sheepfolds" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="diagnosisDialog = false">取消</el-button>
<el-button type="primary" @click="submitDiagnosis">确认</el-button>
</template>
</el-dialog>
<template #footer>
<el-button @click="diagnosisDialog = false">取消</el-button>
<el-button type="primary" @click="submitDiagnosis">确认</el-button>
</template>
</el-dialog>
</div>
</template>
@ -433,7 +446,7 @@ import { useRouter } from 'vue-router'
const router = useRouter()
const { proxy } = getCurrentInstance()
const { sheep_gender,diag_result } = proxy.useDict("sheep_gender","diag_result")
const { sheep_gender, diag_result, treat_status } = proxy.useDict("sheep_gender", "diag_result", "treat_status")
/* ---------- 列表区域 ---------- */
@ -477,6 +490,7 @@ const addForm = reactive({
diseasePid: null,
diseaseId: null,
veterinarian: '',
stats: '',
comment: ''
})
@ -494,6 +508,7 @@ const editForm = reactive({
sheepType: '',
monthAge: '',
gender: '',
status: '',
parity: '',
breed: '',
lactDay: '',
@ -507,7 +522,7 @@ const rules = {
}
const swPresDetailList = ref([
{ mediId: null, dosage: 0, unit: null, usageId: null, usetime: new Date().toISOString().slice(0, 10),manufacturer: '', batchNumber: '' }
{ mediId: null, dosage: 0, unit: null, usageId: null, usetime: new Date().toISOString().slice(0, 10), manufacturer: '', batchNumber: '' }
])
/* ---------- 新增诊疗 ---------- */
@ -515,7 +530,8 @@ const diagnosisDialog = ref(false)
const selectedSheepNos = ref([])
const addDia = reactive({
sheepfoldId: null,
result:null,
result: null,
datetime: new Date().toISOString().slice(0, 10)
})
@ -533,8 +549,9 @@ function handleAddDiagnosis() {
function submitDiagnosis() {
const data = {
treatIds: ids.value,
result:addDia.result,
sheepfoldId:addDia.sheepfoldId
result: addDia.result,
datetime: addDia.datetime,
sheepfoldId: addDia.sheepfoldId
}
request.post('/diagnosis/diagnosis/adds', data).then(() => {
proxy.$modal.msgSuccess('诊疗成功')
@ -592,7 +609,7 @@ function handleAddSwPresDetail() {
dosage: 0,
unit: null,
usageId: null,
usetime:new Date().toISOString().slice(0, 10),
usetime: new Date().toISOString().slice(0, 10),
manufacturer: '',
batchNumber: ''
})
@ -669,6 +686,7 @@ function handleUpdate(row) {
gender: res.data.gender,
parity: res.data.parity,
breed: res.data.breed,
status: res.data.status,
lactDay: res.data.lactDay,
gestDay: res.data.gestDay
})
@ -770,4 +788,3 @@ onMounted(() => {
})
})
</script>

View File

@ -202,6 +202,11 @@
<el-table-column label="用量" prop="dosage" width="80" />
<el-table-column label="单位" prop="unit" align="center" :formatter="formatUnit" />
<el-table-column label="使用方法" align="center" prop="usageId" :formatter="formatUsage" />
<el-table-column v-if="form.useType==4" label="使用时间" align="center" prop="useTime" width="120">
<template #default="scope">
<span>{{ parseTime(scope.row.usetime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="生产厂家" prop="manufacturer" show-overflow-tooltip />
<el-table-column label="生产批号" prop="batchNumber" width="120" />
</el-table>

View File

@ -1,5 +1,6 @@
<template>
<div class="app-container">
<!-- 搜索表单 -->
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="年月" prop="datetime">
<el-date-picker clearable
@ -25,6 +26,7 @@
</el-form-item>
</el-form>
<!-- 操作按钮区域 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
@ -67,7 +69,7 @@
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<!-- 修改表格列宽设置 -->
<!-- 数据表格 -->
<el-table
v-loading="loading"
:data="dryMatterCorrectionList"
@ -88,7 +90,8 @@
<el-table-column label="干物质标准" align="center" prop="standard" />
<el-table-column label="干物质系数" align="center" prop="coefficient">
<template #default="scope">
<span>{{ scope.row.coefficient != null ? scope.row.coefficient.toFixed(4) : '' }}</span>
<!-- 修复确保显示两位小数 -->
<span>{{ formatCoefficient(scope.row.coefficient) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
@ -99,6 +102,7 @@
</el-table-column>
</el-table>
<!-- 分页组件 -->
<pagination
v-show="total>0"
:total="total"
@ -107,7 +111,7 @@
@pagination="getList"
/>
<!-- 添加或修改干物质校正对话框 -->
<!-- 添加/修改对话框 -->
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
<el-form ref="dryMatterCorrectionRef" :model="form" :rules="rules" label-width="100px">
<el-form-item label="年月" prop="datetime">
@ -136,7 +140,8 @@
<el-input v-model="form.standard" placeholder="请输入干物质标准" @input="calculateCoefficient" />
</el-form-item>
<el-form-item label="干物质系数">
<el-input :value="form.coefficient != null ? form.coefficient.toFixed(4) : ''" placeholder="自动计算" readonly>
<!-- 修复确保显示两位小数 -->
<el-input :value="formatCoefficient(form.coefficient)" placeholder="自动计算" readonly>
</el-input>
</el-form-item>
</el-form>
@ -151,6 +156,7 @@
</template>
<script setup name="DryMatterCorrection">
// API
import {
listDryMatterCorrection,
getDryMatterCorrection,
@ -162,6 +168,7 @@ import {
const { proxy } = getCurrentInstance()
const { da_ranch } = proxy.useDict('da_ranch')
//
const dryMatterCorrectionList = ref([])
const open = ref(false)
const loading = ref(true)
@ -172,9 +179,11 @@ const multiple = ref(true)
const total = ref(0)
const title = ref("")
// 使reactive
const data = reactive({
form: {
coefficient: null
coefficient: null,
standard: 18 // 18
},
queryParams: {
pageNum: 1,
@ -183,8 +192,16 @@ const data = reactive({
factory: null,
},
rules: {
datetime: [{ required: true, message: "年月不能为空", trigger: "blur" }],
factory: [{ required: true, message: "厂区不能为空", trigger: "blur" }],
datetime: [{
required: true,
message: "年月不能为空",
trigger: "blur"
}],
factory: [{
required: true,
message: "厂区不能为空",
trigger: "blur"
}],
content: [
{ required: true, message: "干物质含量不能为空", trigger: "blur" },
{ pattern: /^\d+(\.\d+)?$/, message: "请输入有效数字", trigger: "blur" }
@ -205,10 +222,20 @@ const data = reactive({
const { queryParams, form, rules } = toRefs(data)
/** 计算干物质系数 */
/** 格式化系数显示,保留两位小数 */
function formatCoefficient(value) {
if (value === null || value === undefined) return '';
//
const num = typeof value === 'string' ? parseFloat(value) : value;
return !isNaN(num) ? num.toFixed(2) : '';
}
/** 计算干物质系数 - 保留两位小数 */
function calculateCoefficient() {
if (form.value.content && form.value.standard && form.value.standard != 0) {
form.value.coefficient = parseFloat(form.value.content) / parseFloat(form.value.standard);
const content = parseFloat(form.value.content);
const standard = parseFloat(form.value.standard);
form.value.coefficient = Math.round((content / standard) * 100) / 100;
} else {
form.value.coefficient = null;
}
@ -237,12 +264,13 @@ function reset() {
datetime: null,
factory: null,
content: null,
standard: null,
standard: 18, // 18
coefficient: null
}
proxy.resetForm("dryMatterCorrectionRef")
}
/** 搜索按钮操作 */
function handleQuery() {
queryParams.value.pageNum = 1
@ -294,7 +322,9 @@ function submitForm() {
if (valid) {
//
if (form.value.content && form.value.standard && form.value.standard != 0) {
form.value.coefficient = form.value.content / form.value.standard;
const content = parseFloat(form.value.content);
const standard = parseFloat(form.value.standard);
form.value.coefficient = Math.round((content / standard) * 100) / 100;
}
if (form.value.id != null) {
@ -302,12 +332,26 @@ function submitForm() {
proxy.$modal.msgSuccess("修改成功")
open.value = false
getList()
}).catch(error => {
//
if (error.message && error.message.includes("已存在记录")) {
proxy.$modal.msgError(error.message);
} else {
proxy.$modal.msgError("修改失败:" + (error.message || "未知错误"));
}
})
} else {
addDryMatterCorrection(form.value).then(response => {
proxy.$modal.msgSuccess("新增成功")
open.value = false
getList()
}).catch(error => {
//
if (error.message && error.message.includes("已存在记录")) {
proxy.$modal.msgError(error.message);
} else {
proxy.$modal.msgError("新增失败:" + (error.message || "未知错误"));
}
})
}
}

View File

@ -49,8 +49,16 @@
<el-table-column prop="parity" label="胎次" />
<el-table-column prop="factory" label="厂区" />
<el-table-column prop="classes" label="班次" />
<el-table-column prop="milk" label="班次产奶量" />
<el-table-column prop="correctedMilk" label="班次校正奶量" />
<el-table-column prop="milk" label="班次产奶量" >
<template #default="{ row }">
{{ row.milk ? Number(row.milk).toFixed(2) : '-' }}
</template>
</el-table-column>
<el-table-column prop="correctedMilk" label="班次校正奶量" >
<template #default="{ row }">
{{ row.milk ? Number(row.milk).toFixed(2) : '-' }}
</template>
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total"

View File

@ -1,41 +1,217 @@
<template>
<div class="app-container">
<el-table
v-loading="loading"
:data="parityCorrectionList"
style="width: 100%"
border
stripe
>
<el-table-column label="胎次" align="center" prop="parity" width="120" />
<el-table-column label="系数" align="center" prop="coef" width="120" />
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
<!-- 搜索条件 只保留胎次 -->
<el-form-item label="胎次" prop="parity">
<el-input
v-model="queryParams.parity"
placeholder="请输入胎次"
clearable
@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>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="Plus"
@click="handleAdd"
v-hasPermi="['parityCorrection:parityCorrection:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="Edit"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['parityCorrection:parityCorrection:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="Delete"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['parityCorrection:parityCorrection:remove']"
>删除</el-button>
</el-col>
<!-- 去掉导出按钮 -->
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="parityCorrectionList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<!-- 去掉 ${comment} -->
<el-table-column label="胎次" align="center" prop="parity" />
<el-table-column label="系数" align="center" prop="coef" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['parityCorrection:parityCorrection:edit']">修改</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['parityCorrection:parityCorrection:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改胎次校正对话框 -->
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
<el-form ref="parityCorrectionRef" :model="form" :rules="rules" label-width="80px">
<el-form-item label="胎次" prop="parity">
<el-input v-model="form.parity" placeholder="请输入胎次" />
</el-form-item>
<el-form-item label="系数" prop="coef">
<el-input v-model="form.coef" placeholder="请输入系数" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup name="ParityCorrection">
import { listParityCorrection } from '@/api/dairyProducts/parityCorrection/parityCorrection.js'
import { ref, onMounted } from 'vue'
import { listParityCorrection, getParityCorrection, delParityCorrection, addParityCorrection, updateParityCorrection } from "@/api/dairyProducts/parityCorrection/parityCorrection"
const { proxy } = getCurrentInstance()
const loading = ref(false)
const parityCorrectionList = ref([])
const open = ref(false)
const loading = ref(true)
const showSearch = ref(true)
const ids = ref([])
const single = ref(true)
const multiple = ref(true)
const total = ref(0)
const title = ref("")
const data = reactive({
form: {},
queryParams: {
pageNum: 1,
pageSize: 10,
parity: null //
},
rules: {}
})
const { queryParams, form, rules } = toRefs(data)
/** 查询胎次校正列表 */
function getList() {
loading.value = true
listParityCorrection().then(res => {
parityCorrectionList.value = res.rows || res.data || [] //
}).finally(() => {
listParityCorrection(queryParams.value).then(response => {
parityCorrectionList.value = response.rows
total.value = response.total
loading.value = false
})
}
onMounted(() => {
getList()
})
</script>
<style scoped>
.app-container {
padding: 20px;
//
function cancel() {
open.value = false
reset()
}
</style>
//
function reset() {
form.value = {
id: null,
parity: null,
coef: null
}
proxy.resetForm("parityCorrectionRef")
}
/** 搜索按钮操作 */
function handleQuery() {
queryParams.value.pageNum = 1
getList()
}
/** 重置按钮操作 */
function resetQuery() {
proxy.resetForm("queryRef")
handleQuery()
}
//
function handleSelectionChange(selection) {
ids.value = selection.map(item => item.id)
single.value = selection.length != 1
multiple.value = !selection.length
}
/** 新增按钮操作 */
function handleAdd() {
reset()
open.value = true
title.value = "添加胎次校正"
}
/** 修改按钮操作 */
function handleUpdate(row) {
reset()
const _id = row.id || ids.value
getParityCorrection(_id).then(response => {
form.value = response.data
open.value = true
title.value = "修改胎次校正"
})
}
/** 提交按钮 */
function submitForm() {
proxy.$refs["parityCorrectionRef"].validate(valid => {
if (valid) {
if (form.value.id != null) {
updateParityCorrection(form.value).then(() => {
proxy.$modal.msgSuccess("修改成功")
open.value = false
getList()
})
} else {
addParityCorrection(form.value).then(() => {
proxy.$modal.msgSuccess("新增成功")
open.value = false
getList()
})
}
}
})
}
/** 删除按钮操作 */
function handleDelete(row) {
const _ids = row.id || ids.value
proxy.$modal.confirm('是否确认删除胎次校正编号为"' + _ids + '"的数据项?').then(function() {
return delParityCorrection(_ids)
}).then(() => {
getList()
proxy.$modal.msgSuccess("删除成功")
}).catch(() => {})
}
getList()
</script>

View File

@ -83,7 +83,7 @@
<el-table-column label="系统奶量" align="center" prop="systemMilk" /> <!-- 修改这里 -->
<el-table-column label="称重系数" align="center" prop="coefficient">
<template #default="scope">
<span>{{ scope.row.coefficient.toFixed(4) }}</span>
<span>{{ scope.row.coefficient.toFixed(2) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
@ -245,25 +245,31 @@ function handleUpdate(row) {
})
}
/** 提交按钮 */
/* 提交按钮 */
function submitForm() {
proxy.$refs["weightCorrectionRef"].validate(valid => {
if (valid) {
//
form.value.actual = parseFloat(form.value.actual)
form.value.systemMilk = parseFloat(form.value.systemMilk) //
form.value.systemMilk = parseFloat(form.value.systemMilk)
if (form.value.id != null) {
updateWeightCorrection(form.value).then(response => {
proxy.$modal.msgSuccess("修改成功")
open.value = false
getList()
}).catch(error => {
//
proxy.$modal.msgError(error.response.data.msg || "修改失败")
})
} else {
addWeightCorrection(form.value).then(response => {
proxy.$modal.msgSuccess("新增成功")
open.value = false
getList()
}).catch(error => {
//
proxy.$modal.msgError(error.response.data.msg || "新增失败")
})
}
}

View File

@ -43,6 +43,12 @@
<el-table-column label="配方编号" align="center" prop="formulaId" />
<el-table-column label="配方批号" align="center" prop="formulaBatchId" />
<el-table-column label="饲草班人员" align="center" prop="zookeeper" />
<el-table-column label="计划日期" align="center" prop="rootPlan.planDate" width="180">
<template #default="scope">
<!-- <span>{{ parseTime(scope.row.rootPlan.planDate, '{y}-{m}-{d}') }}</span> -->
<span>{{ scope.row.rootPlan ? parseTime(scope.row.rootPlan.planDate, '{y}-{m}-{d}') : '' }}</span>
</template>
</el-table-column>
<el-table-column label="配料日期" align="center" prop="deployDate" width="180">
<template #default="scope">
<span>{{ parseTime(scope.row.deployDate, '{y}-{m}-{d}') }}</span>
@ -85,7 +91,7 @@
</div>
<!-- 弹框详情/修改 -->
<el-dialog :title="title" v-model="open" width="60%" append-to-body s v-if="openModel === 'view'">
<el-dialog :title="title" v-model="open" width="60%" append-to-body v-if="openModel === 'view'">
<!-- 详情页只读展示 -->
<div style="padding-bottom:20px ;">
<el-descriptions :column="2" border>

View File

@ -82,7 +82,8 @@
<el-table-column label="饲草班人员" align="center" prop="zookeeper" />
<el-table-column label="饲喂计划日期" align="center" prop="planDate" width="180">
<template #default="scope">
<span>{{ parseTime(scope.row.planDate, '{y}-{m}-{d}') }}</span>
<!-- <span>{{ parseTime(scope.row.planDate, '{y}-{m}-{d}') }}</span> -->
<span>{{ scope.row.planDate ? parseTime(scope.row.planDate, '{y}-{m}-{d}') : '' }}</span>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />

View File

@ -0,0 +1,619 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="配方编号" prop="formulaId">
<el-input v-model="queryParams.formulaId" placeholder="请输入配方编号" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="配方批号" prop="formulaBatchId">
<el-input v-model="queryParams.formulaBatchId" placeholder="请输入配方批号" clearable @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>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd"
v-hasPermi="['feed:FeedStatistic:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate"
v-hasPermi="['feed:FeedStatistic:edit']">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete"
v-hasPermi="['feed:FeedStatistic:remove']">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport"
v-hasPermi="['feed:FeedStatistic:export']">导出</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="FeedStatisticList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="UUID" align="center" prop="id" />
<el-table-column label="配方编号" align="center" prop="formulaId" />
<el-table-column label="配方批号" align="center" prop="formulaBatchId" />
<el-table-column label="羊只数量" align="center" prop="sheepFoldCount" />
<!-- <el-table-column label="青贮损耗比例" align="center" prop="silageLossRate" /> -->
<el-table-column label="总饲喂量" align="center" prop="feedTotalSize" />
<el-table-column label="日均饲喂量" align="center" prop="feedDailySize" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" icon="Edit" @click="handleMaterialView(scope.row)"
v-hasPermi="['feed:FeedStatistic:edit']">查看</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
v-hasPermi="['feed:FeedStatistic:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize" @pagination="getList" />
<!-- 弹框详情/修改 -->
<el-dialog :title="title" v-model="open" width="60%" append-to-body
v-if="openModel === 'viewMaterial' || openModel === 'add'">
<div>
<el-form ref="FeedStatisticRef" :model="showFeedStatistic" :rules="rules" label-width="100px">
<el-row :gutter="20">
<el-col :span="12" v-if="true">
<el-form-item label="UUID" prop="id">
<el-input v-model="showFeedStatistic.id" :disabled="true" />
</el-form-item>
</el-col>
<el-col :span="12" v-if="true">
<el-form-item label="配方编码" prop="formulaId">
<!-- <el-input v-model="form.formulaId" placeholder="请输入配方编码" /> -->
<el-select v-model="showFeedStatistic.formulaId" filterable placeholder="请选择配方编码" style="width: 100%"
@change="handleFormulaIdChange(showFeedStatistic, $event)" :disabled="isEdit">
<el-option v-for="item in formulaIdDict" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="批号" prop="batchId">
<!-- <el-input v-model="form.batchId" placeholder="请输入批号" /> -->
<el-select v-model="showFeedStatistic.formulaBatchId" filterable placeholder="请选择配方批号"
style="width: 100%" :disabled="isEdit"
@change="handleFormulaBatchIdChange(showFeedStatistic, $event)">
<el-option v-for="item in formulaBatchDict" :key="item.value" :label="item.label"
:value="item.value" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="羊只数量" prop="feedStage">
<el-input v-model="showFeedStatistic.sheepFoldCount" placeholder="请输入饲养阶段" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="日期" prop="planDate">
<el-date-picker clearable v-model="showFeedStatistic.feedDate" type="date" value-format="YYYY-MM-DD"
placeholder="请选择时间">
</el-date-picker>
</el-form-item>
</el-col>
</el-row>
<el-divider content-position="left">配方列表</el-divider>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" icon="Plus" @click="handleAddMaterial()">添加</el-button>
</el-col>
</el-row>
<el-table :data="showFeedStatistic.materialList" :rules="rules" :row-class-name="rowSgFormulaListDetailIndex"
@selection-change="handleSgFormulaListDetailSelectionChange" ref="swPresDetail" border stripe>
<el-table-column label="序号" align="center" prop="index" width="60" />
<el-table-column label="原料" prop="materialId" align="center">
<el-table-column label="名称" align="center">
<template #default="scope">
<el-select v-model="scope.row.materialId" filterable placeholder="请选择原料" style="width: 100%"
@change="handleMaterialChange(scope.row, $event)">
<el-option-group v-for="group in groupedMaterials" :key="group.label" :label="group.label">
<el-option v-for="item in group.options" :key="item.value" :label="item.label"
:value="item.value" />
</el-option-group>
</el-select>
</template>
</el-table-column>
<el-table-column label="类型" align="center" prop="isGranular">
<template #default="scope">
<dict-tag :options="material_type" :value="scope.row.isGranular" />
</template>
</el-table-column>
</el-table-column>
<el-table-column label="总量" prop="feedSize" align="center">
<template #default="scope">
<el-input-number v-model="scope.row.feedSize" placeholder="请输入饲喂总量" :min="0" :precision="1"
controls-position="right" />
</template>
</el-table-column>
<el-table-column label="类型" prop="isSupplement" align="center">
<template #default="scope">
<el-select v-model="scope.row.isSupplement" placeholder="请选择类型">
<el-option v-for="item in materialType" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" icon="Delete" @click="deleteFormulaListDetail(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-divider content-position="left">羊舍列表</el-divider>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" icon="Plus" @click="handleAddSheep()">添加</el-button>
</el-col>
<el-table :data="showFeedStatistic.sheepFoldList" :rules="rules"
:row-class-name="rowSgFormulaListDetailIndex" @selection-change="handleSgFormulaListDetailSelectionChange"
ref="swPresDetail" border stripe>
<el-table-column label="ID" prop="id" align="center" />
<!-- <el-input v-model="form.sheepHouseId" placeholder="请输入羊舍" /> -->
<el-table-column label="名称" align="center" prop="sheepfoldName">
<template #default="scope">
<el-select v-model="scope.row.id" filterable placeholder="请选择羊舍" style="width: 100%">
<el-option v-for="item in sheepFolderDict" :key="item.value" :label="item.label"
:value="item.value" />
</el-select>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" icon="Delete" @click="deleteSheepItem(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-row>
</el-form>
</div>
<!-- 底部按钮仅修改页显示 -->
<template #footer>
<div class="dialog-footer">
<el-button @click="cancel"> </el-button>
<el-button type="primary" @click="submitFormDetil"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup name="FeedStatistic">
import { listFeedStatistic, getFeedStatistic, delFeedStatistic, addFeedStatistic, updateFeedStatistic, initFeedStatistic } from "@/api/feed/FeedStatistic"
import { listFormulaManagement } from "@/api/feed/FormulaManagement"
import { listSheepfold } from "@/api/produce/manage_sheep/trans_group.js";
import { listMaterial } from "@/api/feed/Material"
import { ref } from "vue";
const { proxy } = getCurrentInstance()
const FeedStatisticList = ref([])
const open = ref(false)
const loading = ref(true)
const showSearch = ref(true)
const ids = ref([])
const single = ref(true)
const multiple = ref(true)
const total = ref(0)
const title = ref("")
const data = reactive({
form: {},
queryParams: {
pageNum: 1,
pageSize: 10,
formulaId: null,
formulaBatchId: null,
silageLossRate: null,
},
rules: {
formulaId: [
{ required: true, message: "配方编号不能为空", trigger: "blur" }
],
formulaBatchId: [
{ required: true, message: "配方批号不能为空", trigger: "blur" }
],
}
})
const { queryParams, form, rules } = toRefs(data)
//
const openModel = ref('')
//
const isEdit = ref(true)
const showFeedStatistic = ref({})
//
const sheepNameDict = ref({})
const sheepFolderDict = ref([]) //
const formulaIdDict = ref([]) //
const formulaBatchMap = ref([]) // ID
const formulaBatchDict = ref([]) // ()
//
const { material_type } = proxy.useDict('material_type')
//
const materialType = [
{ value: '1', label: '补饲原料' },
{ value: '0', label: '原料' }
]
//
const materials = ref([])
//
const materialQueryParams = ref({
materialId: null,
materialName: null,
isGranular: null
})
function getMaterials() {
listMaterial(materialQueryParams).then(response => {
console.log("获取原料列表:", response)
materials.value = response.rows.map(item => ({
value: item.materialId,
label: item.materialName,
isGranular: item.isGranular,
isSupplement: "0" // 0
}))
// console.log("", materials.value)
})
}
/** ================== 分组下拉列表部分 ======================== */
const groupedMaterials = ref([]) //
// isGranular
function getGroupMaterials() {
listMaterial(materialQueryParams).then(response => {
console.log("获取原料列表:", response)
// material_type
const groups = material_type.value.map(type => ({
label: type.label,
options: []
}))
// isGranular
response.rows.forEach(item => {
const group = groups.find(group => group.label === material_type.value.find(type => type.value === item.isGranular).label)
group.options.push({
value: item.materialId,
label: item.materialName
})
})
// groupedMaterials
groupedMaterials.value = groups
console.log("分组后的原料列表:", groupedMaterials.value)
})
}
// id
function getSheepHouseName(id) {
const dictItem = sheepFolderDict.value.find(item => item.value === id)
return dictItem ? dictItem.label : id
}
// ID ID
function getSheepHouseId(inputValue, sheepNameDict) {
if (!inputValue) return '';
//
if (/^\d+$/.test(inputValue)) {
return inputValue;
}
// id
const match = sheepNameDict.find(item => item.value === inputValue);
return match ? match.label : '';
}
/** ================== 配方字典 & 批号字典 ======================== */
// &
function getFormulaDict() {
listFormulaManagement().then(response => {
formulaIdDict.value = response.rows.map(item => ({
label: item.formulaId,
value: item.formulaId
}))
//
formulaBatchMap.value = []
//
response.rows.forEach(item => {
if (item.subFormulaList) {
item.subFormulaList.forEach(subItem => {
formulaBatchMap.value.push({
label: subItem.batchId,
value: subItem.batchId,
formulaId: item.formulaId // ID
})
})
}
})
})
}
//
function handleFormulaIdChange(row, value) {
//
if (!value) {
formulaBatchDict.value = []
} else {
// formulaIdbatchId
formulaBatchDict.value = formulaBatchMap.value;
formulaBatchDict.value = formulaBatchDict.value.filter(item => item.formulaId === value)
}
//
if (formulaBatchDict.value.length > 0) {
row.formulaBatchId = formulaBatchDict.value[0].value;
}
handleFormulaBatchIdChange(row, value);
}
// &
function handleFormulaBatchIdChange(row, $event) {
if (row.formulaId && row.formulaBatchId) {
queryParams.value.formulaId = row.formulaId
queryParams.value.formulaBatchId = row.formulaBatchId
queryParams.value.id = null // ID
// console.log("", queryParams.value)
initFeedStatistic(queryParams.value).then(response => {
Object.assign(showFeedStatistic.value, response.rows[0] || {})
total.value = response.total
loading.value = false
})
}
}
//
function handleMaterialView(row) {
showFeedStatistic.value = row
//
// showFeedStatistic.value.materialList = JSON.parse(showFeedStatistic.value.materialList || "[]");
// showFeedStatistic.value.sheepFoldList = JSON.parse(showFeedStatistic.value.sheepFoldList || "[]");
queryParams.value.id = row.id
listFeedStatistic(queryParams.value).then(response => {
FeedStatisticList.value = response.rows
total.value = response.total
loading.value = false
})
open.value = true
title.value = "饲喂量统计详情"
isEdit.value = true
openModel.value = 'viewMaterial'
}
function getSheepfoldDict() {
listSheepfold().then(response => {
sheepFolderDict.value = response.rows.map(item => ({
label: item.sheepfoldName,
value: item.id
}))
sheepNameDict.value = response.rows.map(item => ({
label: item.id,
value: item.sheepfoldName
}))
})
}
//
function handleAddMaterial() {
showFeedStatistic.value.materialList.push({
materialId: null,
materialName: null,
ratio: null,
isGranular: "0",
isSupplement: "0"
})
}
//
function deleteFormulaListDetail(row) {
const index = showFeedStatistic.value.materialList.findIndex(item => item.materialId === row.materialId)
if (index !== -1) {
showFeedStatistic.value.materialList.splice(index, 1)
}
}
//
function handleAddSheep() {
showFeedStatistic.value.sheepFoldList.push({
id: null,
sheepfoldName: null
})
}
//
function deleteSheepItem(row) {
const index = showFeedStatistic.value.sheepFoldList.findIndex(item => item.id === row.id)
if (index !== -1) {
showFeedStatistic.value.sheepFoldList.splice(index, 1)
}
}
//
function handleMaterialChange(row, selectedValue) {
const selectedItem = this.materials.find(item => item.value === selectedValue);
if (selectedItem) {
// materialName row
row.materialName = selectedItem.label;
row.isGranular = selectedItem.isGranular; // isGranular
row.isSupplement = selectedItem.isSupplement; // isSupplement
}
}
/** 查询饲喂量统计列表 */
function getList() {
loading.value = true
listFeedStatistic(queryParams.value).then(response => {
FeedStatisticList.value = response.rows
total.value = response.total
loading.value = false
})
}
//
function cancel() {
open.value = false
reset()
}
//
function reset() {
isEdit.value = true
showFeedStatistic.value = {
id: null,
formulaId: null,
formulaBatchId: null,
sheepFoldCount: null,
silageLossRate: null,
feedTotalSize: null,
feedDailySize: null,
materialList: null,
sheepFoldList: null
}
queryParams.value = {
pageNum: 1,
pageSize: 10,
formulaId: null,
formulaBatchId: null,
silageLossRate: null,
}
proxy.resetForm("FeedStatisticRef")
}
/** 搜索按钮操作 */
function handleQuery() {
queryParams.value.pageNum = 1
getList()
}
/** 重置按钮操作 */
function resetQuery() {
proxy.resetForm("queryRef")
handleQuery()
}
//
function handleSelectionChange(selection) {
ids.value = selection.map(item => item.id)
single.value = selection.length != 1
multiple.value = !selection.length
}
/** 新增按钮操作 */
function handleAdd() {
reset()
open.value = true
openModel.value = 'add'
isEdit.value = false
title.value = "添加饲喂量统计"
}
/** 修改按钮操作 */
function handleUpdate(row) {
reset()
const _id = row.id || ids.value
getFeedStatistic(_id).then(response => {
form.value = response.data
open.value = true
title.value = "修改饲喂量统计"
})
}
/** 提交按钮 */
function submitForm() {
proxy.$refs["FeedStatisticRef"].validate(valid => {
if (valid) {
if (form.value.id != null) {
updateFeedStatistic(form.value).then(response => {
proxy.$modal.msgSuccess("修改成功")
open.value = false
getList()
})
} else {
addFeedStatistic(form.value).then(response => {
proxy.$modal.msgSuccess("新增成功")
open.value = false
getList()
})
}
}
})
}
function submitFormDetil() {
proxy.$refs["FeedStatisticRef"].validate(valid => {
if (valid) {
if (showFeedStatistic.value.id != null) {
updateFeedStatistic(showFeedStatistic.value).then(response => {
proxy.$modal.msgSuccess("修改成功")
open.value = false
reset()
getList()
})
} else {
addFeedStatistic(showFeedStatistic.value).then(response => {
proxy.$modal.msgSuccess("新增成功")
open.value = false
reset()
getList()
})
}
}
})
}
/** 删除按钮操作 */
function handleDelete(row) {
const _ids = row.id || ids.value
proxy.$modal.confirm('是否确认删除饲喂量统计编号为"' + _ids + '"的数据项?').then(function () {
return delFeedStatistic(_ids)
}).then(() => {
getList()
proxy.$modal.msgSuccess("删除成功")
}).catch(() => { })
}
/** 导出按钮操作 */
function handleExport() {
proxy.download('feed/FeedStatistic/export', {
...queryParams.value
}, `FeedStatistic_${new Date().getTime()}.xlsx`)
}
/**
* 子表行序号计算
* 通过 el-table row-class-name 钩子给每一行写入 index 1 开始
*/
function rowSgFormulaListDetailIndex({ row, rowIndex }) {
row.index = rowIndex + 1
}
/**
* 子表多选回调
* 记录被选中的行序号数组
*/
function handleSgFormulaListDetailSelectionChange(selection) {
checkedSwPresDetail.value = selection.map(item => item.index)
}
getList()
getSheepfoldDict()
//
getMaterials()
//
getGroupMaterials()
//
getSheepfoldDict()
//
getFormulaDict()
</script>

View File

@ -0,0 +1,285 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="客户名称" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入客户名称"
clearable
@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>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="Plus"
@click="handleAdd"
v-hasPermi="['customer:customer:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="Edit"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['customer:customer:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="Delete"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['customer:customer:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="Download"
@click="handleExport"
v-hasPermi="['customer:customer:export']"
>导出</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="customerList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="客户名称" align="center" prop="name" />
<el-table-column label="客户电话" align="center" prop="phone" />
<el-table-column label="客户地址" align="center">
<template #default="scope">
{{ scope.row.province }}{{ scope.row.city }}{{ scope.row.district }}{{ scope.row.address }}
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['customer:customer:edit']">修改</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['customer:customer:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改客户管理对话框 -->
<el-dialog :title="title" v-model="open" width="700px" append-to-body>
<el-form ref="customerRef" :model="form" :rules="rules" label-width="80px">
<el-form-item label="客户名称" prop="name">
<el-input v-model="form.name" placeholder="请输入客户名称" />
</el-form-item>
<el-form-item label="客户电话" prop="phone">
<el-input v-model="form.phone" placeholder="请输入客户电话" />
</el-form-item>
<el-form-item label="所在地区" required>
<el-cascader
v-model="selectedArea"
:options="areaOptions"
:props="areaProps"
placeholder="请选择省市区"
style="width: 100%"
clearable
/>
</el-form-item>
<el-form-item label="详细地址" prop="address">
<el-input v-model="form.address" placeholder="请输入详细地址" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup>
import { ref, reactive, getCurrentInstance, onMounted } from 'vue'
import { listCustomer, getCustomer, delCustomer, addCustomer, updateCustomer } from "@/api/sale/customer/customer"
import { regionData } from 'element-china-area-data'
const { proxy } = getCurrentInstance()
const customerList = ref([])
const open = ref(false)
const loading = ref(true)
const showSearch = ref(true)
const ids = ref([])
const single = ref(true)
const multiple = ref(true)
const total = ref(0)
const title = ref("")
//
const areaOptions = ref(regionData)
const areaProps = {
label: 'label',
value: 'label',
children: 'children'
}
const selectedArea = ref([])
const data = reactive({
form: {},
queryParams: {
pageNum: 1,
pageSize: 10,
name: null,
},
rules: {
name: [{ required: true, message: "客户名称不能为空", trigger: "blur" }],
address: [{ required: true, message: "详细地址不能为空", trigger: "blur" }]
}
})
const { queryParams, form, rules } = toRefs(data)
onMounted(() => {
getList()
})
function getList() {
loading.value = true
listCustomer(queryParams.value).then(response => {
customerList.value = response.rows
total.value = response.total
loading.value = false
})
}
function cancel() {
open.value = false
reset()
}
function reset() {
form.value = {
id: null,
name: null,
phone: null,
province: null,
city: null,
district: null,
address: null,
remark: null
}
selectedArea.value = []
proxy.resetForm("customerRef")
}
function handleQuery() {
queryParams.value.pageNum = 1
getList()
}
function resetQuery() {
proxy.resetForm("queryRef")
handleQuery()
}
function handleSelectionChange(selection) {
ids.value = selection.map(item => item.id)
single.value = selection.length != 1
multiple.value = !selection.length
}
function handleAdd() {
reset()
open.value = true
title.value = "添加客户"
}
function handleUpdate(row) {
reset()
const id = row.id || ids.value[0]
getCustomer(id).then(response => {
form.value = response.data
//
if (response.data.province || response.data.city || response.data.district) {
selectedArea.value = [
response.data.province,
response.data.city,
response.data.district
].filter(item => item) //
}
open.value = true
title.value = "修改客户"
})
}
function handleAddress() {
if (selectedArea.value.length > 0) {
form.value.province = selectedArea.value[0] || ''
form.value.city = selectedArea.value[1] || ''
form.value.district = selectedArea.value[2] || ''
} else {
form.value.province = ''
form.value.city = ''
form.value.district = ''
}
}
function submitForm() {
handleAddress() //
proxy.$refs["customerRef"].validate(valid => {
if (valid) {
if (form.value.id != null) {
updateCustomer(form.value).then(() => {
proxy.$modal.msgSuccess("修改成功")
open.value = false
getList()
})
} else {
addCustomer(form.value).then(() => {
proxy.$modal.msgSuccess("新增成功")
open.value = false
getList()
})
}
}
})
}
function handleDelete(row) {
const customerIds = row.id || ids.value
proxy.$modal.confirm('是否确认删除选中的数据?').then(() => {
return delCustomer(customerIds)
}).then(() => {
getList()
proxy.$modal.msgSuccess("删除成功")
}).catch(() => {})
}
function handleExport() {
proxy.download('customer/customer/export', {
...queryParams.value
}, `customer_${new Date().getTime()}.xlsx`)
}
</script>

View File

@ -0,0 +1,935 @@
<template>
<div class="app-container">
<!-- 面包屑导航 -->
<el-breadcrumb separator="/" class="breadcrumb">
<el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
<el-breadcrumb-item>销售管理</el-breadcrumb-item>
<el-breadcrumb-item>销售记录</el-breadcrumb-item>
</el-breadcrumb>
<!-- 搜索区域 -->
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="耳号" prop="bsManageTags">
<el-input
v-model="queryParams.bsManageTags"
placeholder="请输入耳号"
clearable
size="small"
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="销售日期" prop="saleDate">
<el-date-picker
v-model="queryParams.saleDate"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd"
size="small"
/>
</el-form-item>
<el-form-item label="销售类别" prop="saleType">
<el-select v-model="queryParams.saleType" clearable placeholder="请选择" size="small" style="width: 180px">
<el-option
v-for="d in saleTypeOptions"
:key="d.dictValue"
:label="d.dictLabel"
:value="d.dictValue"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<!-- 操作按钮区域 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['saleRecord:saleRecord:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['saleRecord:saleRecord:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['saleRecord:saleRecord:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['saleRecord:saleRecord:export']"
>导出</el-button>
</el-col>
<right-toolbar :show-search="showSearch" @update:showSearch="val => showSearch = val" @queryTable="getList" />
</el-row>
<!-- 表格区域 -->
<el-table v-loading="loading" :data="saleRecordList" @selection-change="handleSelectionChange" style="width: 100%">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" type="index" width="50" align="center" />
<el-table-column label="耳号" align="center" prop="bsManageTags" width="120" show-overflow-tooltip />
<el-table-column label="品种" align="center" prop="variety" width="100" show-overflow-tooltip />
<el-table-column label="事件类型" align="center" prop="eventType" width="100" show-overflow-tooltip />
<el-table-column label="销售日期" align="center" prop="saleDate" width="120">
<template #default="scope">
<span>{{ parseTime(scope.row.saleDate, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="羊只类别" align="center" prop="sheepName" width="100" show-overflow-tooltip />
<el-table-column label="性别" align="center" prop="gender" width="80" />
<el-table-column label="月龄" align="center" prop="monthAge" width="80" />
<el-table-column label="胎次" align="center" prop="parity" width="80" />
<el-table-column label="计价方式" align="center" prop="pricingMethod" width="100" show-overflow-tooltip />
<el-table-column label="单价" align="center" prop="unitPrice" width="100">
<template #default="scope">
<span v-if="scope.row.unitPrice !== null && scope.row.unitPrice !== undefined">{{ scope.row.unitPrice }}</span>
</template>
</el-table-column>
<el-table-column label="总价" align="center" prop="totalPrice" width="100">
<template #default="scope">
<span v-if="scope.row.totalPrice !== null && scope.row.totalPrice !== undefined">{{ scope.row.totalPrice }}</span>
</template>
</el-table-column>
<el-table-column label="总体重" align="center" prop="totalWeight" width="100">
<template #default="scope">
<span v-if="scope.row.totalWeight">{{ scope.row.totalWeight }}kg</span>
</template>
</el-table-column>
<el-table-column label="平均体重" align="center" prop="avgWeight" width="100">
<template #default="scope">
<span v-if="scope.row.avgWeight">{{ scope.row.avgWeight }}kg</span>
</template>
</el-table-column>
<el-table-column label="平均单只价格" align="center" prop="avgPricePerSheep" width="120">
<template #default="scope">
<span v-if="scope.row.avgPricePerSheep">{{ scope.row.avgPricePerSheep }}</span>
</template>
</el-table-column>
<el-table-column label="销售类别" align="center" prop="saleType" width="120" :formatter="saleTypeFormat" show-overflow-tooltip />
<el-table-column label="客户名称" align="center" prop="customerName" width="140" show-overflow-tooltip />
<el-table-column label="客户电话" align="center" prop="customerPhone" width="130" show-overflow-tooltip />
<el-table-column label="客户地址" align="center" prop="customerAddress" width="180" show-overflow-tooltip />
<el-table-column label="销售人员" align="center" prop="salesPersonName" width="120" show-overflow-tooltip />
<el-table-column label="检疫证号" align="center" prop="quarantineNo" width="130" show-overflow-tooltip />
<el-table-column label="审批编号" align="center" prop="approvalNo" width="130" show-overflow-tooltip />
<el-table-column label="疾病类型" align="center" prop="diseaseType" width="120" :formatter="diseaseTypeFormat" show-overflow-tooltip />
<el-table-column label="次要原因" align="center" prop="secondaryReason" width="120" show-overflow-tooltip />
<el-table-column label="羊舍" align="center" prop="sheepfoldName" width="120" show-overflow-tooltip />
<el-table-column label="班组" align="center" prop="groupCode" width="100" :formatter="groupFormat" />
<el-table-column label="繁育状态" align="center" prop="breed" width="100" show-overflow-tooltip />
<el-table-column label="产后天数" align="center" prop="postLambingDay" width="90" />
<el-table-column label="泌乳天数" align="center" prop="lactationDay" width="90" />
<el-table-column label="怀孕天数" align="center" prop="lambingDay" width="90" />
<el-table-column label="创建人" align="center" prop="createdByName" width="120" show-overflow-tooltip />
<el-table-column label="创建日期" align="center" prop="createdAt" width="120">
<template #default="scope">
<span>{{ parseTime(scope.row.createdAt, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="技术员" align="center" prop="technicianName" width="120" show-overflow-tooltip />
<el-table-column label="处理人" align="center" prop="handlerName" width="120" show-overflow-tooltip />
<el-table-column label="备注" align="center" prop="remark" width="150" show-overflow-tooltip />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150" fixed="right">
<template #default="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['saleRecord:saleRecord:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['saleRecord:saleRecord:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page="queryParams.pageNum"
:limit="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改羊只销售记录对话框 -->
<el-dialog :title="title" :model-value="open" width="1200px" append-to-body @update:modelValue="val => open = val">
<el-form ref="formRef" :model="form" :rules="rules" label-width="120px">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="羊舍" prop="sheepfoldId">
<el-select
v-model="form.sheepfoldId"
placeholder="请选择羊舍"
clearable
@change="handleSheepfoldChange"
style="width: 100%"
>
<el-option
v-for="item in sheepfoldOptions"
:key="item.id || item.sheepfoldId"
:label="item.sheepfoldName || item.name"
:value="item.id || item.sheepfoldId"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="耳号" prop="bsManageTagsList">
<!-- 通过 allow-create + 回车新增耳号使用 watch 捕捉新增项并拉取详情 -->
<el-select
v-model="form.bsManageTagsList"
multiple
filterable
allow-create
default-first-option
placeholder="请先选择羊舍,或手动输入耳号并回车确认"
style="width: 100%"
>
<el-option
v-for="tag in earTagOptions"
:key="tag"
:label="tag"
:value="tag"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<!-- 自动填充展示 -->
<el-row :gutter="20">
<el-col :span="8"><el-form-item label="品种">{{ form.variety }}</el-form-item></el-col>
<el-col :span="8"><el-form-item label="羊只类别">{{ form.sheepName }}</el-form-item></el-col>
<el-col :span="8"><el-form-item label="性别">{{ form.gender }}</el-form-item></el-col>
<el-col :span="8"><el-form-item label="月龄">{{ form.monthAge }}</el-form-item></el-col>
<el-col :span="8"><el-form-item label="胎次">{{ form.parity }}</el-form-item></el-col>
<el-col :span="8"><el-form-item label="繁育状态">{{ form.breed }}</el-form-item></el-col>
<el-col :span="8"><el-form-item label="产后天数">{{ form.postLambingDay }}</el-form-item></el-col>
<el-col :span="8"><el-form-item label="泌乳天数">{{ form.lactationDay }}</el-form-item></el-col>
<el-col :span="8"><el-form-item label="怀孕天数">{{ form.lambingDay }}</el-form-item></el-col>
</el-row>
<el-divider />
<el-row :gutter="20">
<el-col :span="8">
<el-form-item label="事件类型" prop="eventType">
<el-input v-model="form.eventType" placeholder="默认为销售" readonly />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="销售日期" prop="saleDate">
<el-date-picker
v-model="form.saleDate"
type="date"
placeholder="选择日期"
value-format="yyyy-MM-dd"
style="width: 100%"
:disabled-date="disabledDate"
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="计价方式" prop="pricingMethod">
<el-select
v-model="form.pricingMethod"
placeholder="请选择计价方式"
@change="handlePricingMethodChange"
style="width: 100%"
>
<el-option label="按个体" value="按个体" />
<el-option label="按体重" value="按体重" />
</el-select>
</el-form-item>
</el-col>
<!-- 动态字段按个体 -->
<template v-if="form.pricingMethod === '按个体'">
<el-col :span="8">
<el-form-item label="单价(元/只)" prop="unitPrice">
<el-input v-model="form.unitPrice" placeholder="请输入单价" @input="calculateIndividualPrice">
<template #append></template>
</el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="总价" prop="totalPrice">
<el-input v-model="form.totalPrice" placeholder="自动计算" readonly>
<template #append></template>
</el-input>
</el-form-item>
</el-col>
</template>
<!-- 动态字段按体重 -->
<template v-if="form.pricingMethod === '按体重'">
<el-col :span="8">
<el-form-item label="总重量" prop="totalWeight">
<el-input v-model="form.totalWeight" placeholder="请输入总重量" @input="calculateWeightPrice">
<template #append>kg</template>
</el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="单价(元/kg)" prop="unitPrice">
<el-input v-model="form.unitPrice" placeholder="请输入单价" @input="calculateWeightPrice">
<template #append></template>
</el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="总价" prop="totalPrice">
<el-input v-model="form.totalPrice" placeholder="自动计算" readonly>
<template #append></template>
</el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="平均体重">
<el-input v-model="form.avgWeight" placeholder="自动计算" readonly>
<template #append>kg</template>
</el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="平均单只价格">
<el-input v-model="form.avgPricePerSheep" placeholder="自动计算" readonly>
<template #append></template>
</el-input>
</el-form-item>
</el-col>
</template>
</el-row>
<el-divider />
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="销售类别" prop="saleType">
<el-select
v-model="form.saleType"
placeholder="请选择销售类别"
@change="handleSaleTypeChange"
style="width: 100%"
>
<el-option
v-for="dict in saleTypeOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="客户名称" prop="customerId">
<el-select
v-model="form.customerId"
filterable
remote
reserve-keyword
placeholder="请输入客户名称"
:remote-method="remoteMethodGetCustomer"
:loading="customerLoading"
@change="handleCustomerChange"
style="width: 100%"
>
<!-- 使用 sx_customer.name 作为显示字段 -->
<el-option
v-for="item in customerOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
<!-- 淘汰相关仅在 销售类别=淘汰销售/淘汰屠宰 时显示 -->
<template v-if="isEliminationSale">
<el-col :span="12">
<el-form-item label="疾病类型" prop="diseaseType">
<el-select v-model="form.diseaseType" placeholder="请选择疾病类型" @change="handleDiseaseTypeChange" style="width: 100%">
<el-option
v-for="dict in diseaseTypeOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="班组" prop="groupCode">
<el-select v-model="form.groupCode" placeholder="请选择班组" style="width: 100%">
<el-option
v-for="dict in groupOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12" v-if="diseaseTypeLabel === '病残羊'">
<el-form-item label="次要原因" prop="secondaryReason">
<el-input v-model="form.secondaryReason" placeholder="请输入次要原因" />
</el-form-item>
</el-col>
</template>
<el-col :span="12">
<el-form-item label="销售人员" prop="salesPersonId">
<el-select v-model="form.salesPersonId" placeholder="请选择销售人员" style="width: 100%">
<el-option v-for="user in userOptions" :key="user.userId" :label="user.nickName" :value="user.userId" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="检疫证号" prop="quarantineNo">
<el-input v-model="form.quarantineNo" placeholder="请输入检疫证号" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="审批编号" prop="approvalNo">
<el-input v-model="form.approvalNo" placeholder="请输入审批编号" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="技术员" prop="technicianId">
<el-select v-model="form.technicianId" placeholder="请选择技术员" style="width: 100%">
<el-option v-for="user in userOptions" :key="user.userId" :label="user.nickName" :value="user.userId" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="处理人" prop="handlerId">
<el-select v-model="form.handlerId" placeholder="请选择处理人" style="width: 100%">
<el-option v-for="user in userOptions" :key="user.userId" :label="user.nickName" :value="user.userId" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" :rows="2" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script>
import {
listSaleRecord,
getSaleRecord,
delSaleRecord,
addSaleRecord,
updateSaleRecord,
getSheepInfo,
} from '@/api/sale/saleRecord/saleRecord'
import { listSheepfold_management } from '@/api/fileManagement/sheepfold_management'
import { listUser } from '@/api/system/user'
import { getDicts } from '@/api/system/dict/data'
import { listCustomer } from '@/api/sale/customer/customer'
export default {
name: 'SxSheepSale',
data() {
return {
//
loading: true,
ids: [],
single: true,
multiple: true,
showSearch: true,
total: 0,
saleRecordList: [],
title: '',
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
bsManageTags: null,
sheepfoldId: null,
saleDate: null,
saleType: null,
},
//
form: {},
//
saleTypeOptions: [],
diseaseTypeOptions: [],
groupOptions: [],
//
sheepfoldOptions: [],
earTagOptions: [],
userOptions: [],
customerOptions: [],
customerLoading: false,
//
_prevTags: [],
// validator
rules: {
sheepfoldId: [{ required: true, message: '羊舍不能为空', trigger: 'change' }],
bsManageTagsList: [{ type: 'array', required: true, message: '至少需要一个耳号', trigger: 'change' }],
saleDate: [{ required: true, message: '销售日期不能为空', trigger: 'change' }],
pricingMethod: [{ required: true, message: '计价方式不能为空', trigger: 'change' }],
unitPrice: [{ required: true, message: '单价不能为空', trigger: 'blur' }],
saleType: [{ required: true, message: '销售类别不能为空', trigger: 'change' }],
customerId: [{ required: true, message: '客户不能为空', trigger: 'change' }],
salesPersonId: [{ required: true, message: '销售人员不能为空', trigger: 'change' }],
diseaseType: [
{
validator: (rule, val, cb) => {
if (this.isEliminationSale && !val) return cb(new Error('淘汰销售必须选择疾病类型'))
cb()
},
trigger: 'change',
},
],
groupCode: [
{
validator: (rule, val, cb) => {
if (this.isEliminationSale && !val) return cb(new Error('淘汰销售必须选择班组'))
cb()
},
trigger: 'change',
},
],
secondaryReason: [
{
validator: (rule, val, cb) => {
if (this.diseaseTypeLabel === '病残羊' && !val) return cb(new Error('疾病类型为病残羊时必须填写次要原因'))
cb()
},
trigger: 'blur',
},
],
},
}
},
computed: {
// "(label)" dictValue
isEliminationSale() {
const opt = this.saleTypeOptions.find(o => o.dictValue === this.form.saleType)
const label = opt ? opt.dictLabel : ''
return label === '淘汰销售' || label === '淘汰屠宰'
},
diseaseTypeLabel() {
const opt = this.diseaseTypeOptions.find(o => o.dictValue === this.form.diseaseType)
return opt ? opt.dictLabel : ''
},
},
watch: {
// ""
'form.bsManageTagsList'(val = []) {
const added = Array.isArray(val) ? val.filter(v => !this._prevTags.includes(v)) : []
if (added.length > 0) {
this.fetchSheepInfo(added[added.length - 1])
}
this._prevTags = Array.isArray(val) ? [...val] : []
//
if (this.form.pricingMethod === '按个体') {
this.calculateIndividualPrice()
} else if (this.form.pricingMethod === '按体重') {
this.calculateWeightPrice()
}
},
'form.unitPrice': function () {
if (this.form.pricingMethod === '按个体') {
this.calculateIndividualPrice()
} else if (this.form.pricingMethod === '按体重') {
this.calculateWeightPrice()
}
},
'form.totalWeight': function () {
if (this.form.pricingMethod === '按体重') this.calculateWeightPrice()
}
},
created() {
this.getList()
this.getDictsData()
this.getSheepfoldOptions()
this.getUserOptions()
this.remoteMethodGetCustomer('') //
},
methods: {
/** 禁用未来日期 */
disabledDate(time) {
return time.getTime() > Date.now()
},
/** 查询列表 */
getList() {
this.loading = true
listSaleRecord(this.queryParams)
.then(res => {
this.saleRecordList = res.rows || []
this.total = res.total || 0
})
.finally(() => (this.loading = false))
},
//
saleTypeFormat(row) {
return this.selectDictLabel(this.saleTypeOptions, row.saleType)
},
diseaseTypeFormat(row) {
return this.selectDictLabel(this.diseaseTypeOptions, row.diseaseType)
},
groupFormat(row) {
return this.selectDictLabel(this.groupOptions, row.groupCode)
},
//
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
resetQuery() {
this.resetForm('queryForm')
this.handleQuery()
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length !== 1
this.multiple = !selection.length
},
//
handleAdd() {
this.reset()
this.open = true
this.title = '添加羊只销售记录'
this.form.eventType = '销售'
// ( value-format="yyyy-MM-dd" )
this.form.saleDate = new Date().toISOString().slice(0, 10)
},
//
handleUpdate(row) {
this.reset()
const id = row.id || this.ids
getSaleRecord(id).then(response => {
this.form = response.data || {}
if (this.form.bsManageTags) {
this.form.bsManageTagsList = String(this.form.bsManageTags).split(',').filter(Boolean)
}
this._prevTags = Array.isArray(this.form.bsManageTagsList) ? [...this.form.bsManageTagsList] : []
this.open = true
this.title = '修改羊只销售记录'
})
},
//
cancel() {
this.open = false
this.reset()
},
//
reset() {
this.form = {
id: null,
bsManageTags: null,
bsManageTagsList: [],
sheepfoldId: null,
variety: null,
sheepName: null,
gender: null,
monthAge: null,
parity: null,
breed: null,
postLambingDay: null,
lactationDay: null,
lambingDay: null,
eventType: '销售',
saleDate: null,
pricingMethod: null,
unitPrice: null,
totalPrice: null,
totalWeight: null,
avgWeight: null,
avgPricePerSheep: null,
saleType: null,
diseaseType: null,
secondaryReason: null,
groupCode: null,
customerId: null,
customerName: null,
customerPhone: null,
customerAddress: null,
salesPersonId: null,
salesPersonName: null,
quarantineNo: null,
approvalNo: null,
technicianId: null,
technicianName: null,
handlerId: null,
handlerName: null,
createdBy: null,
createdByName: null,
createdAt: null,
remark: null
}
this._prevTags = []
this.resetForm('formRef')
},
/** 提交 */
submitForm() {
this.$refs.formRef.validate(valid => {
if (!valid) return
//
if (Array.isArray(this.form.bsManageTagsList) && this.form.bsManageTagsList.length > 0) {
this.form.bsManageTags = this.form.bsManageTagsList.join(',')
} else {
this.form.bsManageTags = null
}
// createdBy / createdAt
const api = this.form.id ? updateSaleRecord : addSaleRecord
api(this.form)
.then(() => {
this.$modal.msgSuccess(this.form.id ? '修改成功' : '新增成功')
this.open = false
this.getList()
})
.catch(err => {
this.$modal.msgError((this.form.id ? '修改失败:' : '新增失败:') + (err.message || '未知错误'))
})
})
},
/** 删除 */
handleDelete(row) {
const ids = row.id || this.ids
this.$modal.confirm('是否确认删除羊只销售记录编号为"' + ids + '"的数据项?')
.then(() => delSaleRecord(ids))
.then(() => {
this.getList()
this.$modal.msgSuccess('删除成功')
})
.catch(() => {})
},
/** 导出 */
handleExport() {
this.$modal.confirm('是否确认导出所有羊只销售记录数据项?').then(() => {
this.download('/saleRecord/saleRecord/export', { ...this.queryParams }, `saleRecord_${new Date().getTime()}.xlsx`)
})
},
/** 字典数据(注意 disease_type */
getDictsData() {
getDicts('sale_type').then(r => (this.saleTypeOptions = r.data || []))
getDicts('disease_type').then(r => (this.diseaseTypeOptions = r.data || []))
getDicts('group').then(r => (this.groupOptions = r.data || []))
},
/** 羊舍下拉 */
getSheepfoldOptions() {
listSheepfold_management().then(r => {
this.sheepfoldOptions = r.rows || r.data || []
})
},
/** 用户下拉(销售人员、技术员、处理人) */
getUserOptions() {
listUser().then(r => {
this.userOptions = r.rows || r.data || []
})
},
/** 客户远程搜索:使用 sx_customer.name 字段 */
remoteMethodGetCustomer(query) {
this.customerLoading = true
const p = query ? { name: query } : {}
listCustomer(p)
.then(r => {
this.customerOptions = r.rows || r.data || []
})
.finally(() => (this.customerLoading = false))
},
/** 客户选择后回填 name/phone/address 到表单 */
handleCustomerChange(customerId) {
const customer = this.customerOptions.find(item => item.id === customerId)
if (customer) {
this.form.customerName = customer.name
this.form.customerPhone = customer.phone
this.form.customerAddress = customer.address
} else {
this.form.customerName = null
this.form.customerPhone = null
this.form.customerAddress = null
}
},
/** 羊舍改变:加载耳号(此处示例,替换成你的真实接口) */
handleSheepfoldChange(sheepfoldId) {
this.form.bsManageTagsList = []
this.earTagOptions = []
// TODO: getEarTagsBySheepfold(sheepfoldId)
if (sheepfoldId) {
this.earTagOptions = ['1001', '1002', '1003', '1004', '1005']
}
},
/** 根据耳号查羊只信息 */
fetchSheepInfo(bsManageTags) {
if (!bsManageTags) return
getSheepInfo(bsManageTags).then(response => {
if (response.code === 200 && response.data) {
const data = response.data
this.form.variety = data.variety
this.form.sheepName = data.sheepName
this.form.gender = data.gender
this.form.monthAge = data.monthAge
this.form.parity = data.parity
this.form.breed = data.breed
this.form.postLambingDay = data.postLambingDay
this.form.lactationDay = data.lactationDay
this.form.lambingDay = data.lambingDay
if (!this.form.sheepfoldId && data.sheepfoldId) {
this.form.sheepfoldId = data.sheepfoldId
this.handleSheepfoldChange(data.sheepfoldId)
}
} else {
this.$modal.msgError(response.msg || '未查询到羊只信息')
}
})
},
/** 计价方式切换 */
handlePricingMethodChange(method) {
if (method === '按个体') {
this.form.totalWeight = null
this.form.avgWeight = null
this.calculateIndividualPrice()
} else if (method === '按体重') {
this.calculateWeightPrice()
}
},
/** 按个体计价 */
calculateIndividualPrice() {
if (this.form.pricingMethod !== '按个体') return
const unitPrice = parseFloat(this.form.unitPrice) || 0
const count = Array.isArray(this.form.bsManageTagsList) ? this.form.bsManageTagsList.length : 0
const total = unitPrice * count
this.form.totalPrice = Number.isFinite(total) ? Number(total.toFixed(2)) : 0
this.form.avgPricePerSheep = Number.isFinite(unitPrice) ? Number(unitPrice.toFixed(2)) : 0
},
/** 按体重计价 */
calculateWeightPrice() {
if (this.form.pricingMethod !== '按体重') return
const unitPrice = parseFloat(this.form.unitPrice) || 0
const totalWeight = parseFloat(this.form.totalWeight) || 0
const count = Array.isArray(this.form.bsManageTagsList) && this.form.bsManageTagsList.length > 0 ? this.form.bsManageTagsList.length : 1
const total = unitPrice * totalWeight
this.form.totalPrice = Number.isFinite(total) ? Number(total.toFixed(2)) : 0
const avgW = totalWeight / count
this.form.avgWeight = Number.isFinite(avgW) ? Number(avgW.toFixed(2)) : 0
const avgP = this.form.totalPrice / count
this.form.avgPricePerSheep = Number.isFinite(avgP) ? Number(avgP.toFixed(2)) : 0
},
/** 销售类别变化:清理并重新校验 */
handleSaleTypeChange() {
if (!this.isEliminationSale) {
this.form.diseaseType = null
this.form.groupCode = null
this.form.secondaryReason = null
}
this.$nextTick(() => {
this.$refs.formRef.clearValidate(['diseaseType', 'groupCode', 'secondaryReason'])
})
},
/** 疾病类型变化:联动"次要原因" */
handleDiseaseTypeChange() {
if (this.diseaseTypeLabel !== '病残羊') {
this.form.secondaryReason = null
}
this.$nextTick(() => this.$refs.formRef.clearValidate('secondaryReason'))
},
},
}
</script>
<style scoped>
.breadcrumb { margin-bottom: 16px; }
.app-container { position: relative; }
.el-table { width: 100%; overflow-x: auto; }
</style>