|
@@ -64,19 +64,58 @@
|
|
|
<span>{{ row.nutrientName }}</span>
|
|
<span>{{ row.nutrientName }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
- <el-table-column label="营养素计量" align="center" width="200">
|
|
|
|
|
|
|
+ <el-table-column label="营养素计量" align="center" width="80">
|
|
|
<template slot-scope="{row}">
|
|
<template slot-scope="{row}">
|
|
|
- <span>{{ row.quantity + row.unit }}</span>
|
|
|
|
|
|
|
+ <template v-if="row.edit">
|
|
|
|
|
+ <el-input v-model="row.quantity" class="filter-item" />
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <span v-else>{{ row.quantity }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
- <el-table-column label="Nv_Spec" align="center" width="200">
|
|
|
|
|
|
|
+ <el-table-column label="计量单位" align="center" width="150">
|
|
|
<template slot-scope="{row}">
|
|
<template slot-scope="{row}">
|
|
|
- <span>{{ row.nvSpec + row.nvSpecUnit }}</span>
|
|
|
|
|
|
|
+ <template v-if="row.edit">
|
|
|
|
|
+ <el-autocomplete v-model="row.unit" :fetch-suggestions="queryUnits" placeholder="单位关键词" />
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <span v-else>{{ row.unit }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
- <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="100">
|
|
|
|
|
|
|
+ <el-table-column label="Nv_Spec" align="center" width="80">
|
|
|
<template slot-scope="{row}">
|
|
<template slot-scope="{row}">
|
|
|
- <el-button size="mini" type="danger" @click="removeNutrient(row)">
|
|
|
|
|
|
|
+ <template v-if="row.edit">
|
|
|
|
|
+ <el-input v-model="row.nvSpec" class="filter-item" />
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <span v-else>{{ row.nvSpec }}</span>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ <el-table-column label="计量单位" align="center" width="150">
|
|
|
|
|
+ <template slot-scope="{row}">
|
|
|
|
|
+ <template v-if="row.edit">
|
|
|
|
|
+ <el-autocomplete v-model="row.nvSpecUnit" :fetch-suggestions="queryUnits" placeholder="单位关键词" />
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <span v-else>{{ row.nvSpecUnit }}</span>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="160">
|
|
|
|
|
+ <template slot-scope="{row}">
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ v-if="row.edit"
|
|
|
|
|
+ type="success"
|
|
|
|
|
+ size="mini"
|
|
|
|
|
+ @click="confirmEdit(row)"
|
|
|
|
|
+ >
|
|
|
|
|
+ 提交
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ <el-button v-else size="mini" type="primary" @click="row.edit=true">编辑</el-button>
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ v-if="row.edit"
|
|
|
|
|
+ type="danger"
|
|
|
|
|
+ size="mini"
|
|
|
|
|
+ @click="fetchData"
|
|
|
|
|
+ >
|
|
|
|
|
+ 取消
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ <el-button v-else size="mini" type="danger" @click="removeNutrient(row)">
|
|
|
删除
|
|
删除
|
|
|
</el-button>
|
|
</el-button>
|
|
|
</template>
|
|
</template>
|
|
@@ -86,7 +125,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
-import { getNutrientList, addFoodNutrient, removeFoodNutrient } from '@/api/food'
|
|
|
|
|
|
|
+import { getNutrientList, addFoodNutrient, updateFoodNutrient, removeFoodNutrient } from '@/api/food'
|
|
|
import { getList } from '@/api/nutrient'
|
|
import { getList } from '@/api/nutrient'
|
|
|
import { getList as getUnits } from '@/api/unit'
|
|
import { getList as getUnits } from '@/api/unit'
|
|
|
|
|
|
|
@@ -141,6 +180,14 @@ export default {
|
|
|
this.$message.error(res.data.message)
|
|
this.$message.error(res.data.message)
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
|
|
+ confirmEdit(row) {
|
|
|
|
|
+ updateFoodNutrient(this.foodId, row.nutrientId, row).then(res => {
|
|
|
|
|
+ this.fetchData()
|
|
|
|
|
+ this.$notify.success('提交成功')
|
|
|
|
|
+ }).catch(res => {
|
|
|
|
|
+ this.$message.error(res.data.message)
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
removeNutrient(row) {
|
|
removeNutrient(row) {
|
|
|
removeFoodNutrient(row.foodId, row.nutrientId).then(res => {
|
|
removeFoodNutrient(row.foodId, row.nutrientId).then(res => {
|
|
|
this.fetchData()
|
|
this.fetchData()
|