• 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>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    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
      }
    ]);
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    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>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
  • 相关阅读:
    顶级AI工具大盘点!
    【Docker】Docker Network(网络)
    webpack优化系列五:vue项目配置 webpack-obfuscator 进行代码加密混淆
    微电子/集成电路专业学术期刊汇总!
    19.12 Boost Asio 获取远程进程
    20232831 袁思承 2023-2024-2 《网络攻防实践》第7次作业
    汇编语言实验1:汇编语言环境的搭建与使用
    Build Data Visualization Apps
    R可视乎|灯芯柱状图代码解读
    create_ncc_model
  • 原文地址:https://blog.csdn.net/baidu_37302589/article/details/132688549