|
@@ -104,6 +104,7 @@
|
|
|
class="filter-item"
|
|
class="filter-item"
|
|
|
style="margin-left: 10px;"
|
|
style="margin-left: 10px;"
|
|
|
type="primary"
|
|
type="primary"
|
|
|
|
|
+ :disabled="!canEdit"
|
|
|
@click="addNutrient">
|
|
@click="addNutrient">
|
|
|
添加
|
|
添加
|
|
|
</el-button>
|
|
</el-button>
|
|
@@ -111,6 +112,7 @@
|
|
|
class="filter-item"
|
|
class="filter-item"
|
|
|
style="margin-left: 10px;"
|
|
style="margin-left: 10px;"
|
|
|
type="success"
|
|
type="success"
|
|
|
|
|
+ :disabled="!canEdit"
|
|
|
@click="handleImport">
|
|
@click="handleImport">
|
|
|
导入营养素
|
|
导入营养素
|
|
|
</el-button>
|
|
</el-button>
|
|
@@ -246,10 +248,10 @@
|
|
|
</el-button>
|
|
</el-button>
|
|
|
</template>
|
|
</template>
|
|
|
<template v-else>
|
|
<template v-else>
|
|
|
- <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="confirmRemoveNutrient(row)">
|
|
|
|
|
|
|
+ <el-button size="mini" type="primary" :disabled="!canEdit" @click="handleEdit(row)">编辑</el-button>
|
|
|
|
|
+ <el-button size="mini" type="primary" :disabled="!canEdit" @click="updateSort(row, 0)">上移</el-button>
|
|
|
|
|
+ <el-button size="mini" type="primary" :disabled="!canEdit" @click="updateSort(row, 1)">下移</el-button>
|
|
|
|
|
+ <el-button size="mini" type="danger" :disabled="!canEdit" @click="confirmRemoveNutrient(row)">
|
|
|
删除
|
|
删除
|
|
|
</el-button>
|
|
</el-button>
|
|
|
</template>
|
|
</template>
|
|
@@ -292,11 +294,12 @@
|
|
|
<script>
|
|
<script>
|
|
|
import { getNutrientList, addFoodNutrient, updateFoodNutrient, removeFoodNutrient,
|
|
import { getNutrientList, addFoodNutrient, updateFoodNutrient, removeFoodNutrient,
|
|
|
updateFoodNutrientSort, confirmDeleteFoodNutrient, importNutrientsFromTemplate,
|
|
updateFoodNutrientSort, confirmDeleteFoodNutrient, importNutrientsFromTemplate,
|
|
|
- getList as getFoodList, importNutrientFromSimilarFood } from '@/api/food'
|
|
|
|
|
|
|
+ getList as getFoodList, importNutrientFromSimilarFood, getDetail } from '@/api/food'
|
|
|
import FloatingWindow from '@/components/FloatingWindow'
|
|
import FloatingWindow from '@/components/FloatingWindow'
|
|
|
import { getList, getNutrientUnits, getNutrientSources } from '@/api/nutrient'
|
|
import { getList, getNutrientUnits, getNutrientSources } from '@/api/nutrient'
|
|
|
import { getList as getUnits } from '@/api/unit'
|
|
import { getList as getUnits } from '@/api/unit'
|
|
|
import { getNutrientTemplates } from '@/api/nutrientTemplate'
|
|
import { getNutrientTemplates } from '@/api/nutrientTemplate'
|
|
|
|
|
+import store from '@/store'
|
|
|
|
|
|
|
|
// 特殊营养素 若单位不为baseUnit,则需要填写来源
|
|
// 特殊营养素 若单位不为baseUnit,则需要填写来源
|
|
|
const SPECIAL_NUTRIENT_NAMES = ['维生素A', '维生素D', '维生素E', '烟酸', '叶酸']
|
|
const SPECIAL_NUTRIENT_NAMES = ['维生素A', '维生素D', '维生素E', '烟酸', '叶酸']
|
|
@@ -353,7 +356,8 @@ export default {
|
|
|
showNutrientSource: false,
|
|
showNutrientSource: false,
|
|
|
showRowNutrientSource: false,
|
|
showRowNutrientSource: false,
|
|
|
nutrientSources: [],
|
|
nutrientSources: [],
|
|
|
- showNRV: false
|
|
|
|
|
|
|
+ showNRV: false,
|
|
|
|
|
+ canEdit: true
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
@@ -370,6 +374,11 @@ export default {
|
|
|
this.$set(this.params, 'nvSpecUnit', '克')
|
|
this.$set(this.params, 'nvSpecUnit', '克')
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
+ getDetail(this.foodId).then(res => {
|
|
|
|
|
+ if (!store.getters.isAdmin && res.data.userId !== store.getters.userId) {
|
|
|
|
|
+ this.canEdit = false
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
addNutrient() {
|
|
addNutrient() {
|
|
|
this.params.foodId = this.foodId
|
|
this.params.foodId = this.foodId
|
|
@@ -456,6 +465,9 @@ export default {
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
handleEdit(row) {
|
|
handleEdit(row) {
|
|
|
|
|
+ if (!this.canEdit) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
this.$set(row, 'edit', true)
|
|
this.$set(row, 'edit', true)
|
|
|
if (row.quantityMax || row.quantityMin) {
|
|
if (row.quantityMax || row.quantityMin) {
|
|
|
this.$set(row, 'radio', 1)
|
|
this.$set(row, 'radio', 1)
|
|
@@ -560,7 +572,7 @@ export default {
|
|
|
} else if (value === 'modifier') {
|
|
} else if (value === 'modifier') {
|
|
|
path = `/food/${this.foodId}/modifier`
|
|
path = `/food/${this.foodId}/modifier`
|
|
|
} else if (value === 'list') {
|
|
} else if (value === 'list') {
|
|
|
- path = `/food`
|
|
|
|
|
|
|
+ path = store.getters.isAdmin ? '/food' : '/food/entry'
|
|
|
}
|
|
}
|
|
|
if (path) {
|
|
if (path) {
|
|
|
this.$router.push({ path: path })
|
|
this.$router.push({ path: path })
|