Comment.js
9.85 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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
/**
* Created by DEV005 on 2017/11/13.
*/
/**
* Created by tdzl2003 on 12/18/16.
*/
import React, {Component} from "react";
import {
Image,
ListView,
NativeModules,
StyleSheet,
Text,
TextInput,
TouchableOpacity,
View,
Platform,
RefreshControl,
ActivityIndicator,
ScrollView,
Dimensions,
Modal
} from "react-native";
import dismissKeyboard from 'react-native/Libraries/Utilities/dismissKeyboard';
import {NavigationActions,StackActions} from 'react-navigation'
import { observable, useStrict, action } from 'mobx';
import { observer } from 'mobx-react';
import {xnToast} from "../utils/utils";
import AppService from "../service/AppService";
import ApprovedLayout from './public/ApprovedLayout';
import moment from "moment";
import WfQuickCommentView from "../components/WfQuickCommentView";
export default class Detail extends Component {
static navigationOptions = ({ navigation, screenProps })=>({
});
constructor(props){
super(props);
this.state = {
content:"",
placeholder:""
};
}
status=this.props.navigation.state.params.status||"";
params=this.props.navigation.state.params;
isRequired=false;
ajaxLoading=false;
componentDidMount(){
let _this=this;
//设置头部
this.props.navigation.setParams({
title:_this.params.title||"审批意见",
isBack:true
});
_this.init();
}
init=()=>{
let _this=this;
switch (_this.status){
//通过
case "approve":
_this.setState({
placeholder:"请输入同意理由(非必填)"
})
_this.isRequired=false;
break;
// 拒绝
case "reject":
_this.setState({
placeholder:"请输入拒绝理由(必填)"
})
_this.isRequired=true;
break;
case "transfer":
_this.setState({
placeholder:"请输入转交理由(非必填)"
})
_this.isRequired=false;
break;
//回退
case "untread":
_this.setState({
placeholder:"请输入回退理由(必填)"
})
_this.isRequired=true;
break;
//评论
case "comment":
_this.setState({
placeholder:"说点什么呗..."
})
_this.isRequired=true;
break;
}
}
doSave=()=>{
let _this=this;
let vm={
id:_this.params.id, //stepId
flowId:_this.params.flowId,
rowVersion:_this.params.rowVersion,
tenantId:global.tenantId,
submitDescription:_this.state.content||""
};
if(_this.ajaxLoading){
return;
}
switch (_this.status){
//通过
case "approve":
//同意
_this.ajaxLoading=true;
AppService.approveFlowStep(vm).then(data=> {
_this.ajaxLoading=false;
if (data.errors == null || data.errors.length > 0) {
xnToast(data.errors[0].message);
return
}
xnToast("已同意!");
dismissKeyboard();
_this.toPage()
});
break;
// 拒绝
case "reject":
//拒绝
if(_this.isRequired &&!vm.submitDescription){
xnToast("拒绝理由不能为空!")
return ;
}
_this.ajaxLoading=true;
AppService.rejectFlowStep(vm).then(data=> {
_this.ajaxLoading=false;
if (data.errors == null || data.errors.length > 0) {
xnToast(data.errors[0].message);
return
}
xnToast("已拒绝!");
dismissKeyboard();
_this.toPage()
});
break;
case "transfer":
if(!_this.params.submitUser){
xnToast("提交人不能为空!");
return
}
vm.assignUserName=_this.params.submitUser.name
vm.assignUserId=_this.params.submitUser.id,
vm.assignReason=_this.state.content||"",
console.log(vm);
_this.ajaxLoading=true;
AppService.transferFlowStep(vm).then(data=> {
_this.ajaxLoading=false;
if (data.errors == null || data.errors.length > 0) {
xnToast(data.errors[0].message);
return
}
xnToast("已转交!");
dismissKeyboard();
_this.toPage();
});
break;
//回退
case "untread":
vm.assignReason=_this.state.content||"";
if(_this.isRequired &&!vm.assignReason){
xnToast("回退理由不能为空!")
return ;
}
//回退
_this.ajaxLoading=true;
AppService.untreadFlowStep(vm).then(data=> {
_this.ajaxLoading=false;
if (data.errors == null || data.errors.length > 0) {
xnToast(data.errors[0].message);
return
}
xnToast("已回退!");
dismissKeyboard();
_this.toPage()
});
break;
//评论
case "comment":
let comment={
content:_this.state.content||"",
businessType:"WORKFLOW",
anonymous:false,
userId:global.userId,
businessId:_this.params.flowId,
}
if(_this.isRequired &&!comment.content){
xnToast("评论内容不能为空!")
return ;
}
//回退
_this.ajaxLoading=true;
AppService.createComment(comment).then(data=> {
_this.ajaxLoading=false;
if (data.errors == null || data.errors.length > 0) {
xnToast(data.errors[0].message);
return
}
xnToast("已评论!");
_this.params.callback();
dismissKeyboard();
_this.props.navigation.goBack();
});
break;
}
}
toPage=()=>{
if (!!global.initParam && global.initParam.page){
global.initParam.page = undefined
}
const resetAction = StackActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: 'TabNav'})
]
})
this.props.navigation.dispatch(resetAction)
};
render() {
let text='';
switch (this.status) {
case "approve":
text = '同意';
break;
case "reject":
//拒绝
text = '拒绝';
break;
case "transfer":
text = '转交';
break;
//回退
case "untread":
text = '回退';
break;
}
return (
<View style={styles.body}>
<View style={styles.input}>
<TextInput
placeholder={this.state.placeholder}
style={styles.inputArea}
multiline={true}
underlineColorAndroid="transparent"
onChangeText={(text)=>{
this.setState({
content:text,
})
}}
value={this.state.content}
/>
</View>
{(this.status == 'approve' || this.status == 'reject') &&
<WfQuickCommentView
style={{flex:1}}
category={'approve'}
userId={global.userId}
chooseCallback={(text)=>{
let current = this.state.content;
current += text;
this.setState({
content:current
})
}}
/>
}
<TouchableOpacity onPress={()=>this.doSave()} style={{width:'70%',height:44,marginTop:10,backgroundColor:global.homeColor,justifyContent:'center',alignItems: "center",borderRadius:4}}>
<Text style={{color:'#fff'}}>确认{text}</Text>
</TouchableOpacity>
</View>
);
}
}
const styles = StyleSheet.create({
body:{
flex:1,
flexDirection:"column",
backgroundColor:"#ecf0f3",
alignItems:'center'
},
input: {
paddingLeft:0,
paddingTop: 15,
paddingRight:0,
marginBottom:15,
width:'100%'
},
inputArea: {
fontSize: 14,
height: 200,
lineHeight:24,
textAlignVertical: "top",
backgroundColor:"#fff",
padding:15
},
});