|
|
@@ -90,7 +90,8 @@
|
|
|
|
|
|
<script>
|
|
|
import { getFoodModifiers, removeFoodModifier, updateFoodModifierSort, convertFoodUnit, getNutrientList,
|
|
|
- getDetail} from '@/api/food'
|
|
|
+ getDetail, calculateNutrientsContent } from '@/api/food'
|
|
|
+import { convertUnits } from '@/api/unit'
|
|
|
|
|
|
export default {
|
|
|
name: 'FoodModifierIndex',
|
|
|
@@ -149,26 +150,11 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
showDialog(row, column, event) {
|
|
|
- getNutrientList(row.foodId).then(res => {
|
|
|
- const nutrients = res.data
|
|
|
- convertFoodUnit(row.foodId, { fromUnit: row.inInitUnit }).then(res => {
|
|
|
- if (!res.data.ratio) {
|
|
|
- return;
|
|
|
- }
|
|
|
- this.dialogHtml = `转换关系:1${row.inInitUnit}${this.food.name}=${res.data.ratio}${this.food.normalizedUnit}${this.food.name}<br>`
|
|
|
- this.dialogHtml += `${row.inInit}${row.inInitUnit}${this.food.name}含有如下营养素:<br>`
|
|
|
- this.dialogHtml += `******************************<br>`
|
|
|
- for (let i=0; i < nutrients.length; i++) {
|
|
|
- const nutrient = nutrients[i]
|
|
|
- const quantity = nutrient.normalizedQuantity * res.data.ratio * row.inInit
|
|
|
- this.dialogHtml += `${nutrient.nutrientName}:${quantity}${nutrient.unit}。<br>`
|
|
|
- this.dialogHtml += `营养素计量为:${nutrient.quantity}${nutrient.unit}。Nv_Spec为:${nutrient.nvSpec}${nutrient.nvSpecUnit}。<br>`
|
|
|
- this.dialogHtml += `******************************<br>`
|
|
|
- }
|
|
|
- this.dialogFormVisible = true
|
|
|
- })
|
|
|
+ calculateNutrientsContent(row.foodId, { unit: row.inInitUnit, quantity: row.inInit }).then(res => {
|
|
|
+ this.dialogFormVisible = true
|
|
|
+ this.dialogHtml = res.data
|
|
|
}).catch(res => {
|
|
|
- this.$message.error('获取数据失败')
|
|
|
+ this.$message.error(res.data.message)
|
|
|
})
|
|
|
}
|
|
|
}
|