forked from alibaba/ice
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLiteTable.jsx
More file actions
88 lines (78 loc) · 2.06 KB
/
LiteTable.jsx
File metadata and controls
88 lines (78 loc) · 2.06 KB
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
import React, { Component } from 'react';
import IceContainer from '@icedesign/container';
import { Table } from '@icedesign/base';
import './LiteTable.scss';
const styles = {
processing: {
color: '#5485F7',
},
finish: {
color: '#64D874',
},
terminated: {
color: '#999999',
},
pass: {
color: '#FA7070',
},
};
const generatorMockStatus = () => {
const random = parseInt(Math.random() * 10, 10);
if (random < 3) {
return 'processing';
} else if (random >= 3 && random < 6) {
return 'finish';
} else if (random >= 6 && random < 8) {
return 'terminated';
} else if (random >= 8) {
return 'pass';
}
};
const generatorData = () => {
return Array.from({ length: 10 }).map((item, index) => {
return {
project: `这里是字数不能太长的项目名 ${index}`,
owner: `开发者 ${index}`,
status: generatorMockStatus(),
};
});
};
const statusComponents = {
processing: <span style={styles.processing}>进行中</span>,
finish: <span style={styles.finish}>已完成</span>,
terminated: <span style={styles.terminated}>已终止</span>,
pass: <span style={styles.pass}>未通过</span>,
};
export default class LiteTable extends Component {
static displayName = 'LiteTable';
static propTypes = {};
static defaultProps = {};
constructor(props) {
super(props);
this.state = {
tableData: generatorData(),
};
}
renderStatus = (value) => {
return statusComponents[value];
};
render() {
const { tableData } = this.state;
return (
<div className="lite-table">
<IceContainer style={styles.tableCard}>
<Table dataSource={tableData} hasBorder={false}>
<Table.Column title="项目名称" dataIndex="project" width={160} />
<Table.Column title="创建者" dataIndex="owner" width={65} />
<Table.Column
title="状态"
dataIndex="status"
cell={this.renderStatus}
width={65}
/>
</Table>
</IceContainer>
</div>
);
}
}