wangyang 4 년 전
부모
커밋
c985889f08
2개의 변경된 파일23개의 추가작업 그리고 8개의 파일을 삭제
  1. 1 1
      src/utils/food-utils.js
  2. 22 7
      src/views/food/index.vue

+ 1 - 1
src/utils/food-utils.js

@@ -24,7 +24,7 @@ export function getFoodSourceByUrl(url='') {
     return 'ENTRY'
   } else if (url.indexOf('cfct') > -1) {
     return 'CFCT'
-  } else if (url.indexOf('usda')) {
+  } else if (url.indexOf('usda') > -1) {
     return 'USDA'
   } else {
     return ''

+ 22 - 7
src/views/food/index.vue

@@ -9,9 +9,12 @@
           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-select v-model="selectType" 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-select v-model="selectType" v-if="foodSourceIsAll" clearable style="width: 160px;margin-left: 10px;" class="filter-item">
+          <el-option v-for="item in allTypes" :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>
@@ -48,7 +51,7 @@
       fit
       highlight-current-row
       style="width: 100%;"
-      @row-click="handleFoodClick"
+      @row-dblclick="handleFoodClick"
     >
       <el-table-column type="index" label="序号" align="center" fixed width="60px" />
       <el-table-column label="名称" align="center" fixed width="200px">
@@ -240,10 +243,15 @@ export default {
       foodQRDialogVisible: false,
       foodQRParams: {},
       isUsda: false,
+      foodSourceIsAll: false,
       usdaTypes: [{ 'label': '全部', 'value': 'ALL' }, { 'label': 'Foundation', 'value': 'USDA_FOUNDATION' },
-                  { 'label': 'Legacy', 'value': 'USDA_SR_LEGACY' }, { 'label': 'Branded', 'value': 'USDA_BRANDED' },
+                  { 'label': 'SR Legacy', 'value': 'USDA_SR_LEGACY' }, { 'label': 'Branded', 'value': 'USDA_BRANDED' },
                   { 'label': 'FNDDS', 'value': 'USDA_FNDDS' }],
-      usdaType: ''
+      allTypes: [{ 'label': '全部', 'value': 'ALL' }, { 'label': '录入', 'value': 'ENTRY' },
+        { 'label': 'CFCT', 'value': 'CFCT' }, { 'label': 'Foundation', 'value': 'USDA_FOUNDATION' },
+        { 'label': 'SR Legacy', 'value': 'USDA_SR_LEGACY' }, { 'label': 'Branded', 'value': 'USDA_BRANDED' },
+        { 'label': 'FNDDS', 'value': 'USDA_FNDDS' }],
+      selectType: ''
     }
   },
   created() {
@@ -254,17 +262,24 @@ export default {
       this.listQuery.orderBy = 1
     }
     this.isUsda = isUsda(this.foodSource)
+    this.foodSourceIsAll = this.foodSource === ''
     this.fetchData()
   },
   methods: {
     fetchData() {
       this.listLoading = true
       this.listQuery.foodSource = this.foodSource
-      if (this.foodSource === 'USDA') {
-        if (!this.usdaType || this.usdaType === 'ALL'){
+      if (this.isUsda) {
+        if (!this.selectType || this.selectType === 'ALL'){
           this.listQuery.foodSource = 'USDA'
         } else {
-          this.listQuery.foodSource = this.usdaType
+          this.listQuery.foodSource = this.selectType
+        }
+      } else if (this.foodSourceIsAll) {
+        if (!this.selectType || this.selectType === 'ALL') {
+          this.listQuery.foodSource = ''
+        } else {
+          this.listQuery.foodSource = this.selectType
         }
       }
       getList(this.listQuery).then(response => {