2021-7-26 表格勾选

本文介绍了一种表格勾选的实现方法,通过在展开表格时为子项添加属性来标识父子关系。在计算属性(rowSelection)中定义勾选逻辑,允许父项自由选择,而子项限制为只能选中一个。勾选状态的变更在onChange事件中处理。最后,提供一个getSelectedModels方法返回选中项的name和filename,并建议将组件以ref引用以便调用此方法。
摘要由CSDN通过智能技术生成

84

先贴个全的

<template>
  <div style="max-height:600px;overflow-y:auto">
    <a-table
      class="ant-table-striped"
      :rowClassName="
        (record, index) => (record.isChild ? 'table-striped' : null)
      "
      :columns="columns"
      :data-source="list"
      rowKey="id"
      v-custom-loading="LoadingData"
      :pagination="false"
      :row-selection="rowSelection"
      @expand="getDetail"
      :expandedRowKeys="expandedRowKeys"
      :expandIconColumnIndex="-1"
    >
      <template #createTime="{ record }">
        {
   {
    timeFormatter(record.last_time) }}
      </template>
      <template #type="{ record }"> {
   {
    record.type_name }}模型 </template>
      <template #last_transform_status="{ record }">
        {
   {
    Status[record.last_transform_status] }}
      </template>
      <template #operation1="{ record }">
        <a-button
          class="link-btn-in-table"
          type="link"
          @click="getDetail(record)"
          v-if="!record.isChild"
          >选择模型版本<up-outlined
            v-if="record.id === expandedRowKeys[0]"/><down-outlined v-else
        /></a-button>
      </template>
    </a-table>
    <div class="pagination">
      <a-pagination
        :current="page"
        :page-size="5"
        :total="total"
        :showTotal="(total, range) => `共${total}条`"
        @change="changePage"
      >
      </a-pagination>
    </div>
  </div>
</template>
<script>
import {
    getSelectModelsList, getDetailModelsList } from '@/requests'
import {
    DownOutlined, UpOutlined } from '@ant-design/icons-vue'
const Status = {
   
  0: '转换成功'
}
const columnConfig = [
  {
   
    title: '模型名称',
    dataIndex: 'name',
    key: 'name',
    ellipsis: true,
    width: 180
  },
  {
   
    title: '模型类型',
    dataIndex: 'type',
    key: 'type',
    slots: {
    customRender: 'type' },
    width: 120,
    ellipsis: true
  },
  {
   
    title: '生成时间',
    dataIndex: 'last_time',
    key: 'last_time',
    ellipsis: true,
    width: 180,
    slots: {
    customRender: 'createTime' }
  },
  {
   
    title: '最新状态',
    dataIndex: 'last_transform_status',
    key: 'last_transform_status',
    slots: {
    customRender: 'last_transform_status' },
    width: 120
  },
  {
   
    title: '模型框架',
    dataIndex: 'framework',
    key: 'framework',
    ellipsis: tru
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值