Jelajahi Sumber

完善导入营养素模版时的排序问题, 增加了模版里营养素计算方式

Yu Kong 4 tahun lalu
induk
melakukan
4608c7efe6
1 mengubah file dengan 15 tambahan dan 7 penghapusan
  1. 15 7
      src/views/food/index.vue

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

@@ -314,10 +314,10 @@
               <span>
                 <el-button size="mini" type="primary" plain @click="addNutrient(dlg.form.data)">添加</el-button>
               </span>
-              <el-select v-model="dlg.form.selectedNutrientTemplate" style="margin-left: 10%; display: float; margin-right: 0.5%" v-on:input.native="getNutrienttemplateList($event)"  filterable placeholder="请输入检索词">
-                <el-option v-for="opt in dlg.form.nutrientTemplateOptions" :key="opt.id" :label="opt.value" :value="opt.name" />
+              <el-select v-model="dlg.form.selectedNutrientTemplate" class="filter-item" style="margin-left: 10%; display: float; margin-right: 0.5%" v-on:input.native="getNutrienttemplateList($event, dlg.form)"  filterable placeholder="请输入检索词">
+                <el-option v-for="opt in dlg.form.nutrientTemplateOptions" :key="opt.id" :label="opt.name" :value="opt.name" />
               </el-select>
-              <el-button v-model="dlg.form.nutrientTemplateTable" size="mini" type="primary" plain @click="importNutrientTemplate()">导入营养素模版</el-button>
+              <el-button size="mini" type="primary" plain @click="importNutrientTemplate()">导入营养素模版</el-button>
 
             </div>
             <el-table :data="dlg.form.data.nutrients" :show-header="false" border fit highlight-current-row style="width:100%">
@@ -682,9 +682,15 @@ export default {
     },
     // 导入营养素模版
     importNutrientTemplate() {
+      console.log(this.dlg.form.data.nutrients)
       if (this.dlg.form.selectedNutrientTemplate == undefined) {
         return
       }
+
+      if (this.dlg.form.data.nutrients == undefined) {
+        this.dlg.form.data.nutrients = []
+      }
+
       this.dlg.form.nutrientTemplateOptions.forEach(opt => {
         if (opt.name == this.dlg.form.selectedNutrientTemplate) {
           this.dlg.form.selectedNutrientTemplateId = opt.id
@@ -714,7 +720,8 @@ export default {
               nvSpec: nv.nvSpec, 
               nvSpecUnit: nv.nvSpecUnit,
               nvSpecUnitId: nv.nvSpecUnitId,
-              nvUnitId: nv.unitId
+              nvUnitId: nv.unitId,
+              nvMeasureMode: nv.quantityType
             })
           }
 
@@ -722,10 +729,11 @@ export default {
       })
 
     },
-    getNutrienttemplateList(e) {
-      this.dlg.form.nutrientTemplateOptions = []
+    getNutrienttemplateList(e, row) {
+      row.nutrientTemplateOptions = []
       fGet(`/api/nutrient-templates`, {keyword: e.target.value}).then(res => {
-        this.dlg.form.nutrientTemplateOptions = res
+        this.$set(row, 'nutrientTemplateOptions', res)
+        console.log(row.nutrientTemplateOptions)
       })
     },
     // 营养素选择