ApprovedLayout.js
8.49 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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
/**
*
* Copyright 2016-present reading
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import React ,{Component} from 'react';
import {StyleSheet, Text, View, Image, TouchableOpacity, NativeModules} from 'react-native';
import {xnToast,xnBorderWidth,toPersonalPageWithUserId} from "../../utils/utils";
import moment from "moment";
let dayTime=moment(new Date()).utc().zone(-8).format('YYYY-MM-DD');
class ApprovedLayout extends Component {
constructor(props) {
super(props);
this.state = {
submitUserName:"张三",
processName:"张三提交的请假单",
flowStatus:"IN_PROCESS"
};
}
render() {
const approvedList=this.props.approvedList;
return (
<View style={styles.approvedLayout}>
{ approvedList.map((v, i) => this._renderRow(v, i))}
</View>
)
}
//
_renderRow = (v, i) =>{
const length= this.props.approvedList.length-1;
let shotName="";
// 开始节点是在RN里自己创建的,头像需要靠
if(v.status == 'START' && !!this.props.startUserAvatar){
v.avatar = this.props.startUserAvatar;
}
if(v.auditUserName && v.auditUserName.length>2){
shotName =v.auditUserName.substring(v.auditUserName.length-2)
}else if(v.auditUserName && v.auditUserName.length>0) {
shotName =v.auditUserName;
}
if(v.endTime){
let submitTimeDay=moment(new Date(Number(v.endTime))).utc().zone(-8).format('YYYY-MM-DD');
if(submitTimeDay!=dayTime){
v.showMonth=moment(new Date(Number(v.endTime))).utc().zone(-8).format('MM/DD')
v.showTime=moment(new Date(Number(v.endTime))).utc().zone(-8).format('HH:mm')
}else{
v.showMonth="今天";
v.showTime=moment(new Date(Number(v.endTime))).utc().zone(-8).format('HH:mm');
}
}else{
v.showTime=""
}
return (
<View style={styles.approvedRow} key={i}>
<View style={styles.approvedTime}>
<Text style={styles.approvedTimeText}>{v.showTime}</Text>
<Text style={styles.approvedTimeText}>{v.showMonth}</Text>
</View>
<View style={styles.approvedLineLayout} >
<View style={[styles.approvedLine]}></View>
{v.status=="RUNNING"&&<View style={[styles.approvedLineIconActive]}></View>}
{v.status!="RUNNING"&&<View style={[styles.approvedLineIcon]}></View>}
</View>
<View style={styles.approvedBox}>
<TouchableOpacity style={[styles.approvedImg,{backgroundColor:global.homeColor}]} onPress={()=>{
if(v.status == 'START'){
toPersonalPageWithUserId(this.props.startUserId);
}else{
toPersonalPageWithUserId(v.auditUserId);
}
}}>
{!v.avatar&&<Text style={styles.approvedImgText}>{shotName}</Text>}
{v.avatar&& <Image style={styles.approvedImgAvatar} source={{uri:v.avatar}} resizeMode="contain"></Image>}
</TouchableOpacity>
<View style={styles.approvedContent}>
<View style={styles.approvedName}>
<Text style={styles.approvedNameText}>{v.auditUserName}</Text>
<Text style={[styles.approvedResultText,{marginLeft:10,paddingLeft:10,borderLeftWidth:1,borderLeftColor:"#ddd"}]} >{v.position}</Text>
</View>
<View style={styles.approvedResult}>
{v.status=="EXECUTED"&&v.status=="NONE"&&<Text style={[styles.infoPass,styles.infoWidth]} >自动通过</Text>}
{v.status=="EXECUTED"&&v.auditResult=="NONE"&&<Text style={[styles.infoPass,styles.infoWidth]} >自动通过</Text>}
{v.status=="EXECUTED"&&v.auditResult=="UNTREAD"&&<Text style={[styles.infoError,styles.infoWidth]} >回退</Text>}
{v.status=="EXECUTED"&&v.auditResult=="APPROVE"&&<Text style={[styles.infoPass,styles.infoWidth]} >同意</Text>}
{v.status=="EXECUTED"&&v.auditResult=="REJECT"&&<Text style={[styles.infoError,styles.infoWidth]} >拒绝</Text>}
{v.status=="EXECUTED"&&v.auditResult=="WITHDRAW"&&<Text style={[styles.infoError,styles.infoWidth]} >撤回</Text>}
{v.status=="EXECUTED"&&v.auditResult=="TRANSFER"&&<Text style={[styles.infoInProcess,styles.infoWidth]} >转交</Text>}
{v.status=="EXECUTED"&&v.auditResult=="TAKE"&&<Text style={[styles.approvedResultText,styles.infoWidth]} >受理</Text>}
{v.status=="RUNNING"&&<Text style={[styles.infoInProcess,styles.infoWidth]} >审批中</Text>}
{v.status=="WAITING"&&<Text style={[styles.infoInProcess,styles.infoWidth]} >待审批</Text>}
{v.status=="START"&&<Text style={[styles.approvedResultText,styles.infoWidth]} >提交</Text>}
<Text style={[styles.approvedResultText]} >{v.auditContent}</Text>
</View>
</View>
</View>
</View>
)
};
}
const styles = StyleSheet.create({
approvedLayout: {
paddingLeft: 15,
paddingRight: 10,
backgroundColor: "#eee",
},
approvedRow: {
flexDirection:"row"
},
approvedTime:{
paddingTop:15,
width:40,
},
approvedTimeText:{
fontSize:10,
color:"#999"
},
approvedLineLayout:{
width:20,
marginRight:15,
alignItems:"center",
paddingTop:15,
},
approvedLine: {
position:"absolute",
left:"50%",
top:0,
bottom:0,
width:xnBorderWidth(),
backgroundColor: "#d8d8d8",
zIndex:1
},
approvedLineIconActive: {
position: "relative",
zIndex:10,
width:14,
height:14,
backgroundColor: "#52c26e",
borderRadius:7
},
approvedLineIcon: {
position: "relative",
zIndex:10,
width:10,
height:10,
backgroundColor: "#d8d8d8",
borderRadius:5
},
approvedBox:{
flex:1,
borderWidth:xnBorderWidth(),
borderColor:"#eee",
borderStyle:"solid",
paddingTop: 15,
paddingBottom: 15,
paddingLeft: 10,
paddingRight: 10,
borderRadius:4,
backgroundColor: "#fff",
marginTop:10,
marginBottom:10,
flexDirection:"row"
},
approvedImg:{
width:40,
height:40,
marginRight:10,
justifyContent:"center",
alignItems:"center",
backgroundColor: "#39f",
borderRadius:4,
},
approvedImgText:{
color:"#fff",
fontSize:10
},
approvedImgAvatar:{
width:40,
height:40,
borderRadius:4,
},
approvedContent:{
flex:1,
flexDirection:"column"
},
approvedName:{
height:20,
flexDirection:"row",
alignItems:"center",
},
approvedNameText:{
fontSize:14,
color:"#333"
},
approvedResult:{
marginRight:5,
marginTop:5,
flex: 1,
flexDirection:"row",
},
approvedResultText:{
fontSize:10,
marginRight:5,
color:"#999",
},
infoInProcess:{
fontSize:10,
marginRight:5,
color:"#dcc38a",
},
infoPass:{
fontSize:10,
marginRight:5,
color:"#52c26e",
},
infoError:{
fontSize:10,
marginRight:5,
color:"#ea281a",
},
infoWidth:{
}
});
export default ApprovedLayout;