BillingAdd.js
7.55 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
/**
* 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";
export default class BillingAdd 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/backB.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/closeB.png')} resizeMode="contain"/>
</TouchableOpacity>
</View>),
headerRight:(<View style={{flexDirection: 'row',flex:1}}>
<TouchableOpacity style={{flexDirection: 'column',justifyContent: 'center',paddingRight:15,paddingLeft:10}} onPress={navigation.state.params?navigation.state.params._save:null}>
<Text style={{fontSize:16,color:"#000"}} >保存</Text>
</TouchableOpacity>
</View>)
});
constructor(props) {
super(props);
this.state = {
legalentityName:"",
creditCode:"",
bankAccountName:"",
bankAccountNumber:"",
legalentityAddress:"",
phoneNumber:"",
};
}
componentDidMount(){
let _this=this;
//设置头部
this.props.navigation.setParams({
_goBack:()=>{
this.props.navigation.goBack();
},
_close:()=>{
NativeModules.system.navTo("BACK")
},
_save:()=>{
_this._save();
}
});
};
render() {
return (
<View style={styles.body}>
<ScrollView style={styles.list}>
<View style={styles.item} >
<TextInput style={styles.input} autoFocus={true}
placeholder="输入开票公司名称" placeholderTextColor="#dddddd"
value={this.state.legalentityName}
onChangeText={v => {this.setState({legalentityName: v});}}
underlineColorAndroid={'transparent'}
/>
</View>
<View style={styles.item} >
<TextInput style={styles.input}
placeholder="输入统一社会信用代码" placeholderTextColor="#dddddd"
value={this.state.creditCode}
onChangeText={v => {this.setState({creditCode: v});}}
underlineColorAndroid={'transparent'}
/>
</View>
<View style={styles.item} >
<TextInput style={styles.input}
placeholder="输入开户银行账号名称" placeholderTextColor="#dddddd"
value={this.state.bankAccountName}
onChangeText={v => {this.setState({bankAccountName: v});}}
underlineColorAndroid={'transparent'}
/>
</View>
<View style={styles.item} >
<TextInput style={styles.input}
placeholder="输入开户银行账号" placeholderTextColor="#dddddd"
value={this.state.bankAccountNumber}
onChangeText={v => {this.setState({bankAccountNumber: v});}}
underlineColorAndroid={'transparent'}
/>
</View>
<View style={styles.item} >
<TextInput style={styles.input}
placeholder="输入单位地址" placeholderTextColor="#dddddd"
value={this.state.legalentityAddress}
onChangeText={v => {this.setState({legalentityAddress: v});}}
underlineColorAndroid={'transparent'}
/>
</View>
<View style={styles.item} >
<TextInput style={styles.input} keyboardType="phone-pad"
placeholder="输入电话号码" placeholderTextColor="#dddddd"
value={this.state.phoneNumber}
onChangeText={v => {this.setState({phoneNumber: v});}}
underlineColorAndroid={'transparent'}
/>
</View>
</ScrollView>
</View>
);
}
_save=()=>{
let _this=this;
if(!_this.state.legalentityName){
xnToast("输入开票公司名称!");
return
}
if(!_this.state.creditCode){
xnToast("输入统一社会信用代码!");
return
}
if(!_this.state.bankAccountName){
xnToast("输入开户银行账号名称!");
return
}
if(!_this.state.bankAccountNumber){
xnToast("输入开户银行账号!");
return
}
if(!_this.state.legalentityAddress){
xnToast("输入单位地址!");
return
}
if(!_this.state.phoneNumber){
xnToast("输入电话号码!");
return
}
var item={
unionId:global.unionId,
legalentityName:_this.state.legalentityName,
creditCode:_this.state.creditCode,
bankAccountName:_this.state.bankAccountName,
bankAccountNumber:_this.state.bankAccountNumber,
legalentityAddress:_this.state.legalentityAddress,
phoneNumber:_this.state.phoneNumber,
};
AppService.createLegalentity(item).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:"#f0eff5",
},
list:{
flex:1
},
item:{
flexDirection:"row",
alignItems:"center",
backgroundColor:"#fff",
marginTop:10,
height:45,
},
input:{
flex:1,
paddingLeft:8,
paddingRight:8,
}
});