Commit e09e0a12531977d679ab0f4574f4016d4c5b2ad0

Authored by vben
1 parent d9b58e46

fix(table): wrong tag label style #134

src/components/Table/src/hooks/useColumns.ts
... ... @@ -40,12 +40,12 @@ function handleIndexColumn(
40 40 getPaginationRef: ComputedRef<boolean | PaginationProps>,
41 41 columns: BasicColumn[]
42 42 ) {
43   - const { showIndexColumn, indexColumnProps, ellipsis } = unref(propsRef);
  43 + const { showIndexColumn, indexColumnProps } = unref(propsRef);
44 44  
45 45 let pushIndexColumns = false;
46 46 columns.forEach((item) => {
47 47 const { children } = item;
48   - handleItem(item, !!ellipsis);
  48 +
49 49 const isTreeTable = children && children.length;
50 50  
51 51 const indIndex = columns.findIndex((column) => column.flag === INDEX_COLUMN_FLAG);
... ... @@ -114,6 +114,16 @@ export function useColumns(
114 114 if (!columns) {
115 115 return [];
116 116 }
  117 + const { ellipsis } = unref(propsRef);
  118 +
  119 + columns.forEach((item) => {
  120 + const { customRender, slots } = item;
  121 +
  122 + handleItem(
  123 + item,
  124 + Reflect.has(item, 'ellipsis') ? !!item.ellipsis : !!ellipsis && !customRender && !slots
  125 + );
  126 + });
117 127 return columns;
118 128 });
119 129  
... ...
src/components/Table/src/style/index.less
... ... @@ -24,20 +24,16 @@
24 24 }
25 25 }
26 26  
27   - &-img__preview {
28   - display: flex;
29   -
30   - img {
31   - margin-right: 4px;
32   - }
33   - }
34   -
35 27 &--inset {
36 28 .ant-table-wrapper {
37 29 padding: 0;
38 30 }
39 31 }
40 32  
  33 + .ant-tag {
  34 + margin-right: 0;
  35 + }
  36 +
41 37 .ant-table-wrapper {
42 38 padding: 8px;
43 39 background: #fff;
... ...
src/views/demo/table/CustomerCell.vue
... ... @@ -10,6 +10,12 @@
10 10 :imgList="['https://picsum.photos/id/66/346/216', 'https://picsum.photos/id/67/346/216']"
11 11 />
12 12 </template>
  13 +
  14 + <template #category="{ record }">
  15 + <Tag color="green">
  16 + {{ record.no }}
  17 + </Tag>
  18 + </template>
13 19 </BasicTable>
14 20 </div>
15 21 </template>
... ... @@ -25,6 +31,13 @@
25 31 slots: { customRender: 'id' },
26 32 },
27 33 {
  34 + title: '分类',
  35 + dataIndex: 'category',
  36 + width: 80,
  37 + align: 'center',
  38 + slots: { customRender: 'category' },
  39 + },
  40 + {
28 41 title: '姓名',
29 42 dataIndex: 'name',
30 43 width: 120,
... ... @@ -60,6 +73,7 @@
60 73 title: '自定义列内容',
61 74 api: demoListApi,
62 75 columns: columns,
  76 + bordered: true,
63 77 });
64 78  
65 79 return {
... ...