wangyang 4 년 전
부모
커밋
83c18e2b5c
3개의 변경된 파일18개의 추가작업 그리고 12개의 파일을 삭제
  1. 6 4
      src/views/food/components/NutrientUnit.vue
  2. 6 4
      src/views/food/nutrient.vue
  3. 6 4
      src/views/nutrientTemplate/detail.vue

+ 6 - 4
src/views/food/components/NutrientUnit.vue

@@ -60,10 +60,12 @@ export default {
     },
     queryNutrientUnits(query, nutrientId, cb) {
       let units = []
-      getNutrientUnits(nutrientId, { query }).then(res => {
-        res.data.forEach(item => units.push({ value: item }))
-        cb(units)
-      })
+      if (nutrientId) {
+        getNutrientUnits(nutrientId, { query }).then(res => {
+          res.data.forEach(item => units.push({ value: item }))
+          cb(units)
+        })
+      }
     },
   },
   watch: {

+ 6 - 4
src/views/food/nutrient.vue

@@ -420,10 +420,12 @@ export default {
     },
     queryNutrientUnits(query, nutrientId, cb) {
       let units = []
-      getNutrientUnits(nutrientId, { query }).then(res => {
-        res.data.forEach(item => units.push({ value: item }))
-        cb(units)
-      })
+      if (nutrientId) {
+        getNutrientUnits(nutrientId, { query }).then(res => {
+          res.data.forEach(item => units.push({ value: item }))
+          cb(units)
+        })
+      }
     },
     queryUnits(query, cb) {
       let units = []

+ 6 - 4
src/views/nutrientTemplate/detail.vue

@@ -324,10 +324,12 @@ export default {
     },
     queryNutrientUnits(query, nutrientId, cb) {
       let units = []
-      getNutrientUnits(nutrientId, { query }).then(res => {
-        res.data.forEach(item => units.push({ value: item }))
-        cb(units)
-      })
+      if (nutrientId) {
+        getNutrientUnits(nutrientId, { query }).then(res => {
+          res.data.forEach(item => units.push({ value: item }))
+          cb(units)
+        })
+      }
     },
     setSort() {
       const el = this.$refs.detailTable.$el.querySelectorAll('.el-table__body-wrapper > table > tbody')[0]