Ant design Table组件子表格展开数据污染问题解决方案

重点在于属性expandedRowKeys,这个属性是控制展开项的数组,在展开获取数据请求时先进行清空这个属性,它是一个数组,然后push进入当前展开项,通过始终保持一个展开项不全部展开就能处理这个问题了

<a-table ref='saleTable' :expandedRowKeys="curExpands" rowKey="PurchaseId"
                :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }" @expand="expand"
                :columns="columns" expandRowByClick :data-source="purchaselistdata" :loading="loading"
                :scroll="{ x: 1600, y: tableHeight }" bordered :pagination="pagination">
                <a-tag slot="Channel" slot-scope="text" :color="text | paytypecolor">
                    {{text | Channel }}
                </a-tag>
                <a-tag slot="Status" slot-scope="text" :color="text | PurchaseStatuscolor">
                    {{text | PurchaseStatus }}
                </a-tag>

                <div slot="action" slot-scope="text,tags,i">
                    <a-button type="link" inline @click.stop="openDetailDialog(text,tags,i)">详情</a-button>
                    <!-- <a-button type="link" inline @click="openDetailDialog(text,tags,i)">明细</a-button> -->
                    <a-button type="link" inline @click.stop="openAfterSaleDialog(text,tags,i)">售后</a-button>
                    <a-button type="link" inline @click.stop="openPutStorageDialog(text,tags,i)">入库</a-button>
                </div>
                <a-table slot="expandedRowRender" :rowKey="(record,index)=>{return index}" slot-scope="text"
                    :columns="innerColumns" :data-source="innerData" :pagination="false">
                    <a-tag slot="Status" slot-scope="text" :color="text | purchaseItemStatuscolor">
                        {{text | purchaseItemStatus }}
                    </a-tag>
                </a-table>
            </a-table>

        在expand事件中进行操作

            expand(e, row) {
                this.curExpands = [];
                if (e) {
                        this.curExpands.push(row.PurchaseId)
                    this.$api.procureItemById(row.PurchaseId).then(res => {
                        this.innerData = res.data;
                    });

                }
            },

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

北海一刀

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值