<template>
<TsTable :singleLine="true" :scrollInline="true" :columns="data.columns" :dataSource="data.dataSource">
<template #expand>
<div class="docs-table-expand-wrap ts-select-none">
<div class="docs-table-expand-item">查看</div>
<div class="docs-table-expand-item">预览</div>
</div>
</template>
</TsTable>
<TsTable :auto-fit="false" :columns="longColumns" :dataSource="longDataSource" single-line :scrollInline="true">
<template #deliveryAreas="{ row }">
<div class="tag-wrap">
<TsTag v-for="(item, index) in row.deliveryAreas" :key="index">{{ item }}</TsTag>
</div>
</template>
</TsTable>
</template>
<script setup lang="ts">
const data = {
columns: [
{ title: 'name', key: 'name' },
{ title: 'age', key: 'age' },
{ title: 'address', key: 'address', width: '1500px' },
{ title: '操作', key: 'expand', custom: true, fixed: 'right' },
],
dataSource: [
{ name: 'John Brown', age: 32, address: 'New York No. 1 Lake Park' },
{ name: 'Jim Green', age: 42, address: 'London No. 1 Lake Park' },
{ name: 'Joe Black', age: 32, address: 'Sydney No. 1 Lake Park' },
]
}
const longColumns = [
{ title: '产品编号', key: 'productCode' },
{ title: '产品名称', key: 'productName', showOverflowTooltip: true },
{ title: '供应商ID', key: 'supplierId', showOverflowTooltip: true },
{ title: '供应商密钥', key: 'supplierSecret', showOverflowTooltip: true },
{ title: '库存数量', key: 'stockCount' },
{ title: '保质期(天)', key: 'shelfLife' },
{ title: '是否热销', key: 'isHot', render: (row: any) => (row.isHot ? '是' : '否') },
{ title: '是否新品', key: 'isNew', render: (row: any) => (row.isNew ? '是' : '否') },
{ title: '支持配送区域', key: 'deliveryAreas', custom: true, minWidth: 200 },
{ title: '是否包邮', key: 'isFreeShipping', render: (row: any) => (row.isFreeShipping ? '是' : '否') },
{ title: '是否限购', key: 'isLimited', render: (row: any) => (row.isLimited ? '是' : '否') },
{ title: '商品类型', key: 'productType' },
{ title: '上架时间', key: 'createdAt', showOverflowTooltip: true },
{ title: '更新时间', key: 'updatedAt', showOverflowTooltip: true },
{ title: '操作', key: 'actions', custom: true, fixed: 'right' },
];
const longDataSource = [
{
productId: 'p10002',
productCode: 'PRD-002',
productName: '蓝牙耳机 AirLite',
supplierId: 'SUP-101',
supplierSecret: 'sec-xyz789qwxyz789qweisiajakkeisiajakk',
deliveryAreas: ['华北', '东北', '西北', '华中'],
isHot: false,
isNew: true,
isFreeShipping: false,
isLimited: true,
stockCount: 50,
shelfLife: 180,
productType: '音频设备',
createdAt: '2025-02-01 09:12:45',
updatedAt: '2025-03-21 11:00:00',
},
{
productId: 'p10003',
productCode: 'PRD-003',
productName: '空气净化器 Pro',
supplierId: 'SUP-102',
supplierSecret: 'sec-555aaa7770555aaa77708s82jskak8s82jskak',
deliveryAreas: ['全国'],
isHot: true,
isNew: true,
isFreeShipping: true,
isLimited: false,
stockCount: 300,
shelfLife: 720,
productType: '家用电器',
createdAt: '2025-02-10 14:35:20',
updatedAt: '2025-03-22 13:25:56',
},
{
productId: 'p10004',
productCode: 'PRD-004',
productName: '运动水杯 Max',
supplierId: 'SUP-103',
supplierSecret: 'sec-999bbb3999bbb333sajslalallsl33sajslalallsl',
deliveryAreas: ['华东', '华中'],
isHot: false,
isNew: false,
isFreeShipping: true,
isLimited: true,
stockCount: 200,
shelfLife: 1095,
productType: '生活用品',
createdAt: '2025-03-01 08:50:05',
updatedAt: '2025-03-23 18:45:33',
},
];
</script>