ant vue3 自定义table一行两列

效果图

在这里插入图片描述

table代码
<a-table
        size="small"
        :columns="columns"
        :row-key="(record, index) => index + 1"
        :data-source="tableInfo.data"
        :pagination="false"
        @change="handleTableChange"
        @resizeColumn="handleResizeColumn"
        bordered
        :scroll="{ x: '100%', y: '66vh' }"
        :row-selection="{
          selectedRowKeys: tableInfo.selectedRowKeys,
          onChange: onSelectChange,
          type: 'radio'
        }"
        :row-class-name="(_record, index) => (index % 2 === 1 ? 'table-striped' : null)"
      >
        <template
          #customFilterDropdown="{ setSelectedKeys, selectedKeys, confirm, clearFilters, column }"
        >
          <CustomFilterBox
            :setSelectedKeys="setSelectedKeys"
            :selectedKeys="selectedKeys"
            :confirm="confirm"
            :clearFilters="clearFilters"
            :placeHolder="`Enter ${column.title}`"
          />
        </template>
        <template #bodyCell="{ column, record }">
          <template v-if="column.dataIndex === 'nominalSize'">
            <p>{{ record.nickName }}</p>
            <a-divider class="my-divider" />
            <a-tooltip placement="left" :title="record.nominalSize">
              <p>{{ record.nominalSize }}</p>
            </a-tooltip>
          </template>
          <template v-if="column.dataIndex === 'qdNo'">
            <p>{{ record.kindProduct }}</p>
            <a-divider class="my-divider" />
            <p>{{ record.qdNo }}</p>
          </template>
          <template v-if="column.dataIndex === 'temper'">
            <p>{{ record.partNo }}</p>
            <a-divider class="my-divider" />
            <p>{{ record.temper }}</p>
          </template>
          <template v-if="column.dataIndex === 'production'">
            <a-tooltip placement="left" :title="record.quality">
              <p>{{ record.quality }}</p>
            </a-tooltip>
            <a-divider class="my-divider" />
            <a-tooltip placement="left" :title="record.production">
              <p>{{ record.production }}</p>
            </a-tooltip>
          </template>
          <template v-if="column.dataIndex === 'other'">
            <a-tooltip placement="left" :title="record.customer">
              <p>{{ record.customer }}</p>
            </a-tooltip>
            <a-divider class="my-divider" />
            <a-tooltip placement="left" :title="record.other">
              <p>{{ record.other }}</p>
            </a-tooltip>
          </template>
          <template v-if="column.dataIndex === 'placeOfDelivery'">
            <div style="text-align: start">{{ record.placeOfDelivery }}</div>
          </template>
        </template>
      </a-table>
colum代码
const columns = reactive([
  {
    title: "Nick Name",
    dataIndex: "nickName",
    customFilterDropdown: true,
    width: 200,
    sorter: true,
    children: [
      {
        title: "Nominal Size",
        dataIndex: "nominalSize",
        customFilterDropdown: true,
        sorter: true,
        resizable: true,
        width: 220
      }
    ]
  },
  {
    title: "Kind Product",
    dataIndex: "kindProduct",
    customFilterDropdown: true,
    width: 200,
    sorter: true,
    customRender: ({ text }) => {
      return text === ":" ? "" : text;
    },
    children: [
      {
        title: "QD No",
        dataIndex: "qdNo",
        resizable: true,
        sorter: true,
        customFilterDropdown: true,
        width: 200
      }
    ]
  },
  {
    title: "PartNo",
    dataIndex: "partNo",
    customFilterDropdown: true,
    width: 200,
    sorter: true,
    children: [
      {
        title: "Temper",
        dataIndex: "temper",
        customFilterDropdown: true,
        resizable: true,
        sorter: true,
        width: 200
      }
    ]
  },
  {
    title: "Remark1(Quality)",
    dataIndex: "quality",
    customFilterDropdown: true,
    width: 200,
    sorter: true,
    children: [
      {
        title: "Remark2(Production)",
        dataIndex: "production",
        customFilterDropdown: true,
        resizable: true,
        sorter: true,
        width: 200
      }
    ]
  },
  {
    title: "Remark3(Customer)",
    dataIndex: "customer",
    customFilterDropdown: true,
    width: 200,
    sorter: true,
    children: [
      {
        title: "Remark4(Other)",
        dataIndex: "other",
        customFilterDropdown: true,
        resizable: true,
        sorter: true,
        width: 200
      }
    ]
  },
  {
    title: "Place of Delivery",
    dataIndex: "placeOfDelivery",
    sorter: true,
    customFilterDropdown: true
  }
]);
css代码
<style scoped lang="less">
p {
  margin-bottom: 0em;
  min-height: 22px;
  line-height: 22px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  overflow: hidden;
  cursor: pointer;
}

.my-divider {
  height: 1px;
  background-color: #f0f0f0;
  margin: 6px 0px;
}
</style>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值