多选框 对应的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=""
          }
          
        },
相关推荐
meilindehuzi_a6 分钟前
LangChain.js 对话 Memory 实战:History 持久化、截断与摘要压缩
java·javascript·langchain
江畔柳前堤22 分钟前
具身智能全景深度指南(2026年9月版):从“会聊天的AI“到“能干活的机器“
大数据·javascript·图像处理·人工智能·分布式·智慧城市·原型模式
️学习的小王26 分钟前
Windows Claude Code 接入 Playwright‑MCP,调用本机Edge浏览器(避坑完整教程)
前端·windows·edge
liuyicenysabel31 分钟前
Grafana + Prometheus 分级告警配置设计(P0/P1/P2)
javascript·grafana·prometheus
律宏阔32 分钟前
CloakBrowser 开发踩坑笔记
前端·浏览器
Made in Haven71238 分钟前
HTML课程笔记补2
前端·笔记·html
Cry丶1 小时前
Vue 3 业务管理页面实战:组件拆分、父子通信与弹窗复用
前端·javascript·vue.js·父子通信·组件拆分·弹窗复用
雪芽蓝域zzs1 小时前
Vue前端配置路由通配捕获 404
前端·javascript·vue.js
计算机魔术师1 小时前
Anthropic 发布电商 Agent 架构与生产实践指南,并开源 commerce-agents 参考实现
前端
IMPYLH1 小时前
HTML 的 <ol> 元素
前端·html