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;
        }
      }
    });
  },
相关推荐
model200541 分钟前
android + tflite 分类APP开发-2
android·分类·tflite
彭于晏6891 小时前
Android广播
android·java·开发语言
与衫2 小时前
掌握嵌套子查询:复杂 SQL 中 * 列的准确表列关系
android·javascript·sql
前端李易安5 小时前
ajax的原理,使用场景以及如何实现
前端·ajax·okhttp
500了8 小时前
Kotlin基本知识
android·开发语言·kotlin
人工智能的苟富贵9 小时前
Android Debug Bridge(ADB)完全指南
android·adb
小雨cc5566ru14 小时前
uniapp+Android面向网络学习的时间管理工具软件 微信小程序
android·微信小程序·uni-app
bianshaopeng15 小时前
android 原生加载pdf
android·pdf
hhzz15 小时前
Linux Shell编程快速入门以及案例(Linux一键批量启动、停止、重启Jar包Shell脚本)
android·linux·jar
火红的小辣椒16 小时前
XSS基础
android·web安全