《js手写穿梭框》element 两个table表格使用selection复选框之间实现穿梭框,左边选中右边添加,左边取消勾选右边删除。

1.table表格中使用selection属性设置复选框勾选

<el-table-column type="selection" width="40" :reserve-selection="true" />

2.table表格中使用 @selection-change="portSelectionChange" 拿到勾选中得数据

    <el-table
      :data="portListData"
       :border="true"
        :row-key="portRowKey"
        @selection-change="portSelectionChange"
         ref="multipleTablet"
          >
             <el-table-column type="selection" width="40" :reserve-selection="true" />
             <el-table-column label="序号" type="index" width="55" />
             <el-table-column prop="interfaceCode" label="接口编码" width="200" />
              
       </el-table>
const portSelectionChange = (val) => {
    let map = JSON.stringify(val);
    let newmap = JSON.parse(map);
    if (newmap.length > pitchonData.value.length) {
        newmap?.map((item, index) => {
            if (item.id !== pitchonData.value[index]?.id) {
                pitchonData.value.push(item);
            }
        });
    } else if (newmap.length < pitchonData.value.length) {
        let getId = newmap?.map((item) => item.id);
        let arr = pitchonData.value?.filter((item) => !getId?.includes(item.id));

        for (let i = 0; i < pitchonData.value.length; i++) {
            for (let j = 0; j < arr.length; j++) {
                if (pitchonData.value[i].id == arr[j].id) {
                    pitchonData.value?.splice(i, 1);
                }
            }
        }
    }
};
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值