Prechádzať zdrojové kódy

完成%Vol单位录入

wangyang 5 rokov pred
rodič
commit
fb90b1ba49

+ 3 - 2
src/api/nutrient.js

@@ -45,9 +45,10 @@ export function updateSortOrder(id, data) {
 }
 
 // 获取营养素单位列表
-export function getNutrientUnits(id) {
+export function getNutrientUnits(id, params) {
   return request({
     url: `/api/nutrients/${id}/units`,
-    method: 'get'
+    method: 'get',
+    params
   })
 }

+ 31 - 23
src/views/food/nutrient.vue

@@ -60,27 +60,31 @@
           :fetch-suggestions="queryNutrientUnits"
           placeholder="单位关键词"
         />
-        NRV%:
-        <el-input
-          v-model="params.nrvPercent"
-          style="width: 80px;"
-          class="filter-item"
-        />
+        <div v-show="!isPercentByVolumeUnit(params)" style="display: inline-block">
+          NRV%:
+          <el-input
+            v-model="params.nrvPercent"
+            style="width: 80px;"
+            class="filter-item"
+          />
+        </div>
       </el-row>
       <el-row style="margin-top: 10px">
-        Nv_Spec计量:
-        <el-input
-          v-model="params.nvSpec"
-          style="width: 80px;"
-          class="filter-item"
-          @focus="getInputFocus"
-        />
-        <el-autocomplete
-          class="inline-input"
-          v-model="params.nvSpecUnit"
-          :fetch-suggestions="queryUnits"
-          placeholder="单位关键词"
-        />
+        <div v-show="!isPercentByVolumeUnit(params)" style="display: inline-block">
+          Nv_Spec计量:
+          <el-input
+            v-model="params.nvSpec"
+            style="width: 80px;"
+            class="filter-item"
+            @focus="getInputFocus"
+          />
+          <el-autocomplete
+            class="inline-input"
+            v-model="params.nvSpecUnit"
+            :fetch-suggestions="queryUnits"
+            placeholder="单位关键词"
+          />
+        </div>
         信息来源:
         <el-autocomplete
           v-model="params.source"
@@ -160,13 +164,13 @@
       <el-table-column label="NRV%" align="center" width="80">
         <template slot-scope="{row}">
           <template v-if="row.edit">
-            <el-input v-model="row.nrvPercent"/>
+            <el-input v-show="!isPercentByVolumeUnit(row)" v-model="row.nrvPercent"/>
           </template>
           <span v-else>{{ row.nrvPercent }}</span>
         </template>
       </el-table-column>
       <el-table-column label="Nv_Spec" align="center" width="80">
-        <template slot-scope="{row}">
+        <template slot-scope="{row}" v-if="!isPercentByVolumeUnit(row)">
           <template v-if="row.edit">
             <el-input v-model="row.nvSpec" class="filter-item" @focus="getInputFocus" />
           </template>
@@ -174,7 +178,7 @@
         </template>
       </el-table-column>
       <el-table-column label="计量单位" align="center" width="150">
-        <template slot-scope="{row}">
+        <template slot-scope="{row}" v-if="!isPercentByVolumeUnit(row)">
           <template v-if="row.edit">
             <el-autocomplete v-model="row.nvSpecUnit" :fetch-suggestions="queryUnits" placeholder="单位关键词" />
           </template>
@@ -321,6 +325,7 @@ export default {
       importItems: [],
       isFixed: false,
       offsetTop: 0
+      // isPercentByVolumeUnit: false
     }
   },
   methods: {
@@ -392,7 +397,7 @@ export default {
     },
     queryNutrientUnits(query, cb) {
       let units = []
-      getNutrientUnits(this.params.nutrientId).then(res => {
+      getNutrientUnits(this.params.nutrientId, { query }).then(res => {
         res.data.forEach(item => units.push({ value: item }))
         cb(units)
       })
@@ -526,6 +531,9 @@ export default {
       if (path) {
         this.$router.push({ path: path })
       }
+    },
+    isPercentByVolumeUnit(row) {
+      return row && row.unit === '%Vol'
     }
   }
 }

+ 1 - 1
src/views/nutrientTemplate/detail.vue

@@ -283,7 +283,7 @@ export default {
     },
     queryNutrientUnits(query, cb) {
       let units = []
-      getNutrientUnits(this.params.nutrientId).then(res => {
+      getNutrientUnits(this.params.nutrientId, { query }).then(res => {
         res.data.forEach(item => units.push({ value: item }))
         cb(units)
       })