|
@@ -2,9 +2,9 @@
|
|
|
<div class="app-container">
|
|
<div class="app-container">
|
|
|
<div class="filter-container" style="position: relative">
|
|
<div class="filter-container" style="position: relative">
|
|
|
|
|
|
|
|
- <floating-window :class="{'is_fixed': isFixed}" >
|
|
|
|
|
|
|
+ <floating-window :class="{'is_fixed': isFixed}">
|
|
|
<el-dropdown @command="handleCommand">
|
|
<el-dropdown @command="handleCommand">
|
|
|
- <img width="50px" height="50px" src="@/assets/navigation.png" alt="导航.png" />
|
|
|
|
|
|
|
+ <img width="50px" height="50px" src="@/assets/navigation.png" alt="导航.png">
|
|
|
<el-dropdown-menu slot="dropdown">
|
|
<el-dropdown-menu slot="dropdown">
|
|
|
<el-dropdown-item command="detail">食物更新</el-dropdown-item>
|
|
<el-dropdown-item command="detail">食物更新</el-dropdown-item>
|
|
|
<el-dropdown-item command="unit">单位管理</el-dropdown-item>
|
|
<el-dropdown-item command="unit">单位管理</el-dropdown-item>
|
|
@@ -55,11 +55,11 @@
|
|
|
@focus="getInputFocus"
|
|
@focus="getInputFocus"
|
|
|
/>
|
|
/>
|
|
|
<el-autocomplete
|
|
<el-autocomplete
|
|
|
- class="inline-input"
|
|
|
|
|
v-model="params.unit"
|
|
v-model="params.unit"
|
|
|
|
|
+ class="inline-input"
|
|
|
:fetch-suggestions="(query, cb) => {queryNutrientUnits(query, params.nutrientId, cb)}"
|
|
:fetch-suggestions="(query, cb) => {queryNutrientUnits(query, params.nutrientId, cb)}"
|
|
|
- @input="handleUnitChanged"
|
|
|
|
|
placeholder="单位关键词"
|
|
placeholder="单位关键词"
|
|
|
|
|
+ @input="handleUnitChanged"
|
|
|
/>
|
|
/>
|
|
|
<div v-show="showNutrientSource" style="display: inline-block">
|
|
<div v-show="showNutrientSource" style="display: inline-block">
|
|
|
<el-select
|
|
<el-select
|
|
@@ -88,8 +88,8 @@
|
|
|
@focus="getInputFocus"
|
|
@focus="getInputFocus"
|
|
|
/>
|
|
/>
|
|
|
<el-autocomplete
|
|
<el-autocomplete
|
|
|
- class="inline-input"
|
|
|
|
|
v-model="params.nvSpecUnit"
|
|
v-model="params.nvSpecUnit"
|
|
|
|
|
+ class="inline-input"
|
|
|
:fetch-suggestions="queryUnits"
|
|
:fetch-suggestions="queryUnits"
|
|
|
placeholder="单位关键词"
|
|
placeholder="单位关键词"
|
|
|
/>
|
|
/>
|
|
@@ -105,7 +105,8 @@
|
|
|
style="margin-left: 10px;"
|
|
style="margin-left: 10px;"
|
|
|
type="primary"
|
|
type="primary"
|
|
|
:disabled="!canEdit"
|
|
:disabled="!canEdit"
|
|
|
- @click="addNutrient">
|
|
|
|
|
|
|
+ @click="addNutrient"
|
|
|
|
|
+ >
|
|
|
添加
|
|
添加
|
|
|
</el-button>
|
|
</el-button>
|
|
|
<el-button
|
|
<el-button
|
|
@@ -113,25 +114,28 @@
|
|
|
style="margin-left: 10px;"
|
|
style="margin-left: 10px;"
|
|
|
type="success"
|
|
type="success"
|
|
|
:disabled="!canEdit"
|
|
:disabled="!canEdit"
|
|
|
- @click="handleImport">
|
|
|
|
|
|
|
+ @click="handleImport"
|
|
|
|
|
+ >
|
|
|
导入营养素
|
|
导入营养素
|
|
|
</el-button>
|
|
</el-button>
|
|
|
<el-button
|
|
<el-button
|
|
|
|
|
+ v-if="!editAll"
|
|
|
class="filter-item"
|
|
class="filter-item"
|
|
|
style="margin-left: 10px;"
|
|
style="margin-left: 10px;"
|
|
|
type="success"
|
|
type="success"
|
|
|
:disabled="!canEdit"
|
|
:disabled="!canEdit"
|
|
|
- v-if="!editAll"
|
|
|
|
|
- @click="handleMultiEdit">
|
|
|
|
|
|
|
+ @click="handleMultiEdit"
|
|
|
|
|
+ >
|
|
|
批量编辑
|
|
批量编辑
|
|
|
</el-button>
|
|
</el-button>
|
|
|
<el-button
|
|
<el-button
|
|
|
|
|
+ v-else
|
|
|
class="filter-item"
|
|
class="filter-item"
|
|
|
style="margin-left: 10px;"
|
|
style="margin-left: 10px;"
|
|
|
type="primary"
|
|
type="primary"
|
|
|
:disabled="!canEdit"
|
|
:disabled="!canEdit"
|
|
|
- v-else
|
|
|
|
|
- @click="submitMulti">
|
|
|
|
|
|
|
+ @click="submitMulti"
|
|
|
|
|
+ >
|
|
|
批量提交
|
|
批量提交
|
|
|
</el-button>
|
|
</el-button>
|
|
|
</el-row>
|
|
</el-row>
|
|
@@ -166,13 +170,13 @@
|
|
|
<el-table-column label="NRV%" align="center" width="80">
|
|
<el-table-column label="NRV%" align="center" width="80">
|
|
|
<template slot-scope="{row}">
|
|
<template slot-scope="{row}">
|
|
|
<template v-if="row.edit || editAll">
|
|
<template v-if="row.edit || editAll">
|
|
|
- <el-input v-show="!isPercentByVolumeUnit(row)" v-model="row.nrvPercent"/>
|
|
|
|
|
|
|
+ <el-input v-show="!isPercentByVolumeUnit(row)" v-model="row.nrvPercent" />
|
|
|
</template>
|
|
</template>
|
|
|
<span v-else>{{ row.nrvPercent }}</span>
|
|
<span v-else>{{ row.nrvPercent }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
<el-table-column label="Nv_Spec" align="center" width="80">
|
|
<el-table-column label="Nv_Spec" align="center" width="80">
|
|
|
- <template slot-scope="{row}" v-if="!isPercentByVolumeUnit(row)">
|
|
|
|
|
|
|
+ <template v-if="!isPercentByVolumeUnit(row)" slot-scope="{row}">
|
|
|
<template v-if="row.edit || editAll">
|
|
<template v-if="row.edit || editAll">
|
|
|
<el-input v-model="row.nvSpec" class="filter-item" @focus="getInputFocus" />
|
|
<el-input v-model="row.nvSpec" class="filter-item" @focus="getInputFocus" />
|
|
|
</template>
|
|
</template>
|
|
@@ -180,7 +184,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
<el-table-column label="计量单位" align="center" width="150">
|
|
<el-table-column label="计量单位" align="center" width="150">
|
|
|
- <template slot-scope="{row}" v-if="!isPercentByVolumeUnit(row)">
|
|
|
|
|
|
|
+ <template v-if="!isPercentByVolumeUnit(row)" slot-scope="{row}">
|
|
|
<template v-if="row.edit || editAll">
|
|
<template v-if="row.edit || editAll">
|
|
|
<el-autocomplete v-model="row.nvSpecUnit" :fetch-suggestions="queryUnits" placeholder="单位关键词" />
|
|
<el-autocomplete v-model="row.nvSpecUnit" :fetch-suggestions="queryUnits" placeholder="单位关键词" />
|
|
|
</template>
|
|
</template>
|
|
@@ -202,7 +206,7 @@
|
|
|
<el-table-column label="信息来源备注" align="center" width="200">
|
|
<el-table-column label="信息来源备注" align="center" width="200">
|
|
|
<template slot-scope="{row}">
|
|
<template slot-scope="{row}">
|
|
|
<template v-if="row.edit || editAll">
|
|
<template v-if="row.edit || editAll">
|
|
|
- <el-input type="text" :rows="2" v-model="row.sourceNote" @focus="getInputFocus" />
|
|
|
|
|
|
|
+ <el-input v-model="row.sourceNote" type="text" :rows="2" @focus="getInputFocus" />
|
|
|
</template>
|
|
</template>
|
|
|
<span v-else>{{ row.sourceNote }}</span>
|
|
<span v-else>{{ row.sourceNote }}</span>
|
|
|
</template>
|
|
</template>
|
|
@@ -237,10 +241,10 @@
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
</el-table>
|
|
</el-table>
|
|
|
|
|
|
|
|
- <el-dialog title="导入营养素" :visible.sync="dialogFormVisible" v-loading="importLoading">
|
|
|
|
|
|
|
+ <el-dialog v-loading="importLoading" title="导入营养素" :visible.sync="dialogFormVisible">
|
|
|
<el-form ref="dialogForm" label-position="left" style="width: 80%; margin-left:50px;">
|
|
<el-form ref="dialogForm" label-position="left" style="width: 80%; margin-left:50px;">
|
|
|
- <el-radio :label="0" v-model="importType" @change="handleImportTypeChange" >从模板导入</el-radio>
|
|
|
|
|
- <el-radio :label="1" v-model="importType" @change="handleImportTypeChange" style="margin-bottom: 10px">从食物导入</el-radio>
|
|
|
|
|
|
|
+ <el-radio v-model="importType" :label="0" @change="handleImportTypeChange">从模板导入</el-radio>
|
|
|
|
|
+ <el-radio v-model="importType" :label="1" style="margin-bottom: 10px" @change="handleImportTypeChange">从食物导入</el-radio>
|
|
|
<el-form-item prop="importId">
|
|
<el-form-item prop="importId">
|
|
|
<el-select
|
|
<el-select
|
|
|
v-model="importId"
|
|
v-model="importId"
|
|
@@ -287,23 +291,11 @@ const SPECIAL_NUTRIENT_NAMES = ['维生素A', '维生素D', '维生素E', '烟
|
|
|
export default {
|
|
export default {
|
|
|
name: 'AddNutrient',
|
|
name: 'AddNutrient',
|
|
|
components: { FloatingWindow, NutrientQuantity, NutrientUnit },
|
|
components: { FloatingWindow, NutrientQuantity, NutrientUnit },
|
|
|
- mounted() {
|
|
|
|
|
- window.addEventListener('scroll', this.initHeight);
|
|
|
|
|
- },
|
|
|
|
|
- //回调中移除监听
|
|
|
|
|
- destroyed() {
|
|
|
|
|
- window.removeEventListener('scroll', this.handleScroll)
|
|
|
|
|
- },
|
|
|
|
|
- created() {
|
|
|
|
|
- this.foodId = this.$route.params && this.$route.params.id
|
|
|
|
|
- this.fetchData()
|
|
|
|
|
- this.queryNutrients()
|
|
|
|
|
- },
|
|
|
|
|
filters: {
|
|
filters: {
|
|
|
nutrientQuantityFilter(row) {
|
|
nutrientQuantityFilter(row) {
|
|
|
if (row.stdError) {
|
|
if (row.stdError) {
|
|
|
return `${row.quantity} ± ${row.stdError}`
|
|
return `${row.quantity} ± ${row.stdError}`
|
|
|
- }else if (row.quantityMin && row.quantityMax) {
|
|
|
|
|
|
|
+ } else if (row.quantityMin && row.quantityMax) {
|
|
|
return `${row.quantityMin} ~ ${row.quantityMax}`
|
|
return `${row.quantityMin} ~ ${row.quantityMax}`
|
|
|
} else if (row.quantityMin) {
|
|
} else if (row.quantityMin) {
|
|
|
return `≥${row.quantityMin}`
|
|
return `≥${row.quantityMin}`
|
|
@@ -325,7 +317,7 @@ export default {
|
|
|
params: { source: '营养标签', radio: 0, nvSpec: 100, nvSpecUnit: '克' },
|
|
params: { source: '营养标签', radio: 0, nvSpec: 100, nvSpecUnit: '克' },
|
|
|
loading: false,
|
|
loading: false,
|
|
|
unitLoading: false,
|
|
unitLoading: false,
|
|
|
- sources: [{ value: "营养标签" }, { value: "食品官方资料" }, { value: "计算值" }],
|
|
|
|
|
|
|
+ sources: [{ value: '营养标签' }, { value: '食品官方资料' }, { value: '计算值' }],
|
|
|
dialogFormVisible: false,
|
|
dialogFormVisible: false,
|
|
|
importType: 0,
|
|
importType: 0,
|
|
|
importId: '',
|
|
importId: '',
|
|
@@ -341,6 +333,18 @@ export default {
|
|
|
editAll: false
|
|
editAll: false
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ mounted() {
|
|
|
|
|
+ window.addEventListener('scroll', this.initHeight)
|
|
|
|
|
+ },
|
|
|
|
|
+ // 回调中移除监听
|
|
|
|
|
+ destroyed() {
|
|
|
|
|
+ window.removeEventListener('scroll', this.handleScroll)
|
|
|
|
|
+ },
|
|
|
|
|
+ created() {
|
|
|
|
|
+ this.foodId = this.$route.params && this.$route.params.id
|
|
|
|
|
+ this.fetchData()
|
|
|
|
|
+ this.queryNutrients()
|
|
|
|
|
+ },
|
|
|
methods: {
|
|
methods: {
|
|
|
fetchData() {
|
|
fetchData() {
|
|
|
this.listLoading = true
|
|
this.listLoading = true
|
|
@@ -352,8 +356,8 @@ export default {
|
|
|
getNutrientList(this.foodId).then(res => {
|
|
getNutrientList(this.foodId).then(res => {
|
|
|
this.list = res.data
|
|
this.list = res.data
|
|
|
if (this.list.length > 0) {
|
|
if (this.list.length > 0) {
|
|
|
- this.$set(this.params, "nvSpec", this.list[0].nvSpec)
|
|
|
|
|
- this.$set(this.params, "nvSpecUnit", this.list[0].nvSpecUnit)
|
|
|
|
|
|
|
+ this.$set(this.params, 'nvSpec', this.list[0].nvSpec)
|
|
|
|
|
+ this.$set(this.params, 'nvSpecUnit', this.list[0].nvSpecUnit)
|
|
|
} else {
|
|
} else {
|
|
|
this.$set(this.params, 'nvSpec', 100)
|
|
this.$set(this.params, 'nvSpec', 100)
|
|
|
this.$set(this.params, 'nvSpecUnit', '克')
|
|
this.$set(this.params, 'nvSpecUnit', '克')
|
|
@@ -419,7 +423,7 @@ export default {
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
queryNutrientUnits(query, nutrientId, cb) {
|
|
queryNutrientUnits(query, nutrientId, cb) {
|
|
|
- let units = []
|
|
|
|
|
|
|
+ const units = []
|
|
|
if (nutrientId) {
|
|
if (nutrientId) {
|
|
|
getNutrientUnits(nutrientId, { query }).then(res => {
|
|
getNutrientUnits(nutrientId, { query }).then(res => {
|
|
|
res.data.forEach(item => units.push({ value: item }))
|
|
res.data.forEach(item => units.push({ value: item }))
|
|
@@ -428,7 +432,7 @@ export default {
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
queryUnits(query, cb) {
|
|
queryUnits(query, cb) {
|
|
|
- let units = []
|
|
|
|
|
|
|
+ const units = []
|
|
|
getUnits({ query }).then(res => {
|
|
getUnits({ query }).then(res => {
|
|
|
res.data.list.forEach(item => units.push({ value: item.name }))
|
|
res.data.list.forEach(item => units.push({ value: item.name }))
|
|
|
cb(units)
|
|
cb(units)
|
|
@@ -443,14 +447,14 @@ export default {
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
querySources(query, cb) {
|
|
querySources(query, cb) {
|
|
|
- let sources = this.sources
|
|
|
|
|
- let results = query ? sources.filter(this.sourcesFilter(query)) : sources;
|
|
|
|
|
|
|
+ const sources = this.sources
|
|
|
|
|
+ const results = query ? sources.filter(this.sourcesFilter(query)) : sources
|
|
|
cb(results)
|
|
cb(results)
|
|
|
},
|
|
},
|
|
|
sourcesFilter(query) {
|
|
sourcesFilter(query) {
|
|
|
return (restaurant) => {
|
|
return (restaurant) => {
|
|
|
- return (restaurant.value.toLowerCase().indexOf(query.toLowerCase()) === 0);
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ return (restaurant.value.toLowerCase().indexOf(query.toLowerCase()) === 0)
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
handleEdit(row) {
|
|
handleEdit(row) {
|
|
|
if (!this.canEdit) {
|
|
if (!this.canEdit) {
|
|
@@ -473,7 +477,7 @@ export default {
|
|
|
this.$set(row, 'quantity', '')
|
|
this.$set(row, 'quantity', '')
|
|
|
},
|
|
},
|
|
|
nutrientChanged(value) {
|
|
nutrientChanged(value) {
|
|
|
- for (let nutrient of this.nutrients) {
|
|
|
|
|
|
|
+ for (const nutrient of this.nutrients) {
|
|
|
if (nutrient.id === value) {
|
|
if (nutrient.id === value) {
|
|
|
this.$set(this.params, 'unit', nutrient.baseUnit)
|
|
this.$set(this.params, 'unit', nutrient.baseUnit)
|
|
|
if (nutrient.nrvUnit) {
|
|
if (nutrient.nrvUnit) {
|
|
@@ -486,7 +490,7 @@ export default {
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
getInputFocus(event) {
|
|
getInputFocus(event) {
|
|
|
- event.currentTarget.select();
|
|
|
|
|
|
|
+ event.currentTarget.select()
|
|
|
},
|
|
},
|
|
|
handleImport() {
|
|
handleImport() {
|
|
|
this.query = ''
|
|
this.query = ''
|
|
@@ -510,10 +514,10 @@ export default {
|
|
|
this.importItems = []
|
|
this.importItems = []
|
|
|
this.queryImportItems()
|
|
this.queryImportItems()
|
|
|
},
|
|
},
|
|
|
- queryImportItems(query=''){
|
|
|
|
|
|
|
+ queryImportItems(query = '') {
|
|
|
this.importType === 0 ? this.queryTemplates(query) : this.queryFoods(query)
|
|
this.importType === 0 ? this.queryTemplates(query) : this.queryFoods(query)
|
|
|
},
|
|
},
|
|
|
- queryTemplates(query='') {
|
|
|
|
|
|
|
+ queryTemplates(query = '') {
|
|
|
this.importLoading = true
|
|
this.importLoading = true
|
|
|
getNutrientTemplates({ query }).then(res => {
|
|
getNutrientTemplates({ query }).then(res => {
|
|
|
this.importItems = res.data.list
|
|
this.importItems = res.data.list
|
|
@@ -526,7 +530,7 @@ export default {
|
|
|
this.importLoading = false
|
|
this.importLoading = false
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
- queryFoods(query='') {
|
|
|
|
|
|
|
+ queryFoods(query = '') {
|
|
|
this.importLoading = true
|
|
this.importLoading = true
|
|
|
getFoodList({ query: query, orderBy: 0, pageNum: 1, pageSize: 20 }).then(res => {
|
|
getFoodList({ query: query, orderBy: 0, pageNum: 1, pageSize: 20 }).then(res => {
|
|
|
this.importItems = res.data.list
|
|
this.importItems = res.data.list
|
|
@@ -538,12 +542,12 @@ export default {
|
|
|
},
|
|
},
|
|
|
submitImport() {
|
|
submitImport() {
|
|
|
this.importLoading = true
|
|
this.importLoading = true
|
|
|
- const resPromise = this.importType === 0 ?
|
|
|
|
|
- importNutrientsFromTemplate(this.foodId, { templateId: this.importId }) :
|
|
|
|
|
- importNutrientFromSimilarFood(this.foodId, { foodId: this.importId })
|
|
|
|
|
|
|
+ const resPromise = this.importType === 0
|
|
|
|
|
+ ? importNutrientsFromTemplate(this.foodId, { templateId: this.importId })
|
|
|
|
|
+ : importNutrientFromSimilarFood(this.foodId, { foodId: this.importId })
|
|
|
resPromise.then(res => {
|
|
resPromise.then(res => {
|
|
|
this.fetchData()
|
|
this.fetchData()
|
|
|
- this.$notify.success("提交成功")
|
|
|
|
|
|
|
+ this.$notify.success('提交成功')
|
|
|
this.dialogFormVisible = false
|
|
this.dialogFormVisible = false
|
|
|
this.importLoading = false
|
|
this.importLoading = false
|
|
|
}).catch(res => {
|
|
}).catch(res => {
|
|
@@ -555,8 +559,8 @@ export default {
|
|
|
initHeight() {
|
|
initHeight() {
|
|
|
// 设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离 (被卷曲的高度)
|
|
// 设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离 (被卷曲的高度)
|
|
|
const scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
|
|
const scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
|
|
|
- //如果被卷曲的高度大于吸顶元素到顶端位置 的距离
|
|
|
|
|
- this.isFixed = scrollTop > this.offsetTop;
|
|
|
|
|
|
|
+ // 如果被卷曲的高度大于吸顶元素到顶端位置 的距离
|
|
|
|
|
+ this.isFixed = scrollTop > this.offsetTop
|
|
|
},
|
|
},
|
|
|
handleCommand(value) {
|
|
handleCommand(value) {
|
|
|
let path = ''
|
|
let path = ''
|
|
@@ -594,8 +598,8 @@ export default {
|
|
|
if (this.isSpecialNutrient(this.params.nutrientId)) {
|
|
if (this.isSpecialNutrient(this.params.nutrientId)) {
|
|
|
getNutrientSources(this.params.nutrientId, { unit: this.params.unit }).then(res => {
|
|
getNutrientSources(this.params.nutrientId, { unit: this.params.unit }).then(res => {
|
|
|
this.nutrientSources = res.data
|
|
this.nutrientSources = res.data
|
|
|
- if (this.nutrientSources.length > 0){
|
|
|
|
|
- this.$set(this.params, "nutrientSource", this.nutrientSources[0])
|
|
|
|
|
|
|
+ if (this.nutrientSources.length > 0) {
|
|
|
|
|
+ this.$set(this.params, 'nutrientSource', this.nutrientSources[0])
|
|
|
this.showNutrientSource = true
|
|
this.showNutrientSource = true
|
|
|
} else {
|
|
} else {
|
|
|
this.showNutrientSource = false
|
|
this.showNutrientSource = false
|
|
@@ -611,7 +615,7 @@ export default {
|
|
|
if (SPECIAL_NUTRIENT_NAMES.indexOf(row.nutrientName) > -1) {
|
|
if (SPECIAL_NUTRIENT_NAMES.indexOf(row.nutrientName) > -1) {
|
|
|
getNutrientSources(row.nutrientId, { unit: row.unit }).then(res => {
|
|
getNutrientSources(row.nutrientId, { unit: row.unit }).then(res => {
|
|
|
this.nutrientSources = res.data
|
|
this.nutrientSources = res.data
|
|
|
- if (this.nutrientSources.length > 0){
|
|
|
|
|
|
|
+ if (this.nutrientSources.length > 0) {
|
|
|
if (!row.nutrientSource) {
|
|
if (!row.nutrientSource) {
|
|
|
this.$set(row, 'nutrientSource', this.nutrientSources[0])
|
|
this.$set(row, 'nutrientSource', this.nutrientSources[0])
|
|
|
}
|
|
}
|