TabDetailView.js
2.86 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
89
90
91
92
93
94
95
96
97
98
99
import React, {Component} from 'react';
import {
View,
Text,
TextInput,
Image,
} from 'react-native';
import {
Cell,
DataTable,
Header,
HeaderCell,
Row,
EditableCell,
CheckableCell,
} from 'react-native-data-table';
/**
* 表格/明细 组件
*/
export default class TabDetailView extends Component {
constructor(props) {
super(props);
}
renderHeader() {
return (
<Header>
<HeaderCell style={styles.headerCell} key="1" text="选择" width={1} />
<HeaderCell
style={styles.headerCell}
key="2"
text="序号"
width={1}
onPress={() => this.onColumnSort()}
/>
<HeaderCell
style={styles.headerCell}
key="3"
text="科室名称"
width={3}
isAscending={false}
onPress={() => this.onColumnSort()}
/>
<HeaderCell
style={styles.headerCell}
key="4"
text="数量"
width={1}
isAscending={false}
onPress={() => this.onColumnSort()}
/>
</Header>
);
}
renderRow(item) {
let rowStyle = item.no%2 === 0 ? styles.whiteRow : styles.row;
return (
<Row style={rowStyle}>
<CheckableCell
style={styles.cell}
width={1}
onPress={() => this.onCheckablePress()}
renderIsChecked={() => (
<Icon name="checkbox-blank-outline" size={20} color="blue" />
)}
renderIsNotChecked={() => (
<Icon name="checkbox-marked" size={20} color="blue" />
)}
isChecked={item.isChecked}
/>
<Cell style={styles.cell} width={1}>
{item.no}
</Cell>
<Cell style={styles.cell} width={3}>
{item.name}
</Cell>
<EditableCell width={1} value={item.qty} onEndEditing={(target, value) => {}}>
</EditableCell>
</Row>
);
}
render() {
return(
<View style={{width: '100%', backgroundColor: 'white', paddingHorizontal: 5, paddingVertical: 10}}>
<DataTable
style={styles.container}
listViewStyle={styles.container}
dataSource={this.state.ds}
renderRow={this.renderRow}
renderHeader={this.renderHeader}
/>
</View>
);
}
}