Skip to content

Commit

Permalink
fix(table): wrong tag label style #134
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Dec 30, 2020
1 parent d9b58e4 commit e09e0a1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
14 changes: 12 additions & 2 deletions src/components/Table/src/hooks/useColumns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ function handleIndexColumn(
getPaginationRef: ComputedRef<boolean | PaginationProps>,
columns: BasicColumn[]
) {
const { showIndexColumn, indexColumnProps, ellipsis } = unref(propsRef);
const { showIndexColumn, indexColumnProps } = unref(propsRef);

let pushIndexColumns = false;
columns.forEach((item) => {
const { children } = item;
handleItem(item, !!ellipsis);

const isTreeTable = children && children.length;

const indIndex = columns.findIndex((column) => column.flag === INDEX_COLUMN_FLAG);
Expand Down Expand Up @@ -114,6 +114,16 @@ export function useColumns(
if (!columns) {
return [];
}
const { ellipsis } = unref(propsRef);

columns.forEach((item) => {
const { customRender, slots } = item;

handleItem(
item,
Reflect.has(item, 'ellipsis') ? !!item.ellipsis : !!ellipsis && !customRender && !slots
);
});
return columns;
});

Expand Down
12 changes: 4 additions & 8 deletions src/components/Table/src/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,16 @@
}
}

&-img__preview {
display: flex;

img {
margin-right: 4px;
}
}

&--inset {
.ant-table-wrapper {
padding: 0;
}
}

.ant-tag {
margin-right: 0;
}

.ant-table-wrapper {
padding: 8px;
background: #fff;
Expand Down
14 changes: 14 additions & 0 deletions src/views/demo/table/CustomerCell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
:imgList="['https://picsum.photos/id/66/346/216', 'https://picsum.photos/id/67/346/216']"
/>
</template>

<template #category="{ record }">
<Tag color="green">
{{ record.no }}
</Tag>
</template>
</BasicTable>
</div>
</template>
Expand All @@ -24,6 +30,13 @@
dataIndex: 'id',
slots: { customRender: 'id' },
},
{
title: '分类',
dataIndex: 'category',
width: 80,
align: 'center',
slots: { customRender: 'category' },
},
{
title: '姓名',
dataIndex: 'name',
Expand Down Expand Up @@ -60,6 +73,7 @@
title: '自定义列内容',
api: demoListApi,
columns: columns,
bordered: true,
});
return {
Expand Down

0 comments on commit e09e0a1

Please sign in to comment.