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;
        }
      }
    });
  },
相关推荐
HZW89709 分钟前
鸿蒙应用开发—数据持久化之SQLite
android·前端·harmonyos
百锦再9 分钟前
Android Studio 日志系统详解
android·java·ide·app·android studio·安卓·idea
fatiaozhang952729 分钟前
晶晨线刷工具下载及易错点说明:Key文件配置错误/mac剩余数为0解决方法
android·电视盒子·魔百盒刷机
QING6184 小时前
详解:Kotlin 类的继承与方法重载
android·kotlin·app
QING6184 小时前
Kotlin 伴生对象(Companion Object)详解 —— 使用指南
android·kotlin·app
一一Null4 小时前
Android studio 动态布局
android·java·android studio
AD钙奶-lalala12 小时前
某车企面试备忘
android
我爱拉臭臭12 小时前
kotlin音乐app之自定义点击缩放组件Shrink Layout
android·java·kotlin
匹马夕阳14 小时前
(二十五)安卓开发一个完整的登录页面-支持密码登录和手机验证码登录
android·智能手机
吃饭了呀呀呀14 小时前
🐳 深度解析:Android 下拉选择控件优化方案——NiceSpinner 实践指南
android·java