|
|
@@ -180,7 +180,7 @@
|
|
|
<el-button size="mini" type="primary" @click="handleEdit(row)">编辑</el-button>
|
|
|
<el-button size="mini" type="primary" @click="updateSort(row, 0)">上移</el-button>
|
|
|
<el-button size="mini" type="primary" @click="updateSort(row, 1)">下移</el-button>
|
|
|
- <el-button size="mini" type="danger" @click="removeNutrient(row)">
|
|
|
+ <el-button size="mini" type="danger" @click="confirmRemoveNutrient(row)">
|
|
|
删除
|
|
|
</el-button>
|
|
|
</template>
|
|
|
@@ -192,7 +192,7 @@
|
|
|
|
|
|
<script>
|
|
|
import { getNutrientList, addFoodNutrient, updateFoodNutrient, removeFoodNutrient,
|
|
|
- updateFoodNutrientSort } from '@/api/food'
|
|
|
+ updateFoodNutrientSort, confirmDeleteFoodNutrient } from '@/api/food'
|
|
|
import { getList } from '@/api/nutrient'
|
|
|
import { getList as getUnits } from '@/api/unit'
|
|
|
|
|
|
@@ -271,6 +271,23 @@ export default {
|
|
|
this.$message.error(res.data.message)
|
|
|
})
|
|
|
},
|
|
|
+ confirmRemoveNutrient(row) {
|
|
|
+ confirmDeleteFoodNutrient(row.foodId, row.nutrientId).then(res => {
|
|
|
+ if (!res.data) {
|
|
|
+ this.$confirm('由于单位转换的原因,删除此条营养素关联数据,将会导致该食物被删除,是否继续?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ this.removeNutrient(row)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.removeNutrient(row)
|
|
|
+ }
|
|
|
+ }).catch(res => {
|
|
|
+ this.$message.error(res.data.message)
|
|
|
+ })
|
|
|
+ },
|
|
|
removeNutrient(row) {
|
|
|
removeFoodNutrient(row.foodId, row.nutrientId).then(res => {
|
|
|
this.fetchData()
|