Skip to content

Commit a597947

Browse files
author
liyuan-meng
committed
[CTable]解决时间范围列模板报错问题
1 parent bc97133 commit a597947

6 files changed

Lines changed: 19 additions & 7 deletions

File tree

src/components/c-table/columnTpl/link.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export default function LinkTpl({ value, row, linkKey, link }) {
2727
ref={ref}
2828
className={`${prefixCls}-table-column-tpl-link`}
2929
onClick={() => {
30-
if (link || row[linkKey]) {
31-
window.open(link || row[linkKey]);
30+
if (link || row?.[linkKey]) {
31+
window.open(link || row?.[linkKey]);
3232
}
3333
}}
3434
>

src/components/c-table/columnTpl/multiLink.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export default function MultiLinkTpl({ value, row, linkKey }) {
2727
ref={ref}
2828
className={`${prefixCls}-table-column-tpl-multi-link`}
2929
onClick={() => {
30-
if (row[linkKey]) {
31-
window.open(row[linkKey]);
30+
if (row?.[linkKey]) {
31+
window.open(row?.[linkKey]);
3232
}
3333
}}
3434
>

src/components/c-table/columnTpl/timeRange.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export default function TimeRangeTpl({
1010
startValue,
1111
endValue,
1212
}) {
13-
const start = startValue || row[startKey];
14-
const end = endValue || row[endKey];
13+
const start = startValue || row?.[startKey];
14+
const end = endValue || row?.[endKey];
1515
if (!start && !end) {
1616
return '-';
1717
}

src/components/c-table/demos/uniform_tag.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ const data = [
5050
{ label: '标签4标签4标签4标签4标签4标签4标签4标签4', value: 4 }
5151
]
5252
},
53+
{
54+
tag: [],
55+
tagInfo: []
56+
},
5357
];
5458

5559
const columns = [

src/components/c-table/demos/uniform_text.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const data = [
2020
{ id: '121408294', name: '文本文本超长超长超长超长超长超长超长超长超长超长超长超长超长超长超长超长', url: 'https://www.taobao.com', createTime: '2021/12/13 11:14:40', creator: 'xiaotong.fan' },
2121
{ id: '121407191', name: '文本文本文本文本文本3', url: 'https://www.taobao.com', createTime: '2021/12/13 11:03:05', creator: 'zhenxiao.guo' },
2222
{ id: '121407192', name: '文本文本4', url: '', createTime: '2021/12/13 11:03:07', creator: 'han.wu' },
23+
{ id: '', name: '', url: '', createTime: '', creator: '' },
2324
];
2425

2526
const columns = [

src/components/c-table/demos/uniform_tpl.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ const data = [
6262
{ label: '标签4', value: 4 }
6363
]
6464
},
65+
{
66+
number: null,
67+
startTime: '',
68+
endTime: '',
69+
name: '',
70+
tagInfo: []
71+
},
6572
];
6673

6774
const columns = [
@@ -86,7 +93,7 @@ const columns = [
8693
dataIndex: 'startTime',
8794
width: 160,
8895
render: (val, row) => {
89-
return <CTable.TimeRangeTpl value={val} format="YYYY-MM-DD" startValue={row.startTime} endValue={row.endTime} />
96+
return <CTable.TimeRangeTpl format="YYYY-MM-DD" startValue={row.startTime} endValue={row.endTime} />
9097
}
9198
},
9299
{

0 commit comments

Comments
 (0)