el-select控制单选还是多选

php 复制代码
 <el-form :inline="true" :model="form" class="demo-form-inline">
    <el-form-item>
      <el-select v-model="form.properties_id" placeholder="请选择样品性质" clearable :multiple="multiple_properties"  @change="getData()" @focus="focus_properties()" style="width: 300px">
        <el-option v-for="item in sample_properties" :label="item.label" :value="item.value" :key="item.value"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item>
      <el-select v-model="form.place_id" placeholder="请选择品名" clearable :multiple="multiple_place" @change="getData()" @focus="focus_place()" style="width: 300px">
        <el-option v-for="item in place_data" :label="item.label" :value="item.value" :key="item.value"></el-option>
      </el-select>
    </el-form-item>
  </el-form>
javascript 复制代码
  form: {
    properties_id : [],
    place_id      : [],
  },
  multiple_properties: true,
  multiple_place: true,
javascript 复制代码
 //properties 获得焦点
 focus_properties(){
   var that = this
   that.form.properties_id = [];
   if(that.form.place_id.length > 1){
     that.multiple_place = true;
     that.multiple_properties = false;
   }
   else{
     that.multiple_properties = true;
     //that.multiple_place = true;
   }
 },
 //place 获得焦点
 focus_place(){
   var that = this
   that.form.place_id = [];
   if(that.form.properties_id.length > 1){
     that.multiple_place = false;
     that.multiple_properties = true;
   }
   else{
     //that.multiple_properties = true;
      that.multiple_place = true;
   }
 },
 getData(){
    var that = this
    //样品性质
    var properties_id = [];
    var properties_id_len = that.form.properties_id.length;
    if(properties_id_len == undefined){
      //此时会变成字符串
      var str = that.form.properties_id
      properties_id= JSON.parse("[" + str + "]");//变成数组形式
    }
    else{
      properties_id = that.form.properties_id;
    }
    //品名
    var place_id = [];
    var place_id_len = that.form.place_id.length;
    if(place_id_len == undefined){
      //此时会变成字符串
      var str = that.form.place_id
      place_id= JSON.parse("[" + str + "]");//变成数组形式
    }
    else{
      place_id = that.form.place_id;
    }

    if(properties_id.length == 0){
      properties_id = null;
    }
    if(place_id.length == 0){
      place_id = null;
    }

    $.ajax({
      url: "/admin/report/getDevetimeData",
      type: "GET",
      data : {
        properties_id : properties_id,
        place_id      : place_id,
      },
      dataType:'json',
      success: function (res) {
        if (res.code == 100) {
          that.data = res.data;
        }
      }
    });
  },
相关推荐
缘来的精彩17 分钟前
Android JNI性能优化与字符串加载实践
android·性能优化·jni·androidndk
weixin_460783878 小时前
Flutter解决TabBar顶部页面切换导致页面重载问题
android·javascript·flutter
qhs15739 小时前
Kotlin字符串操作在Android开发中的应用示例
android·开发语言·kotlin
网络安全(king)11 小时前
Android networkSecurityConfig 代码配置
android
LuXi_foryou11 小时前
【2025深夜随笔】简单认识一下Android Studio
android·ide·android studio
缘来的精彩11 小时前
Android Studio Gradle 8.0 适配指南
android·ide·android studio
星仔_X11 小时前
Android Studio安装配置
android·ide·android studio
驜鸈12 小时前
MySQL 的EXPLAIN 计划 type 字段详细说明
android·数据库·mysql
二流小码农12 小时前
鸿蒙开发:wrapBuilder传递参数
android·ios·harmonyos
ljx140005255013 小时前
推荐一个基于Koin, Ktor & Paging等组件的KMM Compose Multiplatform项目
android·kotlin