增加库存优先型一键生成配方
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
<el-form-item label="生成方式" prop="selectedGenerationMethod" :rules="[{ required: true, message: '请选择生成方式', trigger: 'change' }]">
|
||||
<el-select v-model="form.selectedGenerationMethod" placeholder="请选择生成方式" style="width: 100%;">
|
||||
<el-option label="使用系统中所有可用的原料" value="all_raw_materials"></el-option>
|
||||
<!-- 新增选项 -->
|
||||
<el-option label="优先使用有库存的原料" value="prefer_in_stock_materials"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -93,8 +95,17 @@ export default {
|
||||
try {
|
||||
const pigTypeId = parseInt(form.selectedPigType); // 获取选中的 pigType ID
|
||||
|
||||
// 调用一键生成配方的接口
|
||||
const response = await FeedApi.generateRecipeFromAllMaterials(pigTypeId);
|
||||
if (form.selectedGenerationMethod === 'all_raw_materials') {
|
||||
// 调用使用所有原料生成配方的接口
|
||||
response = await FeedApi.generateRecipeFromAllMaterials(pigTypeId);
|
||||
} else if (form.selectedGenerationMethod === 'prefer_in_stock_materials') {
|
||||
// 调用优先使用有库存原料生成配方的接口
|
||||
response = await FeedApi.generatePrioritizedStockRecipe(pigTypeId);
|
||||
} else {
|
||||
ElMessage.error('未知的生成方式');
|
||||
loading.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (response.data) {
|
||||
ElMessage.success('配方生成成功!');
|
||||
|
||||
Reference in New Issue
Block a user