ant desgin vue 两个表格选中一个 另一个表格禁用

  <a-table
      :row-selection="rowSelection"
      :columns="columnstk"
      :data-source="datatk"
      :pagination="false"
      :scroll="{ y: 200 }"
      :row-key="(record) => record"
    >
      <template #qrCode="{ record }">
        <span v-if="record.processRelType == 1">
          <a-input v-model:value="record.qrCode" placeholder="请输入绑码号" />
        </span>
        <span> </span>
      </template>
   
      <template #operation="{ record }">
        <div class="editable-row-operations">
          <span v-if="editableData[record.id]">
            <a-button type="link" @click="save(record)">保存</a-button>
            <a-button type="link" @click="canle(record.id)">取消</a-button>
          </span>
          <span v-else>
            <a-button type="link" @click="edittbh(record.id)">编辑</a-button>
          </span>
        </div>
      </template>
    </a-table>
  <a-table
      :columns="columnsykg"
      :data-source="dataykg"
      :expand-icon-as-cell="false"
      :default-expand-all="false"
      class="components-table-demo-nested"
      :pagination="false"
      :showHeader="false"
      :row-selection="rowselections"
      :defaultExpandAllRows="defaultExpandAllRows"
      v-if="dataykg && dataykg.length"
      :row-key="(record) => record.id"
      :expandIconColumnIndex="-1"
    >
    </a-table>

 这里的selectedRowKeys1是表一的 通过下面这个勾选事件触发 表二  表一有长度   就禁用表一

反之  表二同理

  const rowselections = {
    onChange: (selectedRowKeys: Key[]) => {
      // console.log(selectedRowKeys, '0000');


      console.log(selectedRowKeys2.value, '222222');
    },
    getCheckboxProps: () => ({
      disabled: selectedRowKeys1.value.length > 0 ? true : false, // Column configuration not to be checked
    }),
  };

如果使用折叠表格的话  想让表格一渲染就默认展开  并且隐藏折叠按钮的话

      :defaultExpandAllRows="true"  默认首次展开
      v-if="dataykg && dataykg.length"  有长度会每次都展开
      :expandIconColumnIndex="-1"   隐藏按钮


 

  • 13
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
### 回答1: Ant Design Vue 表格(Table)组件支持通过 `row-class-name` 属性来设置行的样式类名。你可以使用该属性根据行数据的属性值来动态设置样式。 例如,假设你有一个表格,其中有一个 `status` 字段,它的值为 1 表示正常,值为 0 表示异常。你可以在 `row-class-name` 中设置一个函数,根据 `status` 的值来返回不同的样式类名,如下所示: ```html <template> <a-table :row-class-name="getRowClassName" :columns="columns" :data-source="dataSource"></a-table> </template> <script> export default { data() { return { columns: [ // 列定义 ], dataSource: [ // 数据源 ] }; }, methods: { getRowClassName(record) { return record.status === 0 ? 'error-row' : ''; }, }, }; </script> <style> .error-row { background-color: #ffcccc; } </style> ``` 在上面的代码中,`getRowClassName` 方法接收一个参数 `record`,它是当前行的数据对象。该方法根据 `record.status` 的值来判断是否应该添加 `error-row` 样式类名。当 `status` 的值为 0 时,该行将会添加 `error-row` 类名,从而显示为红色背景。 ### 回答2: 在Ant Design Vue中,我们可以使用Table组件来展示数据,并根据需求定制表格行的样式。具体的步骤如下: 1. 首先,在使用Table组件时,我们需要通过定义columns数组来描述表格的列信息,包括列的标题、字段名等。示例如下: ``` const columns = [ { title: '姓名', dataIndex: 'name', }, { title: '年龄', dataIndex: 'age', }, // 其他列信息 ]; ``` 2. 如果想要为特定行设置样式,可以通过定义rowClassName属性来实现。我们可以给rowClassName传入一个函数,该函数会接收当前行数据作为参数,并返回一个字符串作为该行的类名。示例如下: ``` const rowClassName = (record, index) => { if (record.age > 30) { return 'highlight-row'; } return ''; }; ``` 3. 在CSS里定义highlight-row类,来设置需要突出显示的行的样式。示例如下: ```css .highlight-row { background-color: yellow; font-weight: bold; } ``` 4. 将定义好的columns和rowClassName应用到Table组件中。示例如下: ``` <template> <a-table :columns="columns" :data-source="data" :row-class-name="rowClassName"></a-table> </template> ``` 这样,当data中的某一行的age大于30时,该行的背景颜色会变成黄色,并加粗显示。 总结:通过定义columns和rowClassName属性,我们可以在Ant Design Vue的Table组件中设置表格行的样式,以满足个性化的需求。 ### 回答3: ant design vue表格行样式可以通过自定义的scoped样式和slot-scope来实现。 首先,在样式中添加特定的class来定义表格行的样式,例如定义一个名为"custom-row"的class: ```css .custom-row { background-color: #f5f5f5; } ``` 接下来,在表格组件中使用slot-scope来获取每一行的数据,并通过判断条件来添加自定义的class: ```html <template> <a-table :data-source="dataSource"> <a-table-column title="姓名"> <template slot-scope="text, record"> <a :class="{ 'custom-row': record.age > 30 }"> {{ record.name }} </a> </template> </a-table-column> <a-table-column title="年龄" dataIndex="age"></a-table-column> </a-table> </template> ``` 在上述代码中,通过slot-scope获取到每一行的数据,然后在a标签上使用:class来绑定自定义的class,使用条件判断来确定是否添加该class。 通过以上的代码,当表格中的某一行的年龄大于30时,该行的背景颜色会变为灰色。 备注:以上是使用scoped样式和slot-scope实现表格行样式的一种方法,当然也可以根据具体需求使用其他方法来实现。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值