|
|
@@ -116,6 +116,24 @@
|
|
|
@click="handleImport">
|
|
|
导入营养素
|
|
|
</el-button>
|
|
|
+ <el-button
|
|
|
+ class="filter-item"
|
|
|
+ style="margin-left: 10px;"
|
|
|
+ type="success"
|
|
|
+ :disabled="!canEdit"
|
|
|
+ v-if="!editAll"
|
|
|
+ @click="handleMultiEdit">
|
|
|
+ 批量编辑
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ class="filter-item"
|
|
|
+ style="margin-left: 10px;"
|
|
|
+ type="primary"
|
|
|
+ :disabled="!canEdit"
|
|
|
+ v-else
|
|
|
+ @click="submitMulti">
|
|
|
+ 批量提交
|
|
|
+ </el-button>
|
|
|
</el-row>
|
|
|
</div>
|
|
|
|
|
|
@@ -137,57 +155,17 @@
|
|
|
</el-table-column>
|
|
|
<el-table-column label="营养素计量" align="center" :width="150">
|
|
|
<template slot-scope="{row}">
|
|
|
- <template v-if="row.edit">
|
|
|
- <el-radio v-model="row.radio" :label="0" @change="radioChange(row)">值</el-radio>
|
|
|
- <el-radio v-model="row.radio" :label="1" @change="radioChange(row)">范围</el-radio>
|
|
|
- <el-radio v-model="row.radio" :label="2" @change="radioChange(row)">误差</el-radio>
|
|
|
- <div v-if="row.radio === 1" style="display: inline-block">
|
|
|
- 大于等于:
|
|
|
- <el-input v-model="row.quantityMin" @focus="getInputFocus" />
|
|
|
- 小于等于:
|
|
|
- <el-input v-model="row.quantityMax" @focus="getInputFocus" />
|
|
|
- </div>
|
|
|
- <div v-else-if="row.radio === 2" style="display: inline-block">
|
|
|
- 基准:
|
|
|
- <el-input v-model="row.quantity" @focus="getInputFocus" />
|
|
|
- ±:
|
|
|
- <el-input v-model="row.stdError" @focus="getInputFocus" />
|
|
|
- </div>
|
|
|
- <el-input
|
|
|
- v-else
|
|
|
- v-model="row.quantity"
|
|
|
- style="width: 80px;"
|
|
|
- class="filter-item"
|
|
|
- @focus="getInputFocus"
|
|
|
- />
|
|
|
- </template>
|
|
|
- <span v-else>{{ row | nutrientQuantityFilter }}</span>
|
|
|
+ <nutrient-quantity :data="row" :edit="editAll || row.edit" />
|
|
|
</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.unit"
|
|
|
- @input="handleRowUnitChanged(row)"
|
|
|
- :fetch-suggestions="(query, cb) => {queryNutrientUnits(query, row.nutrientId, cb)}"
|
|
|
- placeholder="单位关键词"
|
|
|
- />
|
|
|
- <el-select
|
|
|
- clearable
|
|
|
- v-show="showRowNutrientSource"
|
|
|
- v-model="row.nutrientSource"
|
|
|
- placeholder="请选择营养素来源"
|
|
|
- >
|
|
|
- <el-option v-for="item in nutrientSources" :key="item" :label="item" :value="item" />
|
|
|
- </el-select>
|
|
|
- </template>
|
|
|
- <span v-else>{{ row.nutrientSource ? `${row.unit}(${row.nutrientSource})` : row.unit }}</span>
|
|
|
+ <nutrient-unit :data="row" :edit="editAll || row.edit" />
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="NRV%" align="center" width="80">
|
|
|
<template slot-scope="{row}">
|
|
|
- <template v-if="row.edit">
|
|
|
+ <template v-if="row.edit || editAll">
|
|
|
<el-input v-show="!isPercentByVolumeUnit(row)" v-model="row.nrvPercent"/>
|
|
|
</template>
|
|
|
<span v-else>{{ row.nrvPercent }}</span>
|
|
|
@@ -195,7 +173,7 @@
|
|
|
</el-table-column>
|
|
|
<el-table-column label="Nv_Spec" align="center" width="80">
|
|
|
<template slot-scope="{row}" v-if="!isPercentByVolumeUnit(row)">
|
|
|
- <template v-if="row.edit">
|
|
|
+ <template v-if="row.edit || editAll">
|
|
|
<el-input v-model="row.nvSpec" class="filter-item" @focus="getInputFocus" />
|
|
|
</template>
|
|
|
<span v-else>{{ row.nvSpec }}</span>
|
|
|
@@ -203,7 +181,7 @@
|
|
|
</el-table-column>
|
|
|
<el-table-column label="计量单位" align="center" width="150">
|
|
|
<template slot-scope="{row}" v-if="!isPercentByVolumeUnit(row)">
|
|
|
- <template v-if="row.edit">
|
|
|
+ <template v-if="row.edit || editAll">
|
|
|
<el-autocomplete v-model="row.nvSpecUnit" :fetch-suggestions="queryUnits" placeholder="单位关键词" />
|
|
|
</template>
|
|
|
<span v-else>{{ row.nvSpecUnit }}</span>
|
|
|
@@ -211,7 +189,7 @@
|
|
|
</el-table-column>
|
|
|
<el-table-column label="信息来源" align="center" width="200">
|
|
|
<template slot-scope="{row}">
|
|
|
- <template v-if="row.edit">
|
|
|
+ <template v-if="row.edit || editAll">
|
|
|
<el-autocomplete
|
|
|
v-model="row.source"
|
|
|
:fetch-suggestions="querySources"
|
|
|
@@ -223,13 +201,13 @@
|
|
|
</el-table-column>
|
|
|
<el-table-column label="信息来源备注" align="center" width="200">
|
|
|
<template slot-scope="{row}">
|
|
|
- <template v-if="row.edit">
|
|
|
+ <template v-if="row.edit || editAll">
|
|
|
<el-input type="text" :rows="2" v-model="row.sourceNote" @focus="getInputFocus" />
|
|
|
</template>
|
|
|
<span v-else>{{ row.sourceNote }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="320" fixed="right">
|
|
|
+ <el-table-column v-if="!editAll" label="操作" align="center" class-name="small-padding fixed-width" width="350" fixed="right">
|
|
|
<template slot-scope="{row}">
|
|
|
<template v-if="row.edit">
|
|
|
<el-button
|
|
|
@@ -280,10 +258,10 @@
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
- <el-button @click="dialogFormVisible = false">
|
|
|
+ <el-button v-if="!editAll" @click="dialogFormVisible = false">
|
|
|
取消
|
|
|
</el-button>
|
|
|
- <el-button type="primary" @click="submitImport">
|
|
|
+ <el-button v-if="!editAll" type="primary" @click="submitImport">
|
|
|
提交
|
|
|
</el-button>
|
|
|
</div>
|
|
|
@@ -294,19 +272,21 @@
|
|
|
<script>
|
|
|
import { getNutrientList, addFoodNutrient, updateFoodNutrient, removeFoodNutrient,
|
|
|
updateFoodNutrientSort, confirmDeleteFoodNutrient, importNutrientsFromTemplate,
|
|
|
- getList as getFoodList, importNutrientFromSimilarFood, getDetail } from '@/api/food'
|
|
|
+ getList as getFoodList, importNutrientFromSimilarFood, getDetail, multiUpdateNutrients } from '@/api/food'
|
|
|
import FloatingWindow from '@/components/FloatingWindow'
|
|
|
import { getList, getNutrientUnits, getNutrientSources } from '@/api/nutrient'
|
|
|
import { getList as getUnits } from '@/api/unit'
|
|
|
import { getNutrientTemplates } from '@/api/nutrientTemplate'
|
|
|
import store from '@/store'
|
|
|
+import NutrientQuantity from '@/views/food/components/NutrientQuantity'
|
|
|
+import NutrientUnit from '@/views/food/components/NutrientUnit'
|
|
|
|
|
|
// 特殊营养素 若单位不为baseUnit,则需要填写来源
|
|
|
const SPECIAL_NUTRIENT_NAMES = ['维生素A', '维生素D', '维生素E', '烟酸', '叶酸']
|
|
|
|
|
|
export default {
|
|
|
name: 'AddNutrient',
|
|
|
- components: { FloatingWindow },
|
|
|
+ components: { FloatingWindow, NutrientQuantity, NutrientUnit },
|
|
|
mounted() {
|
|
|
window.addEventListener('scroll', this.initHeight);
|
|
|
},
|
|
|
@@ -357,15 +337,20 @@ export default {
|
|
|
showRowNutrientSource: false,
|
|
|
nutrientSources: [],
|
|
|
showNRV: false,
|
|
|
- canEdit: true
|
|
|
+ canEdit: true,
|
|
|
+ editAll: false
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
fetchData() {
|
|
|
this.listLoading = true
|
|
|
+ getDetail(this.foodId).then(res => {
|
|
|
+ if (!store.getters.isAdmin && res.data.userId !== store.getters.userId) {
|
|
|
+ this.canEdit = false
|
|
|
+ }
|
|
|
+ })
|
|
|
getNutrientList(this.foodId).then(res => {
|
|
|
this.list = res.data
|
|
|
- this.listLoading = false
|
|
|
if (this.list.length > 0) {
|
|
|
this.$set(this.params, "nvSpec", this.list[0].nvSpec)
|
|
|
this.$set(this.params, "nvSpecUnit", this.list[0].nvSpecUnit)
|
|
|
@@ -373,12 +358,13 @@ export default {
|
|
|
this.$set(this.params, 'nvSpec', 100)
|
|
|
this.$set(this.params, 'nvSpecUnit', '克')
|
|
|
}
|
|
|
+
|
|
|
+ this.resetParams()
|
|
|
})
|
|
|
- getDetail(this.foodId).then(res => {
|
|
|
- if (!store.getters.isAdmin && res.data.userId !== store.getters.userId) {
|
|
|
- this.canEdit = false
|
|
|
- }
|
|
|
- })
|
|
|
+ },
|
|
|
+ resetParams() {
|
|
|
+ this.listLoading = false
|
|
|
+ this.editAll = false
|
|
|
},
|
|
|
addNutrient() {
|
|
|
this.params.foodId = this.foodId
|
|
|
@@ -508,6 +494,15 @@ export default {
|
|
|
this.queryImportItems()
|
|
|
this.dialogFormVisible = true
|
|
|
},
|
|
|
+ handleMultiEdit() {
|
|
|
+ this.editAll = !this.editAll
|
|
|
+ },
|
|
|
+ submitMulti() {
|
|
|
+ multiUpdateNutrients(this.foodId, this.list).then(res => {
|
|
|
+ this.fetchData()
|
|
|
+ this.$notify.success('提交成功')
|
|
|
+ })
|
|
|
+ },
|
|
|
handleImportTypeChange() {
|
|
|
this.importId = ''
|
|
|
this.importItems = []
|