ant design vue 表格Table使用

ant design vue 表格Table使用

1.嵌套子表

在这里插入图片描述

<a-table
   rowKey="arcId"
   :columns="columns"
   :dataSource="loadData"
   @expand="handldOnExpand"
   :loading="tableLoading"
 >
   <span slot="action" slot-scope="text, record">
     <a v-if="record.status !=0" @click="getarcListByStaus(record)">填表归档</a>
     <a-divider v-if="record.status !=0" type="vertical" />
     <a v-if="record.status !=0" @click="getarcListByStaus2(record)">上传归档</a>      
     <a v-else @click="updateByStaus(record.arcId)">取消归档</a>
   </span>
   // 子表格
   <a-table
      slot="expandedRowRender"  slot-scope="record,text"
      :columns="innerColumns"
      :data-source="record.newchildren"
      :pagination="false"
      // 不显示表头
      :showHeader="false"
    >
      <span slot="operation" slot-scope="text,record">
        <a v-if="record.status !=0" @click="getarcListByStaus2(record)">上传归档</a>      
        <a v-else @click="updateByStaus(record.arcId)">取消归档</a>
      </span>
    </a-table>   
 </a-table>


// 展开闭合按钮事件
handldOnExpand(expanded, record) {
      console.log(expanded,record);
      if (!expanded) return //如果是关闭就返回
      if (record.children && record.children.length > 0) return //如果已经有数据就返回
      const id = record.arcId
      // 获取当前行下的子表数据
      getArcList(Object.assign({ parentid: id })).then((res) => {
        // console.log("aaaaaaaaa");
        const children = res.rows || []
        this.loadData.forEach(item =>{
          if(item.arcId === id){
          // 将子表数据存放到父项的newchildren对象中
            item.newchildren=children
            // console.log(item.children);
            this.loadData = [...this.loadData]
        }})
      })
    },

2.给表格加上loading
<a-table
   rowKey="arcId"
   :columns="columns"
   :dataSource="loadData"
   @expand="handldOnExpand"
   :loading="tableLoading"
 >
</a-table>

this.tableLoading = true
//结束
this.tableLoading = false

3.某一列排序
// 表头设置
{
   title: '项目编号',
   dataIndex: 'number',
   align: 'center',
   sorter: (a, b) => a.number.localeCompare(b.number),
},
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值