RechargeAdd.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916
  1. import React, { Component } from 'react'
  2. import {
  3. StyleSheet,
  4. View,
  5. FlatList,
  6. Text,
  7. StatusBar,
  8. TouchableOpacity,
  9. Dimensions,
  10. ScrollView,
  11. TextInput,
  12. PixelRatio,
  13. ActivityIndicator,
  14. } from 'react-native'
  15. import { connect } from 'react-redux'
  16. import Icon from '../../../../components/Iconfont/Iconfont'
  17. import Collapsible from 'react-native-collapsible'
  18. import { HeaderView } from '../../../common/HeaderView'
  19. import SelectTime from '../../../common/SelectTime'
  20. import { NavigationActions, createAction } from '../../../../utils'
  21. import {
  22. ScaleUtil,
  23. accDiv,
  24. accAdd,
  25. ReturnDate,
  26. accSub,
  27. } from '../../../../utils/utils'
  28. import moment from 'moment'
  29. import Toast from 'react-native-root-toast'
  30. const { width, height } = Dimensions.get('window')
  31. @connect(({ theme, rechargeModels, mine }) => ({
  32. ...theme,
  33. ...rechargeModels,
  34. ...mine,
  35. }))
  36. class RechargeAdd extends Component {
  37. constructor(props) {
  38. super(props)
  39. this.state = {
  40. collapsed: true,
  41. allSaleData: [],
  42. chooseOrders:
  43. props.navigation.state.params && props.navigation.state.params.item
  44. ? props.navigation.state.params.item.billclaimDetailDto
  45. : [], //添加的关联订单
  46. payTime:
  47. props.navigation.state.params && props.navigation.state.params.item
  48. ? ReturnDate(props.navigation.state.params.item.claimTime, true)
  49. : ReturnDate(new Date(), true), // 付款单日期
  50. // 付款方信息
  51. payerText:
  52. props.navigation.state.params && props.navigation.state.params.item
  53. ? props.navigation.state.params.item.payAccountAccountName
  54. : '', // 付款方信息 - 付款方
  55. receiptSuppier:
  56. props.navigation.state.params && props.navigation.state.params.item
  57. ? props.navigation.state.params.item.saleOrgName
  58. : '', // 收款方信息 - 供应商Name
  59. receiptSuppierId:
  60. props.navigation.state.params && props.navigation.state.params.item
  61. ? props.navigation.state.params.item.saleOrgId
  62. : '', // 收款方信息 - 供应商Id
  63. // 收款方信息
  64. receipter:
  65. props.navigation.state.params && props.navigation.state.params.item
  66. ? props.navigation.state.params.item.financeOrgName
  67. : '', // 收款方信息 - 收款方Name
  68. receipterId:
  69. props.navigation.state.params && props.navigation.state.params.item
  70. ? props.navigation.state.params.item.financeOrgId
  71. : '', // 收款方信息 - 收款方Id
  72. receiptAccount:
  73. props.navigation.state.params && props.navigation.state.params.item
  74. ? props.navigation.state.params.item.receiptAccountAccountName
  75. : '', // 收款方信息 - 收款方账号Name
  76. receiptAccountId:
  77. props.navigation.state.params && props.navigation.state.params.item
  78. ? props.navigation.state.params.item.receiptAccountId
  79. : '', // 收款方信息 - 收款方账号Id
  80. // 付款业务信息
  81. payType: '', // 付款业务信息 - 收款业务类型Name
  82. payTypeId:
  83. props.navigation.state.params && props.navigation.state.params.item
  84. ? props.navigation.state.params.item.billreceiptType
  85. : '', // 付款业务信息 - 收款业务类型Id
  86. acountText:
  87. props.navigation.state.params && props.navigation.state.params.item
  88. ? props.navigation.state.params.item.money
  89. : '', // 付款业务信息 - 付款金额
  90. payWayName:
  91. props.navigation.state.params && props.navigation.state.params.item
  92. ? props.navigation.state.params.item.payWayName
  93. : '', //支付方式Name
  94. payWayCode:
  95. props.navigation.state.params && props.navigation.state.params.item
  96. ? props.navigation.state.params.item.payWayCode
  97. : '', //支付方式Id
  98. collapsedId: 'sad',
  99. }
  100. this.key = 1
  101. }
  102. // 跳转
  103. NavigateToOthers(routeName, params) {
  104. this.props.dispatch(
  105. NavigationActions.navigate({ routeName: routeName, params: params })
  106. )
  107. }
  108. // 请求
  109. RequestOthers(actionName, actionSearch, dispatchFinally) {
  110. this.props
  111. .dispatch(createAction(actionName)(actionSearch))
  112. .finally(dispatchFinally)
  113. }
  114. componentDidMount = () => {
  115. // 供应商
  116. this.RequestOthers(
  117. 'mine/getCusSup',
  118. {
  119. customerId: CUSTOMERINFO.id,
  120. customerRankCode: CUSTOMERINFO.customerRankCode,
  121. comeFrom: 'supplier',
  122. },
  123. () => {
  124. if (this.props.SupplierInfo) {
  125. const allsaleArr = []
  126. this.props.SupplierInfo.forEach(item => {
  127. allsaleArr.push(item.saleOrganizationId)
  128. })
  129. this.findFinanceBySaleOrg(allsaleArr)
  130. this.setState({ allSaleData: allsaleArr })
  131. }
  132. }
  133. )
  134. // 供应商
  135. this.RequestOthers('mine/getBillWay', '')
  136. // 收款业务类型
  137. this.RequestOthers('mine/getPayTypes', '', () => {
  138. if (
  139. this.state.payTypeId &&
  140. this.props.payTypesData &&
  141. this.props.payTypesData.length > 0
  142. ) {
  143. this.props.payTypesData.forEach(item => {
  144. if (item.id == this.state.payTypeId) {
  145. this.state.payType = item.name
  146. this.setState({ payType: item.name })
  147. }
  148. })
  149. }
  150. })
  151. }
  152. // 通过供应商寻财务组织
  153. findFinanceBySaleOrg(item) {
  154. this.RequestOthers('mine/findFinanceBySaleOrg', {
  155. saleOrgIds: item,
  156. // item && item.saleOrganizationId ? [item.saleOrganizationId] : []
  157. })
  158. }
  159. // 通过财务组织寻收款账户信息
  160. findAccountByFinance(item) {
  161. this.RequestOthers('mine/findAccountByFinanceSaga', {
  162. finanOrgId: item.finanOrgId,
  163. })
  164. }
  165. // 行显示
  166. rowShow(data) {
  167. return (
  168. <View
  169. style={{
  170. paddingVertical: 10,
  171. flexDirection: 'row',
  172. justifyContent: 'space-between',
  173. borderBottomColor: '#EEE',
  174. borderBottomWidth: data.isLast ? 0 : 1,
  175. }}
  176. >
  177. <Text style={{ fontSize: 14, color: '#333', letterSpacing: 0.17 }}>
  178. {data.titleName}
  179. </Text>
  180. <Text style={{ fontSize: 14, color: '#666', letterSpacing: 0.17 }}>
  181. {data.value}
  182. </Text>
  183. </View>
  184. )
  185. }
  186. // 行显示--时间
  187. rowShowForDate(data) {
  188. return (
  189. <View
  190. style={{
  191. paddingVertical: 10,
  192. flexDirection: 'row',
  193. justifyContent: 'space-between',
  194. borderBottomColor: '#EEE',
  195. borderBottomWidth: data.isLast ? 0 : 1,
  196. }}
  197. >
  198. <Text style={{ fontSize: 14, color: '#333', letterSpacing: 0.17 }}>
  199. {data.titleName}
  200. </Text>
  201. <TouchableOpacity
  202. onPress={() => {
  203. this.showTime._openModal()
  204. }}
  205. style={{ flexDirection: 'row' }}
  206. >
  207. <Text
  208. style={{
  209. fontSize: 14,
  210. color: data.value ? '#666' : '#CCC',
  211. letterSpacing: 0.17,
  212. }}
  213. >
  214. {data.value || '请选择'}
  215. </Text>
  216. <Icon
  217. name="icon-icon-xiala"
  218. color={'#999'}
  219. size={14}
  220. style={{
  221. justifyContent: 'center',
  222. marginLeft: 5,
  223. }}
  224. />
  225. </TouchableOpacity>
  226. </View>
  227. )
  228. }
  229. rowShowForInput(data) {
  230. return (
  231. <View
  232. style={{
  233. paddingVertical: 10,
  234. flexDirection: 'row',
  235. justifyContent: 'space-between',
  236. borderBottomColor: '#EEE',
  237. borderBottomWidth: data.isLast ? 0 : 1,
  238. alignItems: 'center',
  239. }}
  240. >
  241. <Text style={{ fontSize: 14, color: '#333', letterSpacing: 0.17 }}>
  242. {data.titleName}
  243. </Text>
  244. <TextInput
  245. style={{
  246. width: width / 2.5,
  247. padding: 0,
  248. fontSize: 14,
  249. lineHeight: 20,
  250. letterSpacing: 0.38,
  251. color: data.isAmount ? '#E70013' : '#333',
  252. marginTop: 4,
  253. textAlign: 'right',
  254. }}
  255. editable={
  256. this.state.chooseOrders && this.state.chooseOrders.length > 0
  257. ? false
  258. : true
  259. }
  260. autoCapitalize="none"
  261. autoCorrect={false}
  262. underlineColorAndroid={'transparent'}
  263. clearButtonMode="while-editing"
  264. onChangeText={text => data.onChange(text)}
  265. defaultValue={
  266. (typeof data.value == 'number'
  267. ? ScaleUtil(data.value, CURRENCY.currencyAmountScale)
  268. : data.value) + ''
  269. }
  270. multiline={false}
  271. // onSubmitEditing={() => this._searchindex()}
  272. placeholder={'请输入'}
  273. placeholderTextColor={'#CCC'}
  274. />
  275. </View>
  276. )
  277. }
  278. // 行显示-下拉
  279. rowShowCollapse(data) {
  280. const valueShow = []
  281. let touchKey
  282. if (data.value && data.value.length > 0) {
  283. data.value.forEach((item, key) => {
  284. valueShow.push(
  285. <TouchableOpacity
  286. onPress={() => {
  287. data.onTouch && data.onTouch(item)
  288. }}
  289. key={key}
  290. style={{
  291. paddingVertical: 10,
  292. flexDirection: 'row',
  293. justifyContent: 'space-between',
  294. }}
  295. >
  296. <Text
  297. style={{
  298. fontSize: 14,
  299. color: key == touchKey ? 'red' : '#666',
  300. letterSpacing: 0.17,
  301. }}
  302. >
  303. {item[data.nameKet]}
  304. </Text>
  305. <Icon
  306. name="icon-icon-duigou"
  307. color={'#999'}
  308. size={14}
  309. style={{
  310. justifyContent: 'center',
  311. marginLeft: 5,
  312. }}
  313. />
  314. </TouchableOpacity>
  315. )
  316. })
  317. }
  318. return (
  319. <View>
  320. <TouchableOpacity
  321. onPress={() => {
  322. if (this.state.collapsed == data.titleName) {
  323. this.setState({ collapsed: true })
  324. } else {
  325. this.setState({ collapsed: data.titleName })
  326. }
  327. }}
  328. style={{
  329. paddingVertical: 10,
  330. flexDirection: 'row',
  331. justifyContent: 'space-between',
  332. borderBottomColor: '#EEE',
  333. borderBottomWidth: data.isLast ? 0 : 1,
  334. }}
  335. >
  336. <Text style={{ fontSize: 14, color: '#333', letterSpacing: 0.17 }}>
  337. {data.titleName}
  338. </Text>
  339. <View style={{ flexDirection: 'row' }}>
  340. <Text
  341. style={{
  342. fontSize: 14,
  343. color: data.rightName ? '#666' : '#CCC',
  344. letterSpacing: 0.17,
  345. }}
  346. >
  347. {data.rightName || '请选择'}
  348. </Text>
  349. <Icon
  350. name="icon-icon-xiala"
  351. size={14}
  352. color={'#999'}
  353. style={{
  354. justifyContent: 'center',
  355. marginLeft: 5,
  356. transform: [
  357. {
  358. rotate:
  359. data.titleName !== this.state.collapsed
  360. ? '0deg'
  361. : '180deg',
  362. },
  363. ],
  364. }}
  365. />
  366. </View>
  367. </TouchableOpacity>
  368. {data.value && data.value.length > 0 ? (
  369. <Collapsible
  370. collapsed={data.titleName !== this.state.collapsed}
  371. align={'center'}
  372. >
  373. <View>{valueShow}</View>
  374. </Collapsible>
  375. ) : null}
  376. </View>
  377. )
  378. }
  379. associateOrder() {
  380. this.state.chooseOrders.push({
  381. key: this.key,
  382. amount: 0,
  383. paymentType: '',
  384. paymentTypeName: '',
  385. persistStatus: 'new',
  386. serialnum: this.key * 10,
  387. })
  388. this.setState({
  389. chooseOrders: this.state.chooseOrders,
  390. })
  391. this.key++
  392. }
  393. // 确定回调
  394. confirmCbFn(e) {
  395. this.calculateTotleAmt()
  396. }
  397. // 计算价格并赋值到付款金额上
  398. calculateTotleAmt(e) {
  399. let totleAmount = 0
  400. const returnData = e ? e : this.state.chooseOrders
  401. returnData.forEach(item => {
  402. totleAmount = ScaleUtil(
  403. accAdd(item.amount, totleAmount),
  404. CURRENCY.currencyAmountScale
  405. )
  406. })
  407. // if (returnData) {
  408. // this.setState({ chooseOrders: returnData });
  409. // }
  410. this.setState({ acountText: totleAmount })
  411. }
  412. // 提交的数据拼装
  413. payDataModal(flag, totleAmt) {
  414. const payReturnData = {
  415. billDate: new Date(this.state.payTime).getTime(),
  416. currencyName: CURRENCY.name,
  417. customerId: CUSTOMERINFO.id,
  418. payBillItemSet: this.state.chooseOrders,
  419. // payeeAccount: this.state.receiptAccountId, //收款方账号
  420. payeeId: this.state.receipterId, //收款方(财务组织)
  421. paymentAmount: this.state.acountText, //付款金额
  422. // paymentModeId: this.state.payWayCode, //支付方式
  423. paymentTypeId: this.state.payTypeId, //付款类型
  424. persistStatus: 'new',
  425. supplierId: this.state.receiptSuppierId,
  426. }
  427. return payReturnData
  428. }
  429. // 提交/暂存付款单
  430. submitPayment() {
  431. let payDataModal = this.payDataModal()
  432. if (
  433. payDataModal.payeeId &&
  434. payDataModal.paymentAmount > 0 &&
  435. payDataModal.paymentTypeId
  436. ) {
  437. this.NavigateToOthers('OrderPay', {
  438. submitData: payDataModal,
  439. totalAmount: payDataModal.paymentAmount,
  440. comeFrom: 'addPayBill',
  441. callBack: () => {
  442. this.props.navigation.state.params.goBackCb()
  443. },
  444. })
  445. } else {
  446. if (this.toast) {
  447. Toast.hide(this.toast)
  448. }
  449. this.toast = Toast.show(
  450. `请选择:${payDataModal.payeeId ? '' : ' "收款方" '}${
  451. this.state.payTime ? '' : ' "时间" '
  452. }${payDataModal.paymentAmount > 0 ? '' : ' "付款金额" '}${
  453. payDataModal.paymentTypeId ? '' : ' "付款类型" '
  454. } 后再保存/提交!`,
  455. { position: toastHeight }
  456. )
  457. }
  458. }
  459. render() {
  460. const {
  461. appTheme,
  462. SupplierInfo,
  463. billwayData,
  464. payTypesData,
  465. payWays,
  466. financeBankAcc,
  467. FinancialOrg,
  468. } = this.props,
  469. //
  470. // 付款单抬头
  471. payJobid = { titleName: '支付单编号', value: ' ' },
  472. // payBillType = {
  473. // titleName: "支付方式",
  474. // value: payWays,
  475. // nameKet: "name",
  476. // rightName: this.state.payWayName,
  477. // onTouch: item => {
  478. // this.setState({
  479. // payWayName: item.name,
  480. // payWayCode: item.code,
  481. // collapsed: true
  482. // });
  483. // }
  484. // },
  485. payCurrency = { titleName: '支付币种', value: CURRENCY.name },
  486. payJobTime = {
  487. titleName: '支付单日期',
  488. value: this.state.payTime,
  489. isLast: true,
  490. },
  491. //
  492. // 收款方信息
  493. receiptSuppier = {
  494. titleName: '供应商',
  495. value: SupplierInfo,
  496. nameKet: 'saleOrganizationName',
  497. rightName: this.state.receiptSuppier,
  498. onTouch: item => {
  499. this.findFinanceBySaleOrg([item.saleOrganizationId])
  500. this.setState({
  501. receiptSuppier: item.saleOrganizationName,
  502. receiptSuppierId: item.saleOrganizationId,
  503. // 置空收款方和收款方账号
  504. receipter: '',
  505. receipterId: '',
  506. receiptAccount: '',
  507. receiptAccountId: '',
  508. collapsed: true,
  509. })
  510. },
  511. },
  512. receipterInfo = {
  513. titleName: '收款方',
  514. value: FinancialOrg,
  515. nameKet: 'finanOrgName',
  516. rightName: this.state.receipter,
  517. onTouch: item => {
  518. this.findAccountByFinance(item)
  519. this.setState({
  520. receipter: item.finanOrgName,
  521. receipterId: item.finanOrgId,
  522. // 置空收款方账号
  523. receiptAccount: '',
  524. receiptAccountId: '',
  525. collapsed: true,
  526. })
  527. },
  528. },
  529. // receiptAccount = {
  530. // titleName: "收款方账号",
  531. // value: financeBankAcc,
  532. // nameKet: "accountName",
  533. // rightName: this.state.receiptAccount,
  534. // onTouch: item => {
  535. // this.setState({
  536. // receiptAccount: item.accountName,
  537. // receiptAccountId: item.id,
  538. // collapsed: true
  539. // });
  540. // },
  541. // isLast: true
  542. // },
  543. //
  544. //付款业务信息
  545. payType = {
  546. titleName: '收款业务类型',
  547. value: payTypesData,
  548. nameKet: 'name',
  549. rightName: this.state.payType,
  550. onTouch: item => {
  551. this.setState({
  552. payType: item.name,
  553. payTypeId: item.id,
  554. collapsed: true,
  555. })
  556. },
  557. },
  558. payAmount = {
  559. titleName: '付款金额',
  560. value: this.state.acountText,
  561. onChange: e => {
  562. this.setState({ acountText: e })
  563. },
  564. isAmount: true,
  565. isLast: true,
  566. }
  567. return (
  568. <View
  569. style={[
  570. styles.container,
  571. { backgroundColor: appTheme.backgroundColor },
  572. ]}
  573. >
  574. <StatusBar
  575. animated={true}
  576. barStyle={appTheme.barStyle}
  577. backgroundColor={'transparent'}
  578. translucent={true}
  579. />
  580. {/* 头部 */}
  581. {HeaderView(this.props.dispatch, '新增支付单')}
  582. <ScrollView style={styles.container}>
  583. {/* 订单信息 */}
  584. <View style={{ backgroundColor: '#FFF', paddingHorizontal: 10 }}>
  585. {this.rowShow(payJobid)}
  586. {/* {this.rowShowCollapse(payBillType)} */}
  587. {this.rowShow(payCurrency)}
  588. {this.rowShowForDate(payJobTime)}
  589. </View>
  590. {/* 收款方信息 */}
  591. <View>
  592. <View
  593. style={{
  594. paddingTop: 10,
  595. paddingBottom: 5,
  596. paddingHorizontal: 10,
  597. flexDirection: 'row',
  598. justifyContent: 'space-between',
  599. }}
  600. >
  601. <Text
  602. style={{
  603. fontSize: 14,
  604. color: '#333',
  605. letterSpacing: 0.17,
  606. fontWeight: '600',
  607. }}
  608. >
  609. 收款方信息
  610. </Text>
  611. <TouchableOpacity
  612. onPress={() => {
  613. this.findFinanceBySaleOrg(this.state.allSaleData)
  614. this.setState({
  615. receiptSuppier: '',
  616. receiptSuppierId: '',
  617. receipter: '',
  618. receipterId: '',
  619. collapsed: true,
  620. })
  621. }}
  622. style={{
  623. borderColor: '#CCC',
  624. borderRadius: 20,
  625. borderWidth: 1 / PixelRatio.get(),
  626. paddingHorizontal: 10,
  627. paddingVertical: 3,
  628. }}
  629. >
  630. <Text
  631. style={{
  632. fontSize: 12,
  633. color: '#333',
  634. letterSpacing: 0.17,
  635. }}
  636. >
  637. 清空
  638. </Text>
  639. </TouchableOpacity>
  640. </View>
  641. <View style={{ backgroundColor: '#FFF', paddingHorizontal: 10 }}>
  642. {this.rowShowCollapse(receiptSuppier)}
  643. {this.rowShowCollapse(receipterInfo)}
  644. {/* {this.rowShowCollapse(receiptAccount)} */}
  645. </View>
  646. </View>
  647. {/* 付款业务信息 */}
  648. <View>
  649. <View
  650. style={{
  651. paddingTop: 10,
  652. paddingBottom: 5,
  653. paddingHorizontal: 10,
  654. }}
  655. >
  656. <Text
  657. style={{
  658. fontSize: 14,
  659. color: '#333',
  660. letterSpacing: 0.17,
  661. fontWeight: '600',
  662. }}
  663. >
  664. 付款业务信息
  665. </Text>
  666. </View>
  667. <View style={{ backgroundColor: '#FFF', paddingHorizontal: 10 }}>
  668. {this.rowShowCollapse(payType)}
  669. {this.rowShowForInput(payAmount)}
  670. </View>
  671. </View>
  672. <View
  673. style={{
  674. padding: 10,
  675. marginTop: 10,
  676. flexDirection: 'row',
  677. backgroundColor: '#FFF',
  678. borderBottomColor: '#EEE',
  679. borderBottomWidth: 1 / PixelRatio.get(),
  680. }}
  681. >
  682. <View style={{ flex: 4 }}>
  683. <Text style={[styles.Text13, { color: '#333' }]}>
  684. 付款业务类型
  685. </Text>
  686. </View>
  687. <View style={{ flex: 4 }}>
  688. <Text style={[styles.Text13]}>金额</Text>
  689. </View>
  690. <View style={{ flex: 1 }}>
  691. <Text style={[styles.Text13]}>操作</Text>
  692. </View>
  693. </View>
  694. <FlatList
  695. extraData={this.state}
  696. keyExtractor={(item, key) => item.key + key}
  697. data={this.state.chooseOrders}
  698. renderItem={({ item, index }) => {
  699. return (
  700. <View>
  701. <View
  702. style={{
  703. flex: 1,
  704. padding: 10,
  705. flexDirection: 'row',
  706. backgroundColor: '#FFF',
  707. }}
  708. >
  709. <TouchableOpacity
  710. style={{ flex: 4 }}
  711. onPress={() => {
  712. if (this.state.collapsedId == item.key) {
  713. this.setState({ collapsedId: 'sad' })
  714. } else {
  715. this.setState({ collapsedId: item.key })
  716. }
  717. }}
  718. >
  719. <Text style={[styles.Text13, { color: '#333' }]}>
  720. {item && item.paymentTypeName
  721. ? item.paymentTypeName
  722. : '请选择...'}
  723. </Text>
  724. </TouchableOpacity>
  725. <View style={{ flex: 4 }}>
  726. <TextInput
  727. style={{
  728. width: width / 2.5,
  729. padding: 0,
  730. fontSize: 14,
  731. lineHeight: 20,
  732. letterSpacing: 0.38,
  733. color: '#333',
  734. marginTop: 4,
  735. }}
  736. autoCapitalize="none"
  737. autoCorrect={false}
  738. underlineColorAndroid={'transparent'}
  739. clearButtonMode="while-editing"
  740. onChangeText={text => {
  741. item.amount = text
  742. this.setState({
  743. chooseOrders: this.state.chooseOrders,
  744. })
  745. }}
  746. value={item.amount ? item.amount + '' : ''}
  747. multiline={false}
  748. onSubmitEditing={() => this.confirmCbFn()}
  749. onBlur={() => this.confirmCbFn()}
  750. placeholder={'请输入'}
  751. placeholderTextColor={'#CCC'}
  752. />
  753. </View>
  754. <TouchableOpacity
  755. onPress={() => {
  756. const { chooseOrders } = this.state
  757. chooseOrders.splice(index, 1)
  758. this.calculateTotleAmt()
  759. this.setState({ chooseOrders: chooseOrders })
  760. }}
  761. style={{ flex: 1 }}
  762. >
  763. <Text style={[styles.Text13, { color: '#333' }]}>
  764. 删除
  765. </Text>
  766. </TouchableOpacity>
  767. </View>
  768. <Collapsible
  769. collapsed={item.key !== this.state.collapsedId}
  770. align={'center'}
  771. >
  772. <FlatList
  773. extraData={this.state}
  774. keyExtractor={(data, key) => data.id + key}
  775. data={payTypesData}
  776. renderItem={data => {
  777. return (
  778. <TouchableOpacity
  779. style={{ padding: 10, backgroundColor: '#FFF' }}
  780. onPress={() => {
  781. item.paymentType = data.item.id
  782. item.paymentTypeName = data.item.name
  783. this.setState({
  784. chooseOrders: this.state.chooseOrders,
  785. collapsedId: 'sad',
  786. })
  787. }}
  788. >
  789. <Text style={[styles.Text13, { color: '#333' }]}>
  790. {data.item.name}
  791. </Text>
  792. </TouchableOpacity>
  793. )
  794. }}
  795. />
  796. </Collapsible>
  797. </View>
  798. )
  799. }}
  800. />
  801. {/* 添加关联订单 */}
  802. <TouchableOpacity
  803. onPress={() => {
  804. this.associateOrder()
  805. }}
  806. style={{
  807. paddingVertical: 7,
  808. justifyContent: 'center',
  809. alignItems: 'center',
  810. backgroundColor: '#FFF',
  811. flexDirection: 'row',
  812. marginTop: 10,
  813. }}
  814. >
  815. <Icon
  816. name="icon-icon-guanbianniu"
  817. size={20}
  818. style={{
  819. transform: [{ rotate: '45deg' }],
  820. marginRight: 7,
  821. marginTop: 4,
  822. }}
  823. />
  824. <Text style={{ fontSize: 12, letterSpacing: 0.14, lineHeight: 17 }}>
  825. 添加付款信息
  826. </Text>
  827. </TouchableOpacity>
  828. </ScrollView>
  829. {/* 底部按钮 */}
  830. <View
  831. style={{ height: 45, flexDirection: 'row', backgroundColor: '#FFF' }}
  832. >
  833. <TouchableOpacity
  834. onPress={() => this.props.dispatch(NavigationActions.back())}
  835. style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}
  836. >
  837. <Text style={styles.bottonText666}>取消</Text>
  838. </TouchableOpacity>
  839. <TouchableOpacity
  840. onPress={() => {
  841. this.submitPayment()
  842. }}
  843. style={{
  844. flex: 1,
  845. justifyContent: 'center',
  846. alignItems: 'center',
  847. backgroundColor: '#E70013',
  848. }}
  849. >
  850. {this.state.isLoading ? (
  851. <ActivityIndicator />
  852. ) : (
  853. <Text style={styles.bottonTextwhite}>提交</Text>
  854. )}
  855. </TouchableOpacity>
  856. </View>
  857. <SelectTime
  858. ref={showTime => (this.showTime = showTime)}
  859. cb={date => {
  860. this.setState({
  861. payTime: moment(date).format('YYYY-MM-DD'),
  862. })
  863. }}
  864. />
  865. </View>
  866. )
  867. }
  868. }
  869. const styles = StyleSheet.create({
  870. container: {
  871. flex: 1,
  872. },
  873. Text13: {
  874. fontSize: 13,
  875. lineHeight: 18,
  876. },
  877. bottonText666: {
  878. fontSize: 14,
  879. lineHeight: 20,
  880. color: '#666',
  881. },
  882. bottonTextwhite: {
  883. fontSize: 14,
  884. lineHeight: 20,
  885. color: '#FFF',
  886. },
  887. })
  888. export default RechargeAdd