• select在项目中的总结(select的状态改变;selsec的二级联动)


    ajax请求传参:

    var stat0,stat1;
    if(data.data[i].STAT==0){
       stat0 ='selected=selected';
       stat1 ='';
     }else{
       stat1 ='selected=selected';
       stat0 ='';
    };
    
    "<td>"+
      "<select name='' autocomplete='off' id='states' style='border:none; outline:none;color: #00a09e;' onchange='ststeCall("+data.data[i].FACID+",this,0)'>"+
        "<option value='0' "+stat0+">有效</option>"+
        "<option value='1' "+stat1+">无效</option>"+
      "</select>"+
    "</td>" +
    
    //状态
    function ststeCall(id,tis,flg){
      var num=$(tis).val(); //0或1
      //掉接口给后端传值,改变状态
    }

    select的二级联动:

    html:

    <select class='scheduli schedu_department' id="liandorgname">
      <!-- <option value ='0'>选择科室</option>
      <option value='1'>内科</option> -->    
    </select>
    
    <select class='scheduli schedu_doctor' id="lianddoctor">
      <option value ='-1'>选择医生</option>
      <!-- <option value='1'>周</option> -->    
    </select>

    js:

    $(function(){
    //科室类型传参获取所有科室
    selectAdd("科室类型",function(data){
      $("#liandorgname").html("");
      $("#liandorgname").append("<option value='-1'>请选择科室</option>");
      for (var i = 0; i < data.length; i++) {
        $("#liandorgname").append("<option value='"+data[i].dictId+"'>"+data[i].dictName+"</option>");
      }
    })
    function selectAdd(name,initSelectfun){
       $.ajax({
         url:"/doctormanage/dict/getdict.do",
         type:"post",
         dataType:"json",
         data:{
           "name":name
         },success:function(data){
           initSelectfun(data.data);
         }
       });
    }
    //一级change改变获取科室id
    $("#liandorgname").on('change',function () { 
      var orgId = $(this).val();
      $('#lianddoctor').val('').trigger('change'); 
      dataAllname(orgId,function(data){
        $("#lianddoctor").html("");
        $("#lianddoctor").append("<option value='-1'>请选择医生</option>");
        for (var i = 0; i < data.length; i++) {
          $("#lianddoctor").append("<option value='"+data[i].id+"'>"+data[i].doctorName+"</option>");
        }
      });
    });
    //二级联动 传科室Id 获取医生列表
    function dataAllname(orgId,initSelectfun){
      var datas;
      $.ajax({
        url:"/doctormanage/user/getuserbyname.do",
        type:"post",
        dataType:"json",
        data:{
          "name":"",
          "orgId":orgId,
          "date":""
        },success:function(data){
          console.log(data)
          initSelectfun(data.data);
        }
      });
      return datas;
    }    
    })
  • 相关阅读:
    Git_创建版本库
    Git_安装Git
    Git_集中式vs分布式
    Git_git的诞生
    echartShow
    微信小程序红包开发 小程序发红包 开发过程中遇到的坑 微信小程序红包接口的
    vue2.0 $router和$route的区别
    vue移动端开发全家桶
    干货分享:vue2.0做移动端开发用到的相关插件和经验总结
    优秀的基于VUE移动端UI框架合集
  • 原文地址:https://www.cnblogs.com/fanting/p/9414272.html
Copyright © 2020-2023  润新知