每{{ baseForm.weight }}g 含营养信息
-
+
热量(千卡)
{{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;
@@ -1584,7 +1586,8 @@
largeWeight: null
}
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;
@@ -1636,34 +1667,37 @@
param.materialCost = Number(param.materialCost)*100;
param.materialList=[]
param.littleMaterialList=[]
- this.materialList.forEach(item=>{
- param.materialList.push({
- materialId: item.materialId,
- materialType: item.materialType,
- weight: item.largeWeight
- })
- param.littleMaterialList.push({
- materialId: item.materialId,
- materialType: item.materialType,
- weight: item.littleWeight
- })
- })
+ this.materialList.forEach(item=>{
+ if(item.materialId!=null){
+ param.materialList.push({
+ materialId: item.materialId,
+ materialType: item.materialType,
+ weight: item.largeWeight
+ })
+ param.littleMaterialList.push({
+ materialId: item.materialId,
+ 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;
- }
+ // }
}
}
})
diff --git a/src/views/dish/nutritionInfo/index.vue b/src/views/dish/nutritionInfo/index.vue
index 6c4df8ed..52c3763e 100644
--- a/src/views/dish/nutritionInfo/index.vue
+++ b/src/views/dish/nutritionInfo/index.vue
@@ -969,13 +969,17 @@ export default {
// 限制小数点后最多两位
if (parts.length === 2 && parts[1].length > 2) {
newValue = parts[0] + '.' + parts[1].substring(0, 2);
+ }
+ if(field=='edible'||field=='water'||field=='protein'||field=='fat'||field=='carbohydrate'||field=='dietaryFiber'||field=='ash'){
+ if (parseFloat(newValue) > 100) {
+ newValue = '100';
+ }
+ }else{
+ // 限制最大值为100
+ if (parseFloat(newValue) > 99999) {
+ newValue = '100000';
+ }
}
-
- // 限制最大值为100
- if (parseFloat(newValue) > 100) {
- newValue = '100.00';
- }
-
this.form[field] = newValue;
},
@@ -984,8 +988,7 @@ export default {
* @param {string} field - 字段名
*/
formatNumericValue(field) {
- let value = this.form[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);
}