多选框 对应的value label id key

1.value 是选项变化时得到的数据 lable 是下拉框中展示的数据

2.选项变化更改对象的数据 页面实时回显更新 用到$set ,

3.后端要求传id(,分割的字符串) ,返回参数也是id,需要自己遍历转换成名称 用$set 回显

复制代码
  <el-form-item label="所属经理" prop="vcManagerName" style="">
       <el-select ref="mySelect" class="queryClass" :max-tag-count="1"  multiple clearable                   
        size="small" v-model="ruleForm.vcManagerName" @on-change="selectFund">
               <el-option v-for="item in vcManagerList" :label="item.vcName" 
                   :value="item.vcName" :key="item.id">
                </el-option>
        </el-select>
    </el-form-item>

 vcManagerList:[
              {vcName:'黄忠',id:"huangz"},
              {vcName:'董丽',id:"dongl"},
              {vcName:'翟腾',id:"zhait"},
              {vcName:'席志学',id:"xizx01"},
              {vcName:'蒋丽娟',id:"jianglj"},
              {vcName:'景宏玉',id:"jinghy"},

            ],

//this.seledtedReceipt.vcManager是"xizx01,jianglj,jinghy"

 arr1=this.seledtedReceipt.vcManager.split(',')
              let arr2=[]
              arr1.map(item=>{
                this.vcManagerList.map(it=>{
                  if(item==it.id){
                    arr2.push(it.vcName)
                  }
                })
              })
              this.ruleForm=this.seledtedReceipt
              // this.ruleForm.vcManagerName=arr2
              this.$set(this.ruleForm,'vcManagerName',arr2)

选择所属经理 重新给vcManagerName赋值,转换得到给后端的id字符串

复制代码
      //选择所属经理
        selectFund(val){
          console.log('val',val);
         
           this.$set(this.ruleForm, 'vcManagerName', val)
          let arrId=[]
          if(val){
            val.map((item)=>{
              this.vcManagerList.map(it=>{
                  if(item==it.vcName){
                    arrId.push(it.id)
                  }
              })   
            })
            this.vcManager=arrId.join(',')
          }else{
            this.vcManager=""
          }
          
        },
相关推荐
松树戈36 分钟前
plus-ui&RuoYi-Vue-Plus 基于pgSql本地运行实践
前端·vue.js·spring boot·ui
new66699942 分钟前
css画图形
前端·css
Yvonne爱编码2 小时前
CSS- 1.1 css选择器
前端·css·状态模式·html5·hbuilder
SHIPKING3932 小时前
【HTML】个人博客页面
javascript·css·html
山河故人1632 小时前
uniapp使用npm下载
前端·npm·uni-app
-曾牛2 小时前
基于微信小程序的在线聊天功能实现:WebSocket通信实战
前端·后端·websocket·网络协议·微信小程序·小程序·notepad++
一口一个橘子3 小时前
[ctfshow web入门] web72
前端·web安全·网络安全
Web极客码3 小时前
如何使用WordPress SEO检查器进行实时内容分析
前端·seo·wordpress
Stella25213 小时前
【Vue】CSS3实现关键帧动画
前端·vue.js·css3
junjun.chen06063 小时前
【在qiankun模式下el-dropdown点击,浏览器报Failed to execute ‘getComputedStyle‘ on ‘Window‘: parameter 1 is not o
前端·javascript·前端框架