Compare commits
2 Commits
c6ab4a7a60
...
3dc635421e
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3dc635421e | ||
![]() |
20abfb342e |
@ -2,36 +2,10 @@
|
||||
<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-input v-model="queryParams.formulaId" placeholder="请输入配方编码" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="羊舍" prop="sheepHouseId">
|
||||
<el-input
|
||||
v-model="queryParams.sheepHouseId"
|
||||
placeholder="请输入羊舍"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="饲草班人员" prop="zookeeper">
|
||||
<el-input
|
||||
v-model="queryParams.zookeeper"
|
||||
placeholder="请输入饲草班人员"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="饲喂计划日期" prop="planDate">
|
||||
<el-date-picker clearable
|
||||
v-model="queryParams.planDate"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="请选择饲喂计划日期">
|
||||
</el-date-picker>
|
||||
<el-input v-model="queryParams.sheepHouseId" placeholder="请输入羊舍" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
@ -41,42 +15,19 @@
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="Plus"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['feed:FeedPlan:add']"
|
||||
>新增</el-button>
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['feed:FeedPlan:add']">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="Edit"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['feed:FeedPlan:edit']"
|
||||
>修改</el-button>
|
||||
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate"
|
||||
v-hasPermi="['feed:FeedPlan:edit']">修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="Delete"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['feed:FeedPlan:remove']"
|
||||
>删除</el-button>
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete"
|
||||
v-hasPermi="['feed:FeedPlan:remove']">删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="Download"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['feed:FeedPlan:export']"
|
||||
>导出</el-button>
|
||||
<el-button type="warning" plain icon="Download" @click="handleExport"
|
||||
v-hasPermi="['feed:FeedPlan:export']">导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
@ -85,25 +36,48 @@
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="创建日期" align="center" prop="createDate" />
|
||||
<el-table-column label="配方编码" align="center" prop="formulaId" />
|
||||
<el-table-column label="批号" align="center" prop="batchId" />
|
||||
<el-table-column label="羊舍" align="center" prop="sheepHouseId">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="sheep_house_list" :value="scope.row.sheepHouseId"/>
|
||||
{{ getSheepHouseName(scope.row.sheepHouseId) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="羊只数量" align="center" prop="sheepCount" />
|
||||
<el-table-column label="日均计划量" align="center" prop="planDailySize" />
|
||||
<el-table-column label="计划量(早)" align="center" prop="planMorningSize" />
|
||||
<el-table-column label="计划总量(早)" align="center" prop="planMorningTotal" />
|
||||
<el-table-column label="饲喂比例(早)" align="center" prop="ratioMorning" />
|
||||
<el-table-column label="实际量(早)" align="center" prop="actualMorningSize" />
|
||||
<el-table-column label="计划量(中)" align="center" prop="planNoonSize" />
|
||||
<el-table-column label="计划总量(中)" align="center" prop="planNoonTotal" />
|
||||
<el-table-column label="实际量(中)" align="center" prop="actualNoonSize" />
|
||||
<el-table-column label="饲喂比例(中)" align="center" prop="ratioNoon" />
|
||||
<el-table-column label="计划量(下)" align="center" prop="planAfternoonSize" />
|
||||
<el-table-column label="计划总量(下)" align="center" prop="planAfternoonTotal" />
|
||||
<el-table-column label="实际量(下)" align="center" prop="actualAfternoonSize" />
|
||||
<el-table-column label="饲喂比例(下)" align="center" prop="ratioAfternoon" />
|
||||
<el-table-column label="上午" prop="materialId" align="center">
|
||||
<el-table-column label="计划量" align="center" prop="planMorningSize">
|
||||
<template #default="{ row }">
|
||||
{{ row.planMorningSize ? row.planMorningSize.toFixed(2) : '0.00' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="计划总量" align="center" prop="planMorningTotal" /> -->
|
||||
<el-table-column label="实际量" align="center" prop="actualMorningSize" />
|
||||
</el-table-column>
|
||||
<el-table-column label="中午" prop="materialId" align="center">
|
||||
<el-table-column label="计划量" align="center" prop="planNoonSize">
|
||||
<template #default="{ row }">
|
||||
{{ row.planNoonSize ? row.planNoonSize.toFixed(2) : '0.00' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="计划总量" align="center" prop="planNoonTotal" /> -->
|
||||
<el-table-column label="实际量" align="center" prop="actualNoonSize" />
|
||||
</el-table-column>
|
||||
<el-table-column label="下午" prop="materialId" align="center">
|
||||
<el-table-column label="计划量" align="center" prop="planAfternoonSize">
|
||||
<template #default="{ row }">
|
||||
{{ row.planAfternoonSize ? row.planAfternoonSize.toFixed(2) : '0.00' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="计划总量" align="center" prop="planAfternoonTotal" /> -->
|
||||
<el-table-column label="实际量" align="center" prop="actualAfternoonSize" />
|
||||
</el-table-column>
|
||||
<el-table-column label="饲喂比例(%)" align="center" prop="ratioTotal">
|
||||
<el-table-column label="上午" align="center" prop="ratioMorning" />
|
||||
<el-table-column label="中午" align="center" prop="ratioNoon" />
|
||||
<el-table-column label="下午" align="center" prop="ratioAfternoon" />
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="计划饲喂总量" align="center" prop="planFeedTotal" />
|
||||
<el-table-column label="饲草班人员" align="center" prop="zookeeper" />
|
||||
<el-table-column label="饲喂计划日期" align="center" prop="planDate" width="180">
|
||||
@ -114,64 +88,67 @@
|
||||
<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="['feed:FeedPlan:edit']">修改</el-button>
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['feed:FeedPlan:remove']">删除</el-button>
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['feed:FeedPlan:edit']">修改</el-button>
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
|
||||
v-hasPermi="['feed:FeedPlan: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"
|
||||
/>
|
||||
|
||||
<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="FeedPlanRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form ref="FeedPlanRef" :model="form" :rules="rules" label-width="100px">
|
||||
<el-form-item label="配方编码" prop="formulaId">
|
||||
<el-input v-model="form.formulaId" placeholder="请输入配方编码" />
|
||||
<!-- <el-input v-model="form.formulaId" placeholder="请输入配方编码" /> -->
|
||||
<el-select v-model="form.formulaId" filterable placeholder="请选择配方编码" style="width: 100%"
|
||||
@change="handleFormulaIdChange(form, $event)">
|
||||
<el-option v-for="item in formulaIdDict" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="批号" prop="batchId">
|
||||
<!-- <el-input v-model="form.batchId" placeholder="请输入批号" /> -->
|
||||
<el-select v-model="form.batchId" filterable placeholder="请选择配方批号" style="width: 100%">
|
||||
<el-option v-for="item in formulaBatchDict" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="羊舍" prop="sheepHouseId">
|
||||
<el-input v-model="form.sheepHouseId" placeholder="请输入羊舍" />
|
||||
<!-- <el-input v-model="form.sheepHouseId" placeholder="请输入羊舍" /> -->
|
||||
<el-select v-model="form.sheepHouseId" filterable placeholder="请选择羊舍" style="width: 100%">
|
||||
<el-option v-for="item in sheepFolderDict" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="日均计划量" prop="planDailySize">
|
||||
<el-input v-model="form.planDailySize" placeholder="请输入日均计划量" />
|
||||
</el-form-item>
|
||||
<el-form-item label="饲喂比例(早)" prop="ratioMorning">
|
||||
<el-input v-model="form.ratioMorning" placeholder="请输入饲喂比例(早)" />
|
||||
<el-form-item label="比例 (%)">
|
||||
<div style="display: flex; gap: 10px;">
|
||||
<el-input v-model="form.ratioMorning" placeholder="早上比例" style="width: 100px;" />
|
||||
<el-input v-model="form.ratioNoon" placeholder="中午比例" style="width: 100px;" />
|
||||
<el-input v-model="form.ratioAfternoon" placeholder="下午比例" style="width: 100px;" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="实际量(早)" prop="actualMorningSize">
|
||||
<el-input v-model="form.actualMorningSize" placeholder="请输入实际量(早)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="实际量(中)" prop="actualNoonSize">
|
||||
<el-input v-model="form.actualNoonSize" placeholder="请输入实际量(中)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="饲喂比例(中)" prop="ratioNoon">
|
||||
<el-input v-model="form.ratioNoon" placeholder="请输入饲喂比例(中)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="实际量(下)" prop="actualAfternoonSize">
|
||||
<el-input v-model="form.actualAfternoonSize" placeholder="请输入实际量(下)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="饲喂比例(下)" prop="ratioAfternoon">
|
||||
<el-input v-model="form.ratioAfternoon" placeholder="请输入饲喂比例(下)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="饲草班人员" prop="zookeeper">
|
||||
<el-form-item label="饲草班人员" prop="Zookeeper">
|
||||
<el-input v-model="form.zookeeper" placeholder="请输入饲草班人员" />
|
||||
</el-form-item>
|
||||
<el-form-item label="饲喂计划日期" prop="planDate">
|
||||
<el-date-picker clearable
|
||||
v-model="form.planDate"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="请选择饲喂计划日期">
|
||||
<el-form-item label="计划日期" prop="planDate">
|
||||
<el-date-picker clearable v-model="form.planDate" type="date" value-format="YYYY-MM-DD"
|
||||
placeholder="请选择计划饲喂时间">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
<div v-if="title === '修改饲喂计划'">
|
||||
<el-divider content-position="left">配方详情</el-divider>
|
||||
<el-form-item label="实际饲喂量">
|
||||
<div style="display: flex; gap: 10px;">
|
||||
<el-input v-model="form.actualMorningSize" placeholder="早上" style="width: 100px;" />
|
||||
<el-input v-model="form.actualNoonSize" placeholder="中午" style="width: 100px;" />
|
||||
<el-input v-model="form.actualAfternoonSize" placeholder="下午" style="width: 100px;" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
@ -184,164 +161,258 @@
|
||||
</template>
|
||||
|
||||
<script setup name="FeedPlan">
|
||||
import { listFeedPlan, getFeedPlan, delFeedPlan, addFeedPlan, updateFeedPlan } from "@/api/feed/FeedPlan"
|
||||
import { listFeedPlan, getFeedPlan, delFeedPlan, addFeedPlan, updateFeedPlan } from "@/api/feed/FeedPlan"
|
||||
import { listFormulaManagement } from "@/api/feed/FormulaManagement";
|
||||
import { listSheepfold } from "@/api/produce/manage_sheep/trans_group.js";
|
||||
import { get } from "@vueuse/core";
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const FeedPlanList = 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 FeedPlanList = 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,
|
||||
sheepHouseId: null,
|
||||
zookeeper: null,
|
||||
planDate: null,
|
||||
},
|
||||
rules: {
|
||||
formulaId: [
|
||||
{ required: true, message: "配方编码不能为空", trigger: "blur" }
|
||||
],
|
||||
sheepHouseId: [
|
||||
{ required: true, message: "羊舍不能为空", trigger: "blur" }
|
||||
],
|
||||
planDailySize: [
|
||||
{ required: true, message: "日均计划量不能为空", trigger: "blur" }
|
||||
],
|
||||
}
|
||||
})
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data)
|
||||
|
||||
/** 查询饲喂计划列表 */
|
||||
function getList() {
|
||||
loading.value = true
|
||||
listFeedPlan(queryParams.value).then(response => {
|
||||
FeedPlanList.value = response.rows
|
||||
total.value = response.total
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
// 取消按钮
|
||||
function cancel() {
|
||||
open.value = false
|
||||
reset()
|
||||
}
|
||||
|
||||
// 表单重置
|
||||
function reset() {
|
||||
form.value = {
|
||||
createDate: null,
|
||||
formulaId: null,
|
||||
sheepHouseId: null,
|
||||
sheepCount: null,
|
||||
planDailySize: null,
|
||||
planMorningSize: null,
|
||||
planMorningTotal: null,
|
||||
ratioMorning: null,
|
||||
actualMorningSize: null,
|
||||
planNoonSize: null,
|
||||
planNoonTotal: null,
|
||||
actualNoonSize: null,
|
||||
ratioNoon: null,
|
||||
planAfternoonSize: null,
|
||||
planAfternoonTotal: null,
|
||||
actualAfternoonSize: null,
|
||||
ratioAfternoon: null,
|
||||
planFeedTotal: null,
|
||||
zookeeper: null,
|
||||
planDate: null,
|
||||
remark: null
|
||||
}
|
||||
proxy.resetForm("FeedPlanRef")
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery() {
|
||||
queryParams.value.pageNum = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function resetQuery() {
|
||||
proxy.resetForm("queryRef")
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
// 多选框选中数据
|
||||
function handleSelectionChange(selection) {
|
||||
ids.value = selection.map(item => item.createDate)
|
||||
single.value = selection.length != 1
|
||||
multiple.value = !selection.length
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
function handleAdd() {
|
||||
reset()
|
||||
open.value = true
|
||||
title.value = "添加饲喂计划"
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
function handleUpdate(row) {
|
||||
reset()
|
||||
const _createDate = row.createDate || ids.value
|
||||
getFeedPlan(_createDate).then(response => {
|
||||
form.value = response.data
|
||||
open.value = true
|
||||
title.value = "修改饲喂计划"
|
||||
})
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs["FeedPlanRef"].validate(valid => {
|
||||
if (valid) {
|
||||
if (form.value.createDate != null) {
|
||||
updateFeedPlan(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("修改成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
} else {
|
||||
addFeedPlan(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("新增成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
}
|
||||
const data = reactive({
|
||||
form: {},
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
formulaId: null,
|
||||
sheepHouseId: null,
|
||||
},
|
||||
rules: {
|
||||
formulaId: [
|
||||
{ required: true, message: "配方编码不能为空", trigger: "blur" }
|
||||
],
|
||||
batchId: [
|
||||
{ required: true, message: "批号不能为空", trigger: "blur" }
|
||||
],
|
||||
sheepHouseId: [
|
||||
{ required: true, message: "羊舍不能为空", trigger: "blur" }
|
||||
],
|
||||
planDailySize: [
|
||||
{ required: true, message: "日均计划量不能为空", trigger: "blur" }
|
||||
],
|
||||
}
|
||||
})
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data)
|
||||
|
||||
const formulaIdDict = ref([]) // 配方编码字典
|
||||
// 用于存储配方批号列表
|
||||
const formulaBatchMap = ref([])
|
||||
const formulaBatchDict = ref([]) // 配方批号字典(过滤后)
|
||||
const sheepFolderDict = ref([]) // 羊舍字典
|
||||
// 用于存储羊舍名称的字典
|
||||
const sheepNameDict = ref({})
|
||||
|
||||
// 获取配方编码 & 配方批号 字典
|
||||
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 {
|
||||
// 根据选择的formulaId筛选batchId
|
||||
formulaBatchDict.value = formulaBatchMap.value;
|
||||
formulaBatchDict.value = formulaBatchDict.value.filter(item => item.formulaId === value)
|
||||
}
|
||||
|
||||
// 重新设置批号为第一个
|
||||
if (formulaBatchDict.value.length > 0) {
|
||||
row.batchId = formulaBatchDict.value[0].value;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
||||
// 根据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 handleDelete(row) {
|
||||
const _createDates = row.createDate || ids.value
|
||||
proxy.$modal.confirm('是否确认删除饲喂计划编号为"' + _createDates + '"的数据项?').then(function() {
|
||||
return delFeedPlan(_createDates)
|
||||
}).then(() => {
|
||||
|
||||
/** 查询饲喂计划列表 */
|
||||
function getList() {
|
||||
loading.value = true
|
||||
listFeedPlan(queryParams.value).then(response => {
|
||||
FeedPlanList.value = response.rows
|
||||
total.value = response.total
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
// 取消按钮
|
||||
function cancel() {
|
||||
open.value = false
|
||||
reset()
|
||||
}
|
||||
|
||||
// 表单重置
|
||||
function reset() {
|
||||
form.value = {
|
||||
createDate: null,
|
||||
formulaId: null,
|
||||
batchId: null,
|
||||
sheepHouseId: null,
|
||||
sheepCount: null,
|
||||
planDailySize: null,
|
||||
ratioMorning: null,
|
||||
ratioNoon: null,
|
||||
ratioAfternoon: null,
|
||||
planMorningSize: null,
|
||||
planMorningTotal: null,
|
||||
actualMorningSize: null,
|
||||
planNoonSize: null,
|
||||
planNoonTotal: null,
|
||||
actualNoonSize: null,
|
||||
planAfternoonSize: null,
|
||||
planAfternoonTotal: null,
|
||||
actualAfternoonSize: null,
|
||||
planFeedTotal: null,
|
||||
zookeeper: null,
|
||||
planDate: null,
|
||||
remark: null
|
||||
}
|
||||
proxy.resetForm("FeedPlanRef")
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery() {
|
||||
queryParams.value.pageNum = 1
|
||||
// 如果羊舍ID是名称,则转换为ID
|
||||
queryParams.value.sheepHouseId = getSheepHouseId(queryParams.value.sheepHouseId, sheepNameDict.value);
|
||||
getList()
|
||||
proxy.$modal.msgSuccess("删除成功")
|
||||
}).catch(() => {})
|
||||
}
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
function handleExport() {
|
||||
proxy.download('feed/FeedPlan/export', {
|
||||
...queryParams.value
|
||||
}, `FeedPlan_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
/** 重置按钮操作 */
|
||||
function resetQuery() {
|
||||
proxy.resetForm("queryRef")
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
getList()
|
||||
// 多选框选中数据
|
||||
function handleSelectionChange(selection) {
|
||||
ids.value = selection.map(item => item.createDate)
|
||||
single.value = selection.length != 1
|
||||
multiple.value = !selection.length
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
function handleAdd() {
|
||||
reset()
|
||||
open.value = true
|
||||
title.value = "添加饲喂计划"
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
function handleUpdate(row) {
|
||||
reset()
|
||||
const _createDate = row.createDate || ids.value
|
||||
getFeedPlan(_createDate).then(response => {
|
||||
form.value = response.data
|
||||
open.value = true
|
||||
title.value = "修改饲喂计划"
|
||||
})
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs["FeedPlanRef"].validate(valid => {
|
||||
if (valid) {
|
||||
if (form.value.createDate != null) {
|
||||
updateFeedPlan(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("修改成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
} else {
|
||||
addFeedPlan(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("新增成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
function handleDelete(row) {
|
||||
const _createDates = row.createDate || ids.value
|
||||
proxy.$modal.confirm('是否确认删除饲喂计划编号为"' + _createDates + '"的数据项?').then(function () {
|
||||
return delFeedPlan(_createDates)
|
||||
}).then(() => {
|
||||
getList()
|
||||
proxy.$modal.msgSuccess("删除成功")
|
||||
}).catch(() => { })
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
function handleExport() {
|
||||
proxy.download('feed/FeedPlan/export', {
|
||||
...queryParams.value
|
||||
}, `FeedPlan_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
|
||||
getList()
|
||||
// 获取配方编码字典
|
||||
getFormulaDict()
|
||||
// 获取羊舍字典
|
||||
getSheepfoldDict()
|
||||
</script>
|
||||
|
@ -35,7 +35,7 @@
|
||||
|
||||
<el-table v-loading="loading" :data="FormulaManagementList">
|
||||
<!-- 表中表展示子配方 -->
|
||||
<el-table-column type="expand" @expand-change="handleExpandChange">
|
||||
<el-table-column type="expand" @expand-change="handleExpandChange">
|
||||
<template #default="props">
|
||||
<el-table :data="props.row.subFormulaList" style="width: 100%">
|
||||
<el-table-column label="批号" align="center" prop="batchId" />
|
||||
@ -148,11 +148,18 @@
|
||||
<el-table :data="showFormulaManagementList.sgFormulaList" stripe border style="width: 100%" max-height="300">
|
||||
<el-table-column label="序号" type="index" width="60" align="center" />
|
||||
<el-table-column label="原料编号" prop="materialId" align="center" />
|
||||
<el-table-column label="原料名称" prop="materialName" />
|
||||
<el-table-column label="原料" align="center">
|
||||
<el-table-column label="名称" prop="materialName" align="center"/>
|
||||
<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="比例" align="center" prop="ratio" />
|
||||
<el-table-column label="类型" prop="isGranular" align="center">
|
||||
<el-table-column label="类型" prop="isSupplement" align="center">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="materialType" :value="scope.row.isGranular" />
|
||||
<dict-tag :options="materialType" :value="scope.row.isSupplement" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -165,7 +172,7 @@
|
||||
<el-col :span="12" v-if="!isView">
|
||||
<el-form-item label="配方编号" prop="formulaId">
|
||||
<el-input v-model="showFormulaManagementList.formulaId" placeholder="请输入配方编号"
|
||||
:disabled="!FormulaIdEditable"/>
|
||||
:disabled="!FormulaIdEditable" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
@ -220,24 +227,33 @@
|
||||
: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">
|
||||
<template #default="scope">
|
||||
<el-select v-model="scope.row.materialId" filterable placeholder="请选择原料" style="width: 100%"
|
||||
@change="handleMaterialChange(scope.row, $event)">
|
||||
<el-option v-for="item in materials" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</template>
|
||||
<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="dosage">
|
||||
<el-table-column label="比例" prop="dosage" align="center">
|
||||
<template #default="scope">
|
||||
<el-input-number v-model="scope.row.ratio" placeholder="请输入比例" :min="0" :precision="1"
|
||||
controls-position="right" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="类型" prop="isGranular">
|
||||
<el-table-column label="类型" prop="isSupplement" align="center">
|
||||
<template #default="scope">
|
||||
<el-select v-model="scope.row.isGranular" placeholder="请选择类型">
|
||||
<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>
|
||||
@ -297,9 +313,12 @@ const FormulaIdEditable = ref(false)
|
||||
const materials = ref([])
|
||||
// 原料类型
|
||||
const materialType = [
|
||||
{ value: '1', label: '颗粒料' },
|
||||
{ value: '0', label: '其他' }
|
||||
{ value: '1', label: '补饲原料' },
|
||||
{ value: '0', label: '原料' }
|
||||
]
|
||||
// 原料类型字典
|
||||
const { material_type } = proxy.useDict('material_type')
|
||||
console.log("material_type: ", material_type);
|
||||
const useStaus = [
|
||||
{ value: '1', label: '启用' },
|
||||
{ value: '0', label: '停用' }
|
||||
@ -581,6 +600,8 @@ function handleMaterialChange(row, selectedValue) {
|
||||
if (selectedItem) {
|
||||
// materialName 也在 row 中
|
||||
row.materialName = selectedItem.label;
|
||||
row.isGranular = selectedItem.isGranular; // 更新 isGranular
|
||||
row.isSupplement = selectedItem.isSupplement; // 更新 isSupplement
|
||||
}
|
||||
}
|
||||
|
||||
@ -633,7 +654,7 @@ function handleFormulaDetailUpdate(row) {
|
||||
showFormulaManagementList.value = {}
|
||||
}
|
||||
formulaListOpen.value = true
|
||||
title.value = "修改处方"
|
||||
title.value = "修改配方"
|
||||
isView.value = false
|
||||
})
|
||||
}
|
||||
@ -680,12 +701,42 @@ function getMaterials() {
|
||||
console.log("获取原料列表:", response)
|
||||
materials.value = response.rows.map(item => ({
|
||||
value: item.materialId,
|
||||
label: item.materialName
|
||||
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)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 子表多选回调
|
||||
@ -714,4 +765,6 @@ function handleExport() {
|
||||
getList()
|
||||
// 加载原料列表
|
||||
getMaterials()
|
||||
// 加载分组原料列表
|
||||
getGroupMaterials()
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user