菜品营养问题修改

This commit is contained in:
zzyuan 2025-05-13 10:48:45 +08:00
parent d62b8344b5
commit 0e96ed0db2
2 changed files with 88 additions and 52 deletions

View File

@ -605,8 +605,6 @@
</el-form>
</el-tab-pane>
<!-- 组成成分 -->
<el-tab-pane label="组成成分" name="2" style="height: 600px;overflow-y: auto;" :disabled="(baseForm.weight==null||baseForm.weight=='')&&(baseForm.largeWeight==null||baseForm.largeWeight=='')&&(baseForm.littleWeight==null||baseForm.littleWeight=='')">
<template #label>
<el-tooltip content="请先填写份量" placement="top">
@ -624,9 +622,10 @@
<el-table-column label="原料" align="center" key="materialId" prop="materialId" width="200">
<template slot-scope="scope">
<el-select v-model="scope.row.materialId" filterable remote
reserve-keyword placeholder="请选择原料" style="width: 180px;margin-right: 20px;"
:remote-method="remoteMethod" :loading="loading">
reserve-keyword placeholder="请查询并选择原料" style="width: 180px;margin-right: 20px;"
:remote-method="remoteMethod" :loading="loading" @change="chosenMaterial">
<el-option v-for="lab in materialOptions"
:disabled="lab.disabled"
:key="lab.materialId"
:label="lab.materialName"
:value="lab.materialId">
@ -708,7 +707,7 @@
</el-tab-pane>
<el-tab-pane label="营养信息" name="3" style="height: 600px;overflow-y: auto;" v-if="title=='修改'">
<div v-if="baseForm.sizeType==1" style="font-size: 18px;font-weight: bold;color: #606266;">{{ baseForm.weight }}g 含营养信息</div>
<el-descriptions v-if="baseForm.sizeType==1" title="" :column="2" size="small" border labelStyle="width:150px;">
<el-descriptions v-if="baseForm.sizeType==1" title="" :column="2" size="small" border :labelStyle="{width:'150px'}">
<el-descriptions-item>
<template slot="label">热量(千卡)</template>
{{baseForm.calories||0}}
@ -1561,6 +1560,9 @@
this.checkUrlList=[]
}
this.$set(this,"materialOptions",response.data.materialList)
this.materialOptions.forEach(item=>{
item.disabled = true
})
this.activeName="1"
this.title = "修改";
this.openDish = true;
@ -1585,6 +1587,7 @@
}
this.materialList.push(obj)
}
this.materialOptions = [];
},
//
delDishMaterial(index){
@ -1603,19 +1606,38 @@
pageSize: 50
}
getMaterialListApi(param).then(response => {
this.materialOptions = response.rows
this.materialOptions = response.rows;
this.materialOptions.forEach(item=>{
let ifIndex = this.materialList.findIndex(v=>v.materialId==item.materialId)
if(ifIndex!=-1){
item.disabled = true
}else{
item.disabled = false
}
})
});
// this.options = this.list.filter(item => {
// return item.label.toLowerCase()
// .indexOf(query.toLowerCase()) > -1;
// });
}, 200);
} else {
this.materialOptions = [];
}
},
chosenMaterial(e){
this.loading=true
this.setDisabled()
this.loading=false
},
//
setDisabled(){
this.materialOptions.forEach(item=>{
let index = this.materialList.findIndex(v=>v.materialId==item.materialId)
if(index!=-1){
item.disabled = true
}else{
item.disabled = false
}
})
},
/** 处理对话框提交 */
handleDialogSubmit() {
this.$refs.baseForm.validate(valid => {
@ -1628,7 +1650,16 @@
if(param.sizeType==1){
param.price = Number(param.price)*100;
param.materialCost = Number(param.materialCost)*100;
param.materialList = this.materialList
param.materialList=[]
this.materialList.forEach(item=>{
if(item.materialId!=null){
param.materialList.push({
materialId: item.materialId,
materialType: item.materialType,
weight: Number(item.weight)
})
}
})
}else{
param.littlePrice = Number(param.littlePrice)*100;
param.largePrice = Number(param.largePrice)*100;
@ -1637,6 +1668,7 @@
param.materialList=[]
param.littleMaterialList=[]
this.materialList.forEach(item=>{
if(item.materialId!=null){
param.materialList.push({
materialId: item.materialId,
materialType: item.materialType,
@ -1647,23 +1679,25 @@
materialType: item.materialType,
weight: item.littleWeight
})
}
})
}
if (this.title === "新增") {
addMenuDishesApi(param).then(response => {
this.openDish = false;
this.$modal.msgSuccess("新增成功");
this.getList();
});
console.log(param.materialList)
// if (this.title === "") {
// addMenuDishesApi(param).then(response => {
// this.openDish = false;
// this.$modal.msgSuccess("");
// this.getList();
// });
// this.btnLoading=false;
// } else {
// editMenuDishesApi(param).then(response => {
// this.openDish = false;
// this.$modal.msgSuccess("");
// this.getList();
// });
this.btnLoading=false;
} else {
editMenuDishesApi(param).then(response => {
this.openDish = false;
this.$modal.msgSuccess("修改成功");
this.getList();
});
this.btnLoading=false;
}
// }
}
}
})

View File

@ -970,12 +970,16 @@ export default {
if (parts.length === 2 && parts[1].length > 2) {
newValue = parts[0] + '.' + parts[1].substring(0, 2);
}
// 100
if(field=='edible'||field=='water'||field=='protein'||field=='fat'||field=='carbohydrate'||field=='dietaryFiber'||field=='ash'){
if (parseFloat(newValue) > 100) {
newValue = '100.00';
newValue = '100';
}
}else{
// 100
if (parseFloat(newValue) > 99999) {
newValue = '100000';
}
}
this.form[field] = newValue;
},
@ -985,7 +989,6 @@ export default {
*/
formatNumericValue(field) {
let value = this.form[field];
if (!value || value === '' || value === '.') {
this.form[field] = '0.00';
return;
@ -997,10 +1000,9 @@ export default {
}
// 100
if (value > 100) {
value = 100;
if (value > 99999) {
value = 100000;
}
//
this.form[field] = value.toFixed(2);
}