Compare commits
2 Commits
9968c67a6b
...
2d47349f24
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2d47349f24 | ||
![]() |
61ed6819b4 |
44
src/api/feed/FeedPlan.js
Normal file
44
src/api/feed/FeedPlan.js
Normal file
@ -0,0 +1,44 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询饲喂计划列表
|
||||
export function listFeedPlan(query) {
|
||||
return request({
|
||||
url: '/feed/FeedPlan/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询饲喂计划详细
|
||||
export function getFeedPlan(createDate) {
|
||||
return request({
|
||||
url: '/feed/FeedPlan/' + createDate,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增饲喂计划
|
||||
export function addFeedPlan(data) {
|
||||
return request({
|
||||
url: '/feed/FeedPlan',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改饲喂计划
|
||||
export function updateFeedPlan(data) {
|
||||
return request({
|
||||
url: '/feed/FeedPlan',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除饲喂计划
|
||||
export function delFeedPlan(createDate) {
|
||||
return request({
|
||||
url: '/feed/FeedPlan/' + createDate,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
44
src/api/feed/FormulaList.js
Normal file
44
src/api/feed/FormulaList.js
Normal file
@ -0,0 +1,44 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询配方列表列表
|
||||
export function listFormulaList(query) {
|
||||
return request({
|
||||
url: '/feed/FormulaList/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询配方列表详细
|
||||
export function getFormulaList(code) {
|
||||
return request({
|
||||
url: '/feed/FormulaList/' + code,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增配方列表
|
||||
export function addFormulaList(data) {
|
||||
return request({
|
||||
url: '/feed/FormulaList',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改配方列表
|
||||
export function updateFormulaList(data) {
|
||||
return request({
|
||||
url: '/feed/FormulaList',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除配方列表
|
||||
export function delFormulaList(code) {
|
||||
return request({
|
||||
url: '/feed/FormulaList/' + code,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
44
src/api/feed/FormulaManagement.js
Normal file
44
src/api/feed/FormulaManagement.js
Normal file
@ -0,0 +1,44 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询配方管理列表
|
||||
export function listFormulaManagement(query) {
|
||||
return request({
|
||||
url: '/feed/FormulaManagement/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询配方管理详细
|
||||
export function getFormulaManagement(formulaId) {
|
||||
return request({
|
||||
url: '/feed/FormulaManagement/' + formulaId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增配方管理
|
||||
export function addFormulaManagement(data) {
|
||||
return request({
|
||||
url: '/feed/FormulaManagement',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改配方管理
|
||||
export function updateFormulaManagement(data) {
|
||||
return request({
|
||||
url: '/feed/FormulaManagement',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除配方管理
|
||||
export function delFormulaManagement(formulaId) {
|
||||
return request({
|
||||
url: '/feed/FormulaManagement/' + formulaId,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
44
src/api/feed/Material.js
Normal file
44
src/api/feed/Material.js
Normal file
@ -0,0 +1,44 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询原料列表
|
||||
export function listMaterial(query) {
|
||||
return request({
|
||||
url: '/feed/material/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询原料详细
|
||||
export function getMaterial(materialId) {
|
||||
return request({
|
||||
url: '/feed/material/' + materialId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增原料
|
||||
export function addMaterial(data) {
|
||||
return request({
|
||||
url: '/feed/material',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改原料
|
||||
export function updateMaterial(data) {
|
||||
return request({
|
||||
url: '/feed/material',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除原料
|
||||
export function delMaterial(materialId) {
|
||||
return request({
|
||||
url: '/feed/material/' + materialId,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
347
src/views/feed/FeedPlan/index.vue
Normal file
347
src/views/feed/FeedPlan/index.vue
Normal file
@ -0,0 +1,347 @@
|
||||
<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="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-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: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-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-col>
|
||||
<el-col :span="1.5">
|
||||
<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>
|
||||
|
||||
<el-table v-loading="loading" :data="FeedPlanList" @selection-change="handleSelectionChange">
|
||||
<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="sheepHouseId">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="sheep_house_list" :value="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="计划饲喂总量" align="center" prop="planFeedTotal" />
|
||||
<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>
|
||||
</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="['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"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改饲喂计划对话框 -->
|
||||
<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-item label="配方编码" prop="formulaId">
|
||||
<el-input v-model="form.formulaId" placeholder="请输入配方编码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="羊舍" prop="sheepHouseId">
|
||||
<el-input v-model="form.sheepHouseId" placeholder="请输入羊舍" />
|
||||
</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>
|
||||
<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-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-date-picker>
|
||||
</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 name="FeedPlan">
|
||||
import { listFeedPlan, getFeedPlan, delFeedPlan, addFeedPlan, updateFeedPlan } from "@/api/feed/FeedPlan"
|
||||
|
||||
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 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()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
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()
|
||||
</script>
|
229
src/views/feed/FormulaList/index.vue
Normal file
229
src/views/feed/FormulaList/index.vue
Normal file
@ -0,0 +1,229 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="原料编号" prop="materialId">
|
||||
<el-input v-model="queryParams.materialId" placeholder="请输入原料编号" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="原料名称" prop="materialName">
|
||||
<el-input v-model="queryParams.materialName" placeholder="请输入原料名称" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="比例" prop="ratio">
|
||||
<el-input v-model="queryParams.ratio" 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:FormulaList:add']">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate"
|
||||
v-hasPermi="['feed:FormulaList:edit']">修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete"
|
||||
v-hasPermi="['feed:FormulaList:remove']">删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="Download" @click="handleExport"
|
||||
v-hasPermi="['feed:FormulaList:export']">导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="FormulaListList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="序号" align="center" prop="code" />
|
||||
<el-table-column label="配方编号" align="center" prop="formulaId" />
|
||||
<el-table-column label="原料编号" align="center" prop="materialId" />
|
||||
<el-table-column label="原料名称" align="center" prop="materialName" />
|
||||
<el-table-column label="比例" align="center" prop="ratio" />
|
||||
<el-table-column label="颗粒原料" align="center" prop="isGranular" />
|
||||
<el-table-column label="补饲" align="center" prop="isSupplement" />
|
||||
<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:FormulaList:edit']">修改</el-button>
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
|
||||
v-hasPermi="['feed:FormulaList: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="FormulaListRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="原料编号" prop="materialId">
|
||||
<el-input v-model="form.materialId" placeholder="请输入原料编号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="原料名称" prop="materialName">
|
||||
<el-input v-model="form.materialName" placeholder="请输入原料名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="比例" prop="ratio">
|
||||
<el-input v-model="form.ratio" 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="FormulaList">
|
||||
import { listFormulaList, getFormulaList, delFormulaList, addFormulaList, updateFormulaList } from "@/api/feed/FormulaList"
|
||||
import { reactive } from "vue"
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const FormulaListList = 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,
|
||||
batchId: "0",
|
||||
materialId: null,
|
||||
materialName: null,
|
||||
ratio: null,
|
||||
isGranular: null,
|
||||
isSupplement: null
|
||||
},
|
||||
rules: {
|
||||
ratio: [
|
||||
{ required: true, message: "比例不能为空", trigger: "blur" }
|
||||
],
|
||||
}
|
||||
})
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data)
|
||||
|
||||
|
||||
/** 查询配方列表列表 */
|
||||
function getList() {
|
||||
loading.value = true
|
||||
listFormulaList(queryParams.value).then(response => {
|
||||
FormulaListList.value = response.rows
|
||||
total.value = response.total
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
// 取消按钮
|
||||
function cancel() {
|
||||
open.value = false
|
||||
reset()
|
||||
}
|
||||
|
||||
// 表单重置
|
||||
function reset() {
|
||||
form.value = {
|
||||
code: null,
|
||||
formulaId: null,
|
||||
materialId: null,
|
||||
materialName: null,
|
||||
ratio: null,
|
||||
isGranular: null,
|
||||
isSupplement: null
|
||||
}
|
||||
proxy.resetForm("FormulaListRef")
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery() {
|
||||
queryParams.value.pageNum = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function resetQuery() {
|
||||
proxy.resetForm("queryRef")
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
// 多选框选中数据
|
||||
function handleSelectionChange(selection) {
|
||||
ids.value = selection.map(item => item.code)
|
||||
single.value = selection.length != 1
|
||||
multiple.value = !selection.length
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
function handleAdd() {
|
||||
reset()
|
||||
open.value = true
|
||||
title.value = "添加配方列表"
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
function handleUpdate(row) {
|
||||
reset()
|
||||
const _code = row.code || ids.value
|
||||
getFormulaList(_code).then(response => {
|
||||
form.value = response.data
|
||||
open.value = true
|
||||
title.value = "修改配方列表"
|
||||
})
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs["FormulaListRef"].validate(valid => {
|
||||
if (valid) {
|
||||
if (form.value.code != null) {
|
||||
updateFormulaList(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("修改成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
} else {
|
||||
addFormulaList(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("新增成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
function handleDelete(row) {
|
||||
const _codes = row.code || ids.value
|
||||
proxy.$modal.confirm('是否确认删除配方列表编号为"' + _codes + '"的数据项?').then(function () {
|
||||
return delFormulaList(_codes)
|
||||
}).then(() => {
|
||||
getList()
|
||||
proxy.$modal.msgSuccess("删除成功")
|
||||
}).catch(() => { })
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
function handleExport() {
|
||||
proxy.download('feed/FormulaList/export', {
|
||||
...queryParams.value
|
||||
}, `FormulaList_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
|
||||
getList()
|
||||
</script>
|
659
src/views/feed/FormulaManagement/index.vue
Normal file
659
src/views/feed/FormulaManagement/index.vue
Normal file
@ -0,0 +1,659 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="饲养阶段" prop="feedStage">
|
||||
<el-input v-model="queryParams.feedStage" placeholder="请输入饲养阶段" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="批号" prop="batchId">
|
||||
<el-input v-model="queryParams.batchId" 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:FormulaManagement:add']">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate"
|
||||
v-hasPermi="['feed:FormulaManagement:edit']">修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete"
|
||||
v-hasPermi="['feed:FormulaManagement:remove']">删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="Download" @click="handleExport"
|
||||
v-hasPermi="['feed:FormulaManagement:export']">导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="FormulaManagementList">
|
||||
<!-- 表中表展示配方原料 -->
|
||||
<el-table-column type="expand">
|
||||
<template #default="props">
|
||||
<el-table :data="props.row.subFormulaList" style="width: 100%">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="批号" align="center" prop="batchId" />
|
||||
<el-table-column label="饲养阶段" align="center" prop="feedStage" />
|
||||
<el-table-column label="开始使用时间" align="center" prop="useStartDate" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.useStartDate, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="结束使用时间" align="center" prop="useEndDate" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.useEndDate, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="使用状态" align="center" prop="useState">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="pres_status" :value="scope.row.useState" />
|
||||
</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="View" @click="handleView(scope.row)">详情</el-button>
|
||||
<el-button link type="primary" icon="Edit" @click="handleFormulaDetailUpdate(scope.row)"
|
||||
v-hasPermi="['feed:FormulaManagement:edit']">修改</el-button>
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
|
||||
v-hasPermi="['feed:FormulaManagement:remove']">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="配方编号" align="center" prop="formulaId" />
|
||||
<el-table-column label="饲养阶段" align="center" prop="feedStage" />
|
||||
<el-table-column label="使用状态" align="center" prop="useState">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="pres_status" :value="scope.row.useState" />
|
||||
</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="Plus" @click="handleAddSgFormulaList(scope.row)"
|
||||
v-hasPermi="['feed:FormulaManagement:add']">新增</el-button>
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['feed:FormulaManagement:edit']">修改</el-button>
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
|
||||
v-hasPermi="['feed:FormulaManagement: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="FormulaManagementRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="饲养阶段" prop="feedStage">
|
||||
<el-input v-model="form.feedStage" placeholder="请输入饲养阶段" />
|
||||
</el-form-item>
|
||||
<el-form-item label="开始使用时间" prop="useStartDate">
|
||||
<el-date-picker clearable v-model="form.useStartDate" type="date" value-format="YYYY-MM-DD"
|
||||
placeholder="请选择开始使用时间">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="结束使用时间" prop="useEndDate">
|
||||
<el-date-picker clearable v-model="form.useEndDate" 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>
|
||||
</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>
|
||||
|
||||
<!-- 弹框:详情/修改 -->
|
||||
<el-dialog :title="title" v-model="formulaListOpen" width="60%" append-to-body s>
|
||||
<!-- 详情页:只读展示 -->
|
||||
<div v-if="isView" style="padding-bottom:20px ;">
|
||||
<el-descriptions :column="2" border>
|
||||
<el-descriptions-item label="配方批号">{{ showFormulaManagementList.batchId }}</el-descriptions-item>
|
||||
<el-descriptions-item label="饲养阶段">{{ showFormulaManagementList.feedStage }}</el-descriptions-item>
|
||||
<el-descriptions-item label="开始使用时间">
|
||||
<span>{{ parseTime(showFormulaManagementList.useStartDate, '{y}-{m}-{d}') }}</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="结束使用时间">
|
||||
<span>{{ parseTime(showFormulaManagementList.useEndDate, '{y}-{m}-{d}') }}</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="使用状态">
|
||||
<dict-tag :options="pres_status" :value="showFormulaManagementList.useState" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="备注" :span="2">
|
||||
{{ showFormulaManagementList.remark || '无' }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<el-divider content-position="left">配方列表</el-divider>
|
||||
|
||||
<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" prop="ratio" />
|
||||
<el-table-column label="类型" prop="isGranular" align="center" >
|
||||
<template #default="scope">
|
||||
<dict-tag :options="materialType" :value="scope.row.isGranular" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<!-- 修改页:可编辑表单 -->
|
||||
<div v-else>
|
||||
<el-form ref="FormulaManagementRef" :model="showFormulaManagementList" :rules="rules" label-width="100px">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="批号" prop="batchId">
|
||||
<el-input v-model="showFormulaManagementList.batchId" placeholder="请输入配方批号" :disabled="!BatchIdEditable" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="饲养阶段" prop="feedStage">
|
||||
<el-input v-model="showFormulaManagementList.feedStage" placeholder="请输入饲养阶段" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="开始使用时间" prop="useStartDate">
|
||||
<el-date-picker clearable v-model="showFormulaManagementList.useStartDate" type="date" value-format="YYYY-MM-DD"
|
||||
placeholder="请选择开始使用时间">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="结束使用时间" prop="useEndDate">
|
||||
<el-date-picker clearable v-model="showFormulaManagementList.useEndDate" type="date" value-format="YYYY-MM-DD"
|
||||
placeholder="请选择结束使用时间">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="使用状态" prop="useState">
|
||||
<el-select v-model="showFormulaManagementList.useState" placeholder="请选择使用状态">
|
||||
<el-option v-for="item in useStaus" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input type="textarea" :rows="2" v-model="showFormulaManagementList.remark" placeholder="请输入备注" />
|
||||
</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="handleAddSgFormulaListDetail()">添加</el-button>
|
||||
</el-col>
|
||||
|
||||
</el-row>
|
||||
|
||||
<el-table :data="showFormulaManagementList.sgFormulaList" :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">
|
||||
<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>
|
||||
|
||||
<el-table-column label="比例" prop="dosage">
|
||||
<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">
|
||||
<template #default="scope">
|
||||
<el-select v-model="scope.row.isGranular" 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-form>
|
||||
</div>
|
||||
|
||||
<!-- 底部按钮:仅修改页显示 -->
|
||||
<template #footer v-if="!isView">
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
<el-button type="primary" @click="submitFormulaListForm">确 定</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { listFormulaManagement, getFormulaManagement, delFormulaManagement, addFormulaManagement, updateFormulaManagement } from "@/api/feed/FormulaManagement"
|
||||
import { ref, reactive, toRefs, getCurrentInstance } from 'vue'
|
||||
import { listFormulaList, getFormulaList, delFormulaList, addFormulaList, updateFormulaList } from "@/api/feed/FormulaList"
|
||||
import { listMaterial } from "@/api/feed/Material"
|
||||
import { fa } from "element-plus/es/locales.mjs"
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { pres_status } = proxy.useDict('pres_status')
|
||||
// Data and refs
|
||||
const FormulaManagementList = ref([])
|
||||
const showFormulaManagementList = ref([])
|
||||
const FormulaDetailList = 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 expandedRows = ref([]) // Track expanded rows
|
||||
const isView = ref(false)
|
||||
|
||||
/**
|
||||
* add : 添加配方
|
||||
* update : 修改配方
|
||||
*/
|
||||
const operationType = ref("") // 操作类型:add 或 update
|
||||
// 控制批号是否可编辑
|
||||
const BatchIdEditable = ref(false)
|
||||
// 原料下拉列表
|
||||
const materials = ref([])
|
||||
// 原料类型
|
||||
const materialType = [
|
||||
{ value: '1', label: '颗粒料' },
|
||||
{ value: '0', label: '其他' }
|
||||
]
|
||||
const useStaus = [
|
||||
{ value: '1', label: '启用' },
|
||||
{ value: '0', label: '停用' }
|
||||
]
|
||||
const checkedSwPresDetail = ref([]) // 子表选中的行序号数组
|
||||
|
||||
const data = reactive({
|
||||
form: {},
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
feedStage: null,
|
||||
batchId: null,
|
||||
},
|
||||
rules: {
|
||||
formulaId: [
|
||||
{ required: true, message: "配方编号不能为空", trigger: "blur" }
|
||||
],
|
||||
feedStage: [
|
||||
{ required: true, message: "饲养阶段不能为空", trigger: "blur" }
|
||||
],
|
||||
ratio:[
|
||||
{required: true, message: "比例不能为空", trigger: "blur"},
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data)
|
||||
|
||||
|
||||
const formulaForm = ref({
|
||||
materialId: '',
|
||||
materialName: '',
|
||||
ratio: '',
|
||||
isGranular: false
|
||||
})
|
||||
const formulaListOpen = ref(false)
|
||||
/** 查询配方管理列表 */
|
||||
function getList() {
|
||||
loading.value = true
|
||||
listFormulaManagement(queryParams.value).then(response => {
|
||||
FormulaManagementList.value = response.rows
|
||||
total.value = response.total
|
||||
loading.value = false
|
||||
console.log("配方管理列表数据:", FormulaManagementList.value)
|
||||
})
|
||||
}
|
||||
|
||||
// 处理展开行的变化
|
||||
function handleExpandChange(row, expanded) {
|
||||
if (expanded) {
|
||||
expandedRows.value.push(row.formulaId) // 添加展开的行
|
||||
} else {
|
||||
expandedRows.value = expandedRows.value.filter(id => id !== row.formulaId) // 移除收起的行
|
||||
}
|
||||
}
|
||||
|
||||
// 取消按钮
|
||||
function cancel() {
|
||||
open.value = false
|
||||
formulaListOpen.value = false
|
||||
formulaFormReset()
|
||||
reset()
|
||||
}
|
||||
|
||||
// 表单重置
|
||||
function reset() {
|
||||
form.value = {
|
||||
formulaId: null,
|
||||
feedStage: null,
|
||||
batchId: null,
|
||||
useStartDate: null,
|
||||
useEndDate: null,
|
||||
useState: null,
|
||||
remark: null
|
||||
}
|
||||
proxy.resetForm("FormulaManagementRef")
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery() {
|
||||
queryParams.value.pageNum = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function resetQuery() {
|
||||
proxy.resetForm("queryRef")
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
// 多选框选中数据
|
||||
function handleSelectionChange(selection) {
|
||||
ids.value = selection.map(item => item.formulaId)
|
||||
single.value = selection.length != 1
|
||||
multiple.value = !selection.length
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
function handleAdd() {
|
||||
reset()
|
||||
open.value = true
|
||||
title.value = "添加配方管理"
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
function handleUpdate(row) {
|
||||
reset()
|
||||
const _formulaId = row.formulaId || ids.value
|
||||
getFormulaManagement(_formulaId).then(response => {
|
||||
form.value = response.data
|
||||
open.value = true
|
||||
title.value = "修改配方管理"
|
||||
})
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs["FormulaManagementRef"].validate(valid => {
|
||||
if (valid) {
|
||||
if (form.value.formulaId != null) {
|
||||
updateFormulaManagement(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("修改成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
} else {
|
||||
addFormulaManagement(form.value).then(response => {
|
||||
proxy.$modal.msgSuccess("新增成功")
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
function handleDelete(row) {
|
||||
const _formulaIds = row.formulaId || ids.value
|
||||
proxy.$modal.confirm('是否确认删除配方管理编号为"' + _formulaIds + '"的数据项?').then(function () {
|
||||
return delFormulaManagement(_formulaIds)
|
||||
}).then(() => {
|
||||
getList()
|
||||
proxy.$modal.msgSuccess("删除成功")
|
||||
}).catch(() => { })
|
||||
}
|
||||
|
||||
/** ================= 配方列表操作 ================= */
|
||||
function handleAddSgFormulaList(row){
|
||||
formulaFormReset()
|
||||
reset()
|
||||
operationType.value = "add"
|
||||
BatchIdEditable.value = true
|
||||
isView.value = false
|
||||
// 初始化表单
|
||||
showFormulaManagementList.value = {
|
||||
formulaId: row.formulaId || null,
|
||||
batchId: null,
|
||||
feedStage: null,
|
||||
useStartDate: null,
|
||||
useEndDate: null,
|
||||
useState: '1', // 默认启用
|
||||
remark: null,
|
||||
sgFormulaList: [{
|
||||
materialId: null,
|
||||
materialName: null,
|
||||
ratio: null,
|
||||
isGranular: "0",
|
||||
isSupplement: "0"
|
||||
}]
|
||||
}
|
||||
formulaListOpen.value = true
|
||||
title.value = "添加配方"
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
function handleFormulaUpdate(row) {
|
||||
formulaFormReset()
|
||||
const _code = row.code || ids.value
|
||||
getFormulaList(_code).then(response => {
|
||||
formulaForm.value = response.data
|
||||
if (formulaForm.value.isGranular === "1") {
|
||||
formulaForm.value.isGranular = true
|
||||
} else {
|
||||
formulaForm.value.isGranular = false
|
||||
}
|
||||
console.log("formulaForm: ", formulaForm.value)
|
||||
formulaListOpen.value = true
|
||||
title.value = "修改配方列表"
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
function handleFormulaDelete_Old(row) {
|
||||
const _codes = row.code || ids.value
|
||||
proxy.$modal.confirm('是否确认删除配方列表编号为"' + _codes + '"的数据项?').then(function () {
|
||||
return delFormulaList(_codes)
|
||||
}).then(() => {
|
||||
getList()
|
||||
proxy.$modal.msgSuccess("删除成功")
|
||||
}).catch(() => { })
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
function submitFormulaListForm() {
|
||||
proxy.$refs["FormulaManagementRef"].validate(valid => {
|
||||
if (valid) {
|
||||
if (showFormulaManagementList.value.formulaId != null && operationType.value === "update") {
|
||||
updateFormulaManagement(showFormulaManagementList.value).then(response => {
|
||||
proxy.$modal.msgSuccess("修改成功")
|
||||
formulaListOpen.value = false
|
||||
getList()
|
||||
})
|
||||
} else if (operationType.value === "add" && showFormulaManagementList.value.formulaId != null && showFormulaManagementList.value.batchId != null) {
|
||||
addFormulaManagement(showFormulaManagementList.value).then(response => {
|
||||
proxy.$modal.msgSuccess("新增成功")
|
||||
formulaListOpen.value = false
|
||||
getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 原料下拉选择变化时,更新对应的原料名称
|
||||
function handleMaterialChange(row, selectedValue) {
|
||||
const selectedItem = this.materials.find(item => item.value === selectedValue);
|
||||
if (selectedItem) {
|
||||
// materialName 也在 row 中
|
||||
row.materialName = selectedItem.label;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看详情
|
||||
* 根据 id 拉取单条记录及子表数据,弹窗只读展示
|
||||
*/
|
||||
function handleView(row) {
|
||||
reset()
|
||||
const _id = row.formulaId || ids.value
|
||||
const batchId = row.batchId
|
||||
const queryParams = {
|
||||
formulaId: _id,
|
||||
batchId: batchId,
|
||||
queryType: "query"
|
||||
}
|
||||
listFormulaManagement(queryParams).then(response => {
|
||||
if (response.rows && response.rows.length > 0) {
|
||||
showFormulaManagementList.value = response.rows[0] // 取第一条记录
|
||||
} else {
|
||||
showFormulaManagementList.value = {}
|
||||
}
|
||||
title.value = "配方详情"
|
||||
isView.value = true
|
||||
formulaListOpen.value = true
|
||||
console.log("handleView showFormulaManagementList: ", showFormulaManagementList.value);
|
||||
console.log("handleView response: ", response);
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改按钮
|
||||
* 与查看详情共用接口,但弹窗可编辑
|
||||
*/
|
||||
function handleFormulaDetailUpdate(row) {
|
||||
reset()
|
||||
operationType.value = "update"
|
||||
const _id = row.formulaId || ids.value
|
||||
BatchIdEditable.value = false // 修改时批号不可编辑
|
||||
const batchId = row.batchId
|
||||
const queryParams = {
|
||||
formulaId: _id,
|
||||
batchId: batchId,
|
||||
queryType: "query"
|
||||
}
|
||||
listFormulaManagement(queryParams).then(response => {
|
||||
if (response.rows && response.rows.length > 0) {
|
||||
showFormulaManagementList.value = response.rows[0] // 取第一条记录
|
||||
} else {
|
||||
showFormulaManagementList.value = {}
|
||||
}
|
||||
formulaListOpen.value = true
|
||||
title.value = "修改处方"
|
||||
isView.value = false
|
||||
})
|
||||
}
|
||||
|
||||
// 添加项
|
||||
function handleAddSgFormulaListDetail() {
|
||||
showFormulaManagementList.value.sgFormulaList.push({
|
||||
materialId: null,
|
||||
materialName: null,
|
||||
ratio: null,
|
||||
isGranular: "0",
|
||||
isSupplement: "0"
|
||||
})
|
||||
}
|
||||
// 删除项
|
||||
function deleteFormulaListDetail(row) {
|
||||
const index = showFormulaManagementList.value.sgFormulaList.findIndex(item => item.index === row.index)
|
||||
if (index !== -1) {
|
||||
showFormulaManagementList.value.sgFormulaList.splice(index, 1)
|
||||
}
|
||||
}
|
||||
// 表单重置
|
||||
function formulaFormReset() {
|
||||
form.value = {
|
||||
code: null,
|
||||
formulaId: null,
|
||||
materialId: null,
|
||||
materialName: null,
|
||||
ratio: null,
|
||||
isGranular: null,
|
||||
isSupplement: null
|
||||
}
|
||||
proxy.resetForm("FormulaListRef")
|
||||
}
|
||||
|
||||
// 原料列表查询参数
|
||||
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
|
||||
}))
|
||||
console.log("原料列表:", materials.value)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 子表多选回调
|
||||
* 记录被选中的行序号数组
|
||||
*/
|
||||
function handleSgFormulaListDetailSelectionChange(selection) {
|
||||
checkedSwPresDetail.value = selection.map(item => item.index)
|
||||
}
|
||||
/**
|
||||
* 子表行序号计算
|
||||
* 通过 el-table 的 row-class-name 钩子给每一行写入 index(从 1 开始)
|
||||
*/
|
||||
function rowSgFormulaListDetailIndex({ row, rowIndex }) {
|
||||
row.index = rowIndex + 1
|
||||
}
|
||||
|
||||
/** ================================= */
|
||||
/** 导出按钮操作 */
|
||||
function handleExport() {
|
||||
proxy.download('feed/FormulaManagement/export', {
|
||||
...queryParams.value
|
||||
}, `FormulaManagement_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
|
||||
// 初始化加载数据
|
||||
getList()
|
||||
// 加载原料列表
|
||||
getMaterials()
|
||||
</script>
|
@ -20,16 +20,16 @@
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['stock:in:add']">新增</el-button>
|
||||
<el-col :span="1.5" >
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['stock:in:add']" v-show="false">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate"
|
||||
v-hasPermi="['stock:in:edit']">修改</el-button>
|
||||
v-hasPermi="['stock:in:edit']" v-show="false">修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete"
|
||||
v-hasPermi="['stock:in:remove']">删除</el-button>
|
||||
v-hasPermi="['stock:in:remove']" v-show="false">删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="Download" @click="handleExport"
|
||||
@ -119,6 +119,7 @@
|
||||
<script setup name="In">
|
||||
import { listIn, getIn, delIn, addIn, updateIn } from "@/api/stock/in"
|
||||
import { getToken } from "@/utils/auth"
|
||||
import { isVisible } from "element-plus/es/utils/index.mjs"
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const inList = ref([])
|
||||
|
@ -97,9 +97,43 @@
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改物资管理对话框 -->
|
||||
<!-- 添加或修改饲喂计划对话框 -->
|
||||
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
||||
<el-form ref="managementRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="存货编码" prop="materialId">
|
||||
<el-input v-model="form.materialId" placeholder="请输入存货编码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="存货" prop="materialName">
|
||||
<el-input v-model="form.materialName" placeholder="请输入存货名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="批号" prop="batchId">
|
||||
<el-input v-model="form.batchId" placeholder="请输入批号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="规格型号" prop="materialSpecification">
|
||||
<el-input v-model="form.materialSpecification" placeholder="请输入规格型号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="主计量" prop="materialUnit">
|
||||
<el-input v-model="form.materialUnit" placeholder="请输入计量单位" />
|
||||
</el-form-item>
|
||||
<el-form-item label="现存量" prop="currentStock">
|
||||
<el-input v-model="form.currentStock" placeholder="请输入现存量" />
|
||||
</el-form-item>
|
||||
<el-form-item label="生产日期" prop="productionDate">
|
||||
<el-date-picker clearable
|
||||
v-model="form.productionDate"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="请选择生产日期">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="失效日期" prop="expirationDate">
|
||||
<el-date-picker clearable
|
||||
v-model="form.expirationDate"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="请选择失效日期">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
|
@ -21,15 +21,15 @@
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['stock:out:add']">新增</el-button>
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['stock:out:add']" v-show="false">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate"
|
||||
v-hasPermi="['stock:out:edit']">修改</el-button>
|
||||
v-hasPermi="['stock:out:edit']" v-show="false">修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete"
|
||||
v-hasPermi="['stock:out:remove']">删除</el-button>
|
||||
v-hasPermi="['stock:out:remove']" v-show="false">删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="Download" @click="handleExport"
|
||||
|
Loading…
x
Reference in New Issue
Block a user