BillingBatch.js
8.34 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
/**
* Created by DEV005 on 2017/11/21.
*/
/**
* 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 { observable, useStrict, action } from 'mobx';
import { observer } from 'mobx-react';
import {xnToast,getHeaderHeight,getHeaderPadding,getFooterBottom,xnBorderWidth} from "../utils/utils";
import AppService from "../service/AppService";
import xnMainCss from "../css/css";
export default class BillingList extends Component {
static navigationOptions = ({ navigation, screenProps })=>({
title: '我的开票公司',
headerLeft:(<View style={{flexDirection: 'row',flex:1}}>
<TouchableOpacity style={{flexDirection: 'column',justifyContent: 'center',paddingRight:15,paddingLeft:10}} onPress={navigation.state.params?navigation.state.params._goBack:null}>
<Image style={{ width:16,height:16}} source={require('../img/back.png')} resizeMode="contain"/>
</TouchableOpacity>
<TouchableOpacity style={{flexDirection: 'column',justifyContent: 'center',paddingRight:15,paddingLeft:15}} onPress={navigation.state.params?navigation.state.params._close:null}>
<Image style={{ width:16,height:16}} source={require('../img/close.png')} resizeMode="contain"/>
</TouchableOpacity>
</View>)
});
constructor(props) {
super(props);
this.state = {
list:[],
totalCount:0,
selectTotal:0
};
}
componentDidMount(){
let _this=this;
//设置头部
this.props.navigation.setParams({
_goBack:()=>{
this.props.navigation.goBack();
},
_close:()=>{
NativeModules.system.navTo("BACK")
}
});
this.getList()
};
getList=(parent)=>{
let _this=this;
let vm={
unionId:global.unionId
};
AppService.getLegalentityAllList(vm).then(data=>{
if (data.errors == null || data.errors.length > 0) {
xnToast(data.errors[0].message);
return
}
let list=data.result||[];
let newList=[];
for(let i=0; i<list.length;i++){
if(list[i].legalentityName){
list[i].selectActive=false;
if(list[i].legalentityName){
list[i].shortName=list[i].legalentityName.substring(0,1);
}
newList.push(list[i]);
}
};
console.log(list);
_this.setState({
list:list,
totalCount:newList.length,
});
})
};
render() {
return (
<View style={styles.body}>
<ScrollView style={styles.list}>
<View style={xnMainCss.xnRowLayout}>
{this.state.list.map((v, i) => this.rowContent(v, i))}
</View>
</ScrollView>
<View style={styles.footLayout}>
<Text style={styles.footInfo}>已选择{this.state.selectTotal}条</Text>
<TouchableOpacity style={styles.footBtn} onPress={()=>{this.save()}}><Text style={styles.footBtnText}>确定({this.state.selectTotal}/{this.state.totalCount})</Text></TouchableOpacity>
</View>
</View>
);
}
rowContent = (v, i) =>{
return (
<View key={i}>
<TouchableOpacity style={xnMainCss.xnRow} onPress={()=>{this.select(v)}} activeOpacity={1}>
<View style={[xnMainCss.xnRowhd]}>
{v.selectActive&&<Image style={styles.xnRowIcon} source={require('../img/selectActive.png')} resizeMode="contain"></Image>}
{!v.selectActive&&<Image style={styles.xnRowIcon} source={require('../img/select.png')} resizeMode="contain"></Image>}
</View>
<View style={[xnMainCss.xnRowhd,styles.imgIcon]}>
<Text style={[xnMainCss.xnRowhdText,styles.imgText]}>{v.shortName}</Text>
</View>
<View style={xnMainCss.xnRowbd }>
<Text style={xnMainCss.xnColumnTiTle}>{v.legalentityName}</Text>
</View>
</TouchableOpacity>
</View>
)
};
select=(item)=>{
let _this=this;
let selectTotal=_this.state.selectTotal;
if(item.selectActive){
selectTotal--;
}else {
selectTotal++;
}
var list=_this.state.list;
for(let i=0; i<list.length;i++){
if(list[i].legalentityName==item.legalentityName){
list[i].selectActive=!list[i].selectActive;
break;
}
};
_this.setState({
selectTotal:selectTotal,
list:list,
});
};
save=()=>{
let _this=this;
if(this.state.selectTotal==0){
xnToast("请选择开票公司!");
return
}
let list=_this.state.list;
let vm={
list:[]
};
for(let i=0;i<list.length;i++){
if(list[i].selectActive){
var item={
unionId:global.unionId,
legalentityName:list[i].legalentityName,
creditCode:list[i].creditCode,
bankAccountName:list[i].bankAccountName,
bankAccountNumber:list[i].bankAccountNumber,
legalentityAddress:list[i].legalentityAddress,
phoneNumber:list[i].phoneNumber,
}
vm.list.push(item);
}
}
AppService.importLegalentityList(vm).then(data=>{
if (data.errors == null || data.errors.length > 0) {
xnToast(data.errors[0].message);
return
}
_this.props.navigation.navigate("Billing");
})
}
}
const styles = StyleSheet.create({
body:{
flex:1,
flexDirection:"column",
backgroundColor:"#fff",
},
list:{
flex:1
},
item:{
flexDirection:"row",
alignItems:"center",
backgroundColor:"#fff",
borderBottomWidth:xnBorderWidth(),
borderBottomColor:"#ddd",
padding:8,
},
imgIcon:{
width:20,
height:20,
alignItems:"center",
justifyContent:"center",
backgroundColor:"#39f",
borderRadius:4,
marginRight:10
},
imgText:{
textAlign:"center",
fontSize:14,
color:"#fff",
},
itemInfo:{
flex:1,
justifyContent:"center",
height:30,
},
itemInfoText:{
color:"#333",
fontSize:14,
},
link:{
width:10,
height:10,
borderTopWidth:xnBorderWidth(),
borderTopColor:"#666",
borderRightWidth:xnBorderWidth(),
borderRightColor:"#666",
transform:[
{rotate:'45deg'},
],
},
bookItemSelect:{
marginLeft:10,
width:20,
height:20,
justifyContent:"center",
alignItems:"center",
marginRight:10,
},
bookItemSelectImg:{
width:20,
height:20,
},
footLayout:{
paddingTop:10,
paddingBottom:10,
backgroundColor:"#eee",
borderTopWidth:xnBorderWidth(),
borderTopColor:"#ddd",
paddingLeft:15,
paddingRight:15,
paddingTop:8,
paddingBottom:8,
flexDirection:"row",
height:50,
justifyContent:"center",
alignItems:"center",
},
footInfo:{
flex:1,
color:"#39f"
},
footBtn:{
backgroundColor:"#3399ff",
height:35,
justifyContent:"center",
alignItems:"center",
paddingLeft:8,
paddingRight:8,
borderRadius:6
},
footBtnText:{
color:"#fff"
},
});