Ver código fonte

增大从模板导入对话框的下拉框长度,默认选中第一个

wangyang 5 anos atrás
pai
commit
2fe218304b

+ 6 - 2
src/views/food/components/FoodDetail.vue

@@ -69,8 +69,8 @@
     </el-form>
 
     <el-dialog title="从模板导入营养素" :visible.sync="dialogFormVisible">
-      <el-form ref="dialogForm" label-position="left" label-width="80px" style="width: 400px; margin-left:50px;">
-        <el-form-item label="模板:" prop="templateId">
+      <el-form ref="dialogForm" label-position="left" label-width="60px" style="width: 80%; margin-left:50px;">
+        <el-form-item label="模板:" prop="templateId" >
           <el-select
             v-model="templateId"
             class="filter-item"
@@ -80,6 +80,7 @@
             placeholder="请输入模板关键词"
             :loading="templateLoading"
             :remote-method="queryTemplates"
+            style="width: 100%"
           >
             <el-option v-for="item in templates" :key="`template${item.id}`" :label="item.name" :value="item.id" />
           </el-select>
@@ -192,6 +193,9 @@ export default {
     queryTemplates(query='') {
       getNutrientTemplates({ query }).then(res => {
         this.templates = res.data.list
+        if (this.templates.length > 0) {
+          this.templateId = this.templates[0].id
+        }
       }).catch(() => {
         this.templates = []
       })

+ 5 - 1
src/views/food/nutrient.vue

@@ -219,7 +219,7 @@
     </el-table>
 
     <el-dialog title="从模板导入营养素" :visible.sync="dialogFormVisible" v-loading="templateLoading">
-      <el-form ref="dialogForm" label-position="left" label-width="80px" style="width: 400px; margin-left:50px;">
+      <el-form ref="dialogForm" label-position="left" label-width="60px" style="width: 80%; margin-left:50px;">
         <el-form-item label="模板:" prop="templateId">
           <el-select
             v-model="templateId"
@@ -229,6 +229,7 @@
             reserve-keyword
             placeholder="请输入模板关键词"
             :remote-method="queryTemplates"
+            style="width: 100%"
           >
             <el-option v-for="item in templates" :key="`template${item.id}`" :label="item.name" :value="item.id" />
           </el-select>
@@ -428,6 +429,9 @@ export default {
     queryTemplates(query='') {
       getNutrientTemplates({ query }).then(res => {
         this.templates = res.data.list
+        if (this.templates.length > 0) {
+          this.templateId = this.templates[0].id
+        }
       }).catch(() => {
         this.templates = []
       })