??还没有重获数据,selection-change得到的数组被清空

很奇怪 在_confirm方法末尾得到了有值的数组this.selectionData,但一进入onSearch方法,this.selectionData数组被清空了。

解决办法:_confirm方法最后拷贝
this.selectionDataCopy = deepClone(this.selectionData)

// An highlighted block
onSearch () { //弹框搜索 <el-input v-model="form.keyword" auto-complete="off" placeholder='输入关键字搜索' @keyup.native.enter="onSearch">
  console.log(this.selectionData, 'onSearch刚进')  //打印出空数组  想不通
  this.getPickData((data) => {
    // 更新选中的数据,搜索时已选中的数据需要保留
    // this.toggleSection(this.selectionData)
    if (data) {
      console.log(this.selectionData, 'onSearch')
      this.toggleSection(this.selectionDataCopy)
    }
  })
},

_confirm (row) { //<el-table :data="tableData" height="300" @selection-change='_confirm' ref="table">
  console.log(this.selectionData, 'selectionData _confirm刚进')
  let ssaId = []
  let ssaNo = []
  let ssaName = []
  let ssaRows = []
  row.map(item => {
    ssaId.push(item.Ssa_Id)
    ssaNo.push(item.Ssa_No)
    ssaName.push(item.Ssa_Name)
  })
  this.paramsList = {
    ssaId: ssaId,
    ssaNo: ssaNo,
    ssaName: ssaName,
    ssaRows: [].concat(row)
  }
  if (this.selectionData.length === 0) {
    this.selectionData = row
  } else {
    let array = this.selectionData.map(item => item.Ssa_Id)
    let tArray = this.tableData.map(item => item.Ssa_Id)
    let rArray = row.map(item => item.Ssa_Id)
    row.forEach(item => {
      if (array.indexOf(item.Ssa_Id) === -1) {
        this.selectionData.push(item)
      }
    })
    for (let i = 0; i < this.selectionData.length; i++) {
      if (tArray.indexOf(this.selectionData[i].Ssa_Id) > -1 && rArray.indexOf(this.selectionData[i].Ssa_Id) === -1) {
        this.selectionData.splice(i--, 1)
      }
    }
  }
  this.selectionDataCopy = deepClone(this.selectionData)
  console.log(this.selectionData, 'selectionData _confirm刚走完')
},

toggleSection (row) { // 列表勾选上
  this.$nextTick(() => {
    let tempData = []
    let that = this
    if (row) {
      tempData = row
      this.tableData.map((temp, index) => {
        tempData.map((item, i) => {
          if (item.Ssa_Id === temp.Ssa_Id) {
            that.$refs['table'].toggleRowSelection(temp, true)
          }
        })
      })
    } else {
      that.$refs['table'].clearSelection()
    }
  })
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值