如果我们想在el-select的change事件中拿到一些特定的参数,就可以用到(…arr) => checkManager(field.name, …arr)的方式传参,下面是我在项目中截取的部分代码,仅供参考。

// html
<el-select
  v-model="projectInfo[field.name]"
  filterable
  remote
  :remote-method="getManagerList"
  @change="(...arr) => checkManager(field.name, ...arr)"
>
  <el-option
    v-for="option in managerList"
    :key="option.account"
    :label="option.dspName + '(' + (option.deptName || '') + ')'"
    :value="option.account"
  />
</el-select>

// js
// 接口请求获取managerList
getManagerList(val) {},
checkManager(name, val) {
   const current = this.managerList.find((e) => e.account === val);
   let obj = {};
   if (name === 'creditManagerAAccount') {
     obj = {
       creditManagerAName: current.dspName,
       creditManagerADeptNo: current.deptCode,
       creditManagerADeptName: current.deptName,
     };
   } else if (name === 'creditManagerBAccount') {
     obj = {
       creditManagerBName: current.dspName,
       creditManagerBDeptNo: current.deptCode,
       creditManagerBDeptName: current.deptName,
     };
   } else if (name === 'legalManagerAccount') {
     obj = {
       legalManagerName: current.dspName,
       legalManagerDeptNo: current.deptCode,
       legalManagerDeptName: current.deptName,
     };
   }
   this.projectInfo = { ...this.projectInfo, ...obj };
}
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐