antDesignForVue 符合条件的表格复选框禁止选中

复制代码

computed: {
    rowSelection() {
      const _this = this
      const { selectedRowKeys } = this
      return {
        selectedRowKeys,
        onChange: (selectedRowKeys) => {
          this.selectedRowKeys = selectedRowKeys
        },
        getCheckboxProps: (record) => ({
         props: {
             // 全部默认禁止选中
             // disabled: true,
             // 某几项默认禁止选中(R: 当state等于1时)
             disabled: record.state === 1,
        // 某几项默认选中(R: 当state等于1时) 
        // defaultChecked: record.state == 1, 
       }, 
      }), 
     } 
    }, 
 },

复制代码

复制代码

 <a-table
  ref="table"
  size="middle"
  bordered
  rowKey="id"
 :columns="columns"
 :dataSource="dataSource"
  :pagination="ipagination"
  :rowSelection="rowSelection"
  :loading="tableLoading"
  class="j-table-force-nowrap"
>
  <!-- 操作 -->
  <template slot="action" slot-scope="text, record">
     <router-link :to="{name: 'bulkDelivery', params: {id: record.id}}">发货</router-link>
  </template>
</a-table>

复制代码

查看效果:

 

 全选也不会被选中

 

 完美~~

转载:https://www.cnblogs.com/xiaomengzhu/p/13615477.html

  • 5
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Ant Design Vue 表格组件提供了分页功能,但默认情况下只显示一页数据。如果你想要实现滚动分页,可以通过以下步骤来实现: 1. 在表格组件中添加 `scroll` 属性来启用滚动条。 2. 将 `pagination` 属性设置为 `false`,以禁用默认的分页。 3. 使用 `@scroll` 事件监听表格滚动事件。 4. 在滚动事件处理函数中,根据滚动条位置和表格高度计算出当前页码。 5. 根据当前页码,使用 `dataSource` 属性来更新表格数据。 具体实现可参考以下代码示例: ```html <template> <a-table :columns="columns" :dataSource="dataSource" :scroll="{ y: 400 }" :pagination="false" @scroll="handleScroll"> <template slot="name" slot-scope="text">{{ text }}</template> </a-table> </template> <script> import { Table } from 'ant-design-vue'; export default { components: { 'a-table': Table, }, data() { return { columns: [ { title: 'Name', dataIndex: 'name', key: 'name', width: 150, }, { title: 'Age', dataIndex: 'age', key: 'age', width: 70, }, { title: 'Address', dataIndex: 'address', key: 'address', width: 200, }, ], dataSource: [], currentPage: 1, }; }, mounted() { this.loadData(); }, methods: { loadData() { // 根据当前页码加载数据 const pageSize = 10; const start = (this.currentPage - 1) * pageSize; const end = start + pageSize; const data = []; for (let i = start; i < end; i++) { data.push({ key: i, name: `User ${i}`, age: Math.floor(Math.random() * 30) + 20, address: `Street ${i}`, }); } this.dataSource = data; }, handleScroll(e) { const tableBody = e.target.querySelector('.ant-table-body'); // 计算当前页码 const currentPage = Math.floor(tableBody.scrollTop / tableBody.clientHeight) + 1; if (currentPage !== this.currentPage) { this.currentPage = currentPage; this.loadData(); } }, }, }; </script> ``` 在以上代码中,我们设置表格高度为 400px,并禁用了默认的分页。当表格滚动时,会触发 `handleScroll` 方法来更新当前页码并加载数据。注意,为了方便起见,这里的数据是随机生成的,实际应用中需要根据实际情况来获取数据。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值