Selaa lähdekoodia

修复单位基础单位保存不上,修复置顶->置底,修复营养素模板单位

wangyang 5 vuotta sitten
vanhempi
commit
2d44e6eb81

+ 17 - 2
src/views/nutrientTemplate/detail.vue

@@ -7,12 +7,14 @@
           ref="nutrientSelect"
           v-model="params.nutrientId"
           filterable
+          clearable
           remote
           reserve-keyword
           style="width: 200px;margin-left: 10px;"
           placeholder="请输入营养素关键词"
           :remote-method="queryNutrients"
           :loading="loading"
+          @change="nutrientChanged"
         >
           <el-option v-for="item in nutrients" :key="item.id" :label="item.name" :value="item.id" />
         </el-select>
@@ -20,7 +22,7 @@
         <el-autocomplete
           class="inline-input"
           v-model="params.unit"
-          :fetch-suggestions="queryNutrientUnits(params.nutrientId)"
+          :fetch-suggestions="(query, cb) => {queryNutrientUnits(query, row.nutrientId, cb)}"
           @input="handleUnitChanged"
           placeholder="单位关键词"
         />
@@ -90,7 +92,7 @@
                 class="inline-input"
                 v-model="row.unit"
                 @input="handleRowUnitChanged(row)"
-                :fetch-suggestions="queryNutrientUnits(row.nutrientId)"
+                :fetch-suggestions="(query, cb) => {queryNutrientUnits(query, row.nutrientId, cb)}"
                 placeholder="单位关键词"
               />
               <el-select
@@ -400,6 +402,19 @@ export default {
     },
     isPercentByVolumeUnit(row) {
       return row && row.unit === '%Vol'
+    },
+    nutrientChanged(value) {
+      for (let nutrient of this.nutrients) {
+        if (nutrient.id === value) {
+          this.$set(this.params, 'unit', nutrient.baseUnit)
+          if (nutrient.nrvUnit) {
+            this.showNRV = true
+          } else {
+            this.showNRV = false
+          }
+          break
+        }
+      }
     }
   }
 }

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

@@ -69,7 +69,7 @@
               <el-dropdown-item :disabled="!canUpdate(row.userId)" :command="{row: row, command: 'moveUp'}">上移</el-dropdown-item>
               <el-dropdown-item :disabled="!canUpdate(row.userId)" :command="{row: row, command: 'moveDown'}">下移</el-dropdown-item>
               <el-dropdown-item :disabled="!canUpdate(row.userId)" :command="{row: row, command: 'moveTop'}">置顶</el-dropdown-item>
-              <el-dropdown-item :disabled="!canUpdate(row.userId)" :command="{row: row, command: 'moveBottom'}">置</el-dropdown-item>
+              <el-dropdown-item :disabled="!canUpdate(row.userId)" :command="{row: row, command: 'moveBottom'}">置</el-dropdown-item>
               <el-dropdown-item :disabled="!canUpdate(row.userId)" :command="{row: row, command: 'delete'}">删除</el-dropdown-item>
             </el-dropdown-menu>
           </el-dropdown>

+ 2 - 2
src/views/unit/index.vue

@@ -88,7 +88,7 @@
               <el-dropdown-item :command="{row: row, command: 'moveUp'}">上移</el-dropdown-item>
               <el-dropdown-item :command="{row: row, command: 'moveDown'}">下移</el-dropdown-item>
               <el-dropdown-item :command="{row: row, command: 'moveTop'}">置顶</el-dropdown-item>
-              <el-dropdown-item :command="{row: row, command: 'moveBottom'}">置</el-dropdown-item>
+              <el-dropdown-item :command="{row: row, command: 'moveBottom'}">置</el-dropdown-item>
               <el-dropdown-item :command="{row: row, command: 'delete'}">删除</el-dropdown-item>
             </el-dropdown-menu>
           </el-dropdown>
@@ -117,7 +117,7 @@
           <el-radio v-model="params.isBaseUnit" :label="false" :disabled="dialogStatus === 'UPDATE'">否</el-radio>
         </el-form-item>
         <el-form-item v-if="!params.isBaseUnit" label="基础单位" prop="code">
-          <el-select v-model="params.baseUnit" :disabled="dialogStatus === 'UPDATE'">
+          <el-select v-model="params.baseUnitId" :disabled="dialogStatus === 'UPDATE'">
             <el-option v-for="item in baseUnits" :key="item.id" :value="item.id" :label="item.name" />
           </el-select>
         </el-form-item>