将两个回显的数据变为一个 使两个地方都显示这个总回显

java 复制代码
 <el-col :span="8">
        <el-form-item :label="`第${index + 1}位监督检查人`" style="margin-left: -40px" required>
          <el-select v-model="item.superviseName" filterable :placeholder="`请选择第${index + 1}位监督检查人`">
            <div v-if="item.isSpDept === 'Y'">
              <el-option v-for="option in userList" :key="option.userId" :label="option.label"
                         :value="option.userId">
              </el-option>
            </div>
            <div v-else>
              <el-option v-for="option in otherUserList" :key="option.userId" :label="option.label"
                         :value="option.userId">
              </el-option>
            </div>
          </el-select>
        </el-form-item>
      </el-col>        


userList: [],
otherUserList: [],              






created() {
let _this = this;
this.user = this.$store.getters.user;
this.form.createByName = this.user.nickName;
// this.form.caseType=this.radio;
console.log(_this.source === 0)
if (this.source === 0) {
  console.log(this.source, '来源类型')
  _this.sourceType = 0
}
// 回显详情
console.log(this.caseId, 'id')
if (this.caseId !== "") {
  caseDetail({
    caseId: this.caseId
  }).then((response) => {
    console.log(response.data, '结果')
    if (response.data) {
      response.data = this.delEmptyQueryNodes(
        this.delEmptyQueryNodes(response.data)
      );
      this.form = response.data;
      this.radio = this.form.caseType;
      this.radioClient = this.form.clueType == 1 ? "单位" : "个人";
      console.log("form值", this.form);
      this.form.createByName = this.user.nickName;
      if (this.form.checkUserList == "") {
        this.form.checkUserList = [];
      }
      // 县局科室登记案源 默认为分流 不需要再选择分流方式
      // 县局人员判断条件为当前用户dept_info_id字段是否为101 是101 为县局人员,非101 则为分局或大队人员
      if (String(this.$store.state.user.user.deptInfoId) == "101") {
        // 0:备案  1:分流
        this.form.recordFlag = "1";
      }
    }
  });
} else {
  // 县局科室登记案源 默认为分流 不需要再选择分流方式
  // 县局人员判断条件为当前用户dept_info_id字段是否为101 是101 为县局人员,非101 则为分局或大队人员
  if (String(this.$store.state.user.user.deptInfoId) == "101") {
    // 0:备案  1:分流
    this.form.recordFlag = "1";
  }
}
// 获取本单位人员下拉框
// isNotDeptInfo:为空则默认查询本单位  不为空则默认查询非本单位人员
listCheckUser(2, true).then((response) => {
  this.userList = response.rows.map((d) => {
    d.label = `${d.nickName}`;
    return d;
  });
});

// 获取其他单位人员下拉框
// isNotDeptInfo:为空则默认查询本单位  不为空则默认查询非本单位人员
listCheckUser(1, true, true
).then(
  (response) => {
    this.otherUserList = response.rows.map((d) => {
      d.label = `${d.nickName}`;
      if (d.deptInfoName) {
        d.label = `${d.nickName}(${d.deptInfoName})`;
      }
      return d;
    });
  }
);将两个回显数据加在一起  使合并的回显数据同时在"本单位"和"其他单位"之间进行选择。

完善:

要将两个回显数据加在一起,您可以使用 concat() 方法将 userList 和 otherUserList 数组合并为一个新的数组,并将该数组赋给一个新的属性,例如 combinedUserList。然后,将 combinedUserList 用于渲染 <el-select> 组件的选项列表。

以下是一种可能的实现方法:

首先,在 data 中添加一个新的属性 combinedUserList

java 复制代码
data() {
  return {
    userList: [],
    otherUserList: [],
    combinedUserList: [],
    // ...
  };
},

然后,在 created 钩子函数中,将 userListotherUserList 数组合并到 combinedUserList

java 复制代码
created() {
  // ...
  listCheckUser(2, true).then((response) => {
    this.userList = response.rows.map((d) => {
      d.label = `${d.nickName}`;
      return d;
    });
    
    this.combinedUserList = this.userList.concat(this.otherUserList);
  });

  // ...
},

最后,将 combinedUserList 用于渲染 <el-select> 组件的选项列表

java 复制代码
<el-select v-model="item.superviseName" filterable :placeholder="`请选择第${index + 1}位监督检查人`">
  <el-option v-for="option in combinedUserList" :key="option.userId" :label="option.label" :value="option.userId"></el-option>
</el-select>

现在,combinedUserList 数组包含了 userListotherUserList 的合并结果,可以使用该数组同时在"本单位"和"其他单位"之间进行选择

相关推荐
博客zhu虎康1 小时前
React Hooks 报错?一招解决useState问题
前端·javascript·react.js
灰海1 小时前
vue中通过heatmap.js实现热力图(多个热力点)热区展示(带鼠标移入弹窗)
前端·javascript·vue.js·heatmap·heatmapjs
码上暴富3 小时前
vue2迁移到vite[保姆级教程]
前端·javascript·vue.js
老华带你飞3 小时前
考研论坛平台|考研论坛小程序系统|基于java和微信小程序的考研论坛平台小程序设计与实现(源码+数据库+文档)
java·vue.js·spring boot·考研·小程序·毕设·考研论坛平台小程序
伍哥的传说3 小时前
Lodash-es 完整开发指南:ES模块化JavaScript工具库实战教程
大数据·javascript·elasticsearch·lodash-es·javascript工具库·es模块·按需导入
@菜菜_达3 小时前
Lodash方法总结
开发语言·前端·javascript
GISer_Jing3 小时前
低代码拖拽实现与bpmn-js详解
开发语言·javascript·低代码
YAY_tyy4 小时前
基于 Vue3 + VueOffice 的多格式文档预览组件实现(支持 PDF/Word/Excel/PPT)
前端·javascript·vue.js·pdf·word·excel
Yvonne爱编码4 小时前
AJAX入门-AJAX 概念和 axios 使用
前端·javascript·ajax·html·js
Pu_Nine_95 小时前
10 分钟上手 ECharts:从“能跑”到“生产级”的完整踩坑之旅
前端·javascript·echarts·css3·html5