Compare commits

...

2 Commits

Author SHA1 Message Date
HashMap
0d09378f2e Merge branch 'feature/feed-management-08011755' 2025-08-12 15:52:39 +08:00
HashMap
d4202616d5 feat(view api) : 实现配方管理功能 2025-08-12 15:51:45 +08:00
2 changed files with 110 additions and 52 deletions

View File

@ -36,9 +36,9 @@ export function updateFormulaManagement(data) {
}
// 删除配方管理
export function delFormulaManagement(formulaId) {
export function delFormulaManagement(formulaIdAndBatchId) {
return request({
url: '/feed/FormulaManagement/' + formulaId,
url: '/feed/FormulaManagement/' + formulaIdAndBatchId,
method: 'delete'
})
}

View File

@ -15,16 +15,16 @@
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd"
<el-button type="primary" plain icon="Plus" @click="handleAddFormulatemplate"
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>
v-hasPermi="['feed:FormulaManagement: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="['feed:FormulaManagement:remove']">删除</el-button>
v-hasPermi="['feed:FormulaManagement:remove']" v-show="false">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport"
@ -34,11 +34,10 @@
</el-row>
<el-table v-loading="loading" :data="FormulaManagementList">
<!-- 表中表展示配方原料 -->
<el-table-column type="expand">
<!-- 表中表展示配方 -->
<el-table-column type="expand" @expand-change="handleExpandChange">
<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">
@ -62,14 +61,13 @@
<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)"
<el-button link type="primary" icon="Delete" @click="handleFormulaDelete(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">
@ -80,11 +78,11 @@
<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)"
<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="handleFormulaTemplateUpdate(scope.row)"
v-hasPermi="['feed:FormulaManagement:edit']">修改</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
<el-button link type="primary" icon="Delete" @click="handleFormulaDelete(scope.row)"
v-hasPermi="['feed:FormulaManagement:remove']">删除</el-button>
</template>
</el-table-column>
@ -152,7 +150,7 @@
<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" >
<el-table-column label="类型" prop="isGranular" align="center">
<template #default="scope">
<dict-tag :options="materialType" :value="scope.row.isGranular" />
</template>
@ -164,9 +162,16 @@
<div v-else>
<el-form ref="FormulaManagementRef" :model="showFormulaManagementList" :rules="rules" label-width="100px">
<el-row :gutter="20">
<el-col :span="12" v-if="!isView">
<el-form-item label="配方编号" prop="formulaId">
<el-input v-model="showFormulaManagementList.formulaId" placeholder="请输入配方编号"
:disabled="!FormulaIdEditable"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="批号" prop="batchId">
<el-input v-model="showFormulaManagementList.batchId" placeholder="请输入配方批号" :disabled="!BatchIdEditable" />
<el-input v-model="showFormulaManagementList.batchId" placeholder="请输入配方批号"
:disabled="!BatchIdEditable" />
</el-form-item>
</el-col>
<el-col :span="12">
@ -176,15 +181,15 @@
</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 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 clearable v-model="showFormulaManagementList.useEndDate" type="date"
value-format="YYYY-MM-DD" placeholder="请选择结束使用时间">
</el-date-picker>
</el-form-item>
</el-col>
@ -211,13 +216,15 @@
</el-row>
<el-table :data="showFormulaManagementList.sgFormulaList" :rules="rules" :row-class-name="rowSgFormulaListDetailIndex"
@selection-change="handleSgFormulaListDetailSelectionChange" ref="swPresDetail" border stripe>
<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 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>
@ -284,7 +291,8 @@ const isView = ref(false)
*/
const operationType = ref("") // add update
//
const BatchIdEditable = ref(false)
const BatchIdEditable = ref(false)
const FormulaIdEditable = ref(false)
//
const materials = ref([])
//
@ -313,8 +321,8 @@ const data = reactive({
feedStage: [
{ required: true, message: "饲养阶段不能为空", trigger: "blur" }
],
ratio:[
{required: true, message: "比例不能为空", trigger: "blur"},
ratio: [
{ required: true, message: "比例不能为空", trigger: "blur" },
]
}
})
@ -341,11 +349,19 @@ function getList() {
}
//
function handleExpandChange(row, expanded) {
if (expanded) {
expandedRows.value.push(row.formulaId) //
} else {
expandedRows.value = expandedRows.value.filter(id => id !== row.formulaId) //
function handleExpandChange(row, expandedRows) {
//
expandedRows.forEach(r => {
if (r !== row) {
mainTable.value.toggleRowExpansion(r, false)
}
})
//
const isExpanded = expandedRows.includes(row)
if (isExpanded) {
loading.value = true
getList();
}
}
@ -391,20 +407,59 @@ function handleSelectionChange(selection) {
}
/** 新增按钮操作 */
function handleAdd() {
function handleAddFormulatemplate() {
formulaFormReset()
reset()
open.value = true
title.value = "添加配方管理"
operationType.value = "add"
//
BatchIdEditable.value = false
//
FormulaIdEditable.value = true
isView.value = false
//
showFormulaManagementList.value = {
formulaId: null,
// 0
batchId: "0",
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 handleUpdate(row) {
function handleFormulaTemplateUpdate(row) {
reset()
const _formulaId = row.formulaId || ids.value
getFormulaManagement(_formulaId).then(response => {
form.value = response.data
open.value = true
title.value = "修改配方管理"
operationType.value = "update"
const _id = row.formulaId || ids.value
BatchIdEditable.value = false //
FormulaIdEditable.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
})
}
@ -441,12 +496,14 @@ function handleDelete(row) {
}
/** ================= 配方列表操作 ================= */
function handleAddSgFormulaList(row){
function handleAddSgFormulaList(row) {
formulaFormReset()
reset()
operationType.value = "add"
BatchIdEditable.value = true
FormulaIdEditable.value = false
isView.value = false
console.log(row.sgFormulaList)
//
showFormulaManagementList.value = {
formulaId: row.formulaId || null,
@ -456,7 +513,7 @@ function handleAddSgFormulaList(row){
useEndDate: null,
useState: '1', //
remark: null,
sgFormulaList: [{
sgFormulaList: row.sgFormulaList || [{
materialId: null,
materialName: null,
ratio: null,
@ -481,15 +538,16 @@ function handleFormulaUpdate(row) {
}
console.log("formulaForm: ", formulaForm.value)
formulaListOpen.value = true
FormulaIdEditable.value = false
title.value = "修改配方列表"
})
}
/** 删除按钮操作 */
function handleFormulaDelete_Old(row) {
const _codes = row.code || ids.value
function handleFormulaDelete(row) {
const _codes = row.formulaId + "/" + row.batchId
proxy.$modal.confirm('是否确认删除配方列表编号为"' + _codes + '"的数据项?').then(function () {
return delFormulaList(_codes)
return delFormulaManagement(_codes)
}).then(() => {
getList()
proxy.$modal.msgSuccess("删除成功")
@ -518,13 +576,13 @@ function submitFormulaListForm() {
}
//
function handleMaterialChange(row, selectedValue) {
const selectedItem = this.materials.find(item => item.value === selectedValue);
if (selectedItem) {
// materialName row
row.materialName = selectedItem.label;
}
function handleMaterialChange(row, selectedValue) {
const selectedItem = this.materials.find(item => item.value === selectedValue);
if (selectedItem) {
// materialName row
row.materialName = selectedItem.label;
}
}
/**
* 查看详情