TBSearch.js
5.28 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
/**
* Created by yzdd on 2018/3/11.
*/
import React, {Component} from 'react';
import {
View,
Text,
StyleSheet,
Image,
TextInput,
FlatList
} from 'react-native';
import SearchBox from "../components/SearchBox";
import {width} from "../utils/publiscStyle";
import SeperatorLine from "../components/SeperatorLine";
import {observer} from 'mobx-react/native';
import {observable} from 'mobx';
const styles = StyleSheet.create({
container: {
flex: 1,
},
con: {
backgroundColor: "#FFFFFF",
paddingLeft: 15,
},
itemView: {
width: width - 15,
height: 65,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
paddingRight: 15
},
icon3: {
width: 47,
height: 47,
marginRight: 14
},
leftCon: {
flexDirection: 'row',
alignItems: 'center'
},
titleCon: {
height: 47,
justifyContent: "center",
alignItems: "flex-start"
},
font2: {
fontSize: 16,
color: "#000000"
},
font3: {
fontSize: 17,
color: "#000000"
},
font4: {
fontSize: 12,
color: "#999999",
marginTop: 2
},
font5: {
fontSize: 14,
color: "#000000",
marginTop: 2
},
font6: {
fontSize: 14
},
rightCon: {
justifyContent: 'center',
alignItems: "flex-end"
},
emptyView: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: "#FFFFFF"
},
icon4: {
width: 80,
height: 80
},
font9: {
fontSize: 14,
color: "#999999",
marginTop: 15
}
});
const inLoad = require("../assests/inLoad.png");
const outLoad = require("../assests/outLoad.png");
const readyLoad = require("../assests/readyLoad.png");
const noResult = require("../assests/noResult.png")
const data = [
{status: 0, mess: "舟山项目出差", time: "12-20 09:10", day: 1},
{status: 2, mess: "舟山项目出差", time: "12-20 09:10", day: 2},
{status: 1, mess: "舟山项目出差", time: "12-20 09:10", day: 3},
{status: 0, mess: "宠儿宠物出差", time: "12-20 09:10", day: 4},
{status: 3, mess: "舟山项目出差", time: "12-20 09:10", day: 5},
{status: 1, mess: "上海出差", time: "12-20 09:10", day: 6},
{status: 3, mess: "舟山项目出差", time: "12-20 09:10", day: 7},
{status: 2, mess: "项目组出差", time: "12-20 09:10", day: 8},
];
//搜索页面
@observer
export default class TBSearch extends Component {
static navigationOptions = ({navigation}) => {
return {
title: "差旅"
}
};
renderItem = (item, index) => {
return (
<Item navigation={this.props.navigation} item={item} index={index}/>
)
};
@observable
searchText = "";
render() {
return (
<View style={styles.container}>
<SearchBox
onChangeText={(text) => this.searchText = text}
value={this.searchText}
/>
{
this.searchText !== "" ?
data.filter((v, i) => v.mess.indexOf(this.searchText) !== -1).length !== 0 ?
<FlatList
style={styles.con}
data={data.filter((v, i) => v.mess.indexOf(this.searchText) !== -1)}
keyExtractor={(item, index) => index}
renderItem={({item, index}) => this.renderItem(item, index)}
ItemSeparatorComponent={() => <SeperatorLine width={width - 15}/>}
/> :
<View style={styles.emptyView}>
<Image
source={noResult}
resizeMode={"contain"}
style={styles.icon4}
/>
<Text style={styles.font9}>无搜索结果</Text>
</View>
: null
}
</View>
);
}
}
class Item extends Component {
getImage = (status) => {
switch (status) {
case 0:
return <Image
source={readyLoad}
resizeMode={"contain"}
style={styles.icon3}
/>;
case 3:
return <Image
source={readyLoad}
resizeMode={"contain"}
style={styles.icon3}
/>;
case 1:
return <Image
source={inLoad}
resizeMode={"contain"}
style={styles.icon3}
/>;
case 2:
return <Image
source={outLoad}
resizeMode={"contain"}
style={styles.icon3}
/>;
}
};
getStatus = (status) => {
switch (status) {
case 0:
return <Text style={[styles.font6, {color: "#ff5c05"}]}>{"待审批"}</Text>;
case 3:
return <Text style={[styles.font6, {color: "#ff5c05"}]}>{"待提交"}</Text>;
case 1:
return <Text style={[styles.font6, {color: "#22ab38"}]}>{"已通过"}</Text>;
case 2:
return <Text style={[styles.font6, {color: "#ea281a"}]}>{"被驳回"}</Text>;
}
};
render() {
const {item} = this.props;
return (
<View style={styles.itemView}>
<View style={styles.leftCon}>
{
this.getImage(item.status)
}
<View style={styles.titleCon}>
<Text style={styles.font3}>{item.mess}</Text>
<Text style={styles.font4}>{item.time}</Text>
</View>
</View>
<View style={styles.rightCon}>
{this.getStatus(item.status)}
<Text style={styles.font5}>{item.day + "天"}</Text>
</View>
</View>
)
}
}