enterprise_edit.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. import React, {Component} from 'react';
  2. import {
  3. View,
  4. Image,
  5. TouchableHighlight,
  6. Text,
  7. StyleSheet,
  8. TextInput,
  9. TouchableOpacity,
  10. Dimensions,
  11. ScrollView,
  12. KeyboardAvoidingView,
  13. DeviceEventEmitter,
  14. } from 'react-native';
  15. import login_css from '../login/login_css';
  16. import public_css from '../../source/css/public_css';
  17. import loading_css from '../../source/css/loading_css';
  18. import Spinner from 'react-native-loading-spinner-overlay';
  19. import {GetDataPost} from '../../data/encryption';
  20. import {ShowToast} from '../../components/rootToast/root_toast';
  21. import {RetrieveData, StorageData} from '../../data/storage';
  22. export default class enterprise_edit extends Component {
  23. constructor(props) {
  24. super(props);
  25. this.props.navigation.dangerouslyGetParent().setOptions({
  26. tabBarVisible: false,
  27. });
  28. this.ent = this.props.route.params.enterprise;
  29. this.state = {
  30. entName: this.ent.entName,
  31. entTaxId: this.ent.entTaxId,
  32. entAddress: this.ent.entAddress,
  33. entContactPerson: this.ent.entContactPerson,
  34. entPhone: this.ent.entPhone,
  35. bankAccountName: this.ent.bankAccountName,
  36. bankAccountNumber: this.ent.bankAccountNumber,
  37. payees: this.ent.payees,
  38. reviewers: this.ent.reviewers,
  39. req_channel: '',
  40. spinner: false,
  41. };
  42. }
  43. render() {
  44. return (
  45. <KeyboardAvoidingView
  46. enabled
  47. style={{flex: 1, backgroundColor: '#ffffff'}}>
  48. <ScrollView>
  49. <View>
  50. <Spinner
  51. visible={this.state.spinner}
  52. textContent={'Loading...'}
  53. textStyle={loading_css.spinnerTextStyle}
  54. />
  55. <View style={login_css.inputView}>
  56. <View style={[public_css.view, public_css.lineTopBottom]}>
  57. <Text
  58. style={[
  59. public_css.text,
  60. {fontFamily: 'PingFang-SC-Regular', color: '#333333'},
  61. ]}>
  62. 企业名称:
  63. </Text>
  64. <TextInput
  65. style={public_css.textInputStyle}
  66. value={this.state.entName}
  67. clearButtonMode="while-editing"
  68. secureTextEntry={false}
  69. editable={false}
  70. />
  71. </View>
  72. <View style={[public_css.view, public_css.lineTopBottom]}>
  73. <Text
  74. style={[
  75. public_css.text,
  76. {fontFamily: 'PingFang-SC-Regular', color: '#333333'},
  77. ]}>
  78. *企业税号:
  79. </Text>
  80. <TextInput
  81. style={public_css.textInputStyle}
  82. value={this.state.entTaxId}
  83. clearButtonMode="while-editing"
  84. secureTextEntry={false}
  85. onChangeText={text => {
  86. this.setState({
  87. entTaxId: text,
  88. });
  89. }}
  90. />
  91. </View>
  92. <View style={[public_css.view, public_css.lineTopBottom]}>
  93. <Text
  94. style={[
  95. public_css.text,
  96. {fontFamily: 'PingFang-SC-Regular', color: '#333333'},
  97. ]}>
  98. 公司地址:
  99. </Text>
  100. <TextInput
  101. style={public_css.textInputStyle}
  102. value={this.state.entAddress}
  103. placeholder="请输入公司地址"
  104. clearButtonMode="while-editing"
  105. secureTextEntry={false}
  106. onChangeText={text => {
  107. this.setState({
  108. entAddress: text,
  109. });
  110. }}
  111. />
  112. </View>
  113. <View style={[public_css.view, public_css.lineTopBottom]}>
  114. <Text style={public_css.text}>企业联系人:</Text>
  115. <TextInput
  116. style={public_css.textInputStyle}
  117. value={this.state.entContactPerson}
  118. placeholder="请输入企业联系人"
  119. clearButtonMode="while-editing"
  120. secureTextEntry={false}
  121. onChangeText={text => {
  122. this.setState({
  123. entContactPerson: text,
  124. });
  125. }}
  126. />
  127. </View>
  128. <View style={[public_css.view, public_css.lineTopBottom]}>
  129. <Text style={public_css.text}>企业电话:</Text>
  130. <TextInput
  131. style={public_css.textInputStyle}
  132. value={this.state.entPhone}
  133. placeholder="请输入企业电话"
  134. clearButtonMode="while-editing"
  135. secureTextEntry={false}
  136. onChangeText={text => {
  137. this.setState({
  138. entPhone: text,
  139. });
  140. }}
  141. />
  142. </View>
  143. <View style={[public_css.view, public_css.lineTopBottom]}>
  144. <Text style={public_css.text}>企业银行户名:</Text>
  145. <TextInput
  146. style={public_css.textInputStyle}
  147. value={this.state.bankAccountName}
  148. placeholder="请输入企业银行户名"
  149. clearButtonMode="while-editing"
  150. secureTextEntry={false}
  151. onChangeText={text => {
  152. this.setState({
  153. bankAccountName: text,
  154. });
  155. }}
  156. />
  157. </View>
  158. <View style={[public_css.view, public_css.lineTopBottom]}>
  159. <Text style={public_css.text}>*企业银行账号:</Text>
  160. <TextInput
  161. style={public_css.textInputStyle}
  162. value={this.state.bankAccountNumber}
  163. placeholder="请输入企业银行账号"
  164. clearButtonMode="while-editing"
  165. secureTextEntry={false}
  166. onChangeText={text => {
  167. this.setState({
  168. bankAccountNumber: text,
  169. });
  170. }}
  171. />
  172. </View>
  173. <View
  174. style={[
  175. public_css.view,
  176. public_css.lineTopBottom,
  177. {alignItems: 'center'},
  178. ]}>
  179. <Text style={public_css.text}>*收款人:</Text>
  180. <TextInput
  181. style={public_css.textInputStyle}
  182. placeholder="请输入收款人"
  183. clearButtonMode="while-editing"
  184. secureTextEntry={false}
  185. value={this.state.payees}
  186. editable={false}
  187. />
  188. <View style={{marginRight: 20}}>
  189. <TouchableOpacity
  190. onPress={() => {
  191. this.props.navigation.navigate('enterprise_user', {
  192. type: 1,
  193. data: this,
  194. });
  195. }}>
  196. <Image
  197. source={require('../../source/img/productImg/addIcon.png')}
  198. style={{height: 16, width: 16}}
  199. />
  200. </TouchableOpacity>
  201. </View>
  202. </View>
  203. <View
  204. style={[
  205. public_css.view,
  206. public_css.lineTopBottom,
  207. {alignItems: 'center'},
  208. ]}>
  209. <Text style={public_css.text}>审核者:</Text>
  210. <TextInput
  211. style={public_css.textInputStyle}
  212. placeholder="请输入审核者"
  213. clearButtonMode="while-editing"
  214. secureTextEntry={false}
  215. value={this.state.reviewers}
  216. editable={false}
  217. />
  218. <View style={{marginRight: 20}}>
  219. <TouchableOpacity
  220. onPress={() => {
  221. this.props.navigation.navigate('enterprise_user', {
  222. type: 2,
  223. data: this,
  224. });
  225. }}>
  226. <Image
  227. source={require('../../source/img/productImg/addIcon.png')}
  228. style={{height: 16, width: 16}}
  229. />
  230. </TouchableOpacity>
  231. </View>
  232. </View>
  233. </View>
  234. </View>
  235. </ScrollView>
  236. <View style={public_css.bottomStaus}>
  237. <TouchableOpacity
  238. style={[public_css.statusBtn, public_css.statusLBtn]}
  239. onPress={() => {
  240. this.setState({
  241. entName: this.ent.entName,
  242. entTaxId: this.ent.entTaxId,
  243. entAddress: this.ent.entAddress,
  244. entContactPerson: this.ent.entContactPerson,
  245. entPhone: this.ent.entPhone,
  246. bankAccountName: this.ent.bankAccountName,
  247. bankAccountNumber: this.ent.bankAccountNumber,
  248. payees: this.ent.payees,
  249. reviewers: this.ent.reviewers,
  250. });
  251. }}>
  252. <Image
  253. source={require('../../source/img/productImg/clear.png')}
  254. style={{width: 32, height: 32}}
  255. />
  256. <Text>全部清除</Text>
  257. </TouchableOpacity>
  258. <TouchableOpacity
  259. style={[public_css.statusBtn, public_css.statusRBtn]}
  260. onPress={() => this.submitData()}>
  261. <Image
  262. source={require('../../source/img/productImg/confirm.png')}
  263. style={{width: 32, height: 32}}
  264. />
  265. <Text style={{color: '#fff'}}>确定添加</Text>
  266. </TouchableOpacity>
  267. </View>
  268. </KeyboardAvoidingView>
  269. );
  270. }
  271. //提交数据
  272. submitData = async () => {
  273. let number = this.state.bankAccountNumber;
  274. if (!number) {
  275. ShowToast('企业银行帐号不可以为空!');
  276. return;
  277. }
  278. let payees = this.state.payees;
  279. if (!payees) {
  280. ShowToast('收款人不可以为空!');
  281. return;
  282. }
  283. let entTaxId = this.state.entTaxId;
  284. if (!entTaxId) {
  285. ShowToast('客户税号不可以为空!');
  286. return;
  287. }
  288. this.setLoadingStatus(true);
  289. let token = await RetrieveData('token');
  290. let account = await RetrieveData('account');
  291. if (token && account) {
  292. token = token.substring(1, token.length - 1);
  293. account = account.substring(1, account.length - 1);
  294. const url = '/sys/entInfo/updateBriefInfo';
  295. let response = await GetDataPost(
  296. url,
  297. token,
  298. {
  299. entTaxId: this.state.entTaxId,
  300. entAddress: this.state.entAddress,
  301. entContactPerson: this.state.entContactPerson,
  302. entPhone: this.state.entPhone,
  303. bankAccountName: this.state.bankAccountName,
  304. bankAccountNumber: this.state.bankAccountNumber,
  305. payees: this.state.payees,
  306. reviewers: this.state.reviewers,
  307. reqChannel: 3,
  308. userMobile: account,
  309. },
  310. false,
  311. 1,
  312. );
  313. if (response) {
  314. if (response.code == 0) {
  315. ShowToast('编辑成功!');
  316. this.setLoadingStatus(false);
  317. this.props.navigation.goBack();
  318. DeviceEventEmitter.emit('企业信息刷新', '');
  319. } else {
  320. ShowToast('编辑失败!');
  321. this.setLoadingStatus(false);
  322. }
  323. } else {
  324. ShowToast(response.msg);
  325. this.setLoadingStatus(false);
  326. }
  327. }
  328. };
  329. //设置loading层是否显示
  330. setLoadingStatus(isLoading) {
  331. this.setState({
  332. spinner: isLoading,
  333. });
  334. }
  335. //加载页面时显示数据
  336. componentDidMount(): void {
  337. // this.getCompanyData();
  338. }
  339. setPayees = data => {
  340. this.setState({
  341. payees: data,
  342. });
  343. };
  344. setReviewers = data => {
  345. this.setState({
  346. reviewers: data,
  347. });
  348. };
  349. }