|
|
@@ -5,10 +5,13 @@
|
|
|
<el-input
|
|
|
v-model="listQuery.query"
|
|
|
placeholder="请输入检索词"
|
|
|
- style="width: 60%;"
|
|
|
+ style="width: 40%;"
|
|
|
class="filter-item"
|
|
|
@keyup.enter.native="fetchData()"
|
|
|
/>
|
|
|
+ <el-select v-model="usdaType" v-if="isUsda" clearable style="width: 160px;margin-left: 10px;" class="filter-item">
|
|
|
+ <el-option v-for="item in usdaTypes" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
+ </el-select>
|
|
|
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-search" @click="fetchData">
|
|
|
检索
|
|
|
</el-button>
|
|
|
@@ -200,7 +203,7 @@ import Pagination from '@/components/Pagination'
|
|
|
import { getList, remove, copyFromSimilarFood } from '@/api/food'
|
|
|
import axios from 'axios'
|
|
|
import { getToken } from '@/utils/auth'
|
|
|
-import { getFoodSourceByUrl } from '@/utils/food-utils'
|
|
|
+import { getFoodSourceByUrl, isUsda } from '@/utils/food-utils'
|
|
|
import store from '@/store'
|
|
|
import VueQr from 'vue-qr'
|
|
|
|
|
|
@@ -235,7 +238,12 @@ export default {
|
|
|
params: {},
|
|
|
foodSource: '',
|
|
|
foodQRDialogVisible: false,
|
|
|
- foodQRParams: {}
|
|
|
+ foodQRParams: {},
|
|
|
+ isUsda: false,
|
|
|
+ usdaTypes: [{ 'label': '全部', 'value': 'ALL' }, { 'label': 'Foundation', 'value': 'USDA_FOUNDATION' },
|
|
|
+ { 'label': 'Legacy', 'value': 'USDA_SR_LEGACY' }, { 'label': 'Branded', 'value': 'USDA_BRANDED' },
|
|
|
+ { 'label': 'FNDDS', 'value': 'USDA_FNDDS' }],
|
|
|
+ usdaType: ''
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
@@ -245,12 +253,20 @@ export default {
|
|
|
} else {
|
|
|
this.listQuery.orderBy = 1
|
|
|
}
|
|
|
+ this.isUsda = isUsda(this.foodSource)
|
|
|
this.fetchData()
|
|
|
},
|
|
|
methods: {
|
|
|
fetchData() {
|
|
|
this.listLoading = true
|
|
|
this.listQuery.foodSource = this.foodSource
|
|
|
+ if (this.foodSource === 'USDA') {
|
|
|
+ if (!this.usdaType || this.usdaType === 'ALL'){
|
|
|
+ this.listQuery.foodSource = 'USDA'
|
|
|
+ } else {
|
|
|
+ this.listQuery.foodSource = this.usdaType
|
|
|
+ }
|
|
|
+ }
|
|
|
getList(this.listQuery).then(response => {
|
|
|
this.list = response.data.list
|
|
|
this.total = response.data.count
|